#Digit-API-Version

1 messages · Page 1 of 1 (latest)

karmic otter
#

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 ?

#

Did you just create the new account this week?

#

And are you using a plugin or developing your own integration?

tidal veldt
#

Yes, I created the account this afternoon

#

No a plugin

#

session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => [[

#

….

karmic otter
#

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.

tidal veldt
#

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 :/

karmic otter
#

Sorry I can only correspond in English here.

tidal veldt
#

I don’t see what to change on my code

karmic otter
#

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'],
      ],
     ],
    ],```
tidal veldt
#

ah okay yes I see a little better

#

I will test then and let you know