-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MBL-1271]Stripe's confirmPayment #2003
Conversation
3308052
to
a5399ab
Compare
Newly created cards already have PaymentIntents and are already confirmed.
|
||
self.present(navigationController, animated: true) | ||
} | ||
|
||
private func confirmPayment(with validation: PaymentSourceValidation) { | ||
guard validation.requiresConfirmation else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could probably be done in a highly clever was in the view model, but I felt that this was going to be the easiest to follow. This way, new and existing cards go through the same input/output flow, all the time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I like this
|
||
let newPaymentIntentEvent = initialData | ||
let newPaymentIntentForExistingCards = initialData |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming for clarity. This does not emit the payment intent for every card; it only emits it when an existing card is selected.
.map { $0.clientSecret } | ||
|
||
// Runs validation for pre-existing cards that were created with setup intents originally but require payment intents for late pledges. | ||
let validateCheckoutExistingCard = Signal | ||
.combineLatest(checkoutId, selectedExistingCard, paymentIntentClientSecret, storedCardsValues) | ||
.combineLatest(checkoutId, selectedCard, paymentIntentClientSecretForExistingCards, storedCardsValues) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ifosli Did I potentially just undo your bug fix from earlier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, you're good - the important part is that we're looking for the most recently selected card in this line and that the filter to check if it's a new or existing card happens after (in line 213-215).
|
||
self.present(navigationController, animated: true) | ||
} | ||
|
||
private func confirmPayment(with validation: PaymentSourceValidation) { | ||
guard validation.requiresConfirmation else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I like this
.map { $0.clientSecret } | ||
|
||
// Runs validation for pre-existing cards that were created with setup intents originally but require payment intents for late pledges. | ||
let validateCheckoutExistingCard = Signal | ||
.combineLatest(checkoutId, selectedExistingCard, paymentIntentClientSecret, storedCardsValues) | ||
.combineLatest(checkoutId, selectedCard, paymentIntentClientSecretForExistingCards, storedCardsValues) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, you're good - the important part is that we're looking for the most recently selected card in this line and that the filter to check if it's a new or existing card happens after (in line 213-215).
📲 What
Calls Stripe.confirmPayment after validating checkout
🤔 Why
We need to confirm payment using the new payment intent with Stripe so that we can charge these cards immediately
🛠 How
When validation is successful for both a new card and an existing card, call this method!
There's a key difference for existing cards:
paymentMethodId
property to be thestripeCardId
that's on the stored card.paymentMethodId
will associate it!🪲
✅ Acceptance criteria