#candy_cane

1 messages · Page 1 of 1 (latest)

velvet etherBOT
fickle yarrow
tribal sapphire
#

I do "confirmCardPayment" on client side, but "stripe.setupIntents.create" raises an error on the server.

fickle yarrow
#

what error?

tribal sapphire
fickle yarrow
#

that's on the backend though

#

that's you calling await stripe.setupIntents.confirm in Node.js

tribal sapphire
#

Yes, I want the error to raise on frontend.

fickle yarrow
#

then confirm the SetupIntent on the frontend.

tribal sapphire
#

Can you send me example on how would I confirm it on frontend?

tribal sapphire
#

This is what I am doing on the backend. Should I create a payment intent?

fickle yarrow
#

Should I create a payment intent?
not sure, do you want to?

#

can I clarify the difference between a SetupIntent and a PaymentIntent?

tribal sapphire
#

I want to create a subscription but when I attach Payment method directly to customer exception on server occurs.

fickle yarrow
#

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.

tribal sapphire
#

Ok, thanks!

fickle yarrow
#

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.

tribal sapphire
#

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".

fickle yarrow
#

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

tribal sapphire
#

Okay, thanks. I will give it a try.

fickle yarrow
#

payment_behavior: 'default_incomplete',