Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Add a javascript method to fetch braintree tokens #37

Merged
merged 1 commit into from
Oct 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/assets/javascripts/spree/frontend/solidus_paypal_braintree.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
window.SolidusPaypalBraintree = {
APPLE_PAY_API_VERSION: 1,

fetchToken: function(tokenCallback) {
Spree.ajax({
dataType: 'json',
type: 'POST',
url: Spree.pathFor('solidus_paypal_braintree/client_token'),
success: function(response) {
tokenCallback(response.client_token, response.payment_method_id);
},
error: function(xhr) {
console.error("Error fetching braintree token");
}
});
},

initialize: function(authToken, clientReadyCallback) {
braintree.client.create({
authorization: authToken
Expand Down