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

Add capabilityCredit and capabilityDebit merchantCapability options for Apple Pay #748

Closed

Conversation

brendanlong
Copy link

These allow developers to pass capabilityCredit: true or capabilityDebit: true when opening
an Apple Pay interface to filter to only credit or debit cards.

See: https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest/1916123-merchantcapabilities

Fixes #728

…or Apple Pay

These allow developers to pass `capabilityCredit: true` or `capabilityDebit: true` when opening
an Apple Pay interface to filter to only credit or debit cards.

See: https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest/1916123-merchantcapabilities
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Brendan Long seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@brendanlong
Copy link
Author

I doubt this is exactly how you want to implement this, but I figured example code would make it easier to find this if you do want to do it.

Comment on lines +475 to +481
if (params["capabilityCredit"] as? Bool ?? false) {
paymentRequest.merchantCapabilities.update(with: .capabilityCredit)
}
if (params["capabilityDebit"] as? Bool ?? false) {
paymentRequest.merchantCapabilities.update(with: .capabilityDebit)
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

what do you think of something like

        if let cardType = params["supportedCardType"] as? NSString {
            if (cardType.isEqual(to: "Credit")) {
                paymentRequest.merchantCapabilities.update(with: .capabilityCredit)
            } else if (cardType.isEqual(to: "Debit")) {
                paymentRequest.merchantCapabilities.update(with: .capabilityDebit)
            }
        }

So we only add 1 param to handle this, and default to accepting both credit and debit?

@charliecruzan-stripe
Copy link
Collaborator

It would also be good to see if Google Pay exposes a similar filter so we have cross-platform support for this feature: https://developers.google.com/pay/api/android/guides/tutorial#allowed-payment-methods

@@ -59,6 +59,8 @@ export namespace ApplePay {
}

export interface PresentParams {
capabilityCredit?: Boolean;
capabilityDebit?: Boolean;

Choose a reason for hiding this comment

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

Not sure if this PR is going to be merged as #1164 is marking as fixing this same issue, but in JS boolean type should use a lower case b.

@charliecruzan-stripe
Copy link
Collaborator

This is now released in v0.22.0 via #1164

@jayfeldman12
Copy link

I might be missing something, but I don't see where the option to specify only credit or debit was done. In presentParams I don't see a field relevant to this.

@charliecruzan-stripe
Copy link
Collaborator

This is released as part of the new Platform Pay API, which replaced the individual Apple/Google Pay APIs: https://github.com/stripe/stripe-react-native/blob/master/src/types/PlatformPay.ts#L65

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.

Support merchantCapabilities for Apple Pay
4 participants