#chris-checkout-tax
1 messages · Page 1 of 1 (latest)
chris-checkout-tax
Hey @jagged ferry. I would recommend reading https://stripe.com/docs/payments/checkout/taxes first
Thanks, Koopajah. I'm a little confused, as I read this earlier, but I don't use defined products.
My code is:
$checkout_session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => [[
'price_data' => [
'currency' => 'gbp',
'unit_amount' => '2000',
'product_data' => [
'name' => 'Test',
'description' => 'Test',
'tax_behavior' => 'exclusive',
'tax_code' => 'txcd_20030000'
],
],
'adjustable_quantity' => [
'enabled' => false
],
'quantity' => 1,
]],
'metadata' => [
'entry_id' => $_POST['entry_id']
],
'automatic_tax' => [
'enabled' => true,
],
'mode' => 'payment',
'allow_promotion_codes' => false,
'billing_address_collection' => 'required',
'success_url' => $YOUR_DOMAIN . 'success',
'cancel_url' => $YOUR_DOMAIN . 'cancelled'
]);
that's a lot of code. So what's the problem? What's confusing/not working?
It returns the error: "Received unknown parameter: line_items[0][price_data][product_data][tax_behavior]"
From what I have understood in the documentation, the product data requires the two tax params
Is this not correcT?
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-product_data-tax_code we support tax_code but not tax_behavior on that API
So if you want to control tax_behavior you have to create the Product upfront
I removed tax behaviour and its now reporting: "One or more provided prices do not have a tax_behavior set which is required for automatic tax computation."
yeah so that means you have to create a Product first
So you can't have tax applied to a on the fly product?
correct, looks like tax_behavior is required in your case and it's not supported in that specific case
Can you confirm where the docs are for adding an existing product from the dashboard in a checkout session?
You would pass product: 'prod_123' instead of product_data in the code above
I get "Received unknown parameter: line_items[0][product]"
$checkout_session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => [[
'product' => 'prod_MysVARSKdidn97',
'adjustable_quantity' => [
'enabled' => false
],
'quantity' => 1,
]],
'metadata' => [
'entry_id' => $_POST['entry_id']
],
'automatic_tax' => [
'enabled' => true,
],
'mode' => 'payment',
'allow_promotion_codes' => false,
'billing_address_collection' => 'required',
'success_url' => $YOUR_DOMAIN . '/account/assured-supplier-application/step-6',
'cancel_url' => $YOUR_DOMAIN . '/account/assured-supplier-application'
]);
yeah sorry that's not what I said to change
I said to remove product_data and put product instead. That still goes inside price_data since you said you create a Product in the Dashboard, not a Price
'payment_method_types' => ['card'],
'line_items' => [[
'price_data' => [
'currency' => 'gbp',
'unit_amount' => '2000',
'product' => 'prod_123',
],
],
...
I'm now getting "One or more provided prices do not have a tax_behavior set which is required for automatic tax computation."
did you properly set tax behavior https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-tax_behavior ?