I've implemented the new Stripe Checkout
on my NodeJS server
, but I cannot specify the Tax Rate for Invoicing.
As per my understanding Tax Rates should be specified in the Payment Intent API. Fact is that the new Checkout
automatically creates a Payment Intent
via its CreateSession (see payment_intent_data
), but I'm not able to insert a Tax Rate upon its creation.
How can this be done? What I want to achieve is to have the user know the Tax % both in the Checkout UI
and in the final email invoice
.
This is my code:
return stripe.checkout.sessions.create({
payment_method_types: [paymentMethod],
line_items: [{
name: name,
description: description,
images: [imageUrl],
amount: amount,
currency: currency,
quantity: 1
}],
success_url: successUrl,
cancel_url: cancelUrl,
customer: stripeId,
payment_intent_data: {
receipt_email: email,
metadata: {
userId: userId,
amount: amount,
currency: currency,
ref: ref,
stripeId: stripeId,
details: details
}
}
}).then(session => {
return res.send(session)
I've implemented the new Stripe Checkout
on my NodeJS server
, but I cannot specify the Tax Rate for Invoicing.
As per my understanding Tax Rates should be specified in the Payment Intent API. Fact is that the new Checkout
automatically creates a Payment Intent
via its CreateSession (see payment_intent_data
), but I'm not able to insert a Tax Rate upon its creation.
How can this be done? What I want to achieve is to have the user know the Tax % both in the Checkout UI
and in the final email invoice
.
This is my code:
return stripe.checkout.sessions.create({
payment_method_types: [paymentMethod],
line_items: [{
name: name,
description: description,
images: [imageUrl],
amount: amount,
currency: currency,
quantity: 1
}],
success_url: successUrl,
cancel_url: cancelUrl,
customer: stripeId,
payment_intent_data: {
receipt_email: email,
metadata: {
userId: userId,
amount: amount,
currency: currency,
ref: ref,
stripeId: stripeId,
details: details
}
}
}).then(session => {
return res.send(session)
Share
Improve this question
edited Jun 4, 2024 at 13:50
Bora M. Alper
3,8441 gold badge26 silver badges36 bronze badges
asked May 12, 2019 at 9:38
r4id4r4id4
6,0778 gold badges47 silver badges81 bronze badges
6
|
Show 1 more comment
4 Answers
Reset to default 7At the time of this answer, Stripe Checkout does not support Tax Rates.
One alternative is to collect payment details using "setup" mode Checkout [1], then create a PaymentIntent [2] from your server with the PaymentMethod collected in Checkout and the Tax Rate you'd like to use.
[1] https://stripe.com/docs/payments/checkout/collecting
[2] https://stripe.com/docs/api/payment_intents/create
Stripe checkout support now Tax rates.
From "Stripe.net" 35.12.0 version, you can set a default tax rate when you create a new session.
var options = new SessionCreateOptions {
PaymentMethodTypes = new List<string> {
"card",
},
SubscriptionData = new SessionSubscriptionDataOptions {
DefaultTaxRates = new List<string> {
_STRIPE_OPTIONS.Tax // Your tax rate id
},
Items = new List<SessionSubscriptionDataItemOptions> {
new SessionSubscriptionDataItemOptions {
Plan = request.PlanId, // Your plan id
},
},
},
Customer = customer.StripeCustomerId,
SuccessUrl = _STRIPE_OPTIONS.SuccessUrl,
CancelUrl = _STRIPE_OPTIONS.CancelUrl
};
var service = new SessionService();
var session = service.Create(options);
Don't forgot to update your webhook version if you are using one.
Tax rates are now in beta on Stripe Checkout for one-time payments, see here: https://stripe.com/docs/payments/checkout/taxes
You can email to join the beta program and try it out.
Right now, note that dynamic tax rates are only supported in US, Europe and certain countries specified here (https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-dynamic_tax_rates) so watch out
Create the object of "stripe.taxRates.create()", then, assign the "id" to "tax_rates" as shown below:
const taxRate = await stripe.taxRates.create({ // Here
display_name: 'Sales Tax',
percentage: 7.25,
inclusive: false
});
const session = await stripe.checkout.sessions.create({
line_items: [
{
'price_data': {
'currency': 'usd',
'unit_amount': 20,
'product_data': {
'name': 'T-shirt',
},
},
'quantity': 2,
'tax_rates': [taxRate.id] // Here
},
],
mode: 'payment',
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel'
});
Invoice
objects, which are primarily used in conjunction withSubscriptions
, not the one time payment 'line items' created by this checkout session. stripe.com/docs/api/subscriptions/… stripe.com/docs/api/payment_intents/create I might email Stripe with a feature request on this! – duck Commented May 12, 2019 at 16:48