部分未显示在新的充电控制器(条带)上

时间:2016-02-13 15:31:12

标签: ruby-on-rails stripe-payments partial

我制作了一个新的控制器来整合Stripe Checkout,但它作为自己的整个网站,我的部分(_header,_footer)都没有显示。

目前的设置直接来自他们的教程https://stripe.com/docs/checkout/guides/rails

充电控制器

class ChargesController < ApplicationController

    def new
    end

def create
  # Amount in cents
  @amount = 100

    customer = Stripe::Customer.create(
        :email => params[:stripeEmail],
        :source  => params[:stripeToken],
        :plan => "tier1",

  )



rescue Stripe::CardError => e
  flash[:error] = e.message
  redirect_to new_charge_path
end


end

路线

Rails.application.routes.draw do
  get 'password_resets/new'

  get 'password_resets/edit'

  get 'sessions/new'

  root             'static_pages#home'
  get 'help'    => 'static_pages#help'
  get 'about'   => 'static_pages#about'
  get 'contact' => 'static_pages#contact'
  get 'signup'  => 'users#new'
  get    'login'   => 'sessions#new'
  post   'login'   => 'sessions#create'
  delete 'logout'  => 'sessions#destroy'
  get 'charges' => 'charges#new'

  resources :users
  resources :account_activations, only: [:edit]
  resources :password_resets,     only: [:new, :create, :edit, :update]
  resources :charges
end

/layouts/charges.html.erb(控制器视图)

<% provide(:title, 'Edit Billing') %>


  <%= yield %>

views / charges / new.html.erb(带有Stripe Checkout的表单)

<%= form_tag charges_path do %>
  <article>
    <% if flash[:error].present? %>
      <div id="error_explanation">
        <p><%= flash[:error] %></p>
      </div>
    <% end %>
    <label class="amount">
      <span>Amount: $1.00</span>
    </label>
  </article>

  <script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
          data-key="<%= Rails.configuration.stripe[:publishable_key] %>"
          data-description="Tier 1 Monthly Subscription"
          data-amount="100"
          data-locale="auto"
          data-image="images/marketplace.png"
          data-name="Pallet Tier 1"
          data-description="Tier 1 Monthly Subscription"
          data-label="Join" >


  </script>

views / charges / create.html.erb(成功收费后重定向)

<% provide(:title, 'Edit Billing') %>

<h2>Thanks, you paid <strong>$1.00</strong>!</h2>

0 个答案:

没有答案