#Jokezor-recurring
1 messages · Page 1 of 1 (latest)
The thing I'm not following is how we'd do the authentication required for users that weren't logged in
hi! not sure I follow that. Do you mean, what happens when you charge the customer's saved card when they're not physically present on the site?
Well both.
-
We have the CardNumberElement, CardExpiryElement, CardCvcElement in our react frontend to collect the card details. But do I need to render something else to the users that are logged in?
-
For users that are not logged in, do I need to save the payment_intent in an email/db and make them login and fetch the payment_intent and then render the verification form like the logged in user?
But do I need to render something else to the users that are logged in?
if you're charging their saved card, then no. You can just have a button("pay with your saved card") and call https://stripe.com/docs/js/payment_intents/confirm_card_payment#stripe_confirm_card_payment-existing directly to attempt the payment
for "non-logged in" customers(i.e charging them directly from your server without them present), you would create and confirm a PaymentIntent off_session on your server as described at https://stripe.com/docs/payments/save-and-reuse?platform=web#web-create-payment-intent-off-session. If that fails for any reason(including requiring authentication) then you would bring the customer back to your site and then you do the same thing as above really, have a button to attempt the payment client-side with the saved card(there's an example in this link too). If that fails too then you might want to present a regular card form and ask them to try a different card.
thanks
I tried now to use a card that required authentication and the payment_intent still just returns the payment_intent id
I used the card 4000 0027 6000 3184
And I have this when creating the payment_intent:
return PaymentIntent.create(**payment_intent_options)
except CardError as e:
error = e.error
print("error is ", error)
return error
The thing is it never gets to the CardError even though it's supposed to according to the docs above
are you passing off_session:true?
yes
you only get a decline like that on off session payments, for on-session you get a 200 response and the PaymentIntent in the requires_action status instead
can you share the pi_xxx then?
These are the parameters I'm using:
Oh
I had setup_future_usage but not off_session to true
Sorry about that.
I'll retry it
yep no worries, setup_future_usage and off_session are entirely different but they are definitely easy to confuse
you use setup_future_usage on the first PI when saving the card, and off_session on the second one when charging the saved card
We have a flow where you might save the card but not pay directly so to keep it simple, does it hurt to keep it regardless if it's the first PI?
I don't track if they have made payments with one card before