This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
site-base/spark/resources/assets/js/mixins/braintree.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-11-03 05:26:07 +00:00
window.braintreeCheckout = [];
module.exports = {
methods: {
/**
* Configure the Braintree container.
*/
braintree(containerName, callback) {
braintree.setup(Spark.braintreeToken, 'dropin', {
container: containerName,
paypal: {
singleUse: false,
locale: 'en_us',
enableShippingAddress: false
},
dataCollector: {
paypal: true
},
onReady(checkout) {
window.braintreeCheckout[containerName] = checkout;
},
onPaymentMethodReceived: callback
});
},
/**
* Reset the Braintree container.
*/
resetBraintree(containerName, callback) {
window.braintreeCheckout[containerName].teardown(() => {
window.braintreeCheckout[containerName] = null;
this.braintree(containerName, callback);
});
}
}
};