我爲我的iOS應用使用Stripe進行支付,使用example provided實施我的後端,唯一的區別是我的應用只使用計劃,而不是收費。我只是想知道plan creation code在web.rb。在Sinatra後端放置條紋計劃的地方
是這樣的:
post '/charge' do
# Get the credit card details submitted by the form
source = params[:source] || params[:stripe_token] || params[:stripeToken]
customer = params[:customer]
# Create the charge on Stripe's servers - this will charge the user's card
begin
Stripe::Plan.create(
:amount => 2000,
:interval => 'month',
:name => 'Amazing Gold Plan',
:currency => 'usd',
:id => 'gold'
)
rescue Stripe::StripeError => e
status 402
return "Error creating charge: #{e.message}"
end
status 200
return "Charge successfully created"
end
還是應該在計劃中的方法之外定義?我的意思是,這個問題是否會在每次調用post /charge
時定義一個名爲「令人驚歎的黃金計劃」的新計劃,還是隻會將新客戶綁定到現有計劃?
是的,我有點想念,說你可以在儀表板上的計劃的一部分。現在變得更有意義了。 – rigdonmr