Created
August 7, 2018 21:40
-
-
Save jakubstraka/0a5c73d98ed1d6b32f4fb683c9bb30db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
script src="https://js.braintreegateway.com/web/dropin/1.9.4/js/dropin.min.js" | |
javascript: | |
var form = document.querySelector('.payment'); | |
var client_token = "#{component.client_token}"; | |
braintree.dropin.create({ | |
authorization: client_token, | |
container: '#bt-dropin', | |
paypal: { | |
flow: 'vault' | |
} | |
}, function (createErr, instance) { | |
if (createErr) { | |
console.log('Error', createErr); | |
return; | |
} | |
form.addEventListener('submit', function (event) { | |
event.preventDefault(); | |
instance.requestPaymentMethod(function (err, payload) { | |
if (err) { | |
console.log('Error', err); | |
return; | |
} | |
// Add the nonce to the form and submit | |
document.querySelector('#nonce').value = payload.nonce; | |
form.submit(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment