diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fb5ab031..3e138c867 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,10 @@ - PayNow - PromptPay +**Fixes** + +- Fixed an issue on iOS where the value for the `paymentMethod` field on the returned `paymentIntent` object from `confirmPlatformPayPayment` and the returned `setupIntent` object from `confirmPlatformPaySetupIntent` would be null. + ## 0.32.0 - 2023-09-15 **Features** diff --git a/ios/ApplePayViewController.swift b/ios/ApplePayViewController.swift index 9eb82943e..57e1e472b 100644 --- a/ios/ApplePayViewController.swift +++ b/ios/ApplePayViewController.swift @@ -165,6 +165,7 @@ extension StripeSdk : PKPaymentAuthorizationViewControllerDelegate, STPApplePayC paymentInformation: PKPayment, completion: @escaping STPIntentClientSecretCompletionBlock ) { + self.confirmApplePayPaymentMethod = paymentMethod if let clientSecret = self.confirmApplePayPaymentClientSecret { completion(clientSecret, nil) } else if let clientSecret = self.confirmApplePaySetupClientSecret { @@ -207,10 +208,15 @@ extension StripeSdk : PKPaymentAuthorizationViewControllerDelegate, STPApplePayC } if let paymentIntent = paymentIntent { - resolve(Mappers.createResult("paymentIntent", Mappers.mapFromPaymentIntent(paymentIntent: paymentIntent))) + let result = Mappers.mapFromPaymentIntent(paymentIntent: paymentIntent) + if (paymentIntent.paymentMethod == nil) { + result.setValue(Mappers.mapFromPaymentMethod(self.confirmApplePayPaymentMethod), forKey: "paymentMethod") + } + resolve(Mappers.createResult("paymentIntent", result)) } else { resolve(Mappers.createResult("paymentIntent", nil)) } + self.confirmApplePayPaymentMethod = nil } } else if let clientSecret = self.confirmApplePaySetupClientSecret { STPAPIClient.shared.retrieveSetupIntent(withClientSecret: clientSecret) { (setupIntent, error) in @@ -224,10 +230,15 @@ extension StripeSdk : PKPaymentAuthorizationViewControllerDelegate, STPApplePayC } if let setupIntent = setupIntent { - resolve(Mappers.createResult("setupIntent", Mappers.mapFromSetupIntent(setupIntent: setupIntent))) + let result = Mappers.mapFromSetupIntent(setupIntent: setupIntent) + if (setupIntent.paymentMethod == nil) { + result.setValue(Mappers.mapFromPaymentMethod(self.confirmApplePayPaymentMethod), forKey: "paymentMethod") + } + resolve(Mappers.createResult("setupIntent", result)) } else { resolve(Mappers.createResult("setupIntent", nil)) } + self.confirmApplePayPaymentMethod = nil } } } diff --git a/ios/StripeSdk.swift b/ios/StripeSdk.swift index b3eafb7e1..6c8390680 100644 --- a/ios/StripeSdk.swift +++ b/ios/StripeSdk.swift @@ -22,6 +22,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap var confirmApplePayResolver: RCTPromiseResolveBlock? = nil var confirmApplePayPaymentClientSecret: String? = nil var confirmApplePaySetupClientSecret: String? = nil + var confirmApplePayPaymentMethod: STPPaymentMethod? = nil var applePaymentAuthorizationController: PKPaymentAuthorizationViewController? = nil var createPlatformPayPaymentMethodResolver: RCTPromiseResolveBlock? = nil