Open shankie-codes opened 8 years ago
I've found a solution – rather than filtering pmpro_tax
(which looks to just add tax onto the total), I've instead added a tax element onto the subscription object. This is likely to be a Stripe-specific solution, so I think that the original problem still needs addressing, but this works in my case for 20% UK VAT:
// Update the tax calculation if buyer is in the UK
function customtax_region_tax_check()
{
// check if a country is set. If it is and the country is GB, then add on VAT
if(isset($_REQUEST['bcountry']) && $_REQUEST['bcountry'] == 'GB')
{
//update the session var
$_SESSION['bcountry'] = $_REQUEST['bcountry'];
// Add VAT
add_filter('pmpro_stripe_create_subscription_array', function($subscription){
$subscription['tax_percent'] = 20;
return $subscription;
}, 20);
}
}
add_action("init", "customtax_region_tax_check");
We will look into passing the tax amount to Stripe separate of the total.
For both subscriptions and single payments, the Stripe gateway adds the tax amount directly to the total rather than using Stripe's tax_percent
The two examples I've found are:
https://github.com/strangerstudios/paid-memberships-pro/blob/dev/classes/gateways/class.pmprogateway_stripe.php#L1092 https://github.com/strangerstudios/paid-memberships-pro/blob/dev/classes/gateways/class.pmprogateway_stripe.php#L1373
I'll do a bit of investigation and if I get anywhere open a PR – but any help would be kindly appreciated!