【发布时间】:2022-01-31 22:06:51
【问题描述】:
我已经实施了按年计费的条带式定期订阅。我向我的客户提出了一项优惠,如果他们将我们的网站推荐给他们的 5 位朋友并注册,他们的订阅将获得 50% 的折扣。
我将如何在下次付款时为该特定客户实施该折扣?
【问题讨论】:
标签: stripe-payments stripe-customer-portal
我已经实施了按年计费的条带式定期订阅。我向我的客户提出了一项优惠,如果他们将我们的网站推荐给他们的 5 位朋友并注册,他们的订阅将获得 50% 的折扣。
我将如何在下次付款时为该特定客户实施该折扣?
【问题讨论】:
标签: stripe-payments stripe-customer-portal
最简单的选择是将Coupon 应用于客户的订阅。然后在订阅的下一个计费周期中,将自动应用优惠券。可以做到的是两步(这里做的是node.js):
// Create the new Coupon, once
// Doc: https://stripe.com/docs/api/coupons/create
const coupon = await stripe.coupons.create({
percent_off: 50,
duration: 'once', // other possible value are 'forever' or 'repeating'
});
// Then every time a customer match your criteria, update their subscription
// Doc: https://stripe.com/docs/api/subscriptions/update
const subscription = await stripe.subscriptions.update(
'sub_xxx',
{ coupon: coupon.id }
);
另一种选择是将优惠券应用于客户,而不是直接应用于订阅。在这种情况下,优惠券将适用于该客户的所有经常性费用。
// Doc: https://stripe.com/docs/api/customers/update
const customer = await stripe.customers.update(
'cus_xxx',
{ coupon: coupon.id }
);
【讨论】: