#eztaxi-checkout-php

1 messages · Page 1 of 1 (latest)

final ledge
#

Hey, what's the error you're seeing?

nimble flax
#

Hi thank you for your reply

#

PHP Fatal error: Uncaught (Status 400) (Request req_cR755gFGJHJ2HW) Received unknown parameters: price, quantity
thrown in /home/if_eztaxi/myezadmin/tickets/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php on line 38

final ledge
#

Thanks, checking

#

Hmm, are you sure that's the code that's triggering that API request? The payload we're receiving doesn't match up

nimble flax
#

let me try again

final ledge
#

For example , that API request (req_cR755gFGJHJ2HW) has a price_data parameter:

price_data: {
        price: "price_1KYx8bAd2Vi4ueDPhm5XgYC2",
        quantity: "1"
      },
      quantity: "1"
#

That API shape is invalid (you can't pass price and price_data)

#

But the code you shared doesn't have that, hence my confusion!

nimble flax
#

Oh sorry, I'm confused too

#

It seems working now! Yay!

#

$checkout_session = \Stripe\Checkout\Session::create([ 'line_items' => [ [ # TODO: replace this with the priceof the product you want to sell 'price' => $price_id, 'quantity' => $adult_qty, ], [ # TODO: replace this with thepriceof the product you want to sell 'price' => $price_id_child, 'quantity' => $child_qty, ],], /* 'line_items' => [[ # TODO: replace this with theprice of the product you want to sell 'price' => $price_id, 'quantity' => $max_qty, ],], */ 'payment_method_types' => [ 'card', ], 'metadata' => ["driver_id" => $driverid, "driver_name" => $driver], 'mode' => 'payment', 'billing_address_collection' => "auto", 'success_url' => $YOUR_DOMAIN . "/success.php?session_id={CHECKOUT_SESSION_ID}".$locid.$pmode, 'cancel_url' => $YOUR_DOMAIN . '/cancel.html', ]);

final ledge
#

Excellent!

nimble flax
#

regarding price_data can I add multiple price_id ?

final ledge
#

You wouldn't pass the ID of an existing Price object no. The purpose of price_data is to create an ad-hoc Price object at the same time as the Checkout Session

#

What are you trying to do?

nimble flax
#

$checkout_session = \Stripe\Checkout\Session::create([ 'line_items' => [ [ 'price_data' => [ 'currency' => 'aed', 'unit_amount' => $adult_amt, //'price' => $price_id, 'product_data' => [ 'name' => 'Adult - '.$prod_name, ], ], 'quantity' => $adult_qty, ], [ 'price_data' => [ 'currency' => 'aed', //'price' => $price_id_child, 'unit_amount' => $child_amt, 'product_data' => [ 'name' => 'Child - ' .$prod_name, ], ], 'quantity' => $child_qty, ], ], /* 'line_items' => [[ # TODO: replace this with the price of the product you want to sell 'price' => $price_id, 'quantity' => $max_qty, ],], */ 'payment_method_types' => [ 'card', ], 'metadata' => ["driver_id" => $driverid, "driver_name" => $driver], 'mode' => 'payment', 'billing_address_collection' => "auto", 'success_url' => $YOUR_DOMAIN . "/success.php?session_id={CHECKOUT_SESSION_ID}".$locid.$pmode, 'cancel_url' => $YOUR_DOMAIN . '/cancel.html', ]);

#

if you see in this code I commented out 'price_id' because it throws error

#

this code works good but it creates new price_id after every transactions

final ledge
#

So you can create a 'custom' price without having to create the Price object prior to using it with Checkout

nimble flax
#

great! this is what I want

final ledge
nimble flax
#

Yeah you're right, I'm already using metadata for driver_id hope it works too

#

It's done! Thank you so much for your help

final ledge
#

Sure. np!