New to GF and Stripe and I'm trying to add taxes to Stripe payments as given below (source https://stripe.com/docs/billing/taxes/tax-rates)
// Set your secret key. Remember to switch to your live secret key in production!
// See your keys here: https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
$tax_rate = \Stripe\TaxRate::create([
'display_name' => 'Sales Tax',
'description' => 'SF Sales Tax',
'jurisdiction' => 'CA - SF',
'percentage' => 8.5,
'inclusive' => false,
]);
However, it doesn't specify how/where the created $tax_rate object should be used.
I have looked through the available GF hooks but unsure where to make the call. Should it be added to charge meta as it looks like this is where the settings are taken from - line 1328 @ https://github.com/masoninthesis/gravityformsstripe/blob/master/class-gf-stripe.php.
$charge_meta = array(
'amount' => $this->get_amount_export( $submission_data['payment_amount'], rgar( $entry, 'currency' ) ),
'currency' => rgar( $entry, 'currency' ),
'description' => $this->get_payment_description( $entry, $submission_data, $feed ),
'capture' => false,
);
Line 1380 shows a call which creates the Stripe charge.
$charge = \Stripe\Charge::create( $charge_meta );
Stripe docs don't mention the tax property @ https://stripe.com/docs/api/orders/object.
I would really appreciate it someone could help me with the missing puzzle piece, please. Thank you!
The TaxRates API is for use with invoices or subscriptions, not one-off charges.
For one-off charges you'd calculate the tax yourself when passing in the amount to your Charge creation request.