Sha256: 73ba91134773e7b21ef557ba0ebda7676d832a8ef6511e6201c7a908e1484479
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
//= require "vendor/braintree-2.14.0" Spree.routes.payment_client_token_api = Spree.pathFor("api/payment_client_token") var braintreeDropinIntegration; var cardSelector = "#new_payment [name=card]"; var getClientToken = function(onSuccess) { return Spree.ajax({ url: Spree.routes.payment_client_token_api, type: "POST", data: { payment_method_id: $('form input[type=radio]:checked').val() }, error: function(xhr, status) { show_flash("error", xhr.responseJSON.message); }, success: function(data) { onSuccess(data); } }); }; var attachDropIn = function(data) { braintree.setup(data.client_token, "dropin", { container: "braintree-dropin", form: "new_payment", onReady: function (integration) { braintreeDropinIntegration = integration; }, onError: function(type, message) { show_flash("error", message); }, onPaymentMethodReceived: function(obj) { $("#payment_method_nonce").val(obj.nonce); $("#new_payment").submit(); return; } }); }; $(document).ready(function() { if ($(cardSelector).length) { $(cardSelector).on("change", function() { if ($(cardSelector + ":checked").val() === "new") { getClientToken(attachDropIn); } else { if (braintreeDropinIntegration) { braintreeDropinIntegration.teardown(); } } }); } else { getClientToken(attachDropIn); } });
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
solidus_braintree-0.2.1 | lib/assets/javascripts/spree/backend/braintree/solidus_braintree.js |
solidus_braintree-0.2.0 | lib/assets/javascripts/spree/backend/braintree/solidus_braintree.js |