#sruilova-applepay
1 messages · Page 1 of 1 (latest)
Could you please tell me which key I should store from the PaymentIntent in order to make future payments with Apple Pay?
I'm not sure what that question could mean exactly. Apple expects you to present the Apple Pay UI/sheet every time someone wants to pay in your app
- I generate a PaymentIntent key on the server, with this code:
PaymentIntentCreateParams params =
PaymentIntentCreateParams.builder()
.setAmount(amount)
.setCurrency(currency)
.build()
PaymentIntent intent = PaymentIntent.create(params)
return intent.getClientSecret()
2)The client sends me the paymentIntent if the process is successful.
3)On the server, check the paymentIntent, but I don't know what key I store to make recurring payments in the future within my application.
The payment method that I get from the paymentintent I can't use it again
you want to read https://stripe.com/docs/payments/save-during-payment
I am using Apple pay, I do not have credit card information, I only have a paymentIntentId
Sorry, you're a bit too far down a rabbit hole thinking it doesn't work
that doc explains exactly what you want: how to save card details as part of a payment, so that you can then do more payments in the future
And that works the same way for Apple Pay
After the payment you get a PaymentMethod (pm_123) attached to your customer and you can charge it again
I tried to attach a customer to the paymentmethod but I get the following error: This PaymentMethod was previously used without being attached to a Customer or was detached from a Customer, and may not be used again.
The paymentintent is attached to a customer.
did you read the doc?
And when I try to use this payment method in another payment I get the error:
The provided PaymentMethod was previously used with a PaymentIntent without Customer attachment, shared with a connected account without Customer attachment, or was detached from a Customer. It may not be used again. To use a PaymentMethod multiple times, you must attach it to a Customer first.; request-id: req_Fbr8aKiOi8z9vN
It says you need to set setup_future_usage: 'off_session'
did you do that?
Basically the idea is that you configure the first payment to indicate you plan to charge the card in the future and that will automatically attach it to the customer
When I get the PaymentIntent from the client, on the server I try to update it with: "setup_future_usage": "off_session".
But it gives me the following error:
This PaymentIntent's setup_future_usage could not be updated because it has a status of succeeded. You may only update the setup_future_usage of a PaymentIntent with one of the following statuses: requires_payment_method, requires_confirmation, requires_action.
yes that's also expected
you need to do this on creation
PaymentIntentCreateParams.builder()
.setAmount(amount)
.setCurrency(currency)
.setSetupFutureUsage(PaymentIntentCreateParams.SetupFutureUsage.OFF_SESSION)
.build()
PaymentIntent intent = PaymentIntent.create(params)
return intent.getClientSecret()```
something like ^ does that make sense @remote peak ?
Thank you very much, you are incredible, you helped me a lot, I am against time but with your help I have advanced.
Of course, sorry it took a while to get there
My English is not good, so they do not understand me well what I am trying to explain.
I'm not a native either, I found your English great in our chat. The issue was the vocabulary that is Stripe specific, which is just hard until you're really experienced with Stripe
Thank you very much for your great help, have a good day!