From 159f892dd3d3f0393111278b3394c0ca2154f31e Mon Sep 17 00:00:00 2001 From: Brendan Long Date: Tue, 14 Dec 2021 14:30:07 -0700 Subject: [PATCH] Add capabilityCredit and capabilityDebit merchantCapability options for 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 --- ios/StripeSdk.swift | 7 +++++++ src/types/ApplePay.ts | 2 ++ 2 files changed, 9 insertions(+) diff --git a/ios/StripeSdk.swift b/ios/StripeSdk.swift index c353d433b..f99f04b0b 100644 --- a/ios/StripeSdk.swift +++ b/ios/StripeSdk.swift @@ -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) + } + let requiredShippingAddressFields = params["requiredShippingAddressFields"] as? NSArray ?? NSArray() let requiredBillingContactFields = params["requiredBillingContactFields"] as? NSArray ?? NSArray() let shippingMethods = params["shippingMethods"] as? NSArray ?? NSArray() diff --git a/src/types/ApplePay.ts b/src/types/ApplePay.ts index bbfb742da..e738a637e 100644 --- a/src/types/ApplePay.ts +++ b/src/types/ApplePay.ts @@ -59,6 +59,8 @@ export namespace ApplePay { } export interface PresentParams { + capabilityCredit?: Boolean; + capabilityDebit?: Boolean; cartItems: CartSummaryItem[]; country: string; currency: string;