#Digit-API-Version
1 messages · Page 1 of 1 (latest)
Hi there!
Moving your other message into this thread: invalid_request_error You cannot use line_items.amount, line_items.currency, line_items.name, line_items.description, or line_items.images in this API version. Please use line_items.price or line_items.price_data. Ces informations vous ont-elles été utiles ?
So this sounds like an effect of our new API version we just released: https://stripe.com/docs/upgrades#2022-08-01
Did you just create the new account this week?
And are you using a plugin or developing your own integration?
Yes, I created the account this afternoon
No a plugin
session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => [[
….
Gotcha. So if you want to use your past code you will need to use the 2020-08-27 API version. You can do this by versioning your requests: https://stripe.com/docs/api/versioning
That said, overall I would recommend updating your code to using price_data as the older parameters have been deprecated (but supported) for quite a while.
Then you can also take advantage of the features in the new API version that was just released.
Here is my full code
require_once('../../assets/stripe-php/init.php');
\Stripe\Stripe::setApiKey('sk_test_XXXXXX');
// Creation d'une session stripe avec vos produits vos prix vos images et urls de retour
$session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => [[
'name' => 'XXXXX',
'description' => 'XXXXX',
'images' => ['XXXXXX'],
'amount' => 500,
'currency' => 'eur',
'quantity' => 1,
]],
'success_url' => 'XXXXXX',
'cancel_url' => 'XXXXXX',
]);
?>
<html>
<!-- Redirection vers le checkout SCA 3D SECURE de stripe avec votre $session->id -->
<script src="https://js.stripe.com/v3/"></script>
<script>
const stripe = Stripe('pk_test_XXXXXXX');
stripe.redirectToCheckout({
sessionId: '<?php echo $session->id;?>'
}).then((result) => {
console.log(result.error.message);
});
</script>
Je ne vois pas trop quoi changer :/
Sorry I can only correspond in English here.
You can take a look at our migration guide here for what to change: https://stripe.com/docs/payments/checkout/migrating-prices#server-side-code-for-inline-items
I don’t see what to change on my code
The line_items hash needs to use the price_data sub-hash.
So instead of 'line_items' => [[ 'name' => 'XXXXX', 'description' => 'XXXXX', 'images' => ['XXXXXX'], 'amount' => 500, 'currency' => 'eur', 'quantity' => 1, ]],
it would be something like:
'price_data' => [
'currency' => 'usd',
'unit_amount' => 500,
'product_data' => [
'name' => 'XXXX',
'description' => 'XXX',
'images' => ['XXX'],
],
],
],```