Skip to content

StripeCryptoOnramp SDK: Better Cancellation Signaling#6322

Merged
mliberatore merged 28 commits intomasterfrom
twigz/proper-payment-collection-cancellation
Apr 23, 2026
Merged

StripeCryptoOnramp SDK: Better Cancellation Signaling#6322
mliberatore merged 28 commits intomasterfrom
twigz/proper-payment-collection-cancellation

Conversation

@Twigz
Copy link
Copy Markdown
Collaborator

@Twigz Twigz commented Apr 9, 2026

Summary

  • Adds new didSelectPaymentOption Bool to signal from Link to Onramp that a payment option was selected or not. This helps CryptoOnramp know if a payment option was selected as part of collection, or was just preserved as part of a previous selection.
  • Adds new state property paymentSourceBeforeApplePay to track an existing payment source during the Apple Pay flow, so that we can preserve the accuracy of selectedPaymentSource if the multi-step apple pay flow is not completed.

Motivation

Making iOS payment collection more in line with how Android handles cancellation.

Testing

  1. Login.
  2. Go to collect a card.
  3. Cancel, make sure it receives a cancellation result.
  4. Collect a card, and successfully collect one.
  5. Go to collect a card, cancel, make sure you receive a cancellation result, but preserve previously selected card.
  6. Make sure checkout still works.
  7. Run these steps again, but with Apple Pay
  8. Run these steps again, but switch back and forth between Link and Apple Pay.

mliberatore and others added 21 commits March 19, 2026 10:05
@mliberatore mliberatore marked this pull request as ready for review April 13, 2026 19:33
@mliberatore mliberatore requested review from a team as code owners April 13, 2026 19:33
@mliberatore mliberatore requested a review from a team as a code owner April 13, 2026 19:33
Copy link
Copy Markdown
Member

@jeanregisser jeanregisser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'll finish reviewing tomorrow,
Note that there's also this proposition: #6354
We can discuss during our sync meeting.

Copy link
Copy Markdown
Member

@jeanregisser jeanregisser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this is a clean fix. One thought on the Apple Pay state. ✨

/// if the Apple Pay flow is canceled or fails after `didCreatePaymentMethod` has already updated
/// `selectedPaymentSource`. This value should only represent pre-existing selection state for the
/// active Apple Pay attempt, and must be cleared once that attempt completes, fails, or the user logs out.
private var paymentSourceBeforeApplePay: SelectedPaymentSource?
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we considered flipping the direction here? Instead of saving what we had before and restoring on cancel, we could use a pendingApplePayPaymentSource that only gets promoted to selectedPaymentSource in didCompleteWith(.success) - leaving it untouched on cancel/error, with nothing to restore. It'd also make cleanup symmetric: just pendingApplePayPaymentSource = nil at the end of didCompleteWith in all cases.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, hadn't thought about it that way. It reduces the overall management of that state. I‘ve implemented the suggestion in 73a636f.

…’s usage and instead keeping a temporary apple pay payment source that then gets promoted on success to `selectedPaymentSource`
Copy link
Copy Markdown
Member

@jeanregisser jeanregisser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@mliberatore mliberatore enabled auto-merge (squash) April 22, 2026 16:28
@mliberatore mliberatore merged commit bcec371 into master Apr 23, 2026
7 checks passed
@mliberatore mliberatore deleted the twigz/proper-payment-collection-cancellation branch April 23, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants