#Marcia da Silva
1 messages · Page 1 of 1 (latest)
Hey @sweet turret , currently, when we create a payment, we use the "charge" endpoint, where we submit a client token and receive the charge data back.
We are planning to start charging customers automatically as part of a renewal logic we are building.
Our implementation idea is to read the customer data we have stored on stripe, and use the payment_method value to get the credit card id, so, we can then charge the user again without having to request them to fill out the form. The implementation would be similar to this:
const stripeChargeData = await stripe.charges.create({
amount: <amount in cents>,
currency: "cad",
description: <description>,
receipt_email: <customer email>,
capture: true,
metadata: <data>,
customer: <customer_id>,
source: <payment_method - credit card id>
})
Do you see any possible problems with this implementation using the stripe call above to generate a new payment for existing customers by sending the payment method as the "source" param?
Overall that works fine, but the Charges API is our legacy API. The recommended route here would be to use the PaymentIntents API: https://stripe.com/docs/api/payment_intents/create. You can do everything you are doing above with PaymentIntents. The payment_method parameter is backwards compatible and accepts Card ID. The main benefit of the PaymentIntents API is that you can set off_session: true (https://stripe.com/docs/api/payment_intents/create#create_payment_intent-off_session) for these recurring payments where your Customer is not present. This allows us to apply for exemptions with the issuing bank so that 3DS (authentication) isn't requested on these charges since the Customer isn't present to handle authentication.
Thank you very much for confirming it. I wasn't aware of the PaymentIntent, that looks like something we can explore, but, I believe at this moment we won't be able to take advantage of this function because we are using an older version and we need to get the renewal done before the upgrade to a newer stripe version. Since you think this is ok, I believe for now we will go ahead with the legacy version and upgrade it later and follow your recommendation. Thanks again.