Reputation: 398
I've followed this integration almost word for word for my Rails 5 app to integrate Braintree 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. It just has the purchase button, but that's it.
Console error says 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
$(document).on('ready page:load', function(){
braintree.setup(gon.client_token, 'dropin', { container: 'dropin'});
});
Upvotes: 0
Views: 198
Reputation: 1701
Make sure to include this:
<script src="https://js.braintreegateway.com/v2/braintree.js"></script>
in your application layout.
Upvotes: 0