Free javascript Hosting


payment.js

Uploaded on Feb 16 2022 19:54 by akhalil

<script>
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
const e="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,t=(e,t,s=null)=>{for(;t!==s;){const s=t.nextSibling;e.removeChild(t),t=s}},s=`{{lit-${String(Math.random()).slice(2)}}}`,i=`\x3c!--${s}--\x3e`,r=new RegExp(`${s}|${i}`);class o{constructor(e,t){this.parts=[],this.element=t;const i=[],o=[],n=document.createTreeWalker(t.content,133,null,!1);let h=0,c=-1,u=0;const{strings:p,values:{length:m}}=e;for(;u<m;){const e=n.nextNode();if(null!==e){if(c++,1===e.nodeType){if(e.hasAttributes()){const t=e.attributes,{length:s}=t;let i=0;for(let e=0;e<s;e++)a(t[e].name,"$lit$")&&i++;for(;i-- >0;){const t=p[u],s=d.exec(t)[2],i=s.toLowerCase()+"$lit$",o=e.getAttribute(i);e.removeAttribute(i);const a=o.split(r);this.parts.push({type:"attribute",index:c,name:s,strings:a}),u+=a.length-1}}"TEMPLATE"===e.tagName&&(o.push(e),n.currentNode=e.content)}else if(3===e.nodeType){const t=e.data;if(t.indexOf(s)>=0){const s=e.parentNode,o=t.split(r),n=o.length-1;for(let t=0;t<n;t++){let i,r=o[t];if(""===r)i=l();else{const e=d.exec(r);null!==e&&a(e[2],"$lit$")&&(r=r.slice(0,e.index)+e[1]+e[2].slice(0,-"$lit$".length)+e[3]),i=document.createTextNode(r)}s.insertBefore(i,e),this.parts.push({type:"node",index:++c})}""===o[n]?(s.insertBefore(l(),e),i.push(e)):e.data=o[n],u+=n}}else if(8===e.nodeType)if(e.data===s){const t=e.parentNode;null!==e.previousSibling&&c!==h||(c++,t.insertBefore(l(),e)),h=c,this.parts.push({type:"node",index:c}),null===e.nextSibling?e.data="":(i.push(e),c--),u++}else{let t=-1;for(;-1!==(t=e.data.indexOf(s,t+1));)this.parts.push({type:"node",index:-1}),u++}}else n.currentNode=o.pop()}for(const e of i)e.parentNode.removeChild(e)}}const a=(e,t)=>{const s=e.length-t.length;return s>=0&&e.slice(s)===t},n=e=>-1!==e.index,l=()=>document.createComment(""),d=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function h(e,t){const{element:{content:s},parts:i}=e,r=document.createTreeWalker(s,133,null,!1);let o=u(i),a=i[o],n=-1,l=0;const d=[];let h=null;for(;r.nextNode();){n++;const e=r.currentNode;for(e.previousSibling===h&&(h=null),t.has(e)&&(d.push(e),null===h&&(h=e)),null!==h&&l++;void 0!==a&&a.index===n;)a.index=null!==h?-1:a.index-l,o=u(i,o),a=i[o]}d.forEach((e=>e.parentNode.removeChild(e)))}const c=e=>{let t=11===e.nodeType?0:1;const s=document.createTreeWalker(e,133,null,!1);for(;s.nextNode();)t++;return t},u=(e,t=-1)=>{for(let s=t+1;s<e.length;s++){const t=e[s];if(n(t))return s}return-1};
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
const p=new WeakMap,m=e=>(...t)=>{const s=e(...t);return p.set(s,!0),s},g=e=>"function"==typeof e&&p.has(e),y={},b={};
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
class f{constructor(e,t,s){this.__parts=[],this.template=e,this.processor=t,this.options=s}update(e){let t=0;for(const s of this.__parts)void 0!==s&&s.setValue(e[t]),t++;for(const e of this.__parts)void 0!==e&&e.commit()}_clone(){const t=e?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),s=[],i=this.template.parts,r=document.createTreeWalker(t,133,null,!1);let o,a=0,l=0,d=r.nextNode();for(;a<i.length;)if(o=i[a],n(o)){for(;l<o.index;)l++,"TEMPLATE"===d.nodeName&&(s.push(d),r.currentNode=d.content),null===(d=r.nextNode())&&(r.currentNode=s.pop(),d=r.nextNode());if("node"===o.type){const e=this.processor.handleTextExpression(this.options);e.insertAfterNode(d.previousSibling),this.__parts.push(e)}else this.__parts.push(...this.processor.handleAttributeExpressions(d,o.name,o.strings,this.options));a++}else this.__parts.push(void 0),a++;return e&&(document.adoptNode(t),customElements.upgrade(t)),t}}
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/const w=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:e=>e}),v=` ${s} `;class S{constructor(e,t,s,i){this.strings=e,this.values=t,this.type=s,this.processor=i}getHTML(){const e=this.strings.length-1;let t="",r=!1;for(let o=0;o<e;o++){const e=this.strings[o],a=e.lastIndexOf("\x3c!--");r=(a>-1||r)&&-1===e.indexOf("--\x3e",a+1);const n=d.exec(e);t+=null===n?e+(r?v:i):e.substr(0,n.index)+n[1]+n[2]+"$lit$"+n[3]+s}return t+=this.strings[e],t}getTemplateElement(){const e=document.createElement("template");let t=this.getHTML();return void 0!==w&&(t=w.createHTML(t)),e.innerHTML=t,e}}
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/const x=e=>null===e||!("object"==typeof e||"function"==typeof e),_=e=>Array.isArray(e)||!(!e||!e[Symbol.iterator]);class C{constructor(e,t,s){this.dirty=!0,this.element=e,this.name=t,this.strings=s,this.parts=[];for(let e=0;e<s.length-1;e++)this.parts[e]=this._createPart()}_createPart(){return new E(this)}_getValue(){const e=this.strings,t=e.length-1,s=this.parts;if(1===t&&""===e[0]&&""===e[1]){const e=s[0].value;if("symbol"==typeof e)return String(e);if("string"==typeof e||!_(e))return e}let i="";for(let r=0;r<t;r++){i+=e[r];const t=s[r];if(void 0!==t){const e=t.value;if(x(e)||!_(e))i+="string"==typeof e?e:String(e);else for(const t of e)i+="string"==typeof t?t:String(t)}}return i+=e[t],i}commit(){this.dirty&&(this.dirty=!1,this.element.setAttribute(this.name,this._getValue()))}}class E{constructor(e){this.value=void 0,this.committer=e}setValue(e){e===y||x(e)&&e===this.value||(this.value=e,g(e)||(this.committer.dirty=!0))}commit(){for(;g(this.value);){const e=this.value;this.value=y,e(this)}this.value!==y&&this.committer.commit()}}class ${constructor(e){this.value=void 0,this.__pendingValue=void 0,this.options=e}appendInto(e){this.startNode=e.appendChild(l()),this.endNode=e.appendChild(l())}insertAfterNode(e){this.startNode=e,this.endNode=e.nextSibling}appendIntoPart(e){e.__insert(this.startNode=l()),e.__insert(this.endNode=l())}insertAfterPart(e){e.__insert(this.startNode=l()),this.endNode=e.endNode,e.endNode=this.startNode}setValue(e){this.__pendingValue=e}commit(){if(null===this.startNode.parentNode)return;for(;g(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=y,e(this)}const e=this.__pendingValue;e!==y&&(x(e)?e!==this.value&&this.__commitText(e):e instanceof S?this.__commitTemplateResult(e):e instanceof Node?this.__commitNode(e):_(e)?this.__commitIterable(e):e===b?(this.value=b,this.clear()):this.__commitText(e))}__insert(e){this.endNode.parentNode.insertBefore(e,this.endNode)}__commitNode(e){this.value!==e&&(this.clear(),this.__insert(e),this.value=e)}__commitText(e){const t=this.startNode.nextSibling,s="string"==typeof(e=null==e?"":e)?e:String(e);t===this.endNode.previousSibling&&3===t.nodeType?t.data=s:this.__commitNode(document.createTextNode(s)),this.value=e}__commitTemplateResult(e){const t=this.options.templateFactory(e);if(this.value instanceof f&&this.value.template===t)this.value.update(e.values);else{const s=new f(t,e.processor,this.options),i=s._clone();s.update(e.values),this.__commitNode(i),this.value=s}}__commitIterable(e){Array.isArray(this.value)||(this.value=[],this.clear());const t=this.value;let s,i=0;for(const r of e)s=t[i],void 0===s&&(s=new $(this.options),t.push(s),0===i?s.appendIntoPart(this):s.insertAfterPart(t[i-1])),s.setValue(r),s.commit(),i++;i<t.length&&(t.length=i,this.clear(s&&s.endNode))}clear(e=this.startNode){t(this.startNode.parentNode,e.nextSibling,this.endNode)}}class N{constructor(e,t,s){if(this.value=void 0,this.__pendingValue=void 0,2!==s.length||""!==s[0]||""!==s[1])throw new Error("Boolean attributes can only contain a single expression");this.element=e,this.name=t,this.strings=s}setValue(e){this.__pendingValue=e}commit(){for(;g(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=y,e(this)}if(this.__pendingValue===y)return;const e=!!this.__pendingValue;this.value!==e&&(e?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name),this.value=e),this.__pendingValue=y}}class I extends C{constructor(e,t,s){super(e,t,s),this.single=2===s.length&&""===s[0]&&""===s[1]}_createPart(){return new P(this)}_getValue(){return this.single?this.parts[0].value:super._getValue()}commit(){this.dirty&&(this.dirty=!1,this.element[this.name]=this._getValue())}}class P extends E{}let B=!1;(()=>{try{const e={get capture(){return B=!0,!1}};window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){}})();class R{constructor(e,t,s){this.value=void 0,this.__pendingValue=void 0,this.element=e,this.eventName=t,this.eventContext=s,this.__boundHandleEvent=e=>this.handleEvent(e)}setValue(e){this.__pendingValue=e}commit(){for(;g(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=y,e(this)}if(this.__pendingValue===y)return;const e=this.__pendingValue,t=this.value,s=null==e||null!=t&&(e.capture!==t.capture||e.once!==t.once||e.passive!==t.passive),i=null!=e&&(null==t||s);s&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),i&&(this.__options=T(e),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=e,this.__pendingValue=y}handleEvent(e){"function"==typeof this.value?this.value.call(this.eventContext||this.element,e):this.value.handleEvent(e)}}const T=e=>e&&(B?{capture:e.capture,passive:e.passive,once:e.once}:e.capture)
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/;function A(e){let t=k.get(e.type);void 0===t&&(t={stringsArray:new WeakMap,keyString:new Map},k.set(e.type,t));let i=t.stringsArray.get(e.strings);if(void 0!==i)return i;const r=e.strings.join(s);return i=t.keyString.get(r),void 0===i&&(i=new o(e,e.getTemplateElement()),t.keyString.set(r,i)),t.stringsArray.set(e.strings,i),i}const k=new Map,O=new WeakMap;
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/const V=new
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
class{handleAttributeExpressions(e,t,s,i){const r=t[0];if("."===r){return new I(e,t.slice(1),s).parts}if("@"===r)return[new R(e,t.slice(1),i.eventContext)];if("?"===r)return[new N(e,t.slice(1),s)];return new C(e,t,s).parts}handleTextExpression(e){return new $(e)}};
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.3.0");const D=(e,...t)=>new S(e,t,"html",V)
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/,M=(e,t)=>`${e}--${t}`;let U=!0;void 0===window.ShadyCSS?U=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),U=!1);const q=e=>t=>{const i=M(t.type,e);let r=k.get(i);void 0===r&&(r={stringsArray:new WeakMap,keyString:new Map},k.set(i,r));let a=r.stringsArray.get(t.strings);if(void 0!==a)return a;const n=t.strings.join(s);if(a=r.keyString.get(n),void 0===a){const s=t.getTemplateElement();U&&window.ShadyCSS.prepareTemplateDom(s,e),a=new o(t,s),r.keyString.set(n,a)}return r.stringsArray.set(t.strings,a),a},z=["html","svg"],j=new Set,H=(e,t,s)=>{j.add(e);const i=s?s.element:document.createElement("template"),r=t.querySelectorAll("style"),{length:o}=r;if(0===o)return void window.ShadyCSS.prepareTemplateStyles(i,e);const a=document.createElement("style");for(let e=0;e<o;e++){const t=r[e];t.parentNode.removeChild(t),a.textContent+=t.textContent}(e=>{z.forEach((t=>{const s=k.get(M(t,e));void 0!==s&&s.keyString.forEach((e=>{const{element:{content:t}}=e,s=new Set;Array.from(t.querySelectorAll("style")).forEach((e=>{s.add(e)})),h(e,s)}))}))})(e);const n=i.content;s?function(e,t,s=null){const{element:{content:i},parts:r}=e;if(null==s)return void i.appendChild(t);const o=document.createTreeWalker(i,133,null,!1);let a=u(r),n=0,l=-1;for(;o.nextNode();)for(l++,o.currentNode===s&&(n=c(t),s.parentNode.insertBefore(t,s));-1!==a&&r[a].index===l;){if(n>0){for(;-1!==a;)r[a].index+=n,a=u(r,a);return}a=u(r,a)}}(s,a,n.firstChild):n.insertBefore(a,n.firstChild),window.ShadyCSS.prepareTemplateStyles(i,e);const l=n.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==l)t.insertBefore(l.cloneNode(!0),t.firstChild);else if(s){n.insertBefore(a,n.firstChild);const e=new Set;e.add(a),h(s,e)}};window.JSCompiler_renameProperty=(e,t)=>e;const F={toAttribute(e,t){switch(t){case Boolean:return e?"":null;case Object:case Array:return null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){switch(t){case Boolean:return null!==e;case Number:return null===e?null:Number(e);case Object:case Array:return JSON.parse(e)}return e}},L=(e,t)=>t!==e&&(t==t||e==e),W={attribute:!0,type:String,converter:F,reflect:!1,hasChanged:L};class Y extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const e=[];return this._classProperties.forEach(((t,s)=>{const i=this._attributeNameForProperty(s,t);void 0!==i&&(this._attributeToPropertyMap.set(i,s),e.push(i))})),e}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const e=Object.getPrototypeOf(this)._classProperties;void 0!==e&&e.forEach(((e,t)=>this._classProperties.set(t,e)))}}static createProperty(e,t=W){if(this._ensureClassProperties(),this._classProperties.set(e,t),t.noAccessor||this.prototype.hasOwnProperty(e))return;const s="symbol"==typeof e?Symbol():`__${e}`,i=this.getPropertyDescriptor(e,s,t);void 0!==i&&Object.defineProperty(this.prototype,e,i)}static getPropertyDescriptor(e,t,s){return{get(){return this[t]},set(i){const r=this[e];this[t]=i,this.requestUpdateInternal(e,r,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this._classProperties&&this._classProperties.get(e)||W}static finalize(){const e=Object.getPrototypeOf(this);if(e.hasOwnProperty("finalized")||e.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const e=this.properties,t=[...Object.getOwnPropertyNames(e),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[]];for(const s of t)this.createProperty(s,e[s])}}static _attributeNameForProperty(e,t){const s=t.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof e?e.toLowerCase():void 0}static _valueHasChanged(e,t,s=L){return s(e,t)}static _propertyValueFromAttribute(e,t){const s=t.type,i=t.converter||F,r="function"==typeof i?i:i.fromAttribute;return r?r(e,s):e}static _propertyValueToAttribute(e,t){if(void 0===t.reflect)return;const s=t.type,i=t.converter;return(i&&i.toAttribute||F.toAttribute)(e,s)}initialize(){this._updateState=0,this._updatePromise=new Promise((e=>this._enableUpdatingResolver=e)),this._changedProperties=new Map,this._saveInstanceProperties(),this.requestUpdateInternal()}_saveInstanceProperties(){this.constructor._classProperties.forEach(((e,t)=>{if(this.hasOwnProperty(t)){const e=this[t];delete this[t],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(t,e)}}))}_applyInstanceProperties(){this._instanceProperties.forEach(((e,t)=>this[t]=e)),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(e,t,s){t!==s&&this._attributeToProperty(e,s)}_propertyToAttribute(e,t,s=W){const i=this.constructor,r=i._attributeNameForProperty(e,s);if(void 0!==r){const e=i._propertyValueToAttribute(t,s);if(void 0===e)return;this._updateState=8|this._updateState,null==e?this.removeAttribute(r):this.setAttribute(r,e),this._updateState=-9&this._updateState}}_attributeToProperty(e,t){if(8&this._updateState)return;const s=this.constructor,i=s._attributeToPropertyMap.get(e);if(void 0!==i){const e=s.getPropertyOptions(i);this._updateState=16|this._updateState,this[i]=s._propertyValueFromAttribute(t,e),this._updateState=-17&this._updateState}}requestUpdateInternal(e,t,s){let i=!0;if(void 0!==e){const r=this.constructor;s=s||r.getPropertyOptions(e),r._valueHasChanged(this[e],t,s.hasChanged)?(this._changedProperties.has(e)||this._changedProperties.set(e,t),!0!==s.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(e,s))):i=!1}!this._hasRequestedUpdate&&i&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(e,t){return this.requestUpdateInternal(e,t),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(e){}const e=this.performUpdate();return null!=e&&await e,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){if(!this._hasRequestedUpdate)return;this._instanceProperties&&this._applyInstanceProperties();let e=!1;const t=this._changedProperties;try{e=this.shouldUpdate(t),e?this.update(t):this._markUpdated()}catch(t){throw e=!1,this._markUpdated(),t}e&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(t)),this.updated(t))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(e){return!0}update(e){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach(((e,t)=>this._propertyToAttribute(t,this[t],e))),this._reflectingProperties=void 0),this._markUpdated()}updated(e){}firstUpdated(e){}}Y.finalized=!0;
/**
@license
Copyright (c) 2019 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
part of the polymer project is also subject to an additional IP rights grant
found at http://polymer.github.io/PATENTS.txt
*/
const K=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,J=Symbol();class Z{constructor(e,t){if(t!==J)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e}get styleSheet(){return void 0===this._styleSheet&&(K?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
(window.litElementVersions||(window.litElementVersions=[])).push("2.4.0");const G={};class Q extends Y{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const e=this.getStyles();if(Array.isArray(e)){const t=(e,s)=>e.reduceRight(((e,s)=>Array.isArray(s)?t(s,e):(e.add(s),e)),s),s=t(e,new Set),i=[];s.forEach((e=>i.unshift(e))),this._styles=i}else this._styles=void 0===e?[]:[e];this._styles=this._styles.map((e=>{if(e instanceof CSSStyleSheet&&!K){const t=Array.prototype.slice.call(e.cssRules).reduce(((e,t)=>e+t.cssText),"");return new Z(String(t),J)}return e}))}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const e=this.constructor._styles;0!==e.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?K?this.renderRoot.adoptedStyleSheets=e.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(e.map((e=>e.cssText)),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(e){const t=this.render();super.update(e),t!==G&&this.constructor.render(t,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach((e=>{const t=document.createElement("style");t.textContent=e.cssText,this.renderRoot.appendChild(t)})))}render(){return G}}Q.finalized=!0,Q.render=(e,s,i)=>{if(!i||"object"!=typeof i||!i.scopeName)throw new Error("The `scopeName` option is required.");const r=i.scopeName,o=O.has(s),a=U&&11===s.nodeType&&!!s.host,n=a&&!j.has(r),l=n?document.createDocumentFragment():s;if(((e,s,i)=>{let r=O.get(s);void 0===r&&(t(s,s.firstChild),O.set(s,r=new $(Object.assign({templateFactory:A},i))),r.appendInto(s)),r.setValue(e),r.commit()})(e,l,Object.assign({templateFactory:q(r)},i)),n){const e=O.get(l);O.delete(l);const i=e.value instanceof f?e.value.template:void 0;H(r,l,i),t(s,s.firstChild),s.appendChild(l),O.set(s,e)}!o&&a&&window.ShadyCSS.styleElement(s.host)};const X=((e,...t)=>{const s=t.reduce(((t,s,i)=>t+(e=>{if(e instanceof Z)return e.cssText;if("number"==typeof e)return e;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${e}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(s)+e[i+1]),e[0]);return new Z(s,J)})`
.card-container {
padding: 10px;
background-color: transparent;
width: fit-content;
display: flex;
}
form {
width: max-content;
height: max-content;
flex-flow: column wrap;
box-sizing: border-box;
display: flex;
place-content: center space-between;
align-items: center;
}

input,
select {
width: 300px;
height: 40px;
border-radius: 5px;
border: 0.5px solid rgba(27, 27, 27, 0.1);
background-color: #f9f9f9;
padding-left: 5px;
font-size: 14px;
background-color: #ffffff;
}

.names div,
.city div,
.state div,
.mobile div {
display: flex;
flex-flow: column wrap;
}

.names input {
width: 140px;
}

label,
p {
font-weight: 500;
color: gray;
font-family: sans-serif;
font-size: 14px;
margin-bottom: 5px;
}

label {
font-size: 12px;
align-self: flex-start;
}

#labelpadding{
padding-left:3px;
}
.powered-by {
height: 48px;
align-self: stretch;
flex-grow: 0;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
background-color: #f7f9fc;
}
#mobiledob{
padding:0px;
margin:0px;
}
section{
padding:0px;
margin:0px;
}
input,
select:focus {
outline: none;
}

.card-info,
.split-inputs {
width: 308px;
height: 40px;
display: flex;
flex-flow: row wrap;
box-sizing: border-box;
place-content: center space-between;
align-items: center;
border-radius: 5px;
border: 0.5px solid rgba(27, 27, 27, 0.1);
background-color: #ffffff;
padding: 0 10px;
}

.radios {
display: flex;
flex-flow: row wrap;
box-sizing: border-box;
place-content: center space-between;
align-items: center;
margin-bottom: 5px;
}

.radio {
display: flex;
flex-flow: row wrap;
box-sizing: border-box;
place-content: center space-between;
align-items: center;
}

.radio input {
width: 14px;
height: 14px;
margin: 0;
}

.radios label {
margin: 0 0 0 10px;
}

.split-inputs input {
width: 265px;
height: 37px;
border: none;
}

.split-inputs img {
width: 40px;
height: 18px;
border-radius: 0;
top: 0;
}

.card-info #card-number {
width: 140px;
height: 35px;
border: none;
box-shadow: none;
border-top-left-radius: 8px;
}

.card-types {
margin-top: 10px;
height: 30px;
margin-right: 8px;
}

img {
height: 20px;
}

.card-info #expiry,
.card-info #cvc {
width: 45px;
height: 35px;
border: none;
}

.card-info img {
width: 28px;
height: 18px;
border-radius: 0;
top: 0;
}

button {
width: 310px;
height: 40px;
color: #ffffff;
border-radius: 6px;
border: none;
font-family: sans-serif;
background-color: #28487f;
font-size: 15px;
font-weight: 500;
}

button:hover {
cursor: pointer;
}

button:focus {
outline: none;
}

button:disabled {
color: #1b1b1b75;
background-color: #b6b6b6;
cursor: default;
}

.hide,
.names.hide,
.mobile.hide {
display: none;
}

.show,
.names.show {
display: block;
}

.names,
.mobile div,
.city,
.state {
width: 309px;
display: flex;
flex-flow: row wrap;
place-content: space-between;
}

.mobile {
display: flex;
flex-flow: column wrap;
}

#zipCode,
#city {
width: 140px;
}

#state,
#country {
height: 43px;
width: 148px;
}

.mobile select {
width: 90px;
}

.mobile input {
height: 36px;
width: 200px;
}

.error-message {
height: 60px;
background-color: #e0202021;
text-align: center;
font-family: sans-serif;
font-size: 13px;
color: #e02020;
width: 100%;
border: none;
border-radius: 5px;
display: flex;
flex-flow: row wrap;
place-content: center center;
}

.error-message.hide,
.state.hide {
display: none;
}

.address {
display: flex;
flex-flow: column wrap;
}

.address #line1,
.address #line2,
#card-regions,
#zip {
margin-top: 5px;
}

input[type='checkbox'] {
width: 14px;
height: 14px;
margin: 0;
}

p {
margin: 0;
}

.policy {
width: 215px;
display: flex;
flex-flow: row wrap;
place-content: space-between;
align-self: flex-start;
}

.policy.hide {
display: none;
}

.red {
color: #e02020;
}

#currency {
width: 300px;
}

a {
color: #28487f;
text-decoration: none;
}

@media screen and (max-width: 359px) {
button {
width: 260px;
}

#zipCode,
#city {
width: 115px;
}

#state,
#country {
width: 124px;
}

input {
width: 250px;
}

.card-info {
width: 257px;
}

.card-info #expiry,
.card-info #cvc {
width: 38px;
}

.card-info #card-number {
width: 95px;
}

.names,
.mobile div,
.city,
.state {
width: auto;
}
}
`
/**
* @license
* Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/,ee=new WeakMap,te=m((e=>t=>{if(!(t instanceof E)||t instanceof P||"style"!==t.committer.name||t.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:s}=t,{style:i}=s.element;let r=ee.get(t);void 0===r&&(i.cssText=s.strings.join(" "),ee.set(t,r=new Set)),r.forEach((t=>{t in e||(r.delete(t),-1===t.indexOf("-")?i[t]=null:i.removeProperty(t))}));for(const t in e)r.add(t),-1===t.indexOf("-")?i[t]=e[t]:i.setProperty(t,e[t])}));
/**
* @license
* Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
var url_string=window.location.href;
var url = new URL(url_string);
var total = url.searchParams.get("total");

class se{constructor(e){this.classes=new Set,this.changed=!1,this.element=e;const t=(e.getAttribute("class")||"").split(/\s+/);for(const e of t)this.classes.add(e)}add(e){this.classes.add(e),this.changed=!0}remove(e){this.classes.delete(e),this.changed=!0}commit(){if(this.changed){let e="";this.classes.forEach((t=>e+=t+" ")),this.element.setAttribute("class",e)}}}const ie=new WeakMap,re=m((e=>t=>{if(!(t instanceof E)||t instanceof P||"class"!==t.committer.name||t.committer.parts.length>1)throw new Error("The `classMap` directive must be used in the `class` attribute and must be the only part in the attribute.");const{committer:s}=t,{element:i}=s;let r=ie.get(t);void 0===r&&(i.setAttribute("class",s.strings.join(" ")),ie.set(t,r=new Set));const o=i.classList||new se(i);r.forEach((t=>{t in e||(o.remove(t),r.delete(t))}));for(const t in e){const s=e[t];s!=r.has(t)&&(s?(o.add(t),r.add(t)):(o.remove(t),r.delete(t)))}"function"==typeof o.commit&&o.commit()}));class oe{constructor(){this.ccNumberPattern=/^\d{0,16}$/g,this.ccExpiryPattern=/^\d{0,4}$/g,this.ccExpirySeparator="/",this.ccNumberSeparator=" ",this.ccNumberInputOldValue,this.ccNumberInputOldCursor,this.ccExpiryInputOldValue,this.ccExpiryInputOldCursor,this.dobInputOldValue,this.dobInputOldCursor,this.phoneInputOldValue,this.phoneInputOldCursor}mask(e,t,s){let i=[];for(let r=0;r<e.length;r++)0!==r&&r%t==0&&i.push(s),i.push(e[r]);return i.join("")}unmask(e){return e.replace(/[^\d]/g,"")}checkSeparator(e,t){return Math.floor(e/(t+1))}ccNumberInputKeyDownHandler(e){let t=e.target;this.ccNumberInputOldValue=t.value,this.ccNumberInputOldCursor=t.selectionEnd}cvcNumberInputInputHandler(e){let t=e.target,s=this.unmask(t.value);s.match(this.ccNumberPattern)?t.value=""!==s?s:"":t.value=this.ccNumberInputOldValue}ccNumberInputInputHandler(e){let t,s=e.target,i=this.unmask(s.value);i.match(this.ccNumberPattern)?(i=this.mask(i,4,this.ccNumberSeparator),t=this.ccNumberInputOldCursor-this.checkSeparator(this.ccNumberInputOldCursor,4)+this.checkSeparator(this.ccNumberInputOldCursor+(i.length-this.ccNumberInputOldValue.length),4)+(this.unmask(i).length-this.unmask(this.ccNumberInputOldValue).length),s.value=""!==i?i:""):(s.value=this.ccNumberInputOldValue,t=this.ccNumberInputOldCursor),s.setSelectionRange(t,t)}ccExpiryInputKeyDownHandler(e){let t=e.target;this.ccExpiryInputOldValue=t.value,this.ccExpiryInputOldCursor=t.selectionEnd}ccExpiryInputInputHandler(e){let t=e.target,s=t.value;s=this.unmask(s),s.match(this.ccExpiryPattern)?(s=this.mask(s,2,this.ccExpirySeparator),t.value=s):t.value=this.ccExpiryInputOldValue}dobInputKeyDownHandler(e){let t=e.target;this.dobInputOldValue=t.value,this.dobInputOldCursor=t.selectionEnd}dobInputInputHandler(e){let t=e.target,s=t.value;if(s=this.unmask(s),s.match(/^\d{0,10}$/g)){const e=s.replace(/\D/g,"").match(/(\d{0,4})(\d{0,2})(\d{0,2})/);let i=e[1]+""+(e[1].length<4||0===e[2].length?"":"-")+e[2]+(e[2].length<2||0===e[3].length?"":"-")+e[3];i=i.trimEnd(),t.value=i}else t.value=this.dobInputOldValue}phoneInputKeyDownHandler(e){let t=e.target;this.phoneInputOldValue=t.value,this.phoneInputOldCursor=t.selectionEnd}phoneInputInputHandler(e){let t=e.target,s=t.value;if(s=s.replace(" ",""),s=this.unmask(s),s.match(/^\d{0,11}$/g)){const e=s.replace(/\D/g,"").match(/(\d{0,3})(\d{0,2})(\d{0,2})(\d{0,4})/);let i="+"+e[1]+" "+e[2]+" "+e[3]+" "+e[4];i=i.trimEnd(),t.value=i}else t.value=this.phoneInputOldValue}checkLuhn(e){let t=e.replace(/\D/g,""),s=0,i=!1;for(let e=t.length-1;e>=0;e--){let r=parseInt(t.charAt(e));i&&(r*=2)>9&&(r-=9),s+=r,i=!i}return s%10==0}}const ae={canada:["AB","BC","MB","NB","NL","NS","NT","NU","ON","PE","QC","SK","YT"],usa:["AL","AK","AS","AZ","AR","CA","CO","CT","DE","DC","FM","FL","GA","GU","HI","ID","IL","IN","IA","KS","KY","LA","ME","MH","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","MP","OH","OK","OR","PW","PA","PR","RI","SC","SD","TN","TX","UT","VT","VI","VA","WA","WV","WI","WY"]};window.customElements.define("leapa-customer",class extends Q{static get styles(){return X}static get properties(){return{countries:{type:Array},states:{type:Array},sortedCountries:{type:Array},cardType:{type:String},errorMessage:{type:String},successMessage:{type:String},countryCode:{type:String},showRed:{type:Boolean},showRedCC:{type:Boolean},showRedCVC:{type:Boolean},showZip:{type:Boolean},state:{type:String},showError:{type:Boolean},showSuccess:{type:Boolean},imgPath:{type:String},logoPath:{type:String},showCard:{type:Boolean},showBadge:{type:Boolean},showDarkBadge:{type:Boolean},showDefaultBadge:{type:Boolean},names:{type:String},mobile:{type:String},mobile:{type:String},dob:{type:String},dob:{type:String},TOS:{type:String},"button-color":{type:String},"button-text-color":{type:String},"button-text":{type:String},"label-color":{type:String},"label-email":{type:String},"label-card-info":{type:String},"label-card-name":{type:String},"label-card-region":{type:String},"label-card-zip":{type:String},"label-first-name":{type:String},"label-last-name":{type:String},"label-phone-number":{type:String},"label-dob":{type:String},"total-amount-paid":{type:String},"label-address-line1":{type:String},"label-address-line2":{type:String},"label-address-city":{type:String},"label-address-country":{type:String},"label-address-state":{type:String},"label-address-zip":{type:String},mode:{type:String},key:{type:String},amount:{type:Number},disabled:{type:Boolean},description:{type:String},firstName:{type:String},"first-name":{type:String},customerReferenceId:{type:String},"customer-reference-id":{type:String},invoiceReferenceId:{type:String},"invoice-reference-id":{type:String},badge:{type:String},showFirstName:{type:Boolean},lastName:{type:String},"last-name":{type:String},showLastName:{type:Boolean},hideDob:{type:Boolean},email:{type:String},showEmail:{type:Boolean},"background-color":{type:String},"invoice-id":{type:String},"customer-id":{type:String},showCustomerDetail:{type:Boolean},showMobileDob:{type:Boolean},showInvoiceEmail:{type:Boolean},currency:{type:String},"label-tos":{type:String},"sucess-message":{type:String},"error-message":{type:String},showRed:{type:Boolean},showRedCC:{type:Boolean},showRedCVC:{type:Boolean}}}constructor(){super(),this.baseUrl="https://api.leapa.co",this.cardValues={},this.showZip=!0,this.state=!0,this.showError=!0,this.showSuccess=!0,this.userValues={},this.validator=new oe,this.showRed=!1,this.showRedCC=!1,this.showRedCVC=!1,this.hostname="localhost"===window.location.hostname?"http://localhost:8000":"https://widgets.leapa.co",this.imgPath=this.hostname+"/assets/logos/default-card.png",this.showCard=!0,this.showBadge=!0,this.hideDob=!1,this.showDarkBadge=!0,this.showDefaultBadge=!0,this.logoPath=this.hostname+"/assets/logos/default-sim.png",this.states=[],this.countries=[{name:"Burundi",alpha2Code:"BI",callingCodes:["257"]}],this.sortedCountries=[{name:"Burundi",alpha2Code:"BI",callingCodes:["257"]}]}firstUpdated(){this.getAllCountries()}render(){return this.checkRequirements(),D`
<div
class="card-container"
style=${te({backgroundColor:`${this["background-color"]}`})}
>
<form id="cardForm" @submit="${this.submitForm}">
<div
class=${re({names:!0,hide:"true"!==this.names,hide:!this.showCustomerDetail})}
>
<div>
<label class=${re({hide:this["first-name"],firstName:!0,hide:"true"!==this["first-name"]})} style=${te({color:`${this["label-color"]}`})}
>${this["label-first-name"]||"First Name"}</label
>
<input
class=${re({hide:this["first-name"],firstName:!0,hide:"true"!==this["first-name"]})}
id="first-name"
name="fname"
autocomplete="given-name"
?required="${"true"===this["first-name"]}"
/>
</div>
<div>
<label class=${re({hide:this["last-name"],lastName:!0,hide:"true"!==this["last-name"]})} style=${te({color:`${this["label-color"]}`})}
>${this["label-last-name"]||"Last Name"}</label
>
<input
class=${re({hide:this["last-name"],lastName:!0,hide:"true"!==this["last-name"]})}
id="last-name"
name="lname"
autocomplete="family-name"
?required="${"true"===this["last-name"]}"
/>
</div>
</div>
<br ?hidden="${"true"!==this.names}" />
<br class=${re({hide:!this.showCustomerDetail})} />
<label
id="labelpadding"
class=${re({hide:!this.showEmail,hide:!this.showCustomerDetail})}
style=${te({color:`${this["label-color"]}`})}
>
${this["label-email"]||"Email"}
</label>
<input
id="email"
name="email"
autocomplete="email"
type="email"
?required="${this.showEmail,"false"===this.showCustomerDetail}"
class=${re({hide:!this.showEmail,hide:!this.showCustomerDetail})}

/>
<br class=${re({hide:!this.showEmail})} />

<label id="labelpadding" class=${re({mobile:!0,hide:"true"!==this.mobile||this["customer-id"]||"true"!==this.mobile})} style=${te({color:`${this["label-color"]}`})}
>${this["label-phone-number"]||"Phone Number"}</label
>

<input class=${re({mobile:!0,hide:"true"!==this.mobile||this["customer-id"]||"true"!==this.mobile})} name="phone-number" id="phone-number"
?required="${"true"===this.mobile}" maxlength="12" />

<br ?hidden="${"true"!==this.mobile}" />
<label
id="labelpadding"
class=${re({dob:!0,hide:"true"!==this.dob||this["customer-id"]||"true"!==this.dob})}
style=${te({color:`${this["label-color"]}`})}
>
${this["label-dob"]||" Date of birth"}
</label>
<input
id="dob"
type="text"
@blur="${this.dobOnBlur}"
autocomplete="bday"
placeholder="YYYY-MM-DD"
@input="${this.dobChange}"
@keydown="${this.dobInput}"
maxlength="10"
class=${re({dob:!0,hide:"true"!==this.dob||this["customer-id"]||"true"!==this.dob})}
?required="${"true"===this.dob}"
/>
<br ?hidden="${"true"!==this.dob}" />
<div class="radios">

</div>
<div class=${re({"split-inputs":!0,hide:this.showCard})}>
<img src="${this.logoPath}" alt="" />
<input
type="text"
@input="${this.mobileInput}"
@keydown="${this.mobileChange}"
value="+257"
maxlength="16"
id="mm-number"
/>
</div>
<label id="labelpadding" style=${te({color:`${this["label-color"]}`})}
>${this["label-card-info"]||"Credit/Debit Card"}</label
>
<div class=${re({"card-info":!0,hide:!this.showCard})}>
<img src="${this.imgPath}" />
<input
id="card-number"
name="cardnumber"
type="text"
placeholder="1234 1234 1234 1234"
@input="${this.cardChange}"
@keydown="${this.cardInput}"
autocomplete="cc-number"
maxlength="19"
class=${re({red:this.showRedCC})}
pattern=".{19,}"
?required="${"invoice"===this.mode||"charge"===this.mode||this["customer-id"]}"
title="Please enter a valid 16-digit card number"
/>
<input
minlength="5"
maxlength="5"
id="expiry"
class=${re({red:this.showRed})}
type="text"
placeholder="MM/YY"
name="cc-exp"
autocomplete="cc-exp"
@input="${this.expChange}"
@keydown="${this.expInput}"
pattern=".{5,}"
?required="${"invoice"===this.mode||"charge"===this.mode||this["customer-id"]}"
title="The format for the expiration date is MM/YY"
/>
<input
name="cvc"
autocomplete="cc-csc"
id="cvc"
type="text"
@input="${this.cvcChange}"
placeholder="CVV"
minlength="3"
maxlength="3"
class=${re({red:this.showRedCVC})}
pattern=".{3,}"
?required="${"invoice"===this.mode||"charge"===this.mode||this["customer-id"]}"
title="Please enter your 3-digit card verification code"
/>
</div>
<br>
<label
id="labelpadding"
class=${re({hide:!this.showCard})}
style=${te({color:`${this["label-color"]}`})}
>
${this["label-card-name"]||"Name on card"}
</label>
<input
id="card-name"
name="ccname"
autocomplete="cc-name"
type="text"
class=${re({hide:!this.showCard})}
?required="${this.showCard}"
/>
<br>
<div class="address">
<label id="labelpadding" style=${te({color:`${this["label-color"]}`})}
>${this["total-amount-paid"]||"Total Amount to be Paid"}</label
>
<input id="total" name="Total Amount to be Paid" readonly="readonly" disabled="disabled" value= ${total} />
<br>
<label id="labelpadding" style=${te({color:`${this["label-color"]}`})}>
${this["label-address-line1"]||"Address Line 1"}
</label>
<input
id="line1"
name="address"
autocomplete="address-line1"
required
/>
<br>
<label id="labelpadding" style=${te({color:`${this["label-color"]}`})}
>${this["label-address-line2"]||"Address Line 2"}</label
>
<input id="line2" name="address" autocomplete="address-line2" />
<br>
<div class="city">
<div>
<label style=${te({color:`${this["label-color"]}`})}
>${this["label-address-city"]||"City"}</label
>
<input
id="city"
name="city"
autocomplete="address-level2"
required
/>
</div>
<div>
<label style=${te({color:`${this["label-color"]}`})}
>${this["label-address-country"]||"Country"}
</label
>
<select
name="country"
autocomplete="country"
id="country"
@change="${this.countryChange}"
required
>
<option></option>
${this.countries.map((e=>D`<option value="${e.code}">
${e.name}
</option>`))}
</select>
</div>
</div>
<br/>
<div class=${re({state:!0,hide:this.state})}>
<div>
<label id="labelpadding" style=${te({color:`${this["label-color"]}`})}
>${this["label-address-state"]||"State"}</label
>
<select
name="state"
autocomplete="address-level1"
id="state"
?required=${!this.state}
>
<option></option>
${this.states.map((e=>D`<option value="${e}">${e}</option>`))}
</select>
</div>
<div>
<label id="labelpadding" style=${te({color:`${this["label-color"]}`})}>
${this["label-address-zip"]||"Zip Code"}
</label>
<input name="zip" autocomplete="postal-code" id="zipCode" />
</div>
</div>
</div>
<br ?hidden="${!this.showZip}" />
<div
class=${re({"error-message":!0,hide:this.showError})}
>
${this.errorMessage}
</div>
<br ?hidden="${this.showError}" />
<div class=${re({policy:!0,hide:"true"!==this.TOS})}>
<input type="checkbox" ?required="${"true"===this.TOS}" />
<p>
${this["label-tos"]||"I accept the"}
<a href="https://leapa.co/terms" target="_blank">
Terms of service
</a>
</p>
</div>
<br ?hidden="${"true"!==this.TOS}" />

<button
style=${te({backgroundColor:`${this["button-color"]}`,color:`${this["button-text-color"]}`})}
type="submit"
?disabled="${this.disabled||this.showRed||this.showRedCC}"
id="button"
>
${this["button-text"]||("add"===this.mode?"Save":"charge"===this.mode?"Charge":"Pay Invoice")}
</button>

<br>
<img class="powered-by ${re({hide:this.badge,hide:this.showBadge,hide:"true"!==this.badge})}" src="https://dev.widgets.leapa.co/assets/badges/light.png" style="with:100%;"/>
<img class="powered-by ${re({hide:this.showDefaultBadge})}" src="https://dev.widgets.leapa.co/assets/badges/light.png" style="with:100%;"/>
<img class="powered-by ${re({hide:this.showDarkBadge})}" src="https://dev.widgets.leapa.co/assets/badges/dark.png" style="with:100%;"/>

</form>


</div>
`}updated(e){}definitelyNaN(e){return isNaN(e&&!0!==e?Number(e):parseFloat(e))}dobOnBlur(e){var t=e.target.value,s=new Date(new Date-new Date(t)).getFullYear()-1970;return!0===this.definitelyNaN(s)?(this.displayDobError("Please enter a valid date"),this.disabled=!0,this.showRed=!0,void(this.showRed=!0)):s<18?(this.displayDobError("You must have 18 years minimum"),this.disabled=!0,this.showRed=!0,void(this.showRed=!0)):(this.displayDobSuccess(),this.disabled=!1,this.showRed=!1,void(this.showRed=!1))}checkRequirements(){const{key:e,mode:t,amount:s,description:i,email:r,currency:o,lastName:a,firstName:n,dob:l}=this;if(!e)return this.displayError("Key attribute is required"),void(this.disabled=!0);if(this["customer-id"]?(this.showCustomerDetail=!1,this.showMobileDob=!1):(this.showCustomerDetail=!0,this.showMobileDob=!0),this.badge||"dark"===this.badge?this.badge&&"dark"===this.badge?(this.showBadge=!1,this.showDarkBadge=!1):this.badge&&"light"===this.badge?this.showDefaultBadge=!1:this.showBadge=!1:(this.showBadge=!0,this.showDarkBadge=!0),r||"invoice"==t){if(""===r||!/\S+@\S+\.\S+/.test(r)&&"invoice"!=t)return this.displayError("Enter a valid email"),void(this.disabled=!0)}else this.showEmail=!0;if("invoice"===t&&(this.showEmail=!1,this.showCustomerDetail=!1,this.showMobileDob=!1),!t)return this.displayError("Mode attribute is required"),void(this.disabled=!0);if("add"!==t&&"charge"!==t&&"invoice"!==t)return this.displayError("Mode can only be 'add', 'invoice' or 'charge'"),void(this.disabled=!0);if("charge"===t&&(s<=0||isNaN(s)||!s))return this.displayError("Amount attribute is required"),void(this.disabled=!0);if("charge"===t&&!i)return this.displayError("Description attribute is required"),void(this.disabled=!0);if("charge"===t&&!o)return this.displayError("Currency is required in charge mode"),void(this.disabled=!0);if("invoice"===t&&!this["invoice-id"])return this.displayError("Invoice ID is required"),void(this.disabled=!0);if(this["customer-id"]&&""!=this["customer-id"]&&this.mobile)return this.displayError("When customer-id is set, mobile is not allowed"),void(this.disabled=!0);if(this["customer-id"]&&""!=this["customer-id"]&&this["first-name"])return this.displayError("When customer-id is set, first-name is not allowed"),void(this.disabled=!0);if(this["customer-id"]&&""!=this["customer-id"]&&this["last-name"])return this.displayError("When customer-id is set, last-name is not allowed"),void(this.disabled=!0);if(this["first-name"]&&!this["last-name"])return this.displayError("Both first-name and last-name are required"),void(this.disabled=!0);if(this["last-name"]&&!this["first-name"])return this.displayError("Both first-name and last-name are required"),void(this.disabled=!0);if("true"===this["last-name"]&&"true"!=this["first-name"])return this.displayError("Both first-name and last-name are required"),void(this.disabled=!0);if("true"===this["first-name"]&&"true"!=this["last-name"])return this.displayError("Both first-name and last-name are required"),void(this.disabled=!0);if(this["customer-id"]&&""!=this["customer-id"]&&this.email)return this.displayError("When customer-id is set, email is not allowed"),void(this.disabled=!0);if(this["customer-id"]&&""!=this["customer-id"]&&this.dob)return this.displayError("When customer-id is set, date of birth is not allowed"),this.hideDob=!0,void(this.disabled=!0);if(this["customer-id"]&&""===this["customer-id"])return this.displayError("Customer-id can't be empty !"),void(this.disabled=!0);if(this.dob){var d=this.dob,h=new Date(new Date-new Date(d)).getFullYear()-1970;if(!0===this.definitelyNaN(h)&&"true"!=this.dob)return this.displayDobError("Please enter a valid date"),this.disabled=!0,this.showRed=!0,void(this.showRed=!0);if(h<18)return this.displayError("You must have 18 years minimum"),void(this.disabled=!0)}this.disabled=!1,this.hideDob=!1}radioChange(e){const t=e.target.value;this.showCard="card"===t}mobileInput(e){const t=function(e){let t;return/7(5|8)/.test(e)?t="smartpesa":/7(1|2|6|9)/.test(e)?t="ecocash":/((31)|6(1|8|9))/.test(e)&&(t="lumicash"),t}(e.target.value);switch(this.validator.phoneInputInputHandler(e),t){case"smartpesa":this.logoPath=this.hostname+"/assets/logos/smartpesa.jpg";break;case"ecocash":this.logoPath=this.hostname+"/assets/logos/ecocash.png";break;case"lumicash":this.logoPath=this.hostname+"/assets/logos/lumicash.png";break;default:this.logoPath=this.hostname+"/assets/logos/default-sim.png"}}mobileChange(e){this.validator.phoneInputKeyDownHandler(e)}cardInput(e){this.validator.ccNumberInputKeyDownHandler(e)}expInput(e){this.validator.ccExpiryInputKeyDownHandler(e)}dobInput(e){this.validator.dobInputKeyDownHandler(e)}dobChange(e){this.validator.dobInputInputHandler(e)}displayError(e){this.showError=!1,this.errorMessage=e,setTimeout((()=>{this.showError=!0}),3e3)}displayDobError(e){this.showError=!1,this.errorMessage=e,setTimeout((()=>{this.showError=!0}),3e7)}displayDobSuccess(e){this.showError=!1,this.errorMessage=e,setTimeout((()=>{this.showError=!0}),0)}displaySucess(e){this.showSuccess=!1,this.successMessage=e,setTimeout((()=>{this.showSuccess=!0}),3e3)}countryCodeChange(e){this.countryCode=e.target.value}countryChange(e){const t=e.target.value;"US"===t||"CA"===t?(this.state=!1,this.states="US"===t?ae.usa:"CA"===t?ae.canada:[]):this.state=!0}submitForm(e){var t,s,i,r,o,a,n,l,d,h;e.preventDefault();const c=this.shadowRoot.getElementById("email").value,u=this.shadowRoot.getElementById("card-number").value,p=this.shadowRoot.getElementById("expiry").value,m=this.shadowRoot.getElementById("cvc").value,g=this.shadowRoot.getElementById("card-name").value,y=(null===(t=this.shadowRoot.getElementById("first-name"))||void 0===t?void 0:t.value)||null;null===(s=this.shadowRoot.getElementById("customer-reference-id"))||void 0===s||s.value;const b=(null===(i=this.shadowRoot.getElementById("invoice-reference-id"))||void 0===i?void 0:i.value)||null,f=(null===(r=this.shadowRoot.getElementById("last-name"))||void 0===r?void 0:r.value)||null,w=(null===(o=this.shadowRoot.getElementById("phone-number"))||void 0===o?void 0:o.value)||null,v=(null===(a=this.shadowRoot.getElementById("dob"))||void 0===a?void 0:a.value)||null,S=this.shadowRoot.getElementById("line1").value,x=(null===(n=this.shadowRoot.getElementById("line2"))||void 0===n?void 0:n.value)||null,_=this.shadowRoot.getElementById("city").value,C=this.shadowRoot.getElementById("country").value,E=(null===(l=this.shadowRoot.getElementById("state"))||void 0===l?void 0:l.value)||null,$=(null===(d=this.shadowRoot.getElementById("zipCode"))||void 0===d?void 0:d.value)||null,N=(null===(h=this.shadowRoot.getElementById("customer-id"))||void 0===h?void 0:h.value)||null;var I;let P;var B,R;(this.hideButton(),I=this.dob&&"true"!=this.dob?this.dob:v,this["customer-id"])?P={amount:"usd"===(null===(B=this.currency)||void 0===B?void 0:B.toLowerCase())?100*this.amount:this.amount,customer:null,customer_id:this["customer-id"],customer_reference_id:b||this["customer-reference-id"],invoice_reference_id:b||this["invoice-reference-id"],description:this.description,is_captured:!0,currency:this.currency||null,source:{address:{city:_,country:C,line1:S,line2:x,state:E,zip:$,type:"personal"},brand:this.cardType,cvc:m,exp_month:p.split("/")[0],exp_year:20+p.split("/")[1],is_default:!1,number:u.replace(/\s/g,""),holder_name:g}}:P={amount:"usd"===(null===(R=this.currency)||void 0===R?void 0:R.toLowerCase())?100*this.amount:this.amount,customer:{address:{city:_,country:C,line1:S,line2:x,state:E,zip:$,type:"personal"},birth_date:I,email:c||this.email,first_name:y||this["first-name"],last_name:f||this["last-name"],mobile:w||this.mobile},customer_id:N,customer_reference_id:b||this["customer-reference-id"],invoice_reference_id:b||this["invoice-reference-id"],description:this.description,is_captured:!0,currency:this.currency||null,source:{address:{city:_,country:C,line1:S,line2:x,state:E,zip:$,type:"personal"},brand:this.cardType,cvc:m,exp_month:p.split("/")[0],exp_year:20+p.split("/")[1],is_default:!1,number:u.replace(/\s/g,""),holder_name:g}};"add"===this.mode?this["customer-id"]?this.addCustomerSource(this["customer-id"],P.source):this.addCustomer(P):"charge"===this.mode?this.chargeCustomer(P):"invoice"===this.mode&&this.payInvoice(P.source)}handleErrors(e){if(console.log(e),!e.ok)throw e;return e}addCustomer(e){const t=this.cleanObj(e.customer);fetch(`${this.baseUrl}/v1/customers`,{method:"POST",headers:{"Content-type":"application/json",Authorization:`Bearer ${this.key}`},body:JSON.stringify(t)}).then((e=>e.json())).then((t=>{const{source:s}=e;this.addCustomerSource(t.id,s,t)})).catch((e=>{this.showButton(),this.displayError(e),this.dispatchError(e)}))}addCustomerSource(e,t,s){const i=this.cleanObj(t);fetch(`${this.baseUrl}/v1/customers/${e}/sources`,{method:"POST",headers:{"Content-type":"application/json",Authorization:`Bearer ${this.key}`},body:JSON.stringify(i)}).then((e=>e.json())).then((e=>{"created"===e.status?(this.showButton(),this.clearForm(),this.dispatchSuccessAdd(e,s)):(this.showButton(),this.dispatchError(e))})).catch((e=>{this.showButton(),this.dispatchError(e)}))}chargeCustomer(e){fetch(`${this.baseUrl}/v1/charges`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.key}`},body:JSON.stringify(e)}).then((e=>e.json())).then((e=>{"succeeded"===e.status?(this.clearForm(),this.showButton(),this.dispatchSuccessCharge(e)):(this.showButton(),this.dispatchError(e))})).catch((e=>{this.showButton(),this.dispatchError(e)}))}hideButton(){const e=this.shadowRoot.getElementById("button");e.disabled=!0,e.innerText="Please wait..."}showButton(){const e=this.shadowRoot.getElementById("button");e.disabled=!1,e.innerText="add"===this.mode?"Save":"charge"===this.mode?"Charge":"Pay Invoice"}dispatchSuccessCharge(e){const t=new CustomEvent("onSuccess",{detail:{charge:e},bubbles:!0});this.dispatchEvent(t)}dispatchSuccessAdd(e,t){const s=new CustomEvent("onSuccess",{detail:{customer:t,source:e},bubbles:!0});this.dispatchEvent(s)}dispatchError(e){const t=new CustomEvent("onFailure",{detail:{error:e},bubbles:!0});this.dispatchEvent(t)}payInvoice(e){const t=this.cleanObj(e);fetch(`${this.baseUrl}/v1/invoices/pages/${this["invoice-id"]}/pay/source`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.key}`},body:JSON.stringify(t)}).then((e=>e.json())).then((e=>{"paid"===e.status?(this.clearForm(),this.dispatchSuccessCharge(e)):(this.showButton(),this.dispatchError(e))})).catch((e=>{this.showButton(),this.dispatchError(e)}))}selectionChange(e){const t=e.target.value;"united states of america"===t.toLowerCase()||"canada"===t.toLowerCase()?this.showZip=!1:this.showZip=!0,this.cardValues={...this.cardValues,address:{country:t}}}cvcChange(e){this.validator.cvcNumberInputInputHandler(e),e.target.value.length<3?(this.showRedCVC=!0,this.showRedCC=!0):(this.showRedCC=!1,this.showRedCVC=!1)}cardChange(e){const t=e.target.value.replace(/\s/g,"");switch(function(e){let t;const s=new RegExp("(?:^(?:(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12})$)");return new RegExp("(?:^(?:4[0-9]{12})(?:[0-9]{3})?$)").test(e)&&(t="visa"),s.test(e)&&(t="mastercard"),t}(t)){case"mastercard":this.imgPath=this.hostname+"/assets/logos/mastercard.png",this.cardType="mastercard";break;case"visa":this.imgPath=this.hostname+"/assets/logos/visa.png",this.cardType="visa";break;default:this.imgPath=this.hostname+"/assets/logos/default-card.png",this.cardType=null}this.validator.ccNumberInputInputHandler(e);const s=e.target.value.replace(/\s/g,"");t.length<16?this.showRedCC=!0:16===s.length?this.validator.checkLuhn(s)?this.showRedCC=!1:this.showRedCC=!0:this.showRedCC=!1}sortCountries(e){let t=e.sort(((e,t)=>e.callingCodes[0]-t.callingCodes[0]));this.sortedCountries=t.filter((e=>""!==e.callingCodes[0]))}getAllCountries(){fetch(`${this.baseUrl}/specs_data/country/BI`,{method:"GET",headers:{"Content-type":"application/json",Accept:"*/*",Authorization:`Bearer ${this.key}`}}).then(this.handleErrors).then((e=>e.json())).then((e=>{this.countries=e.charge_countries.sort(((e,t)=>e.name.localeCompare(t.name)))})).catch((e=>{this.sortedCountries=[],this.countries=[],this.displayError(e)}))}expChange(e){const t=(new Date).getFullYear(),s=(new Date).getMonth()+1,i=e.target.value,r=i.split("/")[0],o=20+i.split("/")[1];this.validator.ccExpiryInputInputHandler(e),5===i.length?(this.showRed=!1,(parseInt(r)<1||parseInt(r)>12)&&(this.showRed=!0),(parseInt(o)<t||parseInt(o)>t+5)&&(this.showRed=!0),s-parseInt(r)>0&&parseInt(o)===t&&(this.showRed=!0)):e.target.value.length<=4?this.showRed=!0:this.showRed=!1}dateChange(e){this.validator.ccExpiryInputInputHandler(e)}cleanObj(e){return Object.entries(e).forEach((([t,s])=>s&&"object"==typeof s&&this.cleanObj(s)||(null===s||""===s)&&delete e[t])),e}clearForm(){this.shadowRoot.getElementById("cardForm").reset(),this.showButton()}});y
</script>

Back to list