Vinu PR
Vinu PR

Reputation: 255

I cant pass client reference id with mode as subscription in Stripe checkout. Is there any way I can pass client reference id?

With mode as 'payment' , I can pass client reference id in stripe implementation. This is the code i have used enter image description here

I have passed client reference id with mode as 'payment' and it worked in my angular project, but when i changed mode to 'subscription' the client reference id is not passing.

Upvotes: 1

Views: 721

Answers (1)

vanya
vanya

Reputation: 623

I replicated the setup on my end and passed the clientReferenceId (see code below). I am seeing the clientReferenceId property on the checkout.session.completed event. Note, the prop is only available on the Checkout Session object, so you will not see it on the PaymentIntent or any other objects.

On another note, client-only checkout is deprecated, I recommend following the Checkout Session integration guide instead.

await stripe.redirectToCheckout({
    mode: 'subscription',
    lineItems: [
        {
            price: SUBSCRIPTION_PRICE,
            quantity: 1,
        },
    ],
    successUrl: `${baseUrl}/redirect`,
    cancelUrl: `${baseUrl}/`,
    clientReferenceId: 'testid',
})

Upvotes: 5

Related Questions