SolidCloudinc
SolidCloudinc

Reputation: 321

Multiple products (shopping cart) stripe API

I'd like to be able to itemize multiple products when charging with the stripe API. That way the automatically sent out receipt will list out each product. I don't want to just charge the total shopping cart amount and a general description.

How would I also add a $5 tie with the description 'tie' to the charge below.

$charge = \Stripe\Charge::create(array(
    "amount" => 1100,
    "currency" => "usd",
    "source" => $_POST['stripeToken'],
    'receipt_email' => $email,
    "description" => 'shirt'))

Upvotes: 2

Views: 2828

Answers (2)

shady
shady

Reputation: 11

i prepare my cart collection as

<?php 

$purchased='';


for($i=0;$i<count($POST['items']);$i++){

    $purchased.=( "=> item id : ".$POST['items'][$i]." unit price  ".$POST['price'][$i]." qnt ".$POST['qnt'][$i]." ;");
}

?>

then pass it to stripe description

<?php 


$charge=\Stripe\Charge::create(array(
"amount"=>$total_fee*100,
    "currency"=>"usd",
    "description"=>$purchased,// the trick
    "customer"=>$customer->id
));
?>

this work fine for me but we need more

Upvotes: 0

koopajah
koopajah

Reputation: 25622

That is not something that Stripe supports today. When you create a one-time charge via the API, you can only pass the total amount to charge.

Another option would be to use the Orders API. This lets you define Products in your account and then create an Order that lists all the products being bought. The limitation though is that email receipts still won't display the list of items and you would have to use a third-party application.

Upvotes: 1

Related Questions