Stripe checkout process
P粉590929392
P粉590929392 2023-09-10 18:27:22
0
1
510

Try implementing a shopping cart using Stripe, but what should it look like?

//checkout.php

$checkout_session = $stripe->checkout->sessions->create([
   'line_items' => [

    // foreach item listed in POST data,
    //  [],[],[],...

   ]
   'mode' => 'payment'
   'success_url' => $YOUR_DOMAIN . '/success.html',
   'cancel_url' => $YOUR_DOMAIN . '/cancel.html'
]);

Do I send everything the client wants in $_POST?

So I'm making a form on my domain?

Is there any other way to do this, where the customer can add to cart and continue shopping on my site, then checkout?

Any words of appreciation.

P粉590929392
P粉590929392

reply all(1)
P粉316110779

As I understand it, you don't want to checkout every time the user selects a product? Maybe you could remember the cart's information in local storage, including the price ID and individual quantity from Stripe. Then, when the user decides to pay, you can use the checkout form (Stripe provides you with a ready-made implementation) and send all the information for all the products the customer has in his/her own shopping cart.

From the code you wrote, you may have already checked it, but please take a closer look here You can see that you can add multiple items in list_items so that you can integrate from The frontend passes them and then sends the request to sripe from the backend like you wrote here.

If I've misunderstood the question here, please tell me more and I'll be happy to help

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template