[英]Tax Rate in new Stripe Checkout
我已经在我的NodeJS server
上实现了新的Stripe Checkout
,但我无法指定发票的税率。
据我了解,应在Payment Intent API中指定税率。 事实上,新的Checkout
会通过其CreateSession自动创建Payment Intent
(请参阅payment_intent_data
),但我无法在创建时插入税率。
如何才能做到这一点? 我想要实现的是让用户在Checkout UI
和最终email invoice
中都知道 Tax % 。
这是我的代码:
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)
在此回答时,Stripe Checkout 不支持税率。
一种替代方法是使用“设置”模式 Checkout [1] 收集付款详细信息,然后使用 Checkout 中收集的 PaymentMethod 和您想要使用的税率从您的服务器创建一个 PaymentIntent [2]。
条纹结帐支持现在税率。
从“Stripe.net”35.12.0 版本开始,您可以在创建新会话时设置默认税率。
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);
如果您使用的是 webhook,请不要忘记更新您的 webhook 版本。
一次性付款的 Stripe Checkout 税率现在处于测试阶段,请参见此处: https ://stripe.com/docs/payments/checkout/taxes
您可以通过电子邮件加入测试计划并试用。
现在,请注意,动态税率仅在美国、欧洲和此处指定的某些国家/地区( https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-dynamic_tax_rates )支持,因此请注意
创建 “stripe.taxRates.create()”的对象,然后将“id”分配给“tax_rates” ,如下所示:
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'
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.