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

fix: include payment method in return from confirmPlatformPayPayment/confirmPlatformPaySetupIntent #1512

Merged
merged 2 commits into from
Sep 22, 2023
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
15 changes: 13 additions & 2 deletions ios/ApplePayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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
}
}
}
Expand Down
1 change: 1 addition & 0 deletions ios/StripeSdk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down