#jagg71

1 messages · Page 1 of 1 (latest)

wooden flaxBOT
steel elm
#

hello

glossy stream
steel elm
#

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?

glossy stream
#

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

steel elm
#

yes, the price for the choosen product but if i have 2 differents products, it will work with this code ?

glossy stream
#

try it out

steel elm
#

ok