0

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!

zumek
  • 608
  • 6
  • 14

1 Answers1

0

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.

Paul Asjes
  • 5,361
  • 1
  • 18
  • 20
  • Thanks Paul. I ended up using Gravity Perks - eCommerce field to add subtotal + tax to the form. It's a complex form and has many conditional pricing. If passing the tax inclusive amount to Stripe, need to be able to show the tax component on the Stripe invoice. Would you please be able to provide more detail as to how and I'll look to accept your answer? – zumek Apr 01 '20 at 00:37
  • You probably want to look at sending one-off invoices: https://stripe.com/docs/billing/invoices/sending You can add the tax as an invoice item, which will show up separately on their invoice. – Paul Asjes Apr 01 '20 at 01:11
  • Thanks Paul. Sorry, but I don't quite understand how that would be integrated with GF? – zumek Apr 02 '20 at 05:12
  • I think we're getting mixed up on terminology here. In Stripe world, invoices are for recurring payments via the Stripe Billing product. Charges or PaymentIntents are for one-off payments that don't require a subscription. It sounds like you want the latter, which doesn't support tax rates. Since you're integrating with Gravity Forms I suggest you reach out to them on whether they have a pre-built tax solution to be used with Stripe. – Paul Asjes Apr 02 '20 at 05:25
  • Thanks for your help on this, Paul - ended up working it out via the Stripe account – zumek Apr 14 '20 at 10:41