#ilyoTheHorrid
1 messages · Page 1 of 1 (latest)
Hi! Let me help you with this.
You can use Stripe Tax for that: https://stripe.com/docs/tax
thank you, but how do I do it as part of the payment intent API call?
As part of this:
const paymentIntent = await stripe.paymentIntents.create({
amount: Number(amount) * 100,
currency: 'usd',
customer: stripeCustomer,
payment_method: paymentMethods.data[0].id,
off_session: true,
confirm: true
})
You can follow this guide for PaymentIntents: https://stripe.com/docs/tax/custom
So to make sure: I need to run stripe.tax.calculations.create and then use and use the result as the amount in checkout?
You will need to create a tax transaction and reference the payment intent, like so: https://stripe.com/docs/tax/custom#tax-transaction
I'm not sure how this answers my question.
What is the difference between using stripe.tax.transactions.createFromCalculation and stripe.tax.calculations.create ?
stripe.tax.calculations.create just calculates a theoretical number,
stripe.tax.transactions.createFromCalculation actually applies the calculation to a specific paymentintent.
What do you mean by "a theoretical number"? This makes no sense. Why would you have an API is the calculation is not accurate?
If I do
paymentIntent = await stripe.paymentIntents.update(cart.paymentIntent, {
amount: taxCalculation.amount_total,
metadata: {calculation: taxCalculation.id},
});
This is also applied to a specific paymentintent. So what is the difference?
Sorry for the wording. I mean it's an exact number, but it's not applied to a real-life transaction at that point.
Here, in stripe.tax.transactions.createFromCalculation you create a record for that tax calculation in your transactions. It helps with your reporting.
This updates the total amount, but there will be no record that some part of this is tax.
Ah, ok, now I understand, than you.