Reputation: 536
Is there a way to pass dynamic data to the Stripe API? I'm using the example found here: https://stripe.com/docs/payments/checkout/client
I'd like to be able to pass a token along with the purchase in order to link an account with that payment. After the client side sends the payment to the API, my backend would receive the details of the payment, including the token to link it to an account created before this. I would add it as a param to to the successful redirect, but if they close the window early then the accounts will not be linked. I set up my product using the dashboard.
I tried using metadata and description as a part of the line item, but it keeps saying "Invalid stripe.redirectToCheckout parameter: lineItems.0.description is not an accepted parameter."
let token;
stripe.redirectToCheckout({
lineItems: [{
price: 'boop', // Replace with the ID of your price
quantity: 1,
description: token
}],
mode: 'payment',
successUrl: 'http://boop.com',
cancelUrl: 'http://boop.com',
}).then(function (result) {
// If `redirectToCheckout` fails due to a browser or network
// error, display the localized error message to your customer
// using `result.error.message`.
});
Thank you!
Upvotes: 0
Views: 587
Reputation: 536
You can achieve what I wanted through the Server + Client integration by using the client_reference_id
when creating a session.
Upvotes: 0
Reputation: 2908
In order to pass metadata
and other fields in Checkout, you need to use the Server + Client integration path instead of the client-only integration.
Upvotes: 1