简体   繁体   English

Braintree JS SDK + Rails集成

[英]Braintree JS SDK + Rails integration

I've followed this integration almost word for word for my Rails 5 app to integrate Braintree SDK. 我已经按照这种整合几乎是逐字逐句为我的Rails应用5,整合布伦特里SDK。 All seems to be going well except my form will not show the default basic form to collect credit card info that comes with Dropin-UI. 一切似乎都进行得很好,除了我的表单不会显示默认的基本表单以收集Dropin-UI随附的信用卡信息。 It just has the purchase button, but that's it. 它只有购买按钮,仅此而已。

Console error says Uncaught ReferenceError: braintree is not defined 控制台错误显示Uncaught ReferenceError: braintree is not defined

Here is code: View (transactions/new): 这是代码:查看(交易/新):

<section class="container nav-main-override">
    <div class="row">
        <div class="form-container radius-box glassy-bg small-10 small-centered medium-8 large-6 columns">
         <h2 class="mbs">New Transaction</h2>
         <%= form_tag transactions_path do%>
         <p>Please enter your payment details:</p>
         <div id="dropin"></div>
         <%=submit_tag "Pay #{current_order.total_price}$", class: "button mt1" %>
         <%end%>
     </div>
   </div>
</section>

transactions controller: 交易控制器:

class TransactionsController < ApplicationController

  def new
      gon.client_token = generate_client_token
  end

  def generate_client_token
      Braintree::ClientToken.generate
    end

end

application.js application.js

$(document).on('ready page:load', function(){
     braintree.setup(gon.client_token, 'dropin', { container: 'dropin'});
});

Make sure to include this: 确保包括以下内容:

<script src="https://js.braintreegateway.com/v2/braintree.js"></script>

in your application layout. 在您的应用程序布局中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM