ill*_*ist 5 coupon stripe-payments ruby-on-rails-4
我有订阅,如果我更新它将coupon如何申请优惠券?客户已经支付了金额,现在我将通过我的管理仪表板编辑来申请100%的折扣优惠券.
这是怎么处理的?
谢谢
这就是我的方式.
首先,我更新了客户的订阅:
customer = Stripe::Customer.retrieve(customer_id)
subscription = customer.retrieve(subscription_id)
subscription.coupon = "coupon_id"
subscription.save
Run Code Online (Sandbox Code Playgroud)
然后coupon,使用折扣散列中的详细信息更新客户的订阅.
然后我手动退还该charge客户的对象(如果优惠券是100%折扣优惠券).
charge = customer.retrieve(stripe_charge_id)
refund = charge.refund
Run Code Online (Sandbox Code Playgroud)
然后charge,amount_refunded在应用优惠券后,使用折扣金额更新对象.refunded使用更新的refunds哈希也设置为true .
您还可以通过传递金额来创建特定金额的退款,例如:
re = Stripe::Refund.create(
charge: charge_id,
amount: amount_you_want_to_refund
)
Run Code Online (Sandbox Code Playgroud)
对于即将开具的发票,将为该折扣金额创建发票.
| 归档时间: |
|
| 查看次数: |
840 次 |
| 最近记录: |