|
Hello I've wrote, taking example from internet, a simple apple pay integration to my app. I've successful complete the Xcode configuration adding apple pay capability, then I've configured all apple store profile with certs and identifier reporting this to xcode. This is my class code:
This is how I show the view
It's seem that everything works well, I can set shipping detail, changing cart an so on, but I can't complete payment or closing the view. It is like no delagate is called from the PKPaymentAuthorizationController. I think that my code is right I've tested it on a minimal xcode project and delegate works well, so I conclude that there is something wrong in my app. Where I should check to resolve my issue? Is there a way to avoid delegates with apple pay? Regards |
|
Ok if you are in trouble with same problem here the solution that worked for me. The problem is in the way I use to call the view
Launch the PKPaymentController in such way, make the delegate unable to trigger so here the solution You need to create a "persistent" variable that survive to launch itself
and then launch controller
Good coding |
|
@PGF, thanks for sharing your solution. It helped me resolve an identical problem yesterday that I was having with Apple Pay sheet not calling its delegate functions and being largely non-responsive (not closing, not completing payment, etc.) I would have expected some debug messages to show up in XCode, but there were none. In my case, I stored reference to an instance of the delegate class into a let constant associated with my SwiftUI view, but I still had an issue. What resolved it for me was to store the reference into a @State variable. So, this was the problem:
And this was the solution:
Just sharing in case is helps the next person. |
SPONSORED An iOS conference hosted in Buenos Aires, Argentina – join us for the third edition from November 29th to December 1st!
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.