我们有以下流程要使用不起作用的条带来实现,
假设我有一个客户,他在2021年9月1日以3000$ per month价格订阅了服务。
现在是月中,假设2021年9月15日,他们已将其价格更改为1500$ per month。
因此,条纹将设置比例,从技术上讲,客户将不会在2021年10月1日收取费用,因为他们在月中将价格降级为半价,因此下个月1500$他们已经支付了。
但这是我们需要的,而不是在2021年10月1日收取0,我们想在2021年10月1日收取1500$,当价格变化差额应该退还给客户时。
我尝试将按比例分配行为设置为“无”,但这不起作用。随之而来的是,我有账单周期锚设置为每月1日,并有30天的试用期,当任何客户第一次进来。
如何创建订阅?
const product = await stripe.products.create({
name: 'Gold Plan',
})
const price = await stripe.prices.create({
unit_amount: 3000,
currency: 'USD',
recurring: {
interval: 'month',
},
product: product.id,
})
const stripeCustomer = await stripe.customers.create({
email: 'dipesh@stackoverflow.com',
})
const paymentMethod = await stripe.paymentMethods.create({
type: 'card',
card: {
number: '4242424242424242',
exp_month: 9,
exp_year: 2022,
cvc: '314',
},
})
const customerPaymentMethod = await stripe.paymentMethods.attach(paymentMethod.id, {
customer: stripeCustomer.id,
})
const subscription = await stripe.subscriptions.create({
customer: stripeCustomer.id,
items: [{
price: price.id,
}],
default_payment_method: paymentMethod.id,
proration_behavior: 'none',
billing_cycle_anchor: Math.round(new Date('2021-10-01').getTime() / 1000),
})如何更新价格?
const subscriptionId = req.query.sid
const subscription = await stripe.subscriptions.update(subscriptionId, {
proration_behavior: 'none',
})
const product = await stripe.products.create({
name: 'Silver Plan',
})
const price = await stripe.prices.create({
unit_amount: 1500,
currency: 'USD',
recurring: {
interval: 'month',
},
product: product.id,
})
const subscriptionItem = await stripe.subscriptionItems.update(subscription.items.data[0].id, {
price: price.id,
})发布于 2021-09-14 18:42:19
如果您根本不想要任何比例分配,那么您的代码需要为订阅的每一次更新设置proration_behavior: none。这包括您正在对订阅项进行的更新,因为该更改将导致基础订阅上的按比例分配。
尝试将您的代码更改为以下代码,看看是否有效:
const subscriptionItem = await stripe.subscriptionItems.update(subscription.items.data[0].id, {
price: price.id,
proration_behavior: 'none',
})您额外询问客户有关任何负差价(如降级)的退款问题不会自动支持条带订阅。支持此流程的唯一方法是继续使用proration_behavior: none,自己计算按比例计算的差价,并生成一个Credit Note,并对适当的金额进行退款。
https://stackoverflow.com/questions/69171259
复制相似问题