I've read this https://stripe.com/docs/tutorials/subscriptions but don't really understand the idea of subscriptions in respect to implementation.
What I need is being to charge the user but the amount of charge is to be calculated by myself because I have a special algorithm for it. So this code:
# create a plan - once!
Stripe::Plan.create(
:amount => 2000,
:interval => 'month',
:name => 'Amazing Gold Plan',
:currency => 'cad',
:id => 'gold'
)
# every month? or also once?
maybe_customer = Stripe::Customer.retrieve(....)
unless maybe_customer
customer = Stripe::Customer.create(
:card => token,
:plan => "gold",
:email => "[email protected]"
)
end
When (how often) do I have to run it: only once or every month (:interval => 'month'
)?
If every month, I'll run it as a cron task. But how to get the user to enter in their credit card details? Or do they have to enter them in only the first time, then I save them and then will be able to re-use them?
UPDATE:
Since it's a subscription, it's to occur automatically. Does that mean that it's completely automatic for the user? Or do they have to enter their card details into the pop up from Stripe once and from that moment on it'll become automatic for the user, meaning they won't have to enter their bank card details anymore, they will be charged automatically by stripe each month later?
How do charge the user zero cents as a monthly pay if some (my) condition is true and using account_balance
? From this https://support.stripe.com/questions/metered-subscription-billing I don't understand how to do that.
I don't see any difference between a subscription and just charging a customer like if it were the normal payments. If both cases I have to run a code once a month on the server. What's the difference?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…