【问题标题】:Changing Stripe currency from default USD to GBP将 Stripe 货币从默认美元更改为英镑
【发布时间】:2016-02-08 08:03:03
【问题描述】:

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

我目前的看法:

    <%= 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 的新手 :)

谢谢!

【问题讨论】:

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


    【解决方案1】:

    您需要将货币添加到 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>
    

    【讨论】:

    • 嗨,马特 - 这似乎不起作用。我认为结束脚本标记之前的 > 是错误的(?)但即使没有它也没有什么区别。没有错误只是美元仍在使用。
    • 我会仔细检查数据货币是否实际被渲染,它应该可以按照stripe.com/docs/checkout
    • 您可能还需要在收费电话中更改货币
    猜你喜欢
    • 1970-01-01
    • 2014-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-28
    • 2019-01-21
    相关资源
    最近更新 更多