#candy_cane
1 messages · Page 1 of 1 (latest)
hi! you would confirm on the client side instead and type the test numbers into Elements etc. https://stripe.com/docs/testing#declined-payments
I do "confirmCardPayment" on client side, but "stripe.setupIntents.create" raises an error on the server.
what error?
For example, when I use test card with insufficient funds:
that's on the backend though
that's you calling await stripe.setupIntents.confirm in Node.js
Yes, I want the error to raise on frontend.
then confirm the SetupIntent on the frontend.
Can you send me example on how would I confirm it on frontend?
Should I create a payment intent?
not sure, do you want to?
can I clarify the difference between a SetupIntent and a PaymentIntent?
I want to create a subscription but when I attach Payment method directly to customer exception on server occurs.
when I attach Payment method directly to customer
the things is you should never be doing that
if it's for a subscription you would use the guide https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements — that involves confirming a PaymentIntent on the frontend and that confirmation will attach the card to the customer, charge it, and make it the default for any future payments all in one step. And it will also handle declines/errors with localised errors since it's on the frontend.
Ok, thanks!
the backend code you presented seems to be following that guide
like you create the Subscription and you return .json({ client_secret: paymentIntent.client_secret! }); to the frontend which is all good. So on the frontend you'd use confirmPayment like it says. Not sure what issue you're running into exactly since you seem to be following the guide.
If I dont attach the Payment method to customer I get "The customer does not have a payment method with the ID pm_1O29wGFd9r7pbKmKqpUBNoJd. The payment method must be attached to the customer.". But I am specifying "default_payment_method: paymentMethodId".
that's why you're not supposed to pass default_payment_method
you're supposed to use the 'incomplete' subscription behaviour as the docs describe
Okay, thanks. I will give it a try.