Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions JobFlow.API/Controllers/OnboardingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ public async Task<IResult> SeedIndustryDefaults()
: result.ToProblemDetails();
}

[HttpPost("defer-payment")]
public async Task<IResult> DeferPayment()
{
var organizationId = HttpContext.GetOrganizationId();
var result = await onboarding.DeferPaymentSetupAsync(organizationId);
return result.IsSuccess
? Results.Ok()
: result.ToProblemDetails();
}

private static bool HasMinPlan(string? planName, string required)
{
static int Rank(string? plan)
Expand Down
1 change: 1 addition & 0 deletions JobFlow.Business/Models/DTOs/OrganizationDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ public class OrganizationDto
public bool IsStripeConnected { get; set; }
public string? SquareMerchantId { get; set; }
public bool IsSquareConnected { get; set; }
public bool PaymentSetupDeferred { get; set; }
}
16 changes: 16 additions & 0 deletions JobFlow.Business/Services/OnboardingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,4 +365,20 @@ await invoicingSettingsRepo.AddAsync(new OrganizationInvoicingSettings
await uow.SaveChangesAsync();
return Result.Success();
}

public async Task<Result> DeferPaymentSetupAsync(Guid organizationId)
{
var org = await orgRepo.GetByIdAsync(organizationId);
if (org == null)
return Result.Failure(OnboardingErrors.OrganizationNotFound);

if (org.CanAcceptPayments)
return Result.Failure(Error.Validation(
"Onboarding.Payment.AlreadyConnected",
"Payment provider is already connected and cannot be deferred."));

org.PaymentSetupSkippedAt = DateTimeOffset.UtcNow;
await uow.SaveChangesAsync();
return Result.Success();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ Task<Result<OnboardingQuickStartStateDto>> ApplyQuickStartAsync(
Task<Result> RecordAnalyticsEventAsync(Guid organizationId, string stepName, string eventType);
Task<Result<OnboardingIndustryDefaultsDto>> GetIndustryDefaultsAsync(Guid organizationId);
Task<Result> SeedIndustryDefaultsAsync(Guid organizationId);
Task<Result> DeferPaymentSetupAsync(Guid organizationId);
}
4 changes: 4 additions & 0 deletions JobFlow.Domain/Models/Organization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ public class Organization : Entity
public string? SubscriptionPlanName { get; set; }
public DateTime? SubscriptionExpiresAt { get; set; }

public DateTimeOffset? PaymentSetupSkippedAt { get; set; }

public bool CanAcceptPayments =>
(PaymentProvider == PaymentProvider.Stripe &&
!string.IsNullOrWhiteSpace(StripeConnectAccountId)) ||
(PaymentProvider == PaymentProvider.Square &&
IsSquareConnected &&
!string.IsNullOrWhiteSpace(SquareMerchantId));

public bool PaymentSetupDeferred => PaymentSetupSkippedAt.HasValue && !CanAcceptPayments;

public PaymentProvider PaymentProvider { get; set; } = PaymentProvider.Stripe;
public ICollection<CustomerPaymentProfile> PaymentProfiles { get; set; } = new List<CustomerPaymentProfile>();
public ICollection<Employee> Employees { get; set; } = new List<Employee>();
Expand Down
Loading
Loading