0
與條紋不同的計劃,我有我的訂閱控制器是這樣的: -如何實現on Rails的
class SubscribeController < ApplicationController
before_filter :authenticate_client!
def new
end
def update
#gets the credit card details submitted in the form
token = params[:stripeToken]
#create a customer
customer = Stripe::Customer.create(
card: token,
plan: 111,
email: current_user.email,
)
current_client.subscribed = true
current_client.stripeid = customer.id
current_client.plan_id = 111
current_client.save
redirect_to root_path, notice: "Your subscription was set up successfully!"
end
end
這裏111是我的計劃ID爲基礎。
現在,我想採取這種不同的付款方式說基本和溢價。例如,如果用戶點擊一個按鈕,他應該能夠支付基本的10美元,並且如果他點擊保險費,他必須能夠支付保險費20美元。
我有我的看法是這樣的: -
#views/subscirbe/new.html.erb
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3 panel panel-default form-style">
<div class="panel-body">
<h2>Final Signup Step</h2>
<h4>This is the final step to give you full access to PinAuth Services</h4>
<%= render 'form' %>
</div>
</div>
</div>
</div>
而作爲
<%= form_tag subscribe_path(1), method: :put do %>
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="<%= Rails.configuration.stripe[:publishable_key] %>"
data-description="A month's subscription"
data-amount="2900"></script><span> $29 per month, cancel at any time.</span>
<% end %>
我使用過https://www.payola.io/blog/payola-subscriptions/ – Abram
此外,這看起來很有幫助https://www.youtube.com/watch?v=hyEsiwc0ys4 – Abram
@Abram,我已經嘗試過之前的YouTube鏈接。謝謝。我通過爲不同的付款方式創建不同的控制器來解決問題。 –