将条纹货币从默认美元更改为英镑

时间:2016-02-08 08:03:03

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

我认为我已经更改了使用GBP而不是USD所需的代码部分。然而,虽然正确的数字显示在我的Stripe卡充电模式中,但“充电”按钮仍显示USD。

我目前的观点:

    <%= link_to 'Enroll', course_enrollments_path(@course), class: 'btn btn-primary', method: :post %>
    <%= form_tag course_enrollments_path(@course) 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="<%= (@course.cost * 100).to_i %>"></script>
    <% end %>

我现在的控制人员:

def create
    current_user.enrollments.create(course: current_course)

    # Amount in pence
    @amount = (current_course.cost * 100).to_i

    customer = Stripe::Customer.create(
      :email => current_user.email,
      :card  => params[:stripeToken]
    )

    charge = Stripe::Charge.create(
      :customer    => customer.id,
      :amount      => @amount,
      :description => 'Flixter Enrollment',
      :currency    => 'gbp'
    )

    redirect_to course_path(current_course)

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

道歉,如果我没有提供足够的信息或我的术语是错误的 - 我是编码和StackOverflow的新手:)

谢谢!

1 个答案:

答案 0 :(得分:2)

您需要将货币添加到Stripe Checkout,如下所示

<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="<%= (@course.cost * 100).to_i %>"
        data-currency="GBP"
        ></script>