【发布时间】:2019-06-20 20:16:42
【问题描述】:
我打算使用 Stripe 来处理信用卡。
但是,我已经有一个程序可以根据客户对我们产品的订阅来计算他们的月薪,而且由于计算非常复杂,我不想使用 Stripe 的系统重新制作整个东西。
所以,
是否可以在不使用 Stripe 的 PLAN api 的情况下定期向客户收费?
如果是这样,我该如何实现?
【问题讨论】:
标签: stripe-payments
我打算使用 Stripe 来处理信用卡。
但是,我已经有一个程序可以根据客户对我们产品的订阅来计算他们的月薪,而且由于计算非常复杂,我不想使用 Stripe 的系统重新制作整个东西。
所以,
是否可以在不使用 Stripe 的 PLAN api 的情况下定期向客户收费?
如果是这样,我该如何实现?
【问题讨论】:
标签: stripe-payments
是的,您可以在 Stripe 中向客户收费,而无需使用他们的订阅逻辑。
为此,您需要在前端收集卡信息,然后将其保存到 Stripe 中的客户;您可以将此客户的 ID 存储在您的数据库中。
在向用户收费时,您可以让您的应用程序从您在 Stripe 中创建的客户的保存卡中收费。
# Create a Customer:
customer = Stripe::Customer.create({
source: 'tok_mastercard',
email: 'paying.user@example.com',
})
# Charge the Customer instead of the card:
charge = Stripe::Charge.create({
amount: 1000,
currency: 'usd',
customer: customer.id,
})
# YOUR CODE: Save the customer ID and other info in a database for later.
# When it's time to charge the customer again, retrieve the customer ID.
charge = Stripe::Charge.create({
amount: 1500, # $15.00 this time
currency: 'usd',
customer: customer_id, # Previously stored, then retrieved
})
【讨论】: