[ios] Close Apple Pay sheet programmatically
See original GitHub issueIs your feature request related to a problem? Please describe. I don’t think so.
Describe the solution you’d like
I would like to be able to call theuseApplePay()
method, and it return a method which can be used to close the Apply Pay window.
Currently, it returns 3 methods, and one property. Can we add a 4th method? Maybe called closeApplePayWindow()
Additional context I have an application where the user can toggle between n subscription tiers. They can pay by entering their card info into the app, or choose to pay with Apple Pay.
If they choose to pay with Apple Pay, the window pops up asking which card they would like to use. Once they decide and select their card, the application sends a request to our Payment Service, with the payment id they selected. Our Payment Service will subscribe the customer to that subscription plan using the payment method. The Payment Service will return success if everything goes well.
The application is then done processing the payment. It updates the state as needed, but there is no way to close the Apple Pay window. This is normally done with the confirmApplePayPayment()
function, but in our case, we did not use a PaymentIntent, and so we have no ClientSecret to pass it.
Describe alternatives you’ve considered The existing implementation outlined in the example project utilizes the PaymentIntent workflow. That is not ideal for the subscription model. If I try to create a PaymentIntent, there is no way I can specify what Subscription it corresponds to. This is a problem because once the PaymentIntent succeeds, there is no way our Payment Service can determine this and provision the correct features.
A work around would be to modify our Payment Service to store the PaymentIntent Id, and what Subscription it corresponds to. We could then setup a webhook that looks this up after the PaymentIntent succeeds, but this is (to me at least) not the cleanest way. I think it would be better to implement a method returned from useApplePay()
. I can call this method and it will close the Apple Pay window.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:12 (1 by maintainers)
I’ve got another use case for this feature… I am confirming all my payments server side so I need to be able to call the completion block myself when I get confirmation from the server.
Edit: Forgot to mention that currently there is no way neither of programatically cancelling apple pay. Example would be: present apple pay, confirm payment, something goes wrong, UI cannot recover
Is there a workaround for this? Even forcing an error state would be good (I’ve tried via calling
confirmApplePayPayment
with a dummyclientSecret
, but that just… crashes the app)