mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 19:34:39 -04:00
Add js
This commit is contained in:
parent
6f7a34ec7e
commit
0e5cd0f4ab
1
public/js/clients/payments/stripe-przelewy24.js
vendored
Normal file
1
public/js/clients/payments/stripe-przelewy24.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(n){var r={};function o(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.m=n,o.c=r,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/",o(o.s=6)}({6:function(e,t,n){e.exports=n("RFiP")},RFiP:function(e,t){var n;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var r=null!==(n=null===(r=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"",i=null!==(n=null===(n=document.querySelector('meta[name="stripe-account-id"]'))||void 0===n?void 0:n.content)&&void 0!==n?n:"";new function t(e,n){var r=this;!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),o(this,"setupStripe",function(){r.stripe=Stripe(r.key),r.stripeConnect&&(r.stripe.stripeAccount=i);let e=r.stripe.elements();return r.p24bank=e.create("p24bank",{style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}}),r.p24bank.mount("#p24-bank-element"),r}),o(this,"handle",function(){document.getElementById("pay-now").addEventListener("click",function(e){let t=document.getElementById("errors");return""===document.getElementById("p24-name").value?(document.getElementById("p24-name").focus(),t.textContent="Name required.",void(t.hidden=!1)):""===document.getElementById("p24-email-address").value?(document.getElementById("p24-email-address").focus(),t.textContent="Email required.",void(t.hidden=!1)):(document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),void this.stripe.confirmP24Payment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{p24:this.p24bank,billing_details:{name:document.getElementById("p24-name").value,email:document.getElementById("p24-email-address").value}},return_url:document.querySelector('meta[name="return-url"]').content}))})}),this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=n}(r,i).setupStripe().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
|
||||||
|
*/
|
89
resources/js/clients/payments/stripe-przelewy24.js
vendored
Normal file
89
resources/js/clients/payments/stripe-przelewy24.js
vendored
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/**
|
||||||
|
* 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 ProcessPRZELEWY24 {
|
||||||
|
constructor(key, stripeConnect) {
|
||||||
|
this.key = key;
|
||||||
|
this.errors = document.getElementById('errors');
|
||||||
|
this.stripeConnect = stripeConnect;
|
||||||
|
}
|
||||||
|
|
||||||
|
setupStripe = () => {
|
||||||
|
this.stripe = Stripe(this.key);
|
||||||
|
|
||||||
|
if(this.stripeConnect)
|
||||||
|
this.stripe.stripeAccount = stripeConnect;
|
||||||
|
let elements = this.stripe.elements()
|
||||||
|
var options = {
|
||||||
|
// Custom styling can be passed to options when creating an Element
|
||||||
|
style: {
|
||||||
|
base: {
|
||||||
|
padding: '10px 12px',
|
||||||
|
color: '#32325d',
|
||||||
|
fontSize: '16px',
|
||||||
|
'::placeholder': {
|
||||||
|
color: '#aab7c4'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
this.p24bank = elements.create('p24bank', options)
|
||||||
|
this.p24bank.mount('#p24-bank-element');
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
handle = () => {
|
||||||
|
document.getElementById('pay-now').addEventListener('click', (e) => {
|
||||||
|
let errors = document.getElementById('errors');
|
||||||
|
|
||||||
|
if (document.getElementById('p24-name').value === "") {
|
||||||
|
document.getElementById('p24-name').focus();
|
||||||
|
errors.textContent = "Name required.";
|
||||||
|
errors.hidden = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (document.getElementById('p24-email-address').value === "") {
|
||||||
|
document.getElementById('p24-email-address').focus();
|
||||||
|
errors.textContent = "Email required.";
|
||||||
|
errors.hidden = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('pay-now').disabled = true;
|
||||||
|
document.querySelector('#pay-now > svg').classList.remove('hidden');
|
||||||
|
document.querySelector('#pay-now > span').classList.add('hidden');
|
||||||
|
|
||||||
|
this.stripe.confirmP24Payment(
|
||||||
|
document.querySelector('meta[name=pi-client-secret').content,
|
||||||
|
{
|
||||||
|
payment_method: {
|
||||||
|
p24: this.p24bank,
|
||||||
|
billing_details: {
|
||||||
|
name: document.getElementById('p24-name').value,
|
||||||
|
email: document.getElementById('p24-email-address').value,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
return_url: document.querySelector(
|
||||||
|
'meta[name="return-url"]'
|
||||||
|
).content,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const publishableKey = document.querySelector(
|
||||||
|
'meta[name="stripe-publishable-key"]'
|
||||||
|
)?.content ?? '';
|
||||||
|
|
||||||
|
const stripeConnect =
|
||||||
|
document.querySelector('meta[name="stripe-account-id"]')?.content ?? '';
|
||||||
|
|
||||||
|
new ProcessPRZELEWY24(publishableKey, stripeConnect).setupStripe().handle();
|
Loading…
x
Reference in New Issue
Block a user