#Lucas974
1 messages · Page 1 of 1 (latest)
Hi there. stripe.redirectToCheckout is our client-side-checkout integration and is not currently recommended. That's a legacy, deprecated flow: https://stripe.com/docs/js/deprecated/redirect_to_checkout
But if you're still intent on using it, a list of valid params are at that above link
Ok, so how can I convert this to the new version?
This migration guide shows how to use the newer flow: https://stripe.com/docs/payments/checkout/migration
Shows all the migrations you need to perform to move to the newer flow
import { loadStripe } from '@stripe/stripe-js';
export default function handlePayment(event){
const stripeLoadedPromise = loadStripe(import.meta.env.VITE_STRIPE_API_KEY);
stripeLoadedPromise.then(stripe => {
stripe.redirectToCheckout({
lineItems:[{
price: import.meta.env.VITE_STRIPE_PRODUCT_ID,
quantity: 1
}],
mode: "payment",
invoice_creation: {enabled: true},
successUrl: '/',
cancelUrl: `${import.meta.env.VITE_URL_ROOT}/`,
billingAddressCollection: 'required',
locale: 'fr',
submitType: 'pay'
})
.then(response => {
console.log(response.error);
})
.catch(error => {
console.log(error);
});
});
}
yeah as you can see at the first link I sent you, invoice_creation isn't a valid param
ok and the rest of the file is so the old version ?
do you have an example like the one I posted but using the new syntax?
And I use it on the client side, not backend side
With the new flow, you'll need to create the checkout session on the server. If you read the guide I sent, it explains everything
ok thank's