阅读背景:

如何使用Stripe API为客户的订阅提供不可退款的信贷?

来源:互联网 

My app charges premium customers $X.00 per month, however, I would like certain actions to give customers a credit against their monthly subscription fee. For example, if a customer submits a record to the database, they are given a credit (stored in the database). I would like each credit they earn to give them

My app charges premium customers $X.00 per month, however, I would like certain actions to give customers a credit against their monthly subscription fee. For example, if a customer submits a record to the database, they are given a credit (stored in the database). I would like each credit they earn to give them $0.50 off of their next month's subscription, however, if they cancel their subscription, I do not want it to seem like I owe them that money (it should only be usable towards subscription fees). What is the best way to achieve this through the Stripe API?

我的应用程序向高级客户收取X美元的费用。但是,我想采取一些行动,根据客户的月订阅费给他们一个信用。例如,如果客户向数据库提交一条记录,就会给他们一个信用(存储在数据库中)。我希望他们挣的每一笔钱都能让他们在下个月的订阅中少赚0.5美元,但是,如果他们取消了订阅,我不想让他们觉得我欠他们那笔钱(应该只用于订阅费用)。通过Stripe API实现这一目标的最佳方式是什么?

If it makes a difference, I am using Rails 4, Ruby 2, Stripe, Koudoku for subscriptions, and Devise for authentication.

如果有什么不同,我将使用Rails 4、Ruby 2、Stripe、Koudoku进行订阅,并设计用于身份验证。

Thanks!

谢谢!

2 个解决方案

#1


4  

You want to set your app up to handle Stripe web hooks if you haven't already done so. When a new invoice is created, if you have a web hook URL set up, it will notify you via the hook and wait an hour before processing payment. This design is setup for exactly what you want.

如果你还没有这样做的话,你可以设置你的应用程序来处理条带网络挂钩。当创建新发票时,如果您设置了一个web hook URL,它将通过hook通知您,并在处理付款前等待一个小时。这个设计是为您想要的东西而设置的。

When you get notified the invoice has been created, if there are credits for the user, create one or more negative invoice items to represent the credits.

当您收到通知时,发票已经创建,如果用户有信用,创建一个或多个负的发票项目来表示信用。

Since you aren't creating the credits in Stripe until right before payment processing, the scenario of them canceling with credit doesn't apply.

由于您在付款处理之前不会在条状中创建信用,因此使用信用取消的场景不适用。

You can also of course do other things when adding the negative invoice items for the credits like check to make sure you aren't crediting them more than their invoice total.

当然,你也可以做其他的事情,当你为信用项加上负的发票项目时,比如支票,以确保你所贷的金额不超过他们的发票总额。

#2


1  

I would give them a coupon. Coupons can have expiration dates and can be a simple percentage, which would ensure that you would owe them nothing should they unsubscribe. You could just convert your $0.50 to the appropriate percentage.

我会给他们一张优惠券。优惠券可以有到期日,也可以是一个简单的百分比,这将确保你在他们退订时不会欠他们任何东西。你可以把0。5美元换成适当的百分比。

The api allows you to create coupons that you can give to users using the user update API:

该api允许您创建优惠券,您可以使用用户更新api向用户提供:

Stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"

cu = Stripe::Customer.retrieve("cus_3oLCDGtGqkJElc")
cu.description = "Customer for [email protected]"
cu.coupon = "12OFF"
cu.save

.50 off of their next month's subscription, however, if they cancel their subscription, I do not want it to seem like I owe them that money (it should only be usable towards subscription fees). What is the best way to achieve this through the Stripe API?My app charges premium customers $X.00 per mont




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: