mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Extract credit cards to separate Javascript
This commit is contained in:
parent
2ab65b12fa
commit
bc23de2ce2
2
public/css/app.css
vendored
2
public/css/app.css
vendored
File diff suppressed because one or more lines are too long
2
public/js/clients/payments/braintree-credit-card.js
vendored
Normal file
2
public/js/clients/payments/braintree-credit-card.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/*! For license information please see braintree-credit-card.js.LICENSE.txt */
|
||||
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=17)}({17:function(e,t,n){e.exports=n("jPAV")},jPAV:function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(new(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,r,o;return t=e,(r=[{key:"initBraintreeDataCollector",value:function(){window.braintree.client.create({authorization:document.querySelector("meta[name=client-token]").content},(function(e,t){window.braintree.dataCollector.create({client:t,paypal:!0},(function(e,t){e||(document.querySelector("input[name=client-data]").value=t.deviceData)}))}))}},{key:"mountBraintreePaymentWidget",value:function(){window.braintree.dropin.create({authorization:document.querySelector("meta[name=client-token]").content,container:"#dropin-container"},this.handleCallback)}},{key:"handleCallback",value:function(e,t){if(e)console.error(e);else{var n=document.getElementById("pay-now");n.addEventListener("click",(function(){t.requestPaymentMethod((function(e,t){if(e)return console.error(e);n.disabled=!0,n.querySelector("svg").classList.remove("hidden"),n.querySelector("span").classList.add("hidden"),document.querySelector("input[name=gateway_response]").value=JSON.stringify(t);var r=document.querySelector('input[name="token-billing-checkbox"]:checked');r&&(document.querySelector('input[name="store_card"]').value=r.value),document.getElementById("server-response").submit()}))}))}}},{key:"handle",value:function(){this.initBraintreeDataCollector(),this.mountBraintreePaymentWidget(),Array.from(document.getElementsByClassName("toggle-payment-with-token")).forEach((function(e){return e.addEventListener("click",(function(e){document.getElementById("dropin-container").classList.add("hidden"),document.getElementById("save-card--container").style.display="none",document.querySelector("input[name=token]").value=e.target.dataset.token,document.getElementById("pay-now-with-token").classList.remove("hidden"),document.getElementById("pay-now").classList.add("hidden")}))})),document.getElementById("toggle-payment-with-credit-card").addEventListener("click",(function(e){document.getElementById("dropin-container").classList.remove("hidden"),document.getElementById("save-card--container").style.display="grid",document.querySelector("input[name=token]").value="",document.getElementById("pay-now-with-token").classList.add("hidden"),document.getElementById("pay-now").classList.remove("hidden")}));var e=document.getElementById("pay-now-with-token");e.addEventListener("click",(function(t){e.disabled=!0,e.querySelector("svg").classList.remove("hidden"),e.querySelector("span").classList.add("hidden"),document.getElementById("server-response").submit()}))}}])&&n(t.prototype,r),o&&n(t,o),e}())).handle()}});
|
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
@ -1,11 +1,12 @@
|
||||
{
|
||||
"/js/app.js": "/js/app.js?id=696e8203d5e8e7cf5ff5",
|
||||
"/css/app.css": "/css/app.css?id=2163e6d43930f4ad9253",
|
||||
"/css/app.css": "/css/app.css?id=941462bb9c0bd274bc70",
|
||||
"/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=a09bb529b8e1826f13b4",
|
||||
"/js/clients/invoices/payment.js": "/js/clients/invoices/payment.js?id=8ce8955ba775ea5f47d1",
|
||||
"/js/clients/linkify-urls.js": "/js/clients/linkify-urls.js?id=0dc8c34010d09195d2f7",
|
||||
"/js/clients/payment_methods/authorize-authorize-card.js": "/js/clients/payment_methods/authorize-authorize-card.js?id=206d7de4ac97612980ff",
|
||||
"/js/clients/payments/authorize-credit-card-payment.js": "/js/clients/payments/authorize-credit-card-payment.js?id=a376eff2227da398b0ba",
|
||||
"/js/clients/payments/braintree-credit-card.js": "/js/clients/payments/braintree-credit-card.js?id=81957e7cb1cb49f23b90",
|
||||
"/js/clients/payments/card-js.min.js": "/js/clients/payments/card-js.min.js?id=5469146cd629ea1b5c20",
|
||||
"/js/clients/payments/checkout-credit-card.js": "/js/clients/payments/checkout-credit-card.js?id=98e406fa8e4db0e93427",
|
||||
"/js/clients/payments/stripe-ach.js": "/js/clients/payments/stripe-ach.js?id=76d8ba6a814b3015e359",
|
||||
|
112
resources/js/clients/payments/braintree-credit-card.js
vendored
Normal file
112
resources/js/clients/payments/braintree-credit-card.js
vendored
Normal file
@ -0,0 +1,112 @@
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
|
||||
class BraintreeCreditCard {
|
||||
initBraintreeDataCollector() {
|
||||
window.braintree.client.create({
|
||||
authorization: document.querySelector('meta[name=client-token]').content
|
||||
}, function (err, clientInstance) {
|
||||
window.braintree.dataCollector.create({
|
||||
client: clientInstance,
|
||||
paypal: true
|
||||
}, function (err, dataCollectorInstance) {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
|
||||
document.querySelector('input[name=client-data]').value = dataCollectorInstance.deviceData;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
mountBraintreePaymentWidget() {
|
||||
window.braintree.dropin.create({
|
||||
authorization: document.querySelector('meta[name=client-token]').content,
|
||||
container: '#dropin-container'
|
||||
}, this.handleCallback);
|
||||
}
|
||||
|
||||
handleCallback(error, dropinInstance) {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let payNow = document.getElementById('pay-now');
|
||||
|
||||
payNow.addEventListener('click', () => {
|
||||
dropinInstance.requestPaymentMethod((error, payload) => {
|
||||
if (error) {
|
||||
return console.error(error);
|
||||
}
|
||||
|
||||
payNow.disabled = true;
|
||||
|
||||
payNow.querySelector('svg').classList.remove('hidden');
|
||||
payNow.querySelector('span').classList.add('hidden');
|
||||
|
||||
document.querySelector('input[name=gateway_response]').value = JSON.stringify(payload);
|
||||
|
||||
let tokenBillingCheckbox = document.querySelector(
|
||||
'input[name="token-billing-checkbox"]:checked'
|
||||
);
|
||||
|
||||
if (tokenBillingCheckbox) {
|
||||
document.querySelector('input[name="store_card"]').value =
|
||||
tokenBillingCheckbox.value;
|
||||
}
|
||||
|
||||
document.getElementById('server-response').submit();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
handle() {
|
||||
this.initBraintreeDataCollector();
|
||||
this.mountBraintreePaymentWidget();
|
||||
|
||||
Array
|
||||
.from(document.getElementsByClassName('toggle-payment-with-token'))
|
||||
.forEach((element) => element.addEventListener('click', (element) => {
|
||||
document.getElementById('dropin-container').classList.add('hidden');
|
||||
document.getElementById('save-card--container').style.display = 'none';
|
||||
document.querySelector('input[name=token]').value = element.target.dataset.token;
|
||||
|
||||
document.getElementById('pay-now-with-token').classList.remove('hidden');
|
||||
document.getElementById('pay-now').classList.add('hidden');
|
||||
}));
|
||||
|
||||
document
|
||||
.getElementById('toggle-payment-with-credit-card')
|
||||
.addEventListener('click', (element) => {
|
||||
document.getElementById('dropin-container').classList.remove('hidden');
|
||||
document.getElementById('save-card--container').style.display = 'grid';
|
||||
document.querySelector('input[name=token]').value = "";
|
||||
|
||||
document.getElementById('pay-now-with-token').classList.add('hidden');
|
||||
document.getElementById('pay-now').classList.remove('hidden');
|
||||
});
|
||||
|
||||
let payNowWithToken = document.getElementById('pay-now-with-token');
|
||||
|
||||
payNowWithToken
|
||||
.addEventListener('click', (element) => {
|
||||
payNowWithToken.disabled = true;
|
||||
payNowWithToken.querySelector('svg').classList.remove('hidden');
|
||||
payNowWithToken.querySelector('span').classList.add('hidden');
|
||||
|
||||
document.getElementById('server-response').submit();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
new BraintreeCreditCard().handle();
|
@ -70,107 +70,5 @@
|
||||
@endsection
|
||||
|
||||
@section('gateway_footer')
|
||||
<script type="text/javascript">
|
||||
class BraintreeCreditCard {
|
||||
initBraintreeDataCollector() {
|
||||
window.braintree.client.create({
|
||||
authorization: document.querySelector('meta[name=client-token]').content
|
||||
}, function (err, clientInstance) {
|
||||
window.braintree.dataCollector.create({
|
||||
client: clientInstance,
|
||||
paypal: true
|
||||
}, function (err, dataCollectorInstance) {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
|
||||
document.querySelector('input[name=client-data]').value = dataCollectorInstance.deviceData;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
mountBraintreePaymentWidget() {
|
||||
window.braintree.dropin.create({
|
||||
authorization: document.querySelector('meta[name=client-token]').content,
|
||||
container: '#dropin-container'
|
||||
}, this.handleCallback);
|
||||
}
|
||||
|
||||
handleCallback(error, dropinInstance) {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let payNow = document.getElementById('pay-now');
|
||||
|
||||
payNow.addEventListener('click', () => {
|
||||
dropinInstance.requestPaymentMethod((error, payload) => {
|
||||
if (error) {
|
||||
return console.error(error);
|
||||
}
|
||||
|
||||
payNow.disabled = true;
|
||||
|
||||
payNow.querySelector('svg').classList.remove('hidden');
|
||||
payNow.querySelector('span').classList.add('hidden');
|
||||
|
||||
document.querySelector('input[name=gateway_response]').value = JSON.stringify(payload);
|
||||
|
||||
let tokenBillingCheckbox = document.querySelector(
|
||||
'input[name="token-billing-checkbox"]:checked'
|
||||
);
|
||||
|
||||
if (tokenBillingCheckbox) {
|
||||
document.querySelector('input[name="store_card"]').value =
|
||||
tokenBillingCheckbox.value;
|
||||
}
|
||||
|
||||
document.getElementById('server-response').submit();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
handle() {
|
||||
this.initBraintreeDataCollector();
|
||||
this.mountBraintreePaymentWidget();
|
||||
|
||||
Array
|
||||
.from(document.getElementsByClassName('toggle-payment-with-token'))
|
||||
.forEach((element) => element.addEventListener('click', (element) => {
|
||||
document.getElementById('dropin-container').classList.add('hidden');
|
||||
document.getElementById('save-card--container').style.display = 'none';
|
||||
document.querySelector('input[name=token]').value = element.target.dataset.token;
|
||||
|
||||
document.getElementById('pay-now-with-token').classList.remove('hidden');
|
||||
document.getElementById('pay-now').classList.add('hidden');
|
||||
}));
|
||||
|
||||
document
|
||||
.getElementById('toggle-payment-with-credit-card')
|
||||
.addEventListener('click', (element) => {
|
||||
document.getElementById('dropin-container').classList.remove('hidden');
|
||||
document.getElementById('save-card--container').style.display = 'grid';
|
||||
document.querySelector('input[name=token]').value = "";
|
||||
|
||||
document.getElementById('pay-now-with-token').classList.add('hidden');
|
||||
document.getElementById('pay-now').classList.remove('hidden');
|
||||
});
|
||||
|
||||
let payNowWithToken = document.getElementById('pay-now-with-token');
|
||||
|
||||
payNowWithToken
|
||||
.addEventListener('click', (element) => {
|
||||
payNowWithToken.disabled = true;
|
||||
payNowWithToken.querySelector('svg').classList.remove('hidden');
|
||||
payNowWithToken.querySelector('span').classList.add('hidden');
|
||||
|
||||
document.getElementById('server-response').submit();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
new BraintreeCreditCard().handle();
|
||||
</script>
|
||||
<script src="{{ asset('js/clients/payments/braintree-credit-card.js') }}"></script>
|
||||
@endsection
|
||||
|
4
webpack.mix.js
vendored
4
webpack.mix.js
vendored
@ -65,6 +65,10 @@ mix.js("resources/js/app.js", "public/js")
|
||||
.js(
|
||||
"resources/js/clients/linkify-urls.js",
|
||||
"public/js/clients/linkify-urls.js"
|
||||
)
|
||||
.js(
|
||||
"resources/js/clients/payments/braintree-credit-card.js",
|
||||
"public/js/clients/payments/braintree-credit-card.js"
|
||||
);
|
||||
|
||||
mix.copyDirectory('node_modules/card-js/card-js.min.css', 'public/css/card-js.min.css');
|
||||
|
Loading…
x
Reference in New Issue
Block a user