Option for business purchase is missing when using the checkout tag
Description
When creating a checkout link in Stripe, I have the option to check if a user can select if the purchase is a business purchase. Then you get 2 more fields in stripe when you pay. Business name and VAT number.
But when creating a checkout link from Enupal, this option is not available. Can you add this option as well?
I fixed this issue for myself, in the services/Checkout.php I changed the following code:
if ($form->automaticTax) {
$sessionParams['automatic_tax'] = [
'enabled' => true
];
if (isset($sessionParams['customer'])) {
$sessionParams['customer_update'] = [
'shipping' => 'auto'
];
}
}
I used the $sessionParams['customer'] outside the automatic Tax block, and added the tax_id_collection parameter.
Like this:
if ($form->automaticTax) {
$sessionParams['automatic_tax'] = [
'enabled' => true
];
}
if (isset($sessionParams['customer'])) {
$sessionParams['customer_update'] = [
'name' => 'auto',
'shipping' => 'auto'
];
}
$sessionParams['tax_id_collection']['enabled'] = true;
Maybe this helps you to implement it ;)
Hi @tomfischerNL Similar to https://github.com/enupal/stripe/issues/334 this is also a great use case to use the beforeCreateSession event:
use enupal\stripe\services\Checkout;
use enupal\stripe\events\CheckoutEvent;
use enupal\stripe\Stripe;
use craft\base\Plugin;
use Craft;
class YourPlugin extends Plugin
{
public function init()
{
....
....
Event::on(Checkout::class, Checkout::EVENT_BEFORE_CREATE_SESSION, function(CheckoutEvent $e) {
$isCart = $e->isCart;
$sessionParams = $e->sessionParams;
//overwrite $sessionParams
$sessionParams['tax_id_collection']['enabled'] = true;
if (isset($sessionParams['customer'])) {
$sessionParams['customer_update'] = [
'name' => 'auto',
'shipping' => 'auto'
];
}
$e->sessionParams = $sessionParams;
});
...
...
}
}
Please let me know if you have any questions
Thanks!
Maybe you can think of a way to implement the $sessionParams['tax_id_collection']['enabled'] = true; tag, as an option to the forms or in the back-end, for example in the sidebar, where you can also check if you want to show the shipping address etc. Because it is a regular option if you create a payment in stripe itself :)

Hi @andrelopez,
Do you have some more info about this? How can I add the "Business purchase" / VAT number to the checkout tag?
Any status update on this?
Hi @tomfischerNL could you please confirm your Craft CMS version?