#chris-checkout-tax

1 messages · Page 1 of 1 (latest)

quaint forgeBOT
little bane
#

chris-checkout-tax

jagged ferry
#

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'
]);

little bane
#

that's a lot of code. So what's the problem? What's confusing/not working?

jagged ferry
#

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?

little bane
jagged ferry
#

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."

little bane
#

yeah so that means you have to create a Product first

jagged ferry
#

So you can't have tax applied to a on the fly product?

little bane
#

correct, looks like tax_behavior is required in your case and it's not supported in that specific case

jagged ferry
#

Can you confirm where the docs are for adding an existing product from the dashboard in a checkout session?

little bane
#

You would pass product: 'prod_123' instead of product_data in the code above

jagged ferry
#

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'
]);

little bane
#

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',
          ],
        ],
        ...
jagged ferry
#

I'm now getting "One or more provided prices do not have a tax_behavior set which is required for automatic tax computation."

jagged ferry
#

Its working now! I moved the param

#

Thank you for your help