Skip to content

Commit

Permalink
DON-819: Refactor: Clarify logic for allowing contination from paymen…
Browse files Browse the repository at this point in the history
…t step
  • Loading branch information
bdsl committed Oct 5, 2023
1 parent 3013e5a commit 46fd61d
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class PaymentReadinessTracker {
/**
* Does the stripe payment element have a complete card?
*/
private stripeManualCardInputValid: boolean = false;
private paymentElementIsComplete: boolean = false;

/**
* Balance of the donors funds accounts in pence
Expand All @@ -37,8 +37,11 @@ export class PaymentReadinessTracker {
}

get readyToProgressFromPaymentStep(): boolean {
const usingSavedCard = this.selectedSavedMethod && this.useSavedCard;
return !(!this.stripeManualCardInputValid && !usingSavedCard && !this.donorCredit || !this.paymentGroup.valid)
const usingSavedCard = !!this.selectedSavedMethod && this.useSavedCard;
const atLeastOneWayOfPayingIsReady = this.donorCredit || usingSavedCard || this.paymentElementIsComplete;
const formHasNoValidationErrors = this.paymentGroup.valid;

return formHasNoValidationErrors && atLeastOneWayOfPayingIsReady
}

selectedSavedPaymentMethod() {
Expand All @@ -51,7 +54,7 @@ export class PaymentReadinessTracker {
}

onStripeCardChange(state: { complete: boolean }) {
this.stripeManualCardInputValid = state.complete;
this.paymentElementIsComplete = state.complete;
}

onUseSavedCardChange(useSavedCard: boolean) {
Expand Down

0 comments on commit 46fd61d

Please sign in to comment.