Closed xujiali08 closed 2 years ago
Hi @xujiali08, can you show the error you're seeing from this method: func applePayContext(_ context: STPApplePayContext, didCompleteWith status: STPPaymentStatus, error: Error?)
Hi @xujiali08, can you show the error you're seeing from this method:
func applePayContext(_ context: STPApplePayContext, didCompleteWith status: STPPaymentStatus, error: Error?)
As I said in Other information.
When testing with the simulator, I can get the didCreatePaymentMethod and didCompleteWith status callbacks, this method: func applePayContext(_ context: STPApplePayContext, didCompleteWith status: STPPaymentStatus, error: Error?)
callback success, but the backend does not receive the callbacks for successful payment. And when testing with the iphone 11, the sandbox account, it shows that the payment is unsuccessful and does not get the didCreatePaymentMethod and didCompleteWith status callbacks.
@xujiali08 Ah I see, apologies for missing that. Some questions for you:
I've had this same issue, what is weird is that the first time I try to checkout with Apple Pay the dialog pops up on the screen, but applePayContextDidCreatePaymentMethod is never called so a payment intent is never retrieved from my server, Apple Pay spins for a minute, and then fails. If I then tap out to cancel, and try again, the server is called to get a payment intent, and the checkout works like expected.
It seems as though there is some issue where the first time you try to checkout with Apple Pay the method applePayContextDidCreatePaymentMethod is not called, but if you cancel and then try again the method is called as expected and everything works.
Also of note, the first time I try to checkout with Apple Pay the method below isn't called either so there is no way for me to report the error. It is almost like the delegate isn't getting registered properly on the first go around. Then, the second time I try to checkout the delegate is stored from the first call so it can be used. Might be a 'race condition' where applePayContextDidCreatePaymentMethod is called before the delegate is stored properly? func applePayContext(_ context: STPApplePayContext, didCompleteWith status: STPPaymentStatus, error: Error?)
Turned out for me to be an issue with App Clips and SwiftUI. The instance of the delegate for me was getting released from memory so the callbacks were not getting registered. To fix I made a static instance of the delegate that was used throughout the app.
Summary
I followed the steps in the documentation (https://stripe.com/docs/apple-pay) to access Apple Pay and have been using it for some time, but now after updating from version 20.1.1 to 21.5.1, Apple Pay is no longer available: after the Apple Pay payment pop-up box appears, enter your password, processing payment -> payment not I'd like to know if there is something new, but the iOS side has upgraded the SDK and the backend has not been upgraded, does this have an impact? From the documentation it looks like it has no effect.
Code to reproduce
iOS version
iOS 14.3
Installation method
cocoapods: pod 'Stripe', '21.5.1'
SDK version
21.5.1
Xcode version
12.0.1
Other information
When testing with the simulator, I can get the didCreatePaymentMethod and didCompleteWith status callbacks, but the backend does not receive the callbacks for successful payment, and when testing with the real machine, the sandbox account, it shows that the payment is unsuccessful and does not get the didCreatePaymentMethod and didCompleteWith status callbacks.