#jagg71
1 messages · Page 1 of 1 (latest)
hello
Hello 👋
For multiple products, you'll just add the appropriate price ID in the line_items parameter
https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=checkout#redirect-customers
maybe it s my fault because i give to the page "create_checkout_session.php" only one product.
if I give more products, they will display them all on the payment page, and calculate the right price with this code ?
$reqVerifArticle = $bdd->prepare('SELECT * FROM table WHERE produit = :id');
$reqVerifArticle->execute(['id' => $_GET['id']]);
if ($verifArticle = $reqVerifArticle->fetch()) {
$stripe = new \Stripe\StripeClient('sk_liv**********w');
$checkout_session = $stripe->checkout->sessions->create([
'line_items' => [[
'price_data' => [
'currency' => 'eur',
'product_data' => [
'name' => htmlspecialchars($verifArticle['produit_nom']),
'images' => [htmlspecialchars($verifArticle['produit_image'])],
],
'unit_amount' => htmlspecialchars($verifArticle['produit_tarif']),
],
'quantity' => $_GET['quant'],
]],
'mode' => 'payment',
'success_url' => 'https://****.fr/success',
'cancel_url' => 'https://****.fr/cancel',
'billing_address_collection' => 'required',
'phone_number_collection' => ['enabled' => true],
'invoice_creation' => ['enabled' => true],
]);
header("HTTP/1.1 303 See Other");
header("Location: " . $checkout_session->url);
}else{
header('Location:/');
exit;
};
?>
it's maybe because i give only only id on my request?
in your `
'price_data' => [
'currency' => 'eur',
'product_data' => [
'name' => htmlspecialchars($verifArticle['produit_nom']),
'images' => [htmlspecialchars($verifArticle['produit_image'])],
],
'unit_amount' => htmlspecialchars($verifArticle['produit_tarif']),
],
'quantity' => $_GET['quant'],
]],```
You're only creating one price
that reflects one line item in the checkout
yes, the price for the choosen product but if i have 2 differents products, it will work with this code ?
try it out
ok