#Nancy-Apple-Pay
1 messages · Page 1 of 1 (latest)
Hi there! If you are using Card Element then you would also need to integrate Payment Request Button (https://stripe.com/docs/stripe-js/elements/payment-request-button) in order to support Apple Pay... I see you do mention paymentRequest so do you already have PRB implemented?
Yes, I have the PaymentRequestButtonElement implemented, but is stuck on passing the paymentMethod return by the paymentMethod event to the server side. Currently, we pass a token generated from cardElement to attached on the the stripe customer/subscription. How can i turn whats returned in payment Method into a token
I see that the stripe.createToken only takes in CardElement and StripeCardNumberElement
whereas I have a payment method right now from apple pay that need to get somehow stored in stripe customer/subscription
A PaymentMethod can be used the same as a token
Tokens are actually legacy at this point
And PaymentMethods are our newer API
So you can attach a PaymentMethod to a Customer just like you would attach a Token
Sorry, I am going to take a step back and ask a few more questions:
- The Apple pay will be used a subscription. Does this mean we have to create a setupIntent to save the card for future usage?
- Regarding the
totalfield requested in payment request, if we have a trial or coupon in place for an subscription how do we display the total and charges after that?
No you wouldn't have to use a SetupIntent. You could grab the clientsecret from the initial invoice of the Subscription and pass that to confirmCardPayment and use that with PaymentRequestButton.
For the second question, you would update the paymentrequest total based on the Subscription
However you can't customize the modal to state something about a trial
You could also utilize pending on the modal (https://stripe.com/docs/js/appendix/payment_item_object#payment_item_object-pending) and show the amount in your own UI
question regarding payment method (as you mentioned it to be used the same as token). Is there a way to create payment method from cardelement instead of creating token if we are to migrate it?
Yep, you use createPaymentMethod() instead of createToken(): https://stripe.com/docs/js/payment_methods/create_payment_method
While reading the documentation - I noticed that payment method is attached on paymentMethod field in Customer, whereas the old token was stored in source. If we are planning to depreciate token and use payment method. What happens when a customer happens to have a paymentMethod and source? For new customer created they will have only paymentMethod, however for old customer they will have a source and only if they update their payment method will the have a new paymentMethod, but they will still have a source?
We built things as backwards compatible
So if someone has a card_123, it works as a PaymentMethod in the API
so mostly you can just migrate to PaymentMethods
do you mean card_123 as source?
Sorry, I am a bit confused. If an exisiting customer have an exisiting source , and we are updating to attached a paymentMethod, won't they have two variables now. Will it just take the paymentMethod as main source of payment? Or will we need to remove the source, while adding the paymentMethod
hmmm sorry I'm not following you now
there's no source
there's sources on Customer which is a collection of "payment sources" which is considered legacy. It's when you used to use Token (tok_123) and then turn them into Card objects (card_123)
Now the newer API is the PaymentMethod API (pm_123)
When we built this in 2018, we made sure that all "legacy objects" continue to work so that no one had to collect card details gain for existing customers
does that make sense?
sorry, I do mean sources. So currently we are using sources and is planning on migrating to paymentMethod. My concern is what happens when a customer used to have sources > basically tokens from cardElement , and now instead of us updating 'sources' we are updating the payment_method (https://stripe.com/docs/api/payment_methods/attach). What happens when they have both 'sources' and payment_method?
that's kinda what I explained above
you seamlessly ignore sources and solely use PaymentMethods moving forward
and all existing "payment sources" will still work on the new API
Like say you have a customer with card_123 and card_ABC and now you add pm_123 now that Customer has all 3 as a PaymentMethod, they all work via the new API and the PaymentIntents API