我有订阅,如果我用coupon更新它,优惠券将如何申请?客户已经支付了金额,现在我将申请一个100%的折扣优惠券,编辑从我的管理仪表板。
这是怎么处理的?
谢谢
发布于 2016-03-16 04:45:37
我就是这样做的。
首先,我更新了客户的订阅:
customer = Stripe::Customer.retrieve(customer_id)
subscription = customer.retrieve(subscription_id)
subscription.coupon = "coupon_id"
subscription.save然后,使用折扣散列中coupon的详细信息更新客户的订阅。
然后我手动退还该客户的charge对象(如果优惠券是100%折扣优惠券)。
charge = customer.retrieve(stripe_charge_id)
refund = charge.refund然后,在应用优惠券之后,用折扣金额用charge对象更新amount_refunded对象。此外,通过更新的refunded哈希将refunds设置为true。
您还可以通过传递金额来为某些金额创建退款,例如:
re = Stripe::Refund.create(
charge: charge_id,
amount: amount_you_want_to_refund
)对于即将到来的发票,发票是为该折扣金额创建的。
发布于 2016-03-14 11:03:29
下面是如何用Ruby中的优惠券更新现有订阅:
customer = Stripe::Customer.retrieve("cus_...")
subscription = customer.subscriptions.retrieve("sub_...")
subscription.coupon = "coupon_code"
subscription.save优惠券将适用于下一张发票的认购,但以往的发票将不受影响。
https://stackoverflow.com/questions/35980553
复制相似问题