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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ios/StripeSdk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,13 @@ class StripeSdk: RCTEventEmitter, STPApplePayContextDelegate, STPBankSelectionVi
let merchantIdentifier = self.merchantIdentifier ?? ""
let paymentRequest = StripeAPI.paymentRequest(withMerchantIdentifier: merchantIdentifier, country: country, currency: currency)

if (params["capabilityCredit"] as? Bool ?? false) {
paymentRequest.merchantCapabilities.update(with: .capabilityCredit)
}
if (params["capabilityDebit"] as? Bool ?? false) {
paymentRequest.merchantCapabilities.update(with: .capabilityDebit)
}

Comment on lines +475 to +481
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?

let requiredShippingAddressFields = params["requiredShippingAddressFields"] as? NSArray ?? NSArray()
let requiredBillingContactFields = params["requiredBillingContactFields"] as? NSArray ?? NSArray()
let shippingMethods = params["shippingMethods"] as? NSArray ?? NSArray()
Expand Down
2 changes: 2 additions & 0 deletions src/types/ApplePay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

cartItems: CartSummaryItem[];
country: string;
currency: string;
Expand Down