Skip to content

Commit

Permalink
fix: include payment method in return from confirmPlatformPayPayment/…
Browse files Browse the repository at this point in the history
…confirmPlatformPaySetupIntent (#1512)

* fix: include payment method in return from confirmPlatformPayPayment/confirmPlatformPaySetupIntent

* [skip actions] changelog
  • Loading branch information
charliecruzan-stripe authored Sep 22, 2023
1 parent 17e3553 commit 16c8c94
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
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

0 comments on commit 16c8c94

Please sign in to comment.