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
2017-11-03 16:26:07 +11:00

39 lines
1.1 KiB
JavaScript
Vendored

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);
});
}
}
};