1
Это моя первая интегральная полоса. Я установил страницы # покупки в качестве моей домашней страницы. Я использую controller_controller для обработки платежа по полосе. ОшибкаОшибочная ошибка «Нет совпадений маршрута» Rails
ActionController::RoutingError (No route matches [POST] "/payments/create"):
Маршруты
resources :payments, only: [:create]
Rake Маршруты
payments POST /payments(.:format) payments#create
Страницы/Покупка
<%= form_tag "/payments/create" do %>
<%= render partial: "shared/stripe_checkout_button" %>
<% end %>
Shared/_stripe_checkout_button
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="<%= Rails.configuration.stripe[:publishable_key] %>"
data-image="/square-image.png"
data-name="Demo Site"
data-description="2 widgets ($20.00)"
data-amount="2000">
</script>
Платежи Контроллер
def create #You want might to make actions more specific.
token = params[:stripeToken] #The token when the form is posted includes the stripe token in the url.
# Create the charge in stripes servers. This is what commits the transaction.
begin
charge = Stripe::Charge.create(
:amount => 200,
:currency => "usd",
:source => token,
:description => params[:stripeEmail]
)
rescue Stripe::CardError => e
#The card was decline because of number/ccv error, expired error, bank decline, or zip error
body = e.json_body
err = body[:error]
flash[:error] = "There was an error in processing your card: #{err[:message]}"
end
end