Skip to content
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

Enable bank payments in native Link #4534

Merged
merged 7 commits into from
Feb 13, 2025

Conversation

tillh-stripe
Copy link
Collaborator

@tillh-stripe tillh-stripe commented Feb 3, 2025

Summary

This pull request adds support for bank payments to the native Link flow.

  • Instead of hard-coding ["card"], we now pass the supported payment details types through to the listPaymentDetails call.
  • We extend the sharePaymentDetails method to take in an expectedPaymentMethodType when sharing a bank account in passthrough mode.

Motivation

Parity with the web flow it replaces.

Testing

Added end-to-end tests.

Changelog

@tillh-stripe tillh-stripe force-pushed the tillh/native-link-bank-payments branch 6 times, most recently from c56d0a9 to 27466bf Compare February 11, 2025 15:02
@tillh-stripe tillh-stripe force-pushed the tillh/native-link-bank-payments branch from 27466bf to 6132647 Compare February 11, 2025 16:00
@tillh-stripe tillh-stripe marked this pull request as ready for review February 11, 2025 16:00
@tillh-stripe tillh-stripe requested review from a team as code owners February 11, 2025 16:00

var expectedPaymentMethodTypeForPassthroughMode: String? {
switch type {
case .card, .unparsable:
Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking, should we not send this for .card?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As far as I know, that’s not necessary. Let me double-check!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The backend will fall back to card, but I added it anyway since that’s what Web is doing 🤷‍♂️

@@ -330,7 +335,7 @@ extension STPAPIClient {
let parameters: [String: Any] = [
"credentials": ["consumer_session_client_secret": consumerSessionClientSecret],
"request_surface": "ios_payment_element",
"types": ["card"],
"types": supportedPaymentDetailsTypes.map(\.rawValue),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we use a Set instead of an Array for supportedPaymentDetailsType? It's a little clunkier in Swift, and I'm not sure if the underlying JSON response can really represent a Set. It was causing issues with ordering in our tests: #4549

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I’ll change it to a list, now that I’ve learned about the test issues it can cause.

- Use list instead of set
- Align with Web logic for ACH-enabled Elements sessions
var supportedPaymentMethodTypes = Set(ConsumerPaymentDetails.DetailsType.allCases) {
didSet {
// TODO(tillh-stripe) Update this as soon as adding bank accounts is supported
addPaymentMethodButton.isHidden = !supportedPaymentMethodTypes.contains(.card)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I noticed that pressing Add payment method in a bank-only session (orderedPaymentMethodTypes == [.USBankAccount]) does nothing, so let’s hide it, @davidme-stripe?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, it's not hooked up yet, I have a JIRA for this somewhere. We should plug it in once all this is working!

Comment on lines +759 to +761
let canAcceptACH = elementsSession.orderedPaymentMethodTypes.contains(.USBankAccount)
let isLinkCardBrand = elementsSession.linkSettings?.linkMode?.isPantherPayment ?? false
return isLinkCardBrand && !canAcceptACH ? "card" : "bank_account"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This mimics behavior on the Web: If we’re in the Link card brand mode, but the merchant accepts ACH, then we want the payment method to be a full bank account.

cc @abagasra-stripe and @constantine-stripe

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, okay!

@tillh-stripe tillh-stripe merged commit 04cf2ff into master Feb 13, 2025
6 checks passed
@tillh-stripe tillh-stripe deleted the tillh/native-link-bank-payments branch February 13, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants