@paystack/checkout-js 1.27.0 → 1.27.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -48,6 +48,6 @@ Checkout JS is deployed to three environments:
48
48
 
49
49
  Checkout JS is automatically packaged and published to the NPM registry on every push to the `master` and `dev` branches.
50
50
 
51
- The `master` branch is publised under the `latest` tag so it can be installed by running `npm i @paystack/checkout-js@latest` while the `dev` branch is published under the `dev` tag so it can be installed using `npm i @paystack/checkout-js@dev`
51
+ The `master` branch is publised under the `latest` tag and can be installed by running `npm i @paystack/checkout-js@latest` while the `dev` branch is published under the `dev` tag and can be installed using `npm i @paystack/checkout-js@dev`
52
52
 
53
53
  All published versions are listed here on NPM https://www.npmjs.com/package/@paystack/checkout-js
package/dist/checkout.js CHANGED
@@ -27,4 +27,4 @@ var Paystack=function(t){"use strict";function e(t,e){var r=Object.keys(t);if(Ob
27
27
  * @since jsrsasign 2.1
28
28
  * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
29
29
  */
30
- var pt={};void 0!==pt.asn1&&pt.asn1||(pt.asn1={}),pt.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var n="",i=0;i<r;i++)n+="f";e=new B(n,16).xor(t).add(B.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=pt.asn1,r=e.DERBoolean,n=e.DERInteger,i=e.DERBitString,o=e.DEROctetString,a=e.DERNull,s=e.DERObjectIdentifier,u=e.DEREnumerated,c=e.DERUTF8String,h=e.DERNumericString,l=e.DERPrintableString,f=e.DERTeletexString,p=e.DERIA5String,d=e.DERUTCTime,g=e.DERGeneralizedTime,m=e.DERSequence,v=e.DERSet,y=e.DERTaggedObject,b=e.ASN1Util.newObject,w=Object.keys(t);if(1!=w.length)throw"key of param shall be only one.";var S=w[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+S+":"))throw"undefined key: "+S;if("bool"==S)return new r(t[S]);if("int"==S)return new n(t[S]);if("bitstr"==S)return new i(t[S]);if("octstr"==S)return new o(t[S]);if("null"==S)return new a(t[S]);if("oid"==S)return new s(t[S]);if("enum"==S)return new u(t[S]);if("utf8str"==S)return new c(t[S]);if("numstr"==S)return new h(t[S]);if("prnstr"==S)return new l(t[S]);if("telstr"==S)return new f(t[S]);if("ia5str"==S)return new p(t[S]);if("utctime"==S)return new d(t[S]);if("gentime"==S)return new g(t[S]);if("seq"==S){for(var T=t[S],E=[],A=0;A<T.length;A++){var x=b(T[A]);E.push(x)}return new m({array:E})}if("set"==S){for(T=t[S],E=[],A=0;A<T.length;A++)x=b(T[A]),E.push(x);return new v({array:E})}if("tag"==S){var k=t[S];if("[object Array]"===Object.prototype.toString.call(k)&&3==k.length){var O=b(k[2]);return new y({tag:k[0],explicit:k[1],obj:O})}var C={};if(void 0!==k.explicit&&(C.explicit=k.explicit),void 0!==k.tag&&(C.tag=k.tag),void 0===k.obj)throw"obj shall be specified for 'tag'.";return C.obj=b(k.obj),new y(C)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},pt.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),n=(e=Math.floor(r/40)+"."+r%40,""),i=2;i<t.length;i+=2){var o=("00000000"+parseInt(t.substr(i,2),16).toString(2)).slice(-8);n+=o.substr(1,7),"0"==o.substr(0,1)&&(e=e+"."+new B(n,2).toString(10),n="")}return e},pt.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=new B(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var o="",a=0;a<i;a++)o+="0";for(n=o+n,a=0;a<n.length-1;a+=7){var s=n.substr(a,7);a!=n.length-7&&(s="1"+s),r+=e(parseInt(s,2))}return r};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var n="",i=t.split("."),o=40*parseInt(i[0])+parseInt(i[1]);n+=e(o),i.splice(0,2);for(var a=0;a<i.length;a++)n+=r(i[a]);return n},pt.asn1.ASN1Object=function(){var t="";this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+t.length+",v="+this.hV;var e=this.hV.length/2,r=e.toString(16);if(r.length%2==1&&(r="0"+r),e<128)return r;var n=r.length/2;if(n>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);return(128+n).toString(16)+r},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},pt.asn1.DERAbstractString=function(t){pt.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},ft.lang.extend(pt.asn1.DERAbstractString,pt.asn1.ASN1Object),pt.asn1.DERAbstractTime=function(t){pt.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,r){var n=this.zeroPadding,i=this.localDateToUTC(t),o=String(i.getFullYear());"utc"==e&&(o=o.substr(2,2));var a=o+n(String(i.getMonth()+1),2)+n(String(i.getDate()),2)+n(String(i.getHours()),2)+n(String(i.getMinutes()),2)+n(String(i.getSeconds()),2);if(!0===r){var s=i.getMilliseconds();if(0!=s){var u=n(String(s),3);a=a+"."+(u=u.replace(/[0]+$/,""))}}return a+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(t)},this.setByDateValue=function(t,e,r,n,i,o){var a=new Date(Date.UTC(t,e-1,r,n,i,o,0));this.setByDate(a)},this.getFreshValueHex=function(){return this.hV}},ft.lang.extend(pt.asn1.DERAbstractTime,pt.asn1.ASN1Object),pt.asn1.DERAbstractStructured=function(t){pt.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},ft.lang.extend(pt.asn1.DERAbstractStructured,pt.asn1.ASN1Object),pt.asn1.DERBoolean=function(){pt.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},ft.lang.extend(pt.asn1.DERBoolean,pt.asn1.ASN1Object),pt.asn1.DERInteger=function(t){pt.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=pt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new B(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},ft.lang.extend(pt.asn1.DERInteger,pt.asn1.ASN1Object),pt.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=pt.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}pt.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var r="0"+t;this.hTLV=null,this.isModified=!0,this.hV=r+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var r=0;r<=e;r++)t+="0";var n="";for(r=0;r<t.length-1;r+=8){var i=t.substr(r,8),o=parseInt(i,2).toString(16);1==o.length&&(o="0"+o),n+=o}this.hTLV=null,this.isModified=!0,this.hV="0"+e+n},this.setByBooleanArray=function(t){for(var e="",r=0;r<t.length;r++)1==t[r]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},ft.lang.extend(pt.asn1.DERBitString,pt.asn1.ASN1Object),pt.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=pt.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}pt.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},ft.lang.extend(pt.asn1.DEROctetString,pt.asn1.DERAbstractString),pt.asn1.DERNull=function(){pt.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},ft.lang.extend(pt.asn1.DERNull,pt.asn1.ASN1Object),pt.asn1.DERObjectIdentifier=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=new B(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var o="",a=0;a<i;a++)o+="0";for(n=o+n,a=0;a<n.length-1;a+=7){var s=n.substr(a,7);a!=n.length-7&&(s="1"+s),r+=e(parseInt(s,2))}return r};pt.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var n="",i=t.split("."),o=40*parseInt(i[0])+parseInt(i[1]);n+=e(o),i.splice(0,2);for(var a=0;a<i.length;a++)n+=r(i[a]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=n},this.setValueName=function(t){var e=pt.asn1.x509.OID.name2oid(t);if(""===e)throw"DERObjectIdentifier oidName undefined: "+t;this.setValueOidString(e)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t):void 0!==t.oid?this.setValueOidString(t.oid):void 0!==t.hex?this.setValueHex(t.hex):void 0!==t.name&&this.setValueName(t.name))},ft.lang.extend(pt.asn1.DERObjectIdentifier,pt.asn1.ASN1Object),pt.asn1.DEREnumerated=function(t){pt.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=pt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new B(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},ft.lang.extend(pt.asn1.DEREnumerated,pt.asn1.ASN1Object),pt.asn1.DERUTF8String=function(t){pt.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},ft.lang.extend(pt.asn1.DERUTF8String,pt.asn1.DERAbstractString),pt.asn1.DERNumericString=function(t){pt.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},ft.lang.extend(pt.asn1.DERNumericString,pt.asn1.DERAbstractString),pt.asn1.DERPrintableString=function(t){pt.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},ft.lang.extend(pt.asn1.DERPrintableString,pt.asn1.DERAbstractString),pt.asn1.DERTeletexString=function(t){pt.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},ft.lang.extend(pt.asn1.DERTeletexString,pt.asn1.DERAbstractString),pt.asn1.DERIA5String=function(t){pt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},ft.lang.extend(pt.asn1.DERIA5String,pt.asn1.DERAbstractString),pt.asn1.DERUTCTime=function(t){pt.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{12}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date))},ft.lang.extend(pt.asn1.DERUTCTime,pt.asn1.DERAbstractTime),pt.asn1.DERGeneralizedTime=function(t){pt.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.withMillis=!1,this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{14}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date),!0===t.millis&&(this.withMillis=!0))},ft.lang.extend(pt.asn1.DERGeneralizedTime,pt.asn1.DERAbstractTime),pt.asn1.DERSequence=function(t){pt.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++)t+=this.asn1Array[e].getEncodedHex();return this.hV=t,this.hV}},ft.lang.extend(pt.asn1.DERSequence,pt.asn1.DERAbstractStructured),pt.asn1.DERSet=function(t){pt.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var r=this.asn1Array[e];t.push(r.getEncodedHex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},ft.lang.extend(pt.asn1.DERSet,pt.asn1.DERAbstractStructured),pt.asn1.DERTaggedObject=function(t){pt.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,r){this.hT=e,this.isExplicit=t,this.asn1Object=r,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=r.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.tag&&(this.hT=t.tag),void 0!==t.explicit&&(this.isExplicit=t.explicit),void 0!==t.obj&&(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},ft.lang.extend(pt.asn1.DERTaggedObject,pt.asn1.ASN1Object);var dt=function(t){function e(r){var n=t.call(this)||this;return r&&("string"==typeof r?n.parseKey(r):(e.hasPrivateKeyProperty(r)||e.hasPublicKeyProperty(r))&&n.parsePropertiesFrom(r)),n}return g(e,t),e.prototype.parseKey=function(t){try{var e=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?v.decode(t):y.unarmor(t),i=O.decode(n);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){e=i.sub[1].getHexStringValue(),this.n=M(e,16),r=i.sub[2].getHexStringValue(),this.e=parseInt(r,16);var o=i.sub[3].getHexStringValue();this.d=M(o,16);var a=i.sub[4].getHexStringValue();this.p=M(a,16);var s=i.sub[5].getHexStringValue();this.q=M(s,16);var u=i.sub[6].getHexStringValue();this.dmp1=M(u,16);var c=i.sub[7].getHexStringValue();this.dmq1=M(c,16);var h=i.sub[8].getHexStringValue();this.coeff=M(h,16)}else{if(2!==i.sub.length)return!1;var l=i.sub[1].sub[0];e=l.sub[0].getHexStringValue(),this.n=M(e,16),r=l.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}},e.prototype.getPrivateBaseKey=function(){var t={array:[new pt.asn1.DERInteger({int:0}),new pt.asn1.DERInteger({bigint:this.n}),new pt.asn1.DERInteger({int:this.e}),new pt.asn1.DERInteger({bigint:this.d}),new pt.asn1.DERInteger({bigint:this.p}),new pt.asn1.DERInteger({bigint:this.q}),new pt.asn1.DERInteger({bigint:this.dmp1}),new pt.asn1.DERInteger({bigint:this.dmq1}),new pt.asn1.DERInteger({bigint:this.coeff})]};return new pt.asn1.DERSequence(t).getEncodedHex()},e.prototype.getPrivateBaseKeyB64=function(){return l(this.getPrivateBaseKey())},e.prototype.getPublicBaseKey=function(){var t=new pt.asn1.DERSequence({array:[new pt.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new pt.asn1.DERNull]}),e=new pt.asn1.DERSequence({array:[new pt.asn1.DERInteger({bigint:this.n}),new pt.asn1.DERInteger({int:this.e})]}),r=new pt.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new pt.asn1.DERSequence({array:[t,r]}).getEncodedHex()},e.prototype.getPublicBaseKeyB64=function(){return l(this.getPublicBaseKey())},e.wordwrap=function(t,e){if(!t)return t;var r="(.{1,"+(e=e||64)+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(r,"g")).join("\n")},e.prototype.getPrivateKey=function(){var t="-----BEGIN RSA PRIVATE KEY-----\n";return t+=e.wordwrap(this.getPrivateBaseKeyB64())+"\n",t+="-----END RSA PRIVATE KEY-----"},e.prototype.getPublicKey=function(){var t="-----BEGIN PUBLIC KEY-----\n";return t+=e.wordwrap(this.getPublicBaseKeyB64())+"\n",t+="-----END PUBLIC KEY-----"},e.hasPublicKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")},e.hasPrivateKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},e.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)},e}(st),gt=function(){function t(t){t=t||{},this.default_key_size=parseInt(t.default_key_size,10)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null}return t.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new dt(t)},t.prototype.setPrivateKey=function(t){this.setKey(t)},t.prototype.setPublicKey=function(t){this.setKey(t)},t.prototype.decrypt=function(t){try{return this.getKey().decrypt(f(t))}catch(t){return!1}},t.prototype.encrypt=function(t){try{return l(this.getKey().encrypt(t))}catch(t){return!1}},t.prototype.sign=function(t,e,r){try{return l(this.getKey().sign(t,e,r))}catch(t){return!1}},t.prototype.verify=function(t,e,r){try{return this.getKey().verify(t,f(e),r)}catch(t){return!1}},t.prototype.getKey=function(t){if(!this.key){if(this.key=new dt,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},t.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},t.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},t.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},t.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},t.version="3.0.0-rc.1",t}();window.JSEncrypt=gt,t.JSEncrypt=gt,t.default=gt,Object.defineProperty(t,"__esModule",{value:!0})}(e)}(0,eE.exports);var nE=O,iE=z,oE=Ms,aE=ot,sE=iE(D.f),uE=iE([].push),cE=function(t){return function(e){for(var r,n=aE(e),i=oE(n),o=i.length,a=0,s=[];o>a;)r=i[a++],nE&&!sE(n,r)||uE(s,t?[r,n[r]]:n[r]);return s}},hE={entries:cE(!0),values:cE(!1)}.values;fi({target:"Object",stat:!0},{values:function(t){return hE(t)}});var lE=fi,fE=Es.find,pE=_d,dE="find",gE=!0;dE in[]&&Array(1).find((function(){gE=!1})),lE({target:"Array",proto:!0,forced:gE},{find:function(t){return fE(this,t,arguments.length>1?arguments[1]:void 0)}}),pE(dE);var mE=function(t){for(var e,r=0,n=!1,i=t.length-1;i>=0;)e=parseInt(t.charAt(i),10),n&&(e*=2)>9&&(e=e%10+1),n=!n,r+=e,i--;return r%10==0};var vE=function(t){return t?JSON.parse(JSON.stringify(t)):null};var yE=function(t){return"string"==typeof t||t instanceof String};var bE=function(t,e){return Array.isArray(e)?function(t,e,r){var n=String(e).length,i=t.substr(0,n),o=parseInt(i,10);return e=parseInt(String(e).substr(0,i.length),10),r=parseInt(String(r).substr(0,i.length),10),o>=e&&o<=r}(t,e[0],e[1]):function(t,e){return(e=String(e)).substring(0,t.length)===t.substring(0,e.length)}(t,e)},wE=vE,SE=bE;var TE,EE=function(t,e,r){var n,i,o,a;for(n=0;n<e.patterns.length;n++)if(i=e.patterns[n],SE(t,i)){a=wE(e),o=Array.isArray(i)?String(i[0]).length:String(i).length,t.length>=o&&(a.matchStrength=o),r.push(a);break}},AE={visa:{niceType:"Visa",type:"visa",patterns:[4],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}},mastercard:{niceType:"Mastercard",type:"mastercard",patterns:[[51,55],[2221,2229],[223,229],[23,26],[270,271],2720],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},"american-express":{niceType:"American Express",type:"american-express",patterns:[34,37],gaps:[4,10],lengths:[15],code:{name:"CID",size:4}},"diners-club":{niceType:"Diners Club",type:"diners-club",patterns:[[300,305],36,38,39],gaps:[4,10],lengths:[14,16,19],code:{name:"CVV",size:3}},discover:{niceType:"Discover",type:"discover",patterns:[6011,[644,649],65],gaps:[4,8,12],lengths:[16,19],code:{name:"CID",size:3}},jcb:{niceType:"JCB",type:"jcb",patterns:[2131,1800,[3528,3589]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVV",size:3}},unionpay:{niceType:"UnionPay",type:"unionpay",patterns:[620,[624,626],[62100,62182],[62184,62187],[62185,62197],[62200,62205],[622010,622999],622018,[622019,622999],[62207,62209],[622126,622925],[623,626],6270,6272,6276,[627700,627779],[627781,627799],[6282,6289],6291,6292],gaps:[4,8,12],lengths:[14,15,16,17,18,19],code:{name:"CVN",size:3}},maestro:{niceType:"Maestro",type:"maestro",patterns:[493698,[5e5,506698],[506779,508999],[56,59],63,67,6],gaps:[4,8,12],lengths:[12,13,14,15,16,17,18,19],code:{name:"CVC",size:3}},elo:{niceType:"Elo",type:"elo",patterns:[401178,401179,438935,457631,457632,431274,451416,457393,504175,[506699,506778],[509e3,509999],627780,636297,636368,[650031,650033],[650035,650051],[650405,650439],[650485,650538],[650541,650598],[650700,650718],[650720,650727],[650901,650978],[651652,651679],[655e3,655019],[655021,655058]],gaps:[4,8,12],lengths:[16],code:{name:"CVE",size:3}},mir:{niceType:"Mir",type:"mir",patterns:[[2200,2204]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVP2",size:3}},hiper:{niceType:"Hiper",type:"hiper",patterns:[637095,637568,637599,637609,637612],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},hipercard:{niceType:"Hipercard",type:"hipercard",patterns:[606282],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}}},xE=vE,kE=function(t){if(function(t){var e=t.filter((function(t){return t.matchStrength})).length;return e>0&&e===t.length}(t))return t.reduce((function(t,e){return t?t.matchStrength<e.matchStrength?e:t:e}))},OE=yE,CE=EE,PE={},RE={VISA:"visa",MASTERCARD:"mastercard",AMERICAN_EXPRESS:"american-express",DINERS_CLUB:"diners-club",DISCOVER:"discover",JCB:"jcb",UNIONPAY:"unionpay",MAESTRO:"maestro",ELO:"elo",MIR:"mir",HIPER:"hiper",HIPERCARD:"hipercard"},BE=[RE.VISA,RE.MASTERCARD,RE.AMERICAN_EXPRESS,RE.DINERS_CLUB,RE.DISCOVER,RE.JCB,RE.UNIONPAY,RE.MAESTRO,RE.ELO,RE.MIR,RE.HIPER,RE.HIPERCARD];function DE(t){return PE[t]||AE[t]}function LE(t,e){var r=TE.indexOf(t);if(!e&&-1===r)throw new Error('"'+t+'" is not a supported card type.');return r}function IE(t){var e,r=[];return OE(t)?0===t.length?TE.map((function(t){return xE(DE(t))})):(TE.forEach((function(e){var n=DE(e);CE(t,n,r)})),(e=kE(r))?[e]:r):[]}TE=xE(BE),IE.getTypeInfo=function(t){return xE(DE(t))},IE.removeCard=function(t){var e=LE(t);TE.splice(e,1)},IE.addCard=function(t){var e=LE(t.type,!0);PE[t.type]=t,-1===e&&TE.push(t.type)},IE.updateCard=function(t,e){var r,n=PE[t]||AE[t];if(!n)throw new Error('"'+t+'" is not a recognized type. Use `addCard` instead.');if(e.type&&n.type!==e.type)throw new Error("Cannot overwrite type parameter.");r=xE(n),Object.keys(r).forEach((function(t){e[t]&&(r[t]=e[t])})),PE[r.type]=r},IE.changeOrder=function(t,e){var r=LE(t);TE.splice(r,1),TE.splice(e,0,t)},IE.resetModifications=function(){TE=xE(BE),PE={}},IE.types=RE;var jE=IE,NE=mE,ME=jE;function _E(t,e,r){return{card:t,isPotentiallyValid:e,isValid:r}}var VE=function(t,e){var r,n,i,o,a;if(e=e||{},"number"==typeof t&&(t=String(t)),"string"!=typeof t)return _E(null,!1,!1);if(t=t.replace(/\-|\s/g,""),!/^\d*$/.test(t))return _E(null,!1,!1);if(0===(r=ME(t)).length)return _E(null,!1,!1);if(1!==r.length)return _E(null,!0,!1);if(n=r[0],e.maxLength&&t.length>e.maxLength)return _E(n,!1,!1);for(i=n.type===ME.types.UNIONPAY&&!0!==e.luhnValidateUnionPay||NE(t),a=Math.max.apply(null,n.lengths),e.maxLength&&(a=Math.min(e.maxLength,a)),o=0;o<n.lengths.length;o++)if(n.lengths[o]===t.length)return _E(n,t.length<a||i,i);return _E(n,t.length<a,!1)};function UE(t,e,r){return{isValid:t,isPotentiallyValid:e,isCurrentYear:r||!1}}var FE=function(t,e){var r,n,i,o,a;return e=e||19,"string"!=typeof t?UE(!1,!1):""===t.replace(/\s/g,"")?UE(!1,!0):/^\d*$/.test(t)?(n=t.length)<2?UE(!1,!0):(r=(new Date).getFullYear(),3===n?UE(!1,t.slice(0,2)===String(r).slice(0,2)):n>4?UE(!1,!1):(t=parseInt(t,10),i=Number(String(r).substr(2,2)),2===n?(a=i===t,o=t>=i&&t<=i+e):4===n&&(a=r===t,o=t>=r&&t<=r+e),UE(o,o,a))):UE(!1,!1)},qE=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},HE=FE,zE=qE;function GE(t,e,r){return{isValid:t,isPotentiallyValid:e,isValidForThisYear:r||!1}}var KE=function(t){var e,r,n=(new Date).getMonth()+1;return"string"!=typeof t?GE(!1,!1):""===t.replace(/\s/g,"")||"0"===t?GE(!1,!0):/^\d*$/.test(t)?(e=parseInt(t,10),isNaN(t)?GE(!1,!1):GE(r=e>0&&e<13,r,r&&e>=n)):GE(!1,!1)},WE=function(t){var e,r,n,i,o;return/^\d{4}-\d{1,2}$/.test(t)?t=t.split("-").reverse():/\//.test(t)?t=t.split(/\s*\/\s*/g):/\s/.test(t)&&(t=t.split(/ +/g)),zE(t)?{month:t[0]||"",year:t.slice(1).join()}:(n=t,r=0===(o=Number(n[0]))?2:o>1||1===o&&Number(n[1])>2?1:1===o?(i=n.substr(1),HE(i).isPotentiallyValid?1:2):5===n.length?1:n.length>5?2:1,{month:e=t.substr(0,r),year:t.substr(e.length)})},XE=KE,YE=FE;function ZE(t,e,r,n){return{isValid:t,isPotentiallyValid:e,month:r,year:n}}function JE(t,e){return{isValid:t,isPotentiallyValid:e}}function $E(t,e){return{isValid:t,isPotentiallyValid:e}}var QE={number:VE,expirationDate:function(t,e){var r,n,i,o;if("string"==typeof t)t=t.replace(/^(\d\d) (\d\d(\d\d)?)$/,"$1/$2"),r=WE(t);else{if(null===t||"object"!=typeof t)return ZE(!1,!1,null,null);r={month:String(t.month),year:String(t.year)}}if(n=XE(r.month),i=YE(r.year,e),n.isValid){if(i.isCurrentYear)return ZE(o=n.isValidForThisYear,o,r.month,r.year);if(i.isValid)return ZE(!0,!0,r.month,r.year)}return n.isPotentiallyValid&&i.isPotentiallyValid?ZE(!1,!0,null,null):ZE(!1,!1,null,null)},expirationMonth:KE,expirationYear:FE,cvv:function(t,e){return e=(e=e||3)instanceof Array?e:[e],"string"!=typeof t?JE(!1,!1):/^\d*$/.test(t)?function(t,e){for(var r=0;r<t.length;r++)if(e===t[r])return!0;return!1}(e,t.length)?JE(!0,!0):t.length<Math.min.apply(null,e)?JE(!1,!0):t.length>function(t){for(var e=3,r=0;r<t.length;r++)e=t[r]>e?t[r]:e;return e}(e)?JE(!1,!1):JE(!0,!0):JE(!1,!1)},postalCode:function(t,e){var r;return r=(e=e||{}).minLength||3,"string"!=typeof t?$E(!1,!1):t.length<r?$E(!1,!0):$E(!0,!0)},creditCardType:jE},tA=[{type:"bank_auth",name:"Bank authorization",number:"4084080000000409",cvv:"000",month:"01",year:"30"},{type:"success",name:"Success",number:"4084084084084081",cvv:"408",month:"12",year:"30"},{type:"declined",name:"Declined",number:"4084080000005408",cvv:"001",month:"12",year:"30"},{type:"pin",name:"Pin only validation",number:"507850785078507812",cvv:"884",month:"01",year:"30"},{type:"pin+otp",name:"Pin and OTP validation",number:"5060666666666666666",cvv:"123",month:"01",year:"30"},{type:"pin+phone+otp",name:"Pin, phone and OTP validation",number:"507850785078507812",cvv:"884",month:"01",year:"30"},{type:"default",name:"No validation",number:"4084084084084081",cvv:"408",month:"01",year:"30"}];QE.creditCardType.addCard({niceType:"Verve",type:"verve",patterns:[[506e3,507999],[65e4,650009]],gaps:[4,8,12,16],lengths:[16,18,19],code:{name:"CVV",size:3}}),QE.creditCardType.changeOrder("verve",0);var eA={getEncryptedPin:function(t){return t?rE(t):void 0},getLast4:function(t){return t.substring(t.length-4)},tokenize:function(t){var e=t.number,r=t.cvv,n=t.month,i=t.year;return rE("".concat(e,"*").concat(r,"*").concat(n,"*").concat(i))},getType:function(t){var e=QE.number(t);return e&&e.card?{type:e.card.type,maxLength:Math.max.apply(Math,b(e.card.lengths)),minLength:Math.min.apply(Math,b(e.card.lengths))}:{type:null,maxLength:0}},validate:function(t){var e=t.number,r=t.cvv,n=t.month,i=t.year,o=this.getType(e).type,a={number:this.isNumberValid(e),expiry:this.isExpiryValid({month:n,year:i}),cvv:this.isCvvValid(r,o)};return{isValid:Object.values(a).every((function(t){return!0===t})),result:a}},validateNumber:function(t){return QE.number(t)},isNumberValid:function(t){return eA.validateNumber(t).isValid},validateCVV:function(t,e){var r="american-express"===e?4:3;return QE.cvv(t,r)},isCvvValid:function(t,e){return eA.validateCVV(t,e).isValid},validateExpiry:function(t){if(null!==t&&"object"===n(t)){var e=t.month,r=t.year;return QE.expirationMonth(e)&&QE.expirationYear(r)}return QE.expirationDate(t)},isExpiryValid:function(t){return eA.validateExpiry(t).isValid},findTestCard:function(t){var e=t||"default";return tA.find((function(t){return t.type===e}))}},rA=function(){function t(e){var r=e.number,n=e.cvv,i=e.month,o=e.year,s=e.pin;a(this,t),this.number=r,this.cvv=n,this.month=i,this.year=o,this.pin=s}return u(t,[{key:"getEncryptedPin",value:function(){return eA.getEncryptedPin(this.pin)}},{key:"getLast4",value:function(){return eA.getLast4(this.number)}},{key:"tokenize",value:function(){return eA.tokenize({number:this.number,cvv:this.cvv,month:this.month,year:this.year})}}],[{key:"getType",value:function(t){return eA.getType(t)}},{key:"validate",value:function(t){var e=t.number,r=t.cvv,n=t.month,i=t.year;return eA.validate({number:e,cvv:r,month:n,year:i})}},{key:"validateNumber",value:function(t){return eA.validateNumber(t)}},{key:"isNumberValid",value:function(t){return eA.isNumberValid(t)}},{key:"validateCVV",value:function(t,e){return eA.validateCVV(t,e)}},{key:"isCvvValid",value:function(t,e){return eA.isCvvValid(t,e)}},{key:"validateExpiry",value:function(t){return eA.validateExpiry(t)}},{key:"isExpiryValid",value:function(t){return eA.isExpiryValid(t)}},{key:"generateTestCard",value:function(e){return new t(eA.findTestCard(e))}}]),t}(),nA=function(t){var e=t.clientdata,n=t.last4,i=t.pin,o=t.trans,a=t.device,s=t.rememberCard,u=t.transactionType,c=t.subscription,h=t.customFields,l="".concat(Dd.paymentBaseUrl,"charge/"),f=RT(),p=r({"Content-Type":"application/x-www-form-urlencoded"},f&&{"Accept-Language":f}),d=r(r(r({clientdata:e,last4:n,trans:o,device:a,offset:(new Date).getTimezoneOffset(),remember_card:s},u&&{transaction_type:u}),c&&{subscription:c}),h&&h);i&&(d.handle=i);var g=FT(d);return PT.post(l,g,{headers:p}).then((function(t){return Wd.parse(t.data)}))},iA=function(t){var e=t.device,n=t.accessCode,i=t.pin,o="".concat(Dd.paymentBaseUrl,"charge/resume/").concat(n),a=RT(),s=r({"Content-Type":"application/x-www-form-urlencoded"},a&&{"Accept-Language":a}),u=r({device:e},i&&{handle:i}),c=FT(u);return PT.post(o,c,{headers:s}).then((function(t){return Wd.parse(t.data)}))},oA=function(t){var e=t.last4,n=t.trans,i=t.device,o=t.authorizationCode,a=t.cvv,s=t.pin,u=t.transactionType,c=t.subscription,h="".concat(Dd.paymentBaseUrl,"charge/"),l=RT(),f=r({"Content-Type":"application/x-www-form-urlencoded"},l&&{"Accept-Language":l}),p=r(r({last4:e,trans:n,device:i,cvv:a,handle:s,authorization_code:o},u&&{transaction_type:u}),c&&{subscription:c}),d=FT(p);return PT.post(h,d,{headers:f}).then((function(t){return Wd.parse(t.data)}))},aA=function(t,e){var n="".concat(Dd.paymentBaseUrl,"charge/validate"),i={trans:t,token:e},o=RT(),a=r({},o&&{"Accept-Language":o}),s=FT(i);return PT.post(n,s,{headers:a}).then((function(t){return Wd.parse(t.data)}))},sA=function(t){var e=t.address,n=t.city,i=t.state,o=t.zipCode,a=t.transactionId,s="".concat(Dd.paymentBaseUrl,"charge/avs"),u=RT(),c=r({"Content-Type":"application/x-www-form-urlencoded"},u&&{"Accept-Language":u}),h=FT({city:n,state:i,address:e,zip_code:o,trans:a});return PT.post(s,h,{headers:c}).then((function(t){return Wd.parse(t.data)}))},uA=function(t){var e=t.authorizationId,n=t.publicKey,i=RT(),o=r({Authorization:"Bearer ".concat(n)},i&&{"Accept-Language":i}),a={authorization_id:e},s="".concat(Dd.paystackApiUrl,"rememberme/forget_card");return PT.post(s,a,{headers:o}).then((function(t){return Wd.parse(t.data)}))},cA=function(t){return o(regeneratorRuntime.mark((function e(){var n,i,o,a,s,u,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.transaction,i=t.phone,o=new URL("/saved_cards/authorize",Dd.paystackApiUrl).toString(),a=RT(),s=r({},a&&{"Accept-Language":a}),u=r(r({},i&&{phone:i}),{},{transaction:n}),e.next=7,PT.post(o,u,{headers:s});case 7:return c=e.sent,e.abrupt("return",c.data);case 9:case"end":return e.stop()}}),e)})))()},hA=function(t){return o(regeneratorRuntime.mark((function e(){var n,i,o,a,s,u,c,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.code,i=t.transaction,o=t.token,a=new URL("/saved_cards/authorize/verify",Dd.paystackApiUrl).toString(),s=RT(),u=r({Authorization:"Bearer ".concat(o)},s&&{"Accept-Language":s}),c={code:n,transaction:i},e.next=7,PT.post(a,c,{headers:u});case 7:return h=e.sent,e.abrupt("return",h.data);case 9:case"end":return e.stop()}}),e)})))()},lA=function(t){return o(regeneratorRuntime.mark((function e(){var n,i,o,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.token,i=new URL("/saved_cards/cards",Dd.paystackApiUrl).toString(),o=RT(),a=r({Authorization:"Bearer ".concat(n),"jwt-auth":!0},o&&{"Accept-Language":o}),e.next=6,PT.get(i,{headers:a});case 6:return s=e.sent,e.abrupt("return",s.data);case 8:case"end":return e.stop()}}),e)})))()},fA=function(t){return o(regeneratorRuntime.mark((function e(){var n,i,o,a,s,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.cardCode,i=t.token,o=new URL("/saved_cards/cards/".concat(n),Dd.paystackApiUrl).toString(),a=RT(),s=r({Authorization:"Bearer ".concat(i),"jwt-auth":!0},a&&{"Accept-Language":a}),e.next=6,PT.delete(o,{headers:s});case 6:return u=e.sent,e.abrupt("return",u.data);case 8:case"end":return e.stop()}}),e)})))()},pA=function(t){return o(regeneratorRuntime.mark((function e(){var n,i,o,a,s,u,c,h,l,f;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.token,i=t.device,o=t.cardCode,a=t.transaction,s=t.selectedCurrency,u=new URL("/saved_cards/cards/".concat(o,"/charge"),Dd.paystackApiUrl).toString(),c=RT(),h=r({Authorization:"Bearer ".concat(n),"jwt-auth":!0},c&&{"Accept-Language":c}),l={device:i,transaction:a,selected_currency:s},e.next=7,PT.post(u,l,{headers:h});case 7:return f=e.sent,e.abrupt("return",Wd.parse(f.data));case 9:case"end":return e.stop()}}),e)})))()},dA="card",gA="saved card",mA="otp";function vA(t,e){return new Promise((function(r,n){var i=rA.validate(t);if(!i.isValid){var o=e||t.number,a=Object.keys(i.result).filter((function(t){return!1===i.result[t]})),s="Invalid card details: ".concat(a.join(", "));n(Error(o?s:"Please set a valid card with Transaction.setCard()"))}r()}))}var yA={setCard:function(t){var e=this;return vA(t,!0).then((function(){e.card=new rA(t)}))},rememberCard:function(){this.remember_card=!0},chargeCard:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return!this.card.number&&this.card.pin?this.chargeCardWithPin(e):vA(this.card).then((function(){t.logAttempt(dA);var r={clientdata:t.card.tokenize(),last4:t.card.getLast4(),pin:t.card.getEncryptedPin(),trans:t.id,device:t.deviceFingerprint,rememberCard:t.remember_card,transactionType:t.transactionType,subscription:t.subscription,customFields:e};return nA(r).then((function(e){return t.logAPIResponse(e,dA),e}))}))},chargeCardWithPin:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logAttempt(dA);var r={pin:rE(this.card.pin),trans:this.id,device:this.deviceFingerprint,rememberCard:this.remember_card,transactionType:this.transactionType,subscription:this.subscription,customFields:e};return nA(r).then((function(e){return t.logAPIResponse(e,dA),e}))},chargeRememberedCard:function(t){var e=this,r=t.cvv,n=t.authorizationCode,i=t.cardLast4,o=t.pin;this.logAttempt(dA);var a=rE(o),s={authorizationCode:n,cvv:r,last4:i,trans:this.id,device:this.deviceFingerprint,pin:a,transactionType:this.transactionType,subscription:this.subscription};return oA(s).then((function(t){return e.logAPIResponse(t,dA),t}))},resumeCardCharge:function(t){var e=this,n=t.accessCode,i=t.pin,o=r(r({},i&&{pin:rE(i)}),{},{accessCode:n,device:this.deviceFingerprint});return iA(o).then((function(t){return e.logAPIResponse(t,dA),t}))},forgetRememberedCard:function(t){var e=this,r={authorizationId:t,publicKey:this.merchant.key};return uA(r).then((function(t){return e.logAPIResponse(t,dA),t}))},authenticateCard:function(t){var e=this;return aA(this.id,t).then((function(t){return e.logAPIResponse(t,dA),t}))},verifyAddress:function(t){var e=this,r=t.address,n={city:t.city,state:t.state,address:r,zipCode:t.zipCode,transactionId:this.id};return sA(n).then((function(t){return e.logAPIResponse(t,dA),t}))},listenFor3DSCharge:function(t){var e={channel:"3DS_".concat(this.id),paymentMethod:dA};return this.listenForCharge(e,t)},sendSavedCardsOTP:function(t){var e=this;return o(regeneratorRuntime.mark((function r(){var n;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,e.logAuth(mA),r.next=4,cA({phone:t,transaction:e.id});case 4:return n=r.sent,e.savedCardsTempAuthToken=n.data.token,r.abrupt("return",n);case 9:throw r.prev=9,r.t0=r.catch(0),e.savedCardsTempAuthToken=null,r.t0;case 13:case"end":return r.stop()}}),r,null,[[0,9]])})))()},verifySavedCardsOtp:function(t){var e=this;return o(regeneratorRuntime.mark((function r(){var n,i,o;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=t.code,i={code:n,transaction:e.id,token:e.savedCardsTempAuthToken},r.prev=2,r.next=5,hA(i);case 5:return o=r.sent,e.savedCardsToken=o.data.token,r.abrupt("return",o);case 10:throw r.prev=10,r.t0=r.catch(2),e.savedCardsToken=null,r.t0;case 14:case"end":return r.stop()}}),r,null,[[2,10]])})))()},getSavedCards:function(){return lA({token:this.savedCardsToken})},deleteSavedCard:function(t){return fA({cardCode:t,token:this.savedCardsToken})},chargeSavedCard:function(t){var e=t.cardCode,r=t.selectedCurrency,n=void 0===r?this.currency:r;return this.logAttempt(gA),pA({cardCode:e,transaction:this.id,token:this.savedCardsToken,device:this.deviceFingerprint,selectedCurrency:n})}},bA=function(){function t(e){var r=e.bankId,n=e.accountType,i=e.accountNumber;a(this,t),this.bankId=r,this.accountType=n,this.accountNumber=i}return u(t,null,[{key:"validate",value:function(e){var r=e.bankId,n=e.accountType,i=e.accountNumber,o=[];return r&&"number"==typeof r||o.push("Invalid bankId. Please check for supported banks with BankAccount.supportedBanks()"),t.types.indexOf(n)>-1?"nuban"!==n||t.isValidNubanAccount(i)||o.push("Invalid account number. Nuban accounts must be 10 digit numbers"):o.push("Invalid bank type. Please check BankAccount.types for the list of valid bank types"),{isValid:0===o.length,errors:o}}},{key:"isValidNubanAccount",value:function(t){return!!t&&(("number"==typeof t||/^\d+$/.test(t))&&10===t.length)}},{key:"supportedBanks",value:function(){var t="".concat(Dd.paymentBaseUrl,"bank?pay_with_bank=true"),e=RT(),n=r({},e&&{"Accept-Language":e});return PT.post(t,{headers:n}).then((function(t){return t.data}))}}]),t}();bA.types=["nuban"];var wA=function(t){var e=t.bankId,n=t.transactionId,i=t.accountNumber,o=t.device,a="".concat(Dd.paymentBaseUrl,"bank/charge_account/").concat(e,"/").concat(n),s=RT(),u=r({"Content-Type":"application/x-www-form-urlencoded"},s&&{"Accept-Language":s}),c=FT({account_number:i,device:o});return PT.post(a,c,{headers:u}).then((function(t){return Wd.parse(t.data)}))},SA=function(t){var e=t.bankId,n=t.transactionId,i=t.accountNumber,o=t.birthday,a="".concat(Dd.paymentBaseUrl,"bank/charge_account/").concat(e,"/").concat(n),s=RT(),u=r({"Content-Type":"application/x-www-form-urlencoded"},s&&{"Accept-Language":s}),c=FT({account_number:i,birthday:o});return PT.post(a,c,{headers:u}).then((function(t){return Wd.parse(t.data)}))},TA=function(t){var e=t.bankId,n=t.transactionId,i=t.token,o=t.device,a="".concat(Dd.paymentBaseUrl,"bank/validate_token/").concat(e,"/").concat(n),s=RT(),u=r({"Content-Type":"application/x-www-form-urlencoded"},s&&{"Accept-Language":s}),c=FT({device:o,token:i});return PT.post(a,c,{headers:u}).then((function(t){return Wd.parse(t.data)}))},EA="bank account";function AA(t,e){return new Promise((function(r,n){var i=bA.validate(t);if(!i.isValid){var o=e||t.accountNumber?i.errors[0]:"Please set a valid bank account with Transaction.setBank()";n(Error(o))}r()}))}var xA={getIbankUrl:function(t){var e=this,r=t.bankId;return new Promise((function(t,n){r||n(Error("Please send bankId"));var i="".concat(Dd.paymentBaseUrl,"bank/ibank/").concat(r,"/").concat(e.id);t(Wd.success({url:i}))}))},listenForIbankCharge:function(t){var e={channel:"IBANK_".concat(this.id),paymentMethod:"ibank"};return this.listenForCharge(e,t)}},kA=function(t){var e=t.bankId,n=t.transactionId,i=t.phoneNumber,o=t.payId,a="".concat(Dd.paymentBaseUrl,"bank/digitalbankmandate/").concat(e,"/").concat(n),s=RT(),u=r({"Content-Type":"application/x-www-form-urlencoded"},s&&{"Accept-Language":s}),c=FT({phone_number:i,token:o});return PT.post(a,c,{headers:u}).then((function(t){return Wd.parse(t.data)}))},OA="bank",CA={chargeDigitalBankMandate:function(t){var e=this,r=t.phoneNumber,n=t.payId,i=t.bankId,o={transactionId:this.id,phoneNumber:r,payId:n,bankId:i};return kA(o).then((function(t){return e.logAPIResponse(t,OA),t}))},listenForDigitalBankMandateCharge:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r={paymentMethod:OA,channel:e};return this.listenForCharge(r,t)}},PA=r(r(r({},{setBankAccount:function(t){var e=this;return AA(t,!0).then((function(){e.bankAccount=new bA(t)}))},chargeBankAccount:function(){var t=this;return AA(this.bankAccount).then((function(){t.logAttempt(EA);var e={bankId:t.bankAccount.bankId,transactionId:t.id,accountNumber:t.bankAccount.accountNumber,device:t.deviceFingerprint};return wA(e).then((function(e){return t.logAPIResponse(e,EA),e}))}))},registerBankAccount:function(t){var e=this;return AA(this.bankAccount).then((function(){var r={bankId:e.bankAccount.bankId,transactionId:e.id,accountNumber:e.bankAccount.accountNumber,birthday:t};return SA(r).then((function(t){return e.logAPIResponse(t,EA),t}))}))},authenticateBankAccount:function(t){var e=this;return AA(this.bankAccount).then((function(){var r={bankId:e.bankAccount.bankId,transactionId:e.id,token:t,device:e.deviceFingerprint};return TA(r).then((function(t){return e.logAPIResponse(t,EA),t}))}))}}),xA),CA),RA=function(t,e){var n=RT(),i=r({Authorization:"Bearer ".concat(e)},n&&{"Accept-Language":n});return PT.post("".concat(Dd.paystackApiUrl,"checkout/ussd/reference"),t,{headers:i}).then((function(t){return Wd.parse(t.data)}))},BA=function(t,e){var n=RT(),i=r({Authorization:"Bearer ".concat(e)},n&&{"Accept-Language":n});return PT.post("".concat(Dd.paystackApiUrl,"checkout/pay_with_transfer_ussd"),t,{headers:i}).then((function(t){return Wd.parse(t.data)}))},DA={getUSSDShortcode:function(t){var e=this,r=t.channel,n={transaction:this.id,channel:r};return RA(n,this.merchant.key).then((function(t){return"success"===t.status&&(e.ussd[r]=t),t}))},getPWTUSSDShortcode:function(t){var e=this,r=t.bankSlug,n=t.fulfilLateNotification,i=void 0!==n&&n,o={transaction_id:this.id,fulfil_late_notification:i,bank_slug:r};return BA(o,this.merchant.key).then((function(t){return"success"===t.status&&(e.ussd[r]=t),t}))},listenForPWTUSSDCharge:function(t,e){var r=t.bankSlug;if(!this.ussd[r])return Promise.reject(Error("Please generate a ussd shortcode with Transaction.getPWTUSSDShortcode()"));var n={channel:this.ussd[r].data.pusher_channel,paymentMethod:"ussd"};return this.listenForCharge(n,e)},listenForUSSDCharge:function(t,e){var r=t.channel;if(!this.ussd[r])return Promise.reject(Error("Please generate a ussd shortcode with Transaction.getUSSDShortcode()"));var n={channel:this.ussd[r].data.channel,paymentMethod:r};return this.listenForCharge(n,e)}},LA=function(t,e){var n={source:"checkout",reference:t.transaction,channel:t.channel},i=RT(),o=r({Authorization:"Bearer ".concat(e)},i&&{"Accept-Language":i});return PT.post("".concat(Dd.paystackApiUrl,"offline/qr/generate"),n,{headers:o}).then((function(t){return Wd.parse(t.data)}))};function IA(t){return new Promise((function(e,r){var n=["visa","MPASS_OLTI"];if(n.indexOf(t)<=-1){var i="Invalid channel. Available channels: ".concat(n.join(", "));r(Error(i))}else e()}))}var jA={getQRCode:function(t){var e=this,r=t.channel;return IA(r).then((function(){if(e.qr[r])return e.qr[r];var t={transaction:e.id,channel:r};return LA(t,e.merchant.key).then((function(t){return"success"===t.status&&(e.qr[r]=t),t}))}))},listenForQRCharge:function(t,e){var r=this,n=t.channel;return IA(n).then((function(){if(!r.qr[n])return Promise.reject(Error("Please generate qr code with Transaction.getQRCode()"));var t={channel:r.qr[n].data.channel,paymentMethod:n};return r.listenForCharge(t,e)}))}},NA=function(){function t(){a(this,t)}return u(t,null,[{key:"hasCountryCode",value:function(t){return t&&"+"===t[0]}},{key:"hasOnlyDigits",value:function(t){var e;return t&&(e=t.substring(1),/^\d+$/.test(e))}},{key:"isE164Number",value:function(t){return t&&t.length<17}},{key:"validate",value:function(e){var r=[];return t.hasCountryCode(e)||r.push("Number should include country code prefix"),t.hasOnlyDigits(e)||r.push("Number should contain only digits"),t.isE164Number(e)||r.push("Number should not be longer than 16 digits"),{isValid:0===r.length,errors:r}}}]),t}(),MA=function(t){var e={transaction:t.transaction,phone:t.phone,device:t.device,channel_name:t.channel_name,provider:t.provider,voucher:t.voucher,registration_token:t.registrationToken},n=RT(),i=r({},n&&{"Accept-Language":n});return PT.post("".concat(Dd.paystackApiUrl,"charge/mobile_money"),e,{headers:i}).then((function(t){return Wd.parse(t.data)})).catch((function(t){var e=t.response;return Wd.parse(e.data)}))},_A=function(t){var e=t.transaction,n=t.code,i=RT(),o=r({},i&&{"Accept-Language":i}),a=FT({transaction:e,otp:n}),s=new URL("charge/momo_payin_finalize",Dd.paymentBaseUrl).toString();return PT.post(s,a,{headers:o}).then((function(t){return Wd.parse(t.data)}))};function VA(t){return new Promise((function(e,r){var n=NA.validate(t);if(!n.isValid){var i=t?n.errors[0]:"Please start a mobile money transaction with Transaction.chargeMobileMoney()";r(Error(i))}e(n)}))}var UA={mobileMoneyChargeAPI:function(t){var e=this;return MA(t).then((function(t){return"success"===t.status&&(e.mobileMoney=t,t.data&&t.data.display&&1===t.data.display.otpSentCount&&e.logTokenRequest("mobile money")),t}))},chargeMobileMoney:function(t){var e=this,r=t.phoneNumber,n=t.provider,i=t.voucher,o=t.registrationToken;return VA(r).then((function(){e.logAttempt("mobile money");var t={provider:n,voucher:i,registrationToken:o,transaction:e.id,phone:r,device:e.deviceFingerprint,channel_name:"MOBILE_MONEY_".concat(e.id)};return e.mobileMoneyChargeAPI(t)}))},chargeMpesaOffline:function(t){var e=t.provider,r=t.voucher,n=t.registrationToken;this.logAttempt("mobile money");var i={provider:e,voucher:r,registrationToken:n,transaction:this.id,device:this.deviceFingerprint,channel_name:"MOBILE_MONEY_".concat(this.id)};return this.mobileMoneyChargeAPI(i)},authenticateMobileMoney:function(t){var e=this,r=t.phoneNumber,n=t.provider,i=t.registrationToken;return VA(r).then((function(){e.logMobileMoneyActions(t);var o={provider:n,registrationToken:i,transaction:e.id,phone:r,device:e.deviceFingerprint,channel_name:"MOBILE_MONEY_".concat(e.id)};return MA(o).then((function(t){return"success"===t.status?(e.mobileMoney=t,t.data&&t.data.display&&1===t.data.display.otpSentCount&&e.logTokenRequest("mobile money")):t.errors&&t.errors.data&&"awaiting_registration_token"===t.errors.data.status?e.logTokenAuthenticationFailure(t.message):e.logError(t.message),t}))}))},submitMobileMoneyCode:function(t){var e=this;return _A({code:t.code,transaction:this.id}).then((function(t){return e.logAPIResponse(t,"mobile_money"),t}))},listenForMobileMoneyCharge:function(t){if("success"!==this.mobileMoney.status)return Promise.reject(Error("Please start a mobile money charge with Transaction.chargeMobileMoney()"));var e=this.mobileMoney.data,r=e.channel,n=e.channel_name,i={channel:r||n,paymentMethod:"mobile_money"};return this.listenForCharge(i,t)}},FA=function(t){var e={email:t.email,password:t.password},n=RT(),i=r({},n&&{"Accept-Language":n});return PT.post("".concat(Dd.paystackApiUrl,"login"),e,{headers:i}).then((function(t){return Wd.parse(t.data)}))},qA=function(t){var e=t.account_code,n=t.transaction,i=t.token,o=RT(),a=r({Authorization:"Bearer ".concat(i),"jwt-auth":!0},o&&{"Accept-Language":o}),s={account_code:e,transaction:n};return PT.post("".concat(Dd.paystackApiUrl,"directdebit/initiate"),s,{headers:a}).then((function(t){return Wd.parse(t.data)}))},HA=function(t){var e=t.otp,n=t.transaction,i=t.token,o=RT(),a=r({Authorization:"Bearer ".concat(i),"jwt-auth":!0},o&&{"Accept-Language":o}),s={otp:e,transaction:n};return PT.post("".concat(Dd.paystackApiUrl,"directdebit/validate"),s,{headers:a}).then((function(t){return Wd.parse(t.data)}))},zA=function(t){var e=RT(),n=r({Authorization:"Bearer ".concat(t),"jwt-auth":!0},e&&{"Accept-Language":e});return PT.get("".concat(Dd.paystackApiUrl,"directdebit/account"),{headers:n}).then((function(t){return t.data}))},GA="direct debit",KA={loginToDirectDebitAccount:function(t){var e=this,r=t.email,n={email:r,password:t.password};return Mc(r)?FA(n).then((function(t){if("success"===t.status){var r=t.data,n=r.token,i=r.user.permissions;if(!i||i.length<1)throw Error("You do not have the privileges to perform this action");if(i.find((function(t){return"directdebit-*"===t})))return e.directDebit.token=n,t;throw Error("You do not have the privileges to perform this action")}return t})):Promise.reject(Error("Invalid email"))},chargeDirectDebit:function(t){var e=this;if(!this.directDebit.token)return Promise.reject(Error("Please login with Transaction.loginToDirectDebitAccount() to start a Direct debit charge"));this.logAttempt(GA);var r={account_code:t,transaction:this.id,token:this.directDebit.token};return qA(r).then((function(t){return e.logAPIResponse(t,GA),t.status&&(e.directDebit.chargeResponse=t),t}))},getProvisionedAccounts:function(){var t=this;return zA(this.directDebit.token).then((function(e){t.logAPIResponse(e,GA);var r=e.status,n=e.data;if(r){if(n&&n.length<1)return Promise.reject(Error("You have not provisioned any bank account for Direct Debit yet"));t.directDebit.accounts=e.data}return e}))},authenticateAccount:function(t){var e=this,r={otp:t,transaction:this.id,token:this.directDebit.token};return HA(r).then((function(t){return e.logAPIResponse(t,GA),t}))}},WA=function(t){return{card:yA,bank:PA,ussd:DA,qr:jA,mobile_money:UA,direct_debit:KA,bank_transfer:VT,eft:GT,payattitude:zT,apple_pay:YT,paypal:tE}[t]},XA=function(t){t||"undefined"==typeof navigator||(t=navigator.userAgent);t&&t.headers&&"string"==typeof t.headers["user-agent"]&&(t=t.headers["user-agent"]);return"string"==typeof t&&(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))};var YA=function(t){var e=t||{},r=e.attempts,n=e.authentication,i=e.errors,o=e.history;return{start_time:Math.round(Date.now()/1e3),time_spent:0,attempts:r||0,authentication:n,errors:i||0,success:!1,mobile:XA(),input:[],history:o||[]}},ZA=function(t){return Math.round(Date.now()/1e3)-t},JA=fi,$A=ft,QA=fa,tx=z,ex=k,rx=A.Array,nx=$A("JSON","stringify"),ix=tx(/./.exec),ox=tx("".charAt),ax=tx("".charCodeAt),sx=tx("".replace),ux=tx(1..toString),cx=/[\uD800-\uDFFF]/g,hx=/^[\uD800-\uDBFF]$/,lx=/^[\uDC00-\uDFFF]$/,fx=function(t,e,r){var n=ox(r,e-1),i=ox(r,e+1);return ix(hx,t)&&!ix(lx,i)||ix(lx,t)&&!ix(hx,n)?"\\u"+ux(ax(t,0),16):t},px=ex((function(){return'"\\udf06\\ud834"'!==nx("\udf06\ud834")||'"\\udead"'!==nx("\udead")}));nx&&JA({target:"JSON",stat:!0,forced:px},{stringify:function(t,e,r){for(var n=0,i=arguments.length,o=rx(i);n<i;n++)o[n]=arguments[n];var a=QA(nx,null,o);return"string"==typeof a?sx(a,cx,fx):a}});var dx=function(t,e){var n=e.merchantKey,i=e.log,o=RT(),a=r({Authorization:"Bearer ".concat(n)},o&&{"Accept-Language":o});return PT.post(t,{payload:JSON.stringify(i)},{headers:a}).then((function(t){return t.data}))},gx=function(t,e){var n=e.merchantKey,i=RT(),o=r({Authorization:"Bearer ".concat(n)},i&&{"Accept-Language":i});return PT.post(t,null,{headers:o}).then((function(t){return t.data}))},mx=function(t,e){var n=e.merchantKey,i=e.referrer,o=RT(),a=r({Authorization:"Bearer ".concat(n)},o&&{"Accept-Language":o});return PT.post(t,{referrer:i},{headers:a}).then((function(t){return t.data}))},vx=function(t,e,r){var n=new URL("transaction/update_log/".concat(t),Dd.paystackApiUrl).toString();return dx(n,{merchantKey:e,log:r})},yx=function(t,e){var r=new URL("transaction/set_ip/".concat(t),Dd.paystackApiUrl).toString();return gx(r,{merchantKey:e})},bx=function(t,e,r){var n=new URL("transaction/set_referrer/".concat(t),Dd.paystackApiUrl).toString();return mx(n,{merchantKey:e,referrer:r})},wx={initializeLog:function(t){this.log=YA(t)},getTimeSpent:function(){return this.log.time_spent=ZA(this.log.start_time),this.log.time_spent},logPageOpen:function(){return this.log.history.push({type:"open",message:"Opened checkout",time:this.getTimeSpent()}),this.saveLog()},logChannelSwitch:function(t){return this.log.history.push({type:"action",message:"Set payment method to: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logValidationErrors:function(t){var e=this;return t.forEach((function(t){e.log.history.push({type:"error",message:"Invalid ".concat(t),time:e.getTimeSpent()})})),this.saveLog()},logInput:function(t){var e=this.log.history.find((function(e){return e.message==="Filled this field: ".concat(t)}));return this.log.history.push({type:"input",message:"".concat(e?"Changed":"Filled"," this field: ").concat(t),time:this.getTimeSpent()}),this.saveLog()},logBankSelect:function(t){return this.log.history.push({type:"action",message:"Selected bank: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logSavedCardSelect:function(){return this.log.history.push({type:"action",message:"Selected saved card",time:this.getTimeSpent()}),this.saveLog()},logAuthWindowOpen:function(){return this.log.history.push({type:"action",message:"Third-party authentication window opened",time:this.getTimeSpent()}),this.saveLog()},logAuthWindowClose:function(){return this.log.history.push({type:"action",message:"Third-party authentication window closed",time:this.getTimeSpent()}),this.saveLog()},logAPIResponse:function(t,e){switch(t.status){case"success":return this.logSuccess(e);case"pending":return this.logPending(e);case"failed":return this.logError(t.message);case"auth":return this.logAuth(t.data.auth);default:return!1}},logMobileMoneyActions:function(t){var e=t.numberOfTokenRequests,r=t.registrationToken;e?this.logTokenRequest("mobile money",e):r?this.logTokenSubmitted("mobile money"):this.logAttempt("mobile money")},logAPIResponseMessage:function(t){return this.log.history.push({type:"action",message:t,time:this.getTimeSpent()}),this.saveLog()},logAttempt:function(t){var e="Attempted to pay";return t&&(e+=" with ".concat(t)),this.log.attempts+=1,this.log.history.push({type:"action",message:e,time:this.getTimeSpent()}),this.saveLog()},logTokenRequest:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=0===e?"Waiting for customer to submit OTP":"Customer requested to resend OTP";return this.log.history.push({type:"action",message:r,channel:t,time:this.getTimeSpent()}),this.saveLog()},logTokenSubmitted:function(t){return this.log.history.push({type:"action",message:"Customer submitted OTP",channel:t,time:this.getTimeSpent()}),this.saveLog()},logTokenAuthenticationFailure:function(t){var e=t?"Error: ".concat(t):"Error";return this.log.errors+=1,this.log.history.push({type:"error",message:e,authentication:"failed",time:this.getTimeSpent()}),this.saveLog()},logError:function(t){var e="Error";return t&&(e+=": ".concat(t)),this.log.errors+=1,this.log.history.push({type:"error",message:e,time:this.getTimeSpent()}),this.saveLog()},logAuth:function(t){return this.log.authentication=t,this.log.history.push({type:"auth",message:"Authentication Required: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logSuccess:function(t){var e="Successfully paid";return t&&(e+=" with ".concat(t)),this.log.success=!0,this.log.history.push({type:"success",message:e,time:this.getTimeSpent()}),this.saveLog()},logPending:function(t){var e="Payment in progress";return t&&(e+=" with ".concat(t)),this.log.history.push({type:"pending",message:e,time:this.getTimeSpent()}),this.saveLog()},logPageClose:function(){return this.log.history.push({type:"close",message:"Closed checkout",time:this.getTimeSpent()}),this.saveLog()},logTransactionCurrencySwitch:function(t){var e=t.currency,r=t.isUserAction,n=void 0===r||r?"User switched":"Switched";return this.log.history.push({type:"action",message:"".concat(n," transaction currency to ").concat(e),time:this.getTimeSpent()}),this.saveLog()},saveLog:function(){return vx(this.id,this.merchant.key,this.log)},saveIpAddress:function(){return yx(this.id,this.merchant.key)},saveReferrer:function(t){return bx(this.id,this.merchant.key,t)}},Sx=function(){function t(e){var r=this;a(this,t),this.email=e.email,this.merchant={id:e.merchant_id,logo:e.merchant_logo,name:e.merchant_name,key:e.merchant_key,channelSettings:e.merchant_channel_settings||{}},this.status=e.transaction_status||e.status,this.accessCode=e.access_code,this.amount=e.amount,this.domain=e.domain,this.isTest="test"===e.domain,this.currency=e.currency,this.id=e.id,this.channels=e.channels,this.label=e.label,this.metadata=e.metadata||{},this.cancel_action=e.cancel_action||null,this.channel_options=e.channel_options||null,this.hash=e.hash||null,this.authorizations=e.authorizations,this.remember_card=!1,this.rememberMeEnabled=e.is_remember_me_enabled,this.card={},this.bankAccount={},this.mobileMoney={},this.ussd={},this.bankTransfer={},this.qr={},this.directDebit={},this.deviceFingerprint=e.deviceFingerprint||null,this.customer=e.customer,this.custom_filters=e.custom_filters||null,this.isCharging=!1,this.isListening=!1,this.transactionType=e.transaction_type||null,this.subscription=e.subscription||null,this.planDetails=e.plan_details||null,this.exchangeRate=e.exchange_rate||null,this.savedCardsConfig=e.saved_cards||{},this.savedCardsTempAuthToken=null,this.savedCardsToken=null,this.reference=e.reference,Xd(),this.log=null,Object.assign(this,wx),this.initializeLog(e.log),this.saveIpAddress(),this.channels.forEach((function(t){var e=WA(t);Object.assign(r,e)})),"GHS"===e.currency&&e.elevy_percentage&&(this.elevyPercentage=e.elevy_percentage)}return u(t,[{key:"setMetadata",value:function(t,e){this.metadata[t]=e}},{key:"setDevice",value:function(t){this.deviceFingerprint?ld("Device ID has already been set by Checkout JS so there's no need to set this again"):this.deviceFingerprint=t}},{key:"listenForCharge",value:function(t,e){return Yd(t,this,e)}},{key:"requery",value:function(){return jT(this.id)}},{key:"markAsAbandoned",value:function(){return NT({publicKey:this.merchant.key,transactionId:this.id})}},{key:"verifyStatus",value:function(){return MT({reference:this.reference,publicKey:this.merchant.key}).then((function(t){return t&&t.data}))}}]),t}(),Tx={validate:function(t){var e=function(t){var e=[];return t&&"object"===n(t)?(Object.keys(Uc).forEach((function(r){var n=Uc[r],i=t[r];!n.required||i||t[n.fallback]?i&&!n.isValid(i)&&e.push({field:r,message:"Invalid field: ".concat(r)}):e.push({field:r,message:"Required field: ".concat(r)})})),e):(e.push({message:"Please supply a valid object"}),e)}(t);if(e.length){var r=y(e,1)[0].message;throw new rs(e,r)}},request:function(t){return o(regeneratorRuntime.mark((function e(){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,pd();case 2:return n=e.sent,e.next=5,BT(r(r({},t),{device:n}));case 5:return i=e.sent,e.abrupt("return",i&&Object.seal(new Sx(r(r({},i.data),{deviceFingerprint:n}))));case 7:case"end":return e.stop()}}),e)})))()},requestWithAccessCode:function(t){return o(regeneratorRuntime.mark((function e(){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,pd();case 2:return n=e.sent,e.next=5,DT(t);case 5:return i=e.sent,e.abrupt("return",i&&Object.seal(new Sx(r(r({},i.data),{deviceFingerprint:n}))));case 7:case"end":return e.stop()}}),e)})))()},getByAccessCode:function(t,e){return o(regeneratorRuntime.mark((function n(){var i,o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,pd();case 2:return i=n.sent,n.next=5,LT(t,e);case 5:return o=n.sent,n.abrupt("return",o&&Object.seal(new Sx(r(r({},o.data),{deviceFingerprint:i}))));case 7:case"end":return n.stop()}}),n)})))()},initialize:function(t){return Object.seal(new Sx(t))},verify:function(t){return o(regeneratorRuntime.mark((function e(){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,IT(t);case 2:return r=e.sent,e.abrupt("return",r&&r.data);case 4:case"end":return e.stop()}}),e)})))()}},Ex={},Ax=function(t){var e=new URL("/bank",Dd.paystackApiUrl).toString(),n=RT(),i={params:t,headers:r({},n&&{"Accept-Language":n})};return PT.get(e,i).then((function(t){return t.data}))},xx=function(){var t=new URL("/checkout/resolutions",Dd.paystackApiUrl).toString(),e=RT(),n=r({},e&&{"Accept-Language":e});return PT.get(t,{headers:n}).then((function(t){return t.data}))},kx=function(){var t=new URL("/checkout/celebrations",Dd.paystackApiUrl).toString(),e=RT(),n=r({},e&&{"Accept-Language":e});return PT.get(t,{headers:n}).then((function(t){return t.data}))},Ox=function(t){var e=new URL("/address_verification/states",Dd.paystackApiUrl).toString(),n=RT(),i={params:t,headers:r({},n&&{"Accept-Language":n})};return PT.get(e,i).then((function(t){return t.data}))},Cx=function(t){var e=new URL("/decision/bin/".concat(t),Dd.paystackApiUrl).toString(),n=RT(),i=r({},n&&{"Accept-Language":n});return Ex[t]?Promise.resolve(Ex[t]):PT.get(e,{headers:i}).then((function(e){var r=e.data;return Ex[t]=r,r}))},Px=function(){function t(){a(this,t)}return u(t,null,[{key:"contents",value:function(){return[{key:"banks",usage:"Returns a list of banks that can be used to complete checkout"},{key:"resolutions",usage:"Returns a list of known errors, mapped to their suggested resolutions"},{key:"celebrations",usage:"Returns a list of upcoming celebrations"},{key:"states",usage:"Returns a list of states for a particular country"}]}},{key:"fetch",value:function(t,e){var r;if(this.contents().map((function(t){return t.key})).indexOf(t)<=-1)throw new Error("Please provide a valid config key. Use Toolkit.contents() to see available options.");switch(t){case"banks":r=Ax(e||{pay_with_bank:"1"});break;case"resolutions":r=xx();break;case"celebrations":r=kx();break;case"states":r=Ox(e)}return r}},{key:"resolveCardBin",value:function(t){return Cx(t)}}]),t}(),Rx=function(){function t(e){var r=e.number,n=e.cvv,i=e.month,o=e.year,s=e.pin;a(this,t),this.number=r,this.cvv=n,this.month=i,this.year=o,this.pin=s}return u(t,[{key:"getEncryptedPin",value:function(){return eA.getEncryptedPin(this.pin)}},{key:"getLast4",value:function(){return eA.getLast4(this.number)}},{key:"tokenize",value:function(){return eA.tokenize({number:this.number,cvv:this.cvv,month:this.month,year:this.year})}}],[{key:"getType",value:function(t){return eA.getType(t)}},{key:"validate",value:function(t){var e=t.number,r=t.cvv,n=t.month,i=t.year;return eA.validate({number:e,cvv:r,month:n,year:i})}},{key:"validateNumber",value:function(t){return eA.validateNumber(t)}},{key:"isNumberValid",value:function(t){return eA.isNumberValid(t)}},{key:"validateCVV",value:function(t,e){return eA.validateCVV(t,e)}},{key:"isCvvValid",value:function(t,e){return eA.isCvvValid(t,e)}},{key:"validateExpiry",value:function(t){return eA.validateExpiry(t)}},{key:"isExpiryValid",value:function(t){return eA.isExpiryValid(t)}},{key:"generateTestCard",value:function(e){return new t(eA.findTestCard(e))}}]),t}(),Bx=function(t){var e=t.clientdata,n=t.last4,i=t.preauthorizationId,o=t.publicKey,a=new URL("preauthorization/create",Dd.paystackApiUrl).toString(),s=RT(),u=r({Authorization:"Bearer ".concat(o)},s&&{"Accept-Language":s});return PT.post(a,{clientdata:e,last4:n,preauthorization:i},{headers:u}).then((function(t){return Wd.parse(t.data)}))},Dx="card";function Lx(t,e){return new Promise((function(r,n){var i=Rx.validate(t);if(!i.isValid){var o=e||t.number,a=Object.keys(i.result).filter((function(t){return!1===i.result[t]})),s="Invalid card details: ".concat(a.join(", "));n(Error(o?s:"Please set a valid card with setCard()"))}r()}))}var Ix={setCard:function(t){var e=this;return Lx(t,!0).then((function(){e.card=new Rx(t)}))},reserveFunds:function(t){var e=this,r=t.preauthorizationId,n=t.publicKey,i=t.customFields,o=void 0===i?{}:i;return Lx(this.card).then((function(){e.logAttempt(Dx);var t={clientdata:e.card.tokenize(),last4:e.card.getLast4(),device:e.deviceFingerprint,preauthorizationId:r,publicKey:n,customFields:o};return Bx(t).then((function(t){return e.logAPIResponse(t,Dx),t}))}))},listenFor3DSCharge:function(t){var e={channel:"3DS_".concat(this.id),paymentMethod:Dx};return this.listenForCharge(e,t)}},jx=function(t){var e=RT(),n=r({},e&&{"Accept-Language":e}),i=new URL("preauthorization/verify_access_code/".concat(t),Dd.paystackApiUrl).toString();return PT.get(i,{headers:n}).then((function(t){return t.data}))},Nx=function(t){var e=t.reference,n=t.publicKey,i=RT(),o=r({Authorization:"Bearer ".concat(n)},i&&{"Accept-Language":i}),a=new URL("preauthorization/verify/".concat(e),Dd.paystackApiUrl).toString();return PT.get(a,{headers:o}).then((function(t){return Wd.parse(t.data)}))},Mx=function(t,e,r){var n=new URL("preauthorization/update_log/".concat(t),Dd.paystackApiUrl).toString();return dx(n,{merchantKey:e,log:r})},_x=function(t,e){var r=new URL("preauthorization/set_ip/".concat(t),Dd.paystackApiUrl).toString();return gx(r,{merchantKey:e})},Vx={initializeLog:function(t){this.log=YA(t)},getTimeSpent:function(){return this.log.time_spent=ZA(this.log.start_time),this.log.time_spent},logPageOpen:function(){return this.log.history.push({type:"open",message:"Opened checkout",time:this.getTimeSpent()}),this.saveLog()},logChannelSwitch:function(t){return this.log.history.push({type:"action",message:"Set charge method to: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logValidationErrors:function(t){var e=this;return t.forEach((function(t){e.log.history.push({type:"error",message:"Invalid ".concat(t),time:e.getTimeSpent()})})),this.saveLog()},logInput:function(t){var e=this.log.history.find((function(e){return e.message==="Filled this field: ".concat(t)}));return this.log.history.push({type:"input",message:"".concat(e?"Changed":"Filled"," this field: ").concat(t),time:this.getTimeSpent()}),this.saveLog()},logAuthWindowOpen:function(){return this.log.history.push({type:"action",message:"Third-party authentication window opened",time:this.getTimeSpent()}),this.saveLog()},logAuthWindowClose:function(){return this.log.history.push({type:"action",message:"Third-party authentication window closed",time:this.getTimeSpent()}),this.saveLog()},logAPIResponse:function(t,e){switch(t.status){case"success":return this.logSuccess(e);case"failed":return this.logError(t.message);case"auth":return this.logAuth(t.data.auth);default:return!1}},logAPIResponseMessage:function(t){return this.log.history.push({type:"action",message:t,time:this.getTimeSpent()}),this.saveLog()},logAttempt:function(t){var e="Attempted to charge";return t&&(e+=" with ".concat(t)),this.log.attempts+=1,this.log.history.push({type:"action",message:e,time:this.getTimeSpent()}),this.saveLog()},logAuth:function(t){return this.log.authentication=t,this.log.history.push({type:"auth",message:"Authentication Required: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logSuccess:function(t){var e="Successfully preauthorised funds";return t&&(e+=" with ".concat(t)),this.log.success=!0,this.log.history.push({type:"success",message:e,time:this.getTimeSpent()}),this.saveLog()},logPageClose:function(){return this.log.history.push({type:"close",message:"Closed checkout",time:this.getTimeSpent()}),this.saveLog()},logError:function(t){var e="Error";return t&&(e+=": ".concat(t)),this.log.errors+=1,this.log.history.push({type:"error",message:e,time:this.getTimeSpent()}),this.saveLog()},saveLog:function(){return Mx(this.id,this.merchant.key,this.log)},saveIpAddress:function(){return _x(this.id,this.merchant.key)}},Ux=function(){function t(e){a(this,t),this.id=e.id,this.email=e.email,this.status=e.status,this.reference=e.reference,this.amount=e.amount,this.currency=e.currency,this.metadata=e.metadata||{},this.customer=e.customer,this.channels=e.channels||["card"],this.isListening=!1,this.isTest="test"===e.domain,this.deviceFingerprint=e.deviceFingerprint||null,this.merchant={id:e.merchant_id,logo:e.merchant_logo,name:e.merchant_name,key:e.merchant_key},this.card={},Xd(),this.log=null,Object.assign(this,Vx),this.initializeLog(e.log),this.saveIpAddress(),Object.assign(this,Ix)}return u(t,[{key:"setMetadata",value:function(t,e){this.metadata[t]=e}},{key:"requery",value:function(){return Nx({reference:this.reference,publicKey:this.merchant.key})}},{key:"listenForCharge",value:function(t,e){return Yd(t,this,e)}}]),t}(),Fx={initialize:function(t){return Object.seal(new Ux(t))},getByAccessCode:function(t){return o(regeneratorRuntime.mark((function e(){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,pd();case 2:return n=e.sent,e.next=5,jx(t);case 5:return i=e.sent,e.abrupt("return",i&&Object.seal(new Ux(r(r({},i.data),{},{deviceFingerprint:n}))));case 7:case"end":return e.stop()}}),e)})))()}};return t.BankAccount=bA,t.Card=rA,t.Preauthorization=Fx,t.Toolkit=Px,t.Transaction=Tx,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
30
+ var pt={};void 0!==pt.asn1&&pt.asn1||(pt.asn1={}),pt.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var n="",i=0;i<r;i++)n+="f";e=new B(n,16).xor(t).add(B.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=pt.asn1,r=e.DERBoolean,n=e.DERInteger,i=e.DERBitString,o=e.DEROctetString,a=e.DERNull,s=e.DERObjectIdentifier,u=e.DEREnumerated,c=e.DERUTF8String,h=e.DERNumericString,l=e.DERPrintableString,f=e.DERTeletexString,p=e.DERIA5String,d=e.DERUTCTime,g=e.DERGeneralizedTime,m=e.DERSequence,v=e.DERSet,y=e.DERTaggedObject,b=e.ASN1Util.newObject,w=Object.keys(t);if(1!=w.length)throw"key of param shall be only one.";var S=w[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+S+":"))throw"undefined key: "+S;if("bool"==S)return new r(t[S]);if("int"==S)return new n(t[S]);if("bitstr"==S)return new i(t[S]);if("octstr"==S)return new o(t[S]);if("null"==S)return new a(t[S]);if("oid"==S)return new s(t[S]);if("enum"==S)return new u(t[S]);if("utf8str"==S)return new c(t[S]);if("numstr"==S)return new h(t[S]);if("prnstr"==S)return new l(t[S]);if("telstr"==S)return new f(t[S]);if("ia5str"==S)return new p(t[S]);if("utctime"==S)return new d(t[S]);if("gentime"==S)return new g(t[S]);if("seq"==S){for(var T=t[S],E=[],A=0;A<T.length;A++){var x=b(T[A]);E.push(x)}return new m({array:E})}if("set"==S){for(T=t[S],E=[],A=0;A<T.length;A++)x=b(T[A]),E.push(x);return new v({array:E})}if("tag"==S){var k=t[S];if("[object Array]"===Object.prototype.toString.call(k)&&3==k.length){var O=b(k[2]);return new y({tag:k[0],explicit:k[1],obj:O})}var C={};if(void 0!==k.explicit&&(C.explicit=k.explicit),void 0!==k.tag&&(C.tag=k.tag),void 0===k.obj)throw"obj shall be specified for 'tag'.";return C.obj=b(k.obj),new y(C)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},pt.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),n=(e=Math.floor(r/40)+"."+r%40,""),i=2;i<t.length;i+=2){var o=("00000000"+parseInt(t.substr(i,2),16).toString(2)).slice(-8);n+=o.substr(1,7),"0"==o.substr(0,1)&&(e=e+"."+new B(n,2).toString(10),n="")}return e},pt.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=new B(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var o="",a=0;a<i;a++)o+="0";for(n=o+n,a=0;a<n.length-1;a+=7){var s=n.substr(a,7);a!=n.length-7&&(s="1"+s),r+=e(parseInt(s,2))}return r};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var n="",i=t.split("."),o=40*parseInt(i[0])+parseInt(i[1]);n+=e(o),i.splice(0,2);for(var a=0;a<i.length;a++)n+=r(i[a]);return n},pt.asn1.ASN1Object=function(){var t="";this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+t.length+",v="+this.hV;var e=this.hV.length/2,r=e.toString(16);if(r.length%2==1&&(r="0"+r),e<128)return r;var n=r.length/2;if(n>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);return(128+n).toString(16)+r},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},pt.asn1.DERAbstractString=function(t){pt.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},ft.lang.extend(pt.asn1.DERAbstractString,pt.asn1.ASN1Object),pt.asn1.DERAbstractTime=function(t){pt.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,r){var n=this.zeroPadding,i=this.localDateToUTC(t),o=String(i.getFullYear());"utc"==e&&(o=o.substr(2,2));var a=o+n(String(i.getMonth()+1),2)+n(String(i.getDate()),2)+n(String(i.getHours()),2)+n(String(i.getMinutes()),2)+n(String(i.getSeconds()),2);if(!0===r){var s=i.getMilliseconds();if(0!=s){var u=n(String(s),3);a=a+"."+(u=u.replace(/[0]+$/,""))}}return a+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(t)},this.setByDateValue=function(t,e,r,n,i,o){var a=new Date(Date.UTC(t,e-1,r,n,i,o,0));this.setByDate(a)},this.getFreshValueHex=function(){return this.hV}},ft.lang.extend(pt.asn1.DERAbstractTime,pt.asn1.ASN1Object),pt.asn1.DERAbstractStructured=function(t){pt.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},ft.lang.extend(pt.asn1.DERAbstractStructured,pt.asn1.ASN1Object),pt.asn1.DERBoolean=function(){pt.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},ft.lang.extend(pt.asn1.DERBoolean,pt.asn1.ASN1Object),pt.asn1.DERInteger=function(t){pt.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=pt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new B(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},ft.lang.extend(pt.asn1.DERInteger,pt.asn1.ASN1Object),pt.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=pt.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}pt.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var r="0"+t;this.hTLV=null,this.isModified=!0,this.hV=r+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var r=0;r<=e;r++)t+="0";var n="";for(r=0;r<t.length-1;r+=8){var i=t.substr(r,8),o=parseInt(i,2).toString(16);1==o.length&&(o="0"+o),n+=o}this.hTLV=null,this.isModified=!0,this.hV="0"+e+n},this.setByBooleanArray=function(t){for(var e="",r=0;r<t.length;r++)1==t[r]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},ft.lang.extend(pt.asn1.DERBitString,pt.asn1.ASN1Object),pt.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=pt.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}pt.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},ft.lang.extend(pt.asn1.DEROctetString,pt.asn1.DERAbstractString),pt.asn1.DERNull=function(){pt.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},ft.lang.extend(pt.asn1.DERNull,pt.asn1.ASN1Object),pt.asn1.DERObjectIdentifier=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=new B(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var o="",a=0;a<i;a++)o+="0";for(n=o+n,a=0;a<n.length-1;a+=7){var s=n.substr(a,7);a!=n.length-7&&(s="1"+s),r+=e(parseInt(s,2))}return r};pt.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var n="",i=t.split("."),o=40*parseInt(i[0])+parseInt(i[1]);n+=e(o),i.splice(0,2);for(var a=0;a<i.length;a++)n+=r(i[a]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=n},this.setValueName=function(t){var e=pt.asn1.x509.OID.name2oid(t);if(""===e)throw"DERObjectIdentifier oidName undefined: "+t;this.setValueOidString(e)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t):void 0!==t.oid?this.setValueOidString(t.oid):void 0!==t.hex?this.setValueHex(t.hex):void 0!==t.name&&this.setValueName(t.name))},ft.lang.extend(pt.asn1.DERObjectIdentifier,pt.asn1.ASN1Object),pt.asn1.DEREnumerated=function(t){pt.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=pt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new B(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},ft.lang.extend(pt.asn1.DEREnumerated,pt.asn1.ASN1Object),pt.asn1.DERUTF8String=function(t){pt.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},ft.lang.extend(pt.asn1.DERUTF8String,pt.asn1.DERAbstractString),pt.asn1.DERNumericString=function(t){pt.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},ft.lang.extend(pt.asn1.DERNumericString,pt.asn1.DERAbstractString),pt.asn1.DERPrintableString=function(t){pt.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},ft.lang.extend(pt.asn1.DERPrintableString,pt.asn1.DERAbstractString),pt.asn1.DERTeletexString=function(t){pt.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},ft.lang.extend(pt.asn1.DERTeletexString,pt.asn1.DERAbstractString),pt.asn1.DERIA5String=function(t){pt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},ft.lang.extend(pt.asn1.DERIA5String,pt.asn1.DERAbstractString),pt.asn1.DERUTCTime=function(t){pt.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{12}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date))},ft.lang.extend(pt.asn1.DERUTCTime,pt.asn1.DERAbstractTime),pt.asn1.DERGeneralizedTime=function(t){pt.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.withMillis=!1,this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{14}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date),!0===t.millis&&(this.withMillis=!0))},ft.lang.extend(pt.asn1.DERGeneralizedTime,pt.asn1.DERAbstractTime),pt.asn1.DERSequence=function(t){pt.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++)t+=this.asn1Array[e].getEncodedHex();return this.hV=t,this.hV}},ft.lang.extend(pt.asn1.DERSequence,pt.asn1.DERAbstractStructured),pt.asn1.DERSet=function(t){pt.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var r=this.asn1Array[e];t.push(r.getEncodedHex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},ft.lang.extend(pt.asn1.DERSet,pt.asn1.DERAbstractStructured),pt.asn1.DERTaggedObject=function(t){pt.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,r){this.hT=e,this.isExplicit=t,this.asn1Object=r,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=r.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.tag&&(this.hT=t.tag),void 0!==t.explicit&&(this.isExplicit=t.explicit),void 0!==t.obj&&(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},ft.lang.extend(pt.asn1.DERTaggedObject,pt.asn1.ASN1Object);var dt=function(t){function e(r){var n=t.call(this)||this;return r&&("string"==typeof r?n.parseKey(r):(e.hasPrivateKeyProperty(r)||e.hasPublicKeyProperty(r))&&n.parsePropertiesFrom(r)),n}return g(e,t),e.prototype.parseKey=function(t){try{var e=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?v.decode(t):y.unarmor(t),i=O.decode(n);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){e=i.sub[1].getHexStringValue(),this.n=M(e,16),r=i.sub[2].getHexStringValue(),this.e=parseInt(r,16);var o=i.sub[3].getHexStringValue();this.d=M(o,16);var a=i.sub[4].getHexStringValue();this.p=M(a,16);var s=i.sub[5].getHexStringValue();this.q=M(s,16);var u=i.sub[6].getHexStringValue();this.dmp1=M(u,16);var c=i.sub[7].getHexStringValue();this.dmq1=M(c,16);var h=i.sub[8].getHexStringValue();this.coeff=M(h,16)}else{if(2!==i.sub.length)return!1;var l=i.sub[1].sub[0];e=l.sub[0].getHexStringValue(),this.n=M(e,16),r=l.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}},e.prototype.getPrivateBaseKey=function(){var t={array:[new pt.asn1.DERInteger({int:0}),new pt.asn1.DERInteger({bigint:this.n}),new pt.asn1.DERInteger({int:this.e}),new pt.asn1.DERInteger({bigint:this.d}),new pt.asn1.DERInteger({bigint:this.p}),new pt.asn1.DERInteger({bigint:this.q}),new pt.asn1.DERInteger({bigint:this.dmp1}),new pt.asn1.DERInteger({bigint:this.dmq1}),new pt.asn1.DERInteger({bigint:this.coeff})]};return new pt.asn1.DERSequence(t).getEncodedHex()},e.prototype.getPrivateBaseKeyB64=function(){return l(this.getPrivateBaseKey())},e.prototype.getPublicBaseKey=function(){var t=new pt.asn1.DERSequence({array:[new pt.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new pt.asn1.DERNull]}),e=new pt.asn1.DERSequence({array:[new pt.asn1.DERInteger({bigint:this.n}),new pt.asn1.DERInteger({int:this.e})]}),r=new pt.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new pt.asn1.DERSequence({array:[t,r]}).getEncodedHex()},e.prototype.getPublicBaseKeyB64=function(){return l(this.getPublicBaseKey())},e.wordwrap=function(t,e){if(!t)return t;var r="(.{1,"+(e=e||64)+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(r,"g")).join("\n")},e.prototype.getPrivateKey=function(){var t="-----BEGIN RSA PRIVATE KEY-----\n";return t+=e.wordwrap(this.getPrivateBaseKeyB64())+"\n",t+="-----END RSA PRIVATE KEY-----"},e.prototype.getPublicKey=function(){var t="-----BEGIN PUBLIC KEY-----\n";return t+=e.wordwrap(this.getPublicBaseKeyB64())+"\n",t+="-----END PUBLIC KEY-----"},e.hasPublicKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")},e.hasPrivateKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},e.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)},e}(st),gt=function(){function t(t){t=t||{},this.default_key_size=parseInt(t.default_key_size,10)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null}return t.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new dt(t)},t.prototype.setPrivateKey=function(t){this.setKey(t)},t.prototype.setPublicKey=function(t){this.setKey(t)},t.prototype.decrypt=function(t){try{return this.getKey().decrypt(f(t))}catch(t){return!1}},t.prototype.encrypt=function(t){try{return l(this.getKey().encrypt(t))}catch(t){return!1}},t.prototype.sign=function(t,e,r){try{return l(this.getKey().sign(t,e,r))}catch(t){return!1}},t.prototype.verify=function(t,e,r){try{return this.getKey().verify(t,f(e),r)}catch(t){return!1}},t.prototype.getKey=function(t){if(!this.key){if(this.key=new dt,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},t.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},t.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},t.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},t.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},t.version="3.0.0-rc.1",t}();window.JSEncrypt=gt,t.JSEncrypt=gt,t.default=gt,Object.defineProperty(t,"__esModule",{value:!0})}(e)}(0,eE.exports);var nE=O,iE=z,oE=Ms,aE=ot,sE=iE(D.f),uE=iE([].push),cE=function(t){return function(e){for(var r,n=aE(e),i=oE(n),o=i.length,a=0,s=[];o>a;)r=i[a++],nE&&!sE(n,r)||uE(s,t?[r,n[r]]:n[r]);return s}},hE={entries:cE(!0),values:cE(!1)}.values;fi({target:"Object",stat:!0},{values:function(t){return hE(t)}});var lE=fi,fE=Es.find,pE=_d,dE="find",gE=!0;dE in[]&&Array(1).find((function(){gE=!1})),lE({target:"Array",proto:!0,forced:gE},{find:function(t){return fE(this,t,arguments.length>1?arguments[1]:void 0)}}),pE(dE);var mE=function(t){for(var e,r=0,n=!1,i=t.length-1;i>=0;)e=parseInt(t.charAt(i),10),n&&(e*=2)>9&&(e=e%10+1),n=!n,r+=e,i--;return r%10==0};var vE=function(t){return t?JSON.parse(JSON.stringify(t)):null};var yE=function(t){return"string"==typeof t||t instanceof String};var bE=function(t,e){return Array.isArray(e)?function(t,e,r){var n=String(e).length,i=t.substr(0,n),o=parseInt(i,10);return e=parseInt(String(e).substr(0,i.length),10),r=parseInt(String(r).substr(0,i.length),10),o>=e&&o<=r}(t,e[0],e[1]):function(t,e){return(e=String(e)).substring(0,t.length)===t.substring(0,e.length)}(t,e)},wE=vE,SE=bE;var TE,EE=function(t,e,r){var n,i,o,a;for(n=0;n<e.patterns.length;n++)if(i=e.patterns[n],SE(t,i)){a=wE(e),o=Array.isArray(i)?String(i[0]).length:String(i).length,t.length>=o&&(a.matchStrength=o),r.push(a);break}},AE={visa:{niceType:"Visa",type:"visa",patterns:[4],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}},mastercard:{niceType:"Mastercard",type:"mastercard",patterns:[[51,55],[2221,2229],[223,229],[23,26],[270,271],2720],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},"american-express":{niceType:"American Express",type:"american-express",patterns:[34,37],gaps:[4,10],lengths:[15],code:{name:"CID",size:4}},"diners-club":{niceType:"Diners Club",type:"diners-club",patterns:[[300,305],36,38,39],gaps:[4,10],lengths:[14,16,19],code:{name:"CVV",size:3}},discover:{niceType:"Discover",type:"discover",patterns:[6011,[644,649],65],gaps:[4,8,12],lengths:[16,19],code:{name:"CID",size:3}},jcb:{niceType:"JCB",type:"jcb",patterns:[2131,1800,[3528,3589]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVV",size:3}},unionpay:{niceType:"UnionPay",type:"unionpay",patterns:[620,[624,626],[62100,62182],[62184,62187],[62185,62197],[62200,62205],[622010,622999],622018,[622019,622999],[62207,62209],[622126,622925],[623,626],6270,6272,6276,[627700,627779],[627781,627799],[6282,6289],6291,6292],gaps:[4,8,12],lengths:[14,15,16,17,18,19],code:{name:"CVN",size:3}},maestro:{niceType:"Maestro",type:"maestro",patterns:[493698,[5e5,506698],[506779,508999],[56,59],63,67,6],gaps:[4,8,12],lengths:[12,13,14,15,16,17,18,19],code:{name:"CVC",size:3}},elo:{niceType:"Elo",type:"elo",patterns:[401178,401179,438935,457631,457632,431274,451416,457393,504175,[506699,506778],[509e3,509999],627780,636297,636368,[650031,650033],[650035,650051],[650405,650439],[650485,650538],[650541,650598],[650700,650718],[650720,650727],[650901,650978],[651652,651679],[655e3,655019],[655021,655058]],gaps:[4,8,12],lengths:[16],code:{name:"CVE",size:3}},mir:{niceType:"Mir",type:"mir",patterns:[[2200,2204]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVP2",size:3}},hiper:{niceType:"Hiper",type:"hiper",patterns:[637095,637568,637599,637609,637612],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},hipercard:{niceType:"Hipercard",type:"hipercard",patterns:[606282],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}}},xE=vE,kE=function(t){if(function(t){var e=t.filter((function(t){return t.matchStrength})).length;return e>0&&e===t.length}(t))return t.reduce((function(t,e){return t?t.matchStrength<e.matchStrength?e:t:e}))},OE=yE,CE=EE,PE={},RE={VISA:"visa",MASTERCARD:"mastercard",AMERICAN_EXPRESS:"american-express",DINERS_CLUB:"diners-club",DISCOVER:"discover",JCB:"jcb",UNIONPAY:"unionpay",MAESTRO:"maestro",ELO:"elo",MIR:"mir",HIPER:"hiper",HIPERCARD:"hipercard"},BE=[RE.VISA,RE.MASTERCARD,RE.AMERICAN_EXPRESS,RE.DINERS_CLUB,RE.DISCOVER,RE.JCB,RE.UNIONPAY,RE.MAESTRO,RE.ELO,RE.MIR,RE.HIPER,RE.HIPERCARD];function DE(t){return PE[t]||AE[t]}function LE(t,e){var r=TE.indexOf(t);if(!e&&-1===r)throw new Error('"'+t+'" is not a supported card type.');return r}function IE(t){var e,r=[];return OE(t)?0===t.length?TE.map((function(t){return xE(DE(t))})):(TE.forEach((function(e){var n=DE(e);CE(t,n,r)})),(e=kE(r))?[e]:r):[]}TE=xE(BE),IE.getTypeInfo=function(t){return xE(DE(t))},IE.removeCard=function(t){var e=LE(t);TE.splice(e,1)},IE.addCard=function(t){var e=LE(t.type,!0);PE[t.type]=t,-1===e&&TE.push(t.type)},IE.updateCard=function(t,e){var r,n=PE[t]||AE[t];if(!n)throw new Error('"'+t+'" is not a recognized type. Use `addCard` instead.');if(e.type&&n.type!==e.type)throw new Error("Cannot overwrite type parameter.");r=xE(n),Object.keys(r).forEach((function(t){e[t]&&(r[t]=e[t])})),PE[r.type]=r},IE.changeOrder=function(t,e){var r=LE(t);TE.splice(r,1),TE.splice(e,0,t)},IE.resetModifications=function(){TE=xE(BE),PE={}},IE.types=RE;var jE=IE,NE=mE,ME=jE;function _E(t,e,r){return{card:t,isPotentiallyValid:e,isValid:r}}var VE=function(t,e){var r,n,i,o,a;if(e=e||{},"number"==typeof t&&(t=String(t)),"string"!=typeof t)return _E(null,!1,!1);if(t=t.replace(/\-|\s/g,""),!/^\d*$/.test(t))return _E(null,!1,!1);if(0===(r=ME(t)).length)return _E(null,!1,!1);if(1!==r.length)return _E(null,!0,!1);if(n=r[0],e.maxLength&&t.length>e.maxLength)return _E(n,!1,!1);for(i=n.type===ME.types.UNIONPAY&&!0!==e.luhnValidateUnionPay||NE(t),a=Math.max.apply(null,n.lengths),e.maxLength&&(a=Math.min(e.maxLength,a)),o=0;o<n.lengths.length;o++)if(n.lengths[o]===t.length)return _E(n,t.length<a||i,i);return _E(n,t.length<a,!1)};function UE(t,e,r){return{isValid:t,isPotentiallyValid:e,isCurrentYear:r||!1}}var FE=function(t,e){var r,n,i,o,a;return e=e||19,"string"!=typeof t?UE(!1,!1):""===t.replace(/\s/g,"")?UE(!1,!0):/^\d*$/.test(t)?(n=t.length)<2?UE(!1,!0):(r=(new Date).getFullYear(),3===n?UE(!1,t.slice(0,2)===String(r).slice(0,2)):n>4?UE(!1,!1):(t=parseInt(t,10),i=Number(String(r).substr(2,2)),2===n?(a=i===t,o=t>=i&&t<=i+e):4===n&&(a=r===t,o=t>=r&&t<=r+e),UE(o,o,a))):UE(!1,!1)},qE=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},HE=FE,zE=qE;function GE(t,e,r){return{isValid:t,isPotentiallyValid:e,isValidForThisYear:r||!1}}var KE=function(t){var e,r,n=(new Date).getMonth()+1;return"string"!=typeof t?GE(!1,!1):""===t.replace(/\s/g,"")||"0"===t?GE(!1,!0):/^\d*$/.test(t)?(e=parseInt(t,10),isNaN(t)?GE(!1,!1):GE(r=e>0&&e<13,r,r&&e>=n)):GE(!1,!1)},WE=function(t){var e,r,n,i,o;return/^\d{4}-\d{1,2}$/.test(t)?t=t.split("-").reverse():/\//.test(t)?t=t.split(/\s*\/\s*/g):/\s/.test(t)&&(t=t.split(/ +/g)),zE(t)?{month:t[0]||"",year:t.slice(1).join()}:(n=t,r=0===(o=Number(n[0]))?2:o>1||1===o&&Number(n[1])>2?1:1===o?(i=n.substr(1),HE(i).isPotentiallyValid?1:2):5===n.length?1:n.length>5?2:1,{month:e=t.substr(0,r),year:t.substr(e.length)})},XE=KE,YE=FE;function ZE(t,e,r,n){return{isValid:t,isPotentiallyValid:e,month:r,year:n}}function JE(t,e){return{isValid:t,isPotentiallyValid:e}}function $E(t,e){return{isValid:t,isPotentiallyValid:e}}var QE={number:VE,expirationDate:function(t,e){var r,n,i,o;if("string"==typeof t)t=t.replace(/^(\d\d) (\d\d(\d\d)?)$/,"$1/$2"),r=WE(t);else{if(null===t||"object"!=typeof t)return ZE(!1,!1,null,null);r={month:String(t.month),year:String(t.year)}}if(n=XE(r.month),i=YE(r.year,e),n.isValid){if(i.isCurrentYear)return ZE(o=n.isValidForThisYear,o,r.month,r.year);if(i.isValid)return ZE(!0,!0,r.month,r.year)}return n.isPotentiallyValid&&i.isPotentiallyValid?ZE(!1,!0,null,null):ZE(!1,!1,null,null)},expirationMonth:KE,expirationYear:FE,cvv:function(t,e){return e=(e=e||3)instanceof Array?e:[e],"string"!=typeof t?JE(!1,!1):/^\d*$/.test(t)?function(t,e){for(var r=0;r<t.length;r++)if(e===t[r])return!0;return!1}(e,t.length)?JE(!0,!0):t.length<Math.min.apply(null,e)?JE(!1,!0):t.length>function(t){for(var e=3,r=0;r<t.length;r++)e=t[r]>e?t[r]:e;return e}(e)?JE(!1,!1):JE(!0,!0):JE(!1,!1)},postalCode:function(t,e){var r;return r=(e=e||{}).minLength||3,"string"!=typeof t?$E(!1,!1):t.length<r?$E(!1,!0):$E(!0,!0)},creditCardType:jE},tA=[{type:"bank_auth",name:"Bank authorization",number:"4084080000000409",cvv:"000",month:"01",year:"30"},{type:"success",name:"Success",number:"4084084084084081",cvv:"408",month:"12",year:"30"},{type:"declined",name:"Declined",number:"4084080000005408",cvv:"001",month:"12",year:"30"},{type:"pin",name:"Pin only validation",number:"507850785078507812",cvv:"884",month:"01",year:"30"},{type:"pin+otp",name:"Pin and OTP validation",number:"5060666666666666666",cvv:"123",month:"01",year:"30"},{type:"pin+phone+otp",name:"Pin, phone and OTP validation",number:"507850785078507812",cvv:"884",month:"01",year:"30"},{type:"default",name:"No validation",number:"4084084084084081",cvv:"408",month:"01",year:"30"}];QE.creditCardType.addCard({niceType:"Verve",type:"verve",patterns:[[506e3,507999],[65e4,650009]],gaps:[4,8,12,16],lengths:[16,18,19],code:{name:"CVV",size:3}}),QE.creditCardType.changeOrder("verve",0);var eA={getEncryptedPin:function(t){return t?rE(t):void 0},getLast4:function(t){return t.substring(t.length-4)},tokenize:function(t){var e=t.number,r=t.cvv,n=t.month,i=t.year;return rE("".concat(e,"*").concat(r,"*").concat(n,"*").concat(i))},getType:function(t){var e=QE.number(t);return e&&e.card?{type:e.card.type,maxLength:Math.max.apply(Math,b(e.card.lengths)),minLength:Math.min.apply(Math,b(e.card.lengths))}:{type:null,maxLength:0}},validate:function(t){var e=t.number,r=t.cvv,n=t.month,i=t.year,o=this.getType(e).type,a={number:this.isNumberValid(e),expiry:this.isExpiryValid({month:n,year:i}),cvv:this.isCvvValid(r,o)};return{isValid:Object.values(a).every((function(t){return!0===t})),result:a}},validateNumber:function(t){return QE.number(t)},isNumberValid:function(t){return eA.validateNumber(t).isValid},validateCVV:function(t,e){var r="american-express"===e?4:3;return QE.cvv(t,r)},isCvvValid:function(t,e){return eA.validateCVV(t,e).isValid},validateExpiry:function(t){if(null!==t&&"object"===n(t)){var e=t.month,r=t.year;return QE.expirationMonth(e)&&QE.expirationYear(r)}return QE.expirationDate(t)},isExpiryValid:function(t){return eA.validateExpiry(t).isValid},findTestCard:function(t){var e=t||"default";return tA.find((function(t){return t.type===e}))}},rA=function(){function t(e){var r=e.number,n=e.cvv,i=e.month,o=e.year,s=e.pin;a(this,t),this.number=r,this.cvv=n,this.month=i,this.year=o,this.pin=s}return u(t,[{key:"getEncryptedPin",value:function(){return eA.getEncryptedPin(this.pin)}},{key:"getLast4",value:function(){return eA.getLast4(this.number)}},{key:"tokenize",value:function(){return eA.tokenize({number:this.number,cvv:this.cvv,month:this.month,year:this.year})}}],[{key:"getType",value:function(t){return eA.getType(t)}},{key:"validate",value:function(t){var e=t.number,r=t.cvv,n=t.month,i=t.year;return eA.validate({number:e,cvv:r,month:n,year:i})}},{key:"validateNumber",value:function(t){return eA.validateNumber(t)}},{key:"isNumberValid",value:function(t){return eA.isNumberValid(t)}},{key:"validateCVV",value:function(t,e){return eA.validateCVV(t,e)}},{key:"isCvvValid",value:function(t,e){return eA.isCvvValid(t,e)}},{key:"validateExpiry",value:function(t){return eA.validateExpiry(t)}},{key:"isExpiryValid",value:function(t){return eA.isExpiryValid(t)}},{key:"generateTestCard",value:function(e){return new t(eA.findTestCard(e))}}]),t}(),nA=function(t){var e=t.clientdata,n=t.last4,i=t.pin,o=t.trans,a=t.device,s=t.rememberCard,u=t.transactionType,c=t.subscription,h=t.customFields,l="".concat(Dd.paymentBaseUrl,"charge/"),f=RT(),p=r({"Content-Type":"application/x-www-form-urlencoded"},f&&{"Accept-Language":f}),d=r(r(r({clientdata:e,last4:n,trans:o,device:a,offset:(new Date).getTimezoneOffset(),remember_card:s},u&&{transaction_type:u}),c&&{subscription:c}),h&&h);i&&(d.handle=i);var g=FT(d);return PT.post(l,g,{headers:p}).then((function(t){return Wd.parse(t.data)}))},iA=function(t){var e=t.device,n=t.accessCode,i=t.pin,o="".concat(Dd.paymentBaseUrl,"charge/resume/").concat(n),a=RT(),s=r({"Content-Type":"application/x-www-form-urlencoded"},a&&{"Accept-Language":a}),u=r({device:e},i&&{handle:i}),c=FT(u);return PT.post(o,c,{headers:s}).then((function(t){return Wd.parse(t.data)}))},oA=function(t){var e=t.last4,n=t.trans,i=t.device,o=t.authorizationCode,a=t.cvv,s=t.pin,u=t.transactionType,c=t.subscription,h="".concat(Dd.paymentBaseUrl,"charge/"),l=RT(),f=r({"Content-Type":"application/x-www-form-urlencoded"},l&&{"Accept-Language":l}),p=r(r({last4:e,trans:n,device:i,cvv:a,handle:s,authorization_code:o},u&&{transaction_type:u}),c&&{subscription:c}),d=FT(p);return PT.post(h,d,{headers:f}).then((function(t){return Wd.parse(t.data)}))},aA=function(t,e){var n="".concat(Dd.paymentBaseUrl,"charge/validate"),i={trans:t,token:e},o=RT(),a=r({},o&&{"Accept-Language":o}),s=FT(i);return PT.post(n,s,{headers:a}).then((function(t){return Wd.parse(t.data)}))},sA=function(t){var e=t.address,n=t.city,i=t.state,o=t.zipCode,a=t.transactionId,s="".concat(Dd.paymentBaseUrl,"charge/avs"),u=RT(),c=r({"Content-Type":"application/x-www-form-urlencoded"},u&&{"Accept-Language":u}),h=FT({city:n,state:i,address:e,zip_code:o,trans:a});return PT.post(s,h,{headers:c}).then((function(t){return Wd.parse(t.data)}))},uA=function(t){var e=t.authorizationId,n=t.publicKey,i=RT(),o=r({Authorization:"Bearer ".concat(n)},i&&{"Accept-Language":i}),a={authorization_id:e},s="".concat(Dd.paystackApiUrl,"rememberme/forget_card");return PT.post(s,a,{headers:o}).then((function(t){return Wd.parse(t.data)}))},cA=function(t){return o(regeneratorRuntime.mark((function e(){var n,i,o,a,s,u,c,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.transaction,i=t.phone,o=t.channels,a=new URL("/saved_cards/authorize",Dd.paystackApiUrl).toString(),s=RT(),u=r({},s&&{"Accept-Language":s}),c=r(r(r({},i&&{phone:i}),o&&{channels:o}),{},{transaction:n}),e.next=7,PT.post(a,c,{headers:u});case 7:return h=e.sent,e.abrupt("return",h.data);case 9:case"end":return e.stop()}}),e)})))()},hA=function(t){return o(regeneratorRuntime.mark((function e(){var n,i,o,a,s,u,c,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.code,i=t.transaction,o=t.token,a=new URL("/saved_cards/authorize/verify",Dd.paystackApiUrl).toString(),s=RT(),u=r({Authorization:"Bearer ".concat(o)},s&&{"Accept-Language":s}),c={code:n,transaction:i},e.next=7,PT.post(a,c,{headers:u});case 7:return h=e.sent,e.abrupt("return",h.data);case 9:case"end":return e.stop()}}),e)})))()},lA=function(t){return o(regeneratorRuntime.mark((function e(){var n,i,o,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.token,i=new URL("/saved_cards/cards",Dd.paystackApiUrl).toString(),o=RT(),a=r({Authorization:"Bearer ".concat(n),"jwt-auth":!0},o&&{"Accept-Language":o}),e.next=6,PT.get(i,{headers:a});case 6:return s=e.sent,e.abrupt("return",s.data);case 8:case"end":return e.stop()}}),e)})))()},fA=function(t){return o(regeneratorRuntime.mark((function e(){var n,i,o,a,s,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.cardCode,i=t.token,o=new URL("/saved_cards/cards/".concat(n),Dd.paystackApiUrl).toString(),a=RT(),s=r({Authorization:"Bearer ".concat(i),"jwt-auth":!0},a&&{"Accept-Language":a}),e.next=6,PT.delete(o,{headers:s});case 6:return u=e.sent,e.abrupt("return",u.data);case 8:case"end":return e.stop()}}),e)})))()},pA=function(t){return o(regeneratorRuntime.mark((function e(){var n,i,o,a,s,u,c,h,l,f;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.token,i=t.device,o=t.cardCode,a=t.transaction,s=t.selectedCurrency,u=new URL("/saved_cards/cards/".concat(o,"/charge"),Dd.paystackApiUrl).toString(),c=RT(),h=r({Authorization:"Bearer ".concat(n),"jwt-auth":!0},c&&{"Accept-Language":c}),l={device:i,transaction:a,selected_currency:s},e.next=7,PT.post(u,l,{headers:h});case 7:return f=e.sent,e.abrupt("return",Wd.parse(f.data));case 9:case"end":return e.stop()}}),e)})))()},dA="card",gA="saved card",mA="otp";function vA(t,e){return new Promise((function(r,n){var i=rA.validate(t);if(!i.isValid){var o=e||t.number,a=Object.keys(i.result).filter((function(t){return!1===i.result[t]})),s="Invalid card details: ".concat(a.join(", "));n(Error(o?s:"Please set a valid card with Transaction.setCard()"))}r()}))}var yA={setCard:function(t){var e=this;return vA(t,!0).then((function(){e.card=new rA(t)}))},rememberCard:function(){this.remember_card=!0},chargeCard:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return!this.card.number&&this.card.pin?this.chargeCardWithPin(e):vA(this.card).then((function(){t.logAttempt(dA);var r={clientdata:t.card.tokenize(),last4:t.card.getLast4(),pin:t.card.getEncryptedPin(),trans:t.id,device:t.deviceFingerprint,rememberCard:t.remember_card,transactionType:t.transactionType,subscription:t.subscription,customFields:e};return nA(r).then((function(e){return t.logAPIResponse(e,dA),e}))}))},chargeCardWithPin:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logAttempt(dA);var r={pin:rE(this.card.pin),trans:this.id,device:this.deviceFingerprint,rememberCard:this.remember_card,transactionType:this.transactionType,subscription:this.subscription,customFields:e};return nA(r).then((function(e){return t.logAPIResponse(e,dA),e}))},chargeRememberedCard:function(t){var e=this,r=t.cvv,n=t.authorizationCode,i=t.cardLast4,o=t.pin;this.logAttempt(dA);var a=rE(o),s={authorizationCode:n,cvv:r,last4:i,trans:this.id,device:this.deviceFingerprint,pin:a,transactionType:this.transactionType,subscription:this.subscription};return oA(s).then((function(t){return e.logAPIResponse(t,dA),t}))},resumeCardCharge:function(t){var e=this,n=t.accessCode,i=t.pin,o=r(r({},i&&{pin:rE(i)}),{},{accessCode:n,device:this.deviceFingerprint});return iA(o).then((function(t){return e.logAPIResponse(t,dA),t}))},forgetRememberedCard:function(t){var e=this,r={authorizationId:t,publicKey:this.merchant.key};return uA(r).then((function(t){return e.logAPIResponse(t,dA),t}))},authenticateCard:function(t){var e=this;return aA(this.id,t).then((function(t){return e.logAPIResponse(t,dA),t}))},verifyAddress:function(t){var e=this,r=t.address,n={city:t.city,state:t.state,address:r,zipCode:t.zipCode,transactionId:this.id};return sA(n).then((function(t){return e.logAPIResponse(t,dA),t}))},listenFor3DSCharge:function(t){var e={channel:"3DS_".concat(this.id),paymentMethod:dA};return this.listenForCharge(e,t)},sendSavedCardsOTP:function(t,e){var r=this;return o(regeneratorRuntime.mark((function n(){var i;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,r.logAuth(mA),n.next=4,cA({phone:t,transaction:r.id,channels:e});case 4:return i=n.sent,r.savedCardsTempAuthToken=i.data.token,n.abrupt("return",i);case 9:throw n.prev=9,n.t0=n.catch(0),r.savedCardsTempAuthToken=null,n.t0;case 13:case"end":return n.stop()}}),n,null,[[0,9]])})))()},verifySavedCardsOtp:function(t){var e=this;return o(regeneratorRuntime.mark((function r(){var n,i,o;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=t.code,i={code:n,transaction:e.id,token:e.savedCardsTempAuthToken},r.prev=2,r.next=5,hA(i);case 5:return o=r.sent,e.savedCardsToken=o.data.token,r.abrupt("return",o);case 10:throw r.prev=10,r.t0=r.catch(2),e.savedCardsToken=null,r.t0;case 14:case"end":return r.stop()}}),r,null,[[2,10]])})))()},getSavedCards:function(){return lA({token:this.savedCardsToken})},deleteSavedCard:function(t){return fA({cardCode:t,token:this.savedCardsToken})},chargeSavedCard:function(t){var e=t.cardCode,r=t.selectedCurrency,n=void 0===r?this.currency:r;return this.logAttempt(gA),pA({cardCode:e,transaction:this.id,token:this.savedCardsToken,device:this.deviceFingerprint,selectedCurrency:n})}},bA=function(){function t(e){var r=e.bankId,n=e.accountType,i=e.accountNumber;a(this,t),this.bankId=r,this.accountType=n,this.accountNumber=i}return u(t,null,[{key:"validate",value:function(e){var r=e.bankId,n=e.accountType,i=e.accountNumber,o=[];return r&&"number"==typeof r||o.push("Invalid bankId. Please check for supported banks with BankAccount.supportedBanks()"),t.types.indexOf(n)>-1?"nuban"!==n||t.isValidNubanAccount(i)||o.push("Invalid account number. Nuban accounts must be 10 digit numbers"):o.push("Invalid bank type. Please check BankAccount.types for the list of valid bank types"),{isValid:0===o.length,errors:o}}},{key:"isValidNubanAccount",value:function(t){return!!t&&(("number"==typeof t||/^\d+$/.test(t))&&10===t.length)}},{key:"supportedBanks",value:function(){var t="".concat(Dd.paymentBaseUrl,"bank?pay_with_bank=true"),e=RT(),n=r({},e&&{"Accept-Language":e});return PT.post(t,{headers:n}).then((function(t){return t.data}))}}]),t}();bA.types=["nuban"];var wA=function(t){var e=t.bankId,n=t.transactionId,i=t.accountNumber,o=t.device,a="".concat(Dd.paymentBaseUrl,"bank/charge_account/").concat(e,"/").concat(n),s=RT(),u=r({"Content-Type":"application/x-www-form-urlencoded"},s&&{"Accept-Language":s}),c=FT({account_number:i,device:o});return PT.post(a,c,{headers:u}).then((function(t){return Wd.parse(t.data)}))},SA=function(t){var e=t.bankId,n=t.transactionId,i=t.accountNumber,o=t.birthday,a="".concat(Dd.paymentBaseUrl,"bank/charge_account/").concat(e,"/").concat(n),s=RT(),u=r({"Content-Type":"application/x-www-form-urlencoded"},s&&{"Accept-Language":s}),c=FT({account_number:i,birthday:o});return PT.post(a,c,{headers:u}).then((function(t){return Wd.parse(t.data)}))},TA=function(t){var e=t.bankId,n=t.transactionId,i=t.token,o=t.device,a="".concat(Dd.paymentBaseUrl,"bank/validate_token/").concat(e,"/").concat(n),s=RT(),u=r({"Content-Type":"application/x-www-form-urlencoded"},s&&{"Accept-Language":s}),c=FT({device:o,token:i});return PT.post(a,c,{headers:u}).then((function(t){return Wd.parse(t.data)}))},EA="bank account";function AA(t,e){return new Promise((function(r,n){var i=bA.validate(t);if(!i.isValid){var o=e||t.accountNumber?i.errors[0]:"Please set a valid bank account with Transaction.setBank()";n(Error(o))}r()}))}var xA={getIbankUrl:function(t){var e=this,r=t.bankId;return new Promise((function(t,n){r||n(Error("Please send bankId"));var i="".concat(Dd.paymentBaseUrl,"bank/ibank/").concat(r,"/").concat(e.id);t(Wd.success({url:i}))}))},listenForIbankCharge:function(t){var e={channel:"IBANK_".concat(this.id),paymentMethod:"ibank"};return this.listenForCharge(e,t)}},kA=function(t){var e=t.bankId,n=t.transactionId,i=t.phoneNumber,o=t.payId,a="".concat(Dd.paymentBaseUrl,"bank/digitalbankmandate/").concat(e,"/").concat(n),s=RT(),u=r({"Content-Type":"application/x-www-form-urlencoded"},s&&{"Accept-Language":s}),c=FT({phone_number:i,token:o});return PT.post(a,c,{headers:u}).then((function(t){return Wd.parse(t.data)}))},OA="bank",CA={chargeDigitalBankMandate:function(t){var e=this,r=t.phoneNumber,n=t.payId,i=t.bankId,o={transactionId:this.id,phoneNumber:r,payId:n,bankId:i};return kA(o).then((function(t){return e.logAPIResponse(t,OA),t}))},listenForDigitalBankMandateCharge:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r={paymentMethod:OA,channel:e};return this.listenForCharge(r,t)}},PA=r(r(r({},{setBankAccount:function(t){var e=this;return AA(t,!0).then((function(){e.bankAccount=new bA(t)}))},chargeBankAccount:function(){var t=this;return AA(this.bankAccount).then((function(){t.logAttempt(EA);var e={bankId:t.bankAccount.bankId,transactionId:t.id,accountNumber:t.bankAccount.accountNumber,device:t.deviceFingerprint};return wA(e).then((function(e){return t.logAPIResponse(e,EA),e}))}))},registerBankAccount:function(t){var e=this;return AA(this.bankAccount).then((function(){var r={bankId:e.bankAccount.bankId,transactionId:e.id,accountNumber:e.bankAccount.accountNumber,birthday:t};return SA(r).then((function(t){return e.logAPIResponse(t,EA),t}))}))},authenticateBankAccount:function(t){var e=this;return AA(this.bankAccount).then((function(){var r={bankId:e.bankAccount.bankId,transactionId:e.id,token:t,device:e.deviceFingerprint};return TA(r).then((function(t){return e.logAPIResponse(t,EA),t}))}))}}),xA),CA),RA=function(t,e){var n=RT(),i=r({Authorization:"Bearer ".concat(e)},n&&{"Accept-Language":n});return PT.post("".concat(Dd.paystackApiUrl,"checkout/ussd/reference"),t,{headers:i}).then((function(t){return Wd.parse(t.data)}))},BA=function(t,e){var n=RT(),i=r({Authorization:"Bearer ".concat(e)},n&&{"Accept-Language":n});return PT.post("".concat(Dd.paystackApiUrl,"checkout/pay_with_transfer_ussd"),t,{headers:i}).then((function(t){return Wd.parse(t.data)}))},DA={getUSSDShortcode:function(t){var e=this,r=t.channel,n={transaction:this.id,channel:r};return RA(n,this.merchant.key).then((function(t){return"success"===t.status&&(e.ussd[r]=t),t}))},getPWTUSSDShortcode:function(t){var e=this,r=t.bankSlug,n=t.fulfilLateNotification,i=void 0!==n&&n,o={transaction_id:this.id,fulfil_late_notification:i,bank_slug:r};return BA(o,this.merchant.key).then((function(t){return"success"===t.status&&(e.ussd[r]=t),t}))},listenForPWTUSSDCharge:function(t,e){var r=t.bankSlug;if(!this.ussd[r])return Promise.reject(Error("Please generate a ussd shortcode with Transaction.getPWTUSSDShortcode()"));var n={channel:this.ussd[r].data.pusher_channel,paymentMethod:"ussd"};return this.listenForCharge(n,e)},listenForUSSDCharge:function(t,e){var r=t.channel;if(!this.ussd[r])return Promise.reject(Error("Please generate a ussd shortcode with Transaction.getUSSDShortcode()"));var n={channel:this.ussd[r].data.channel,paymentMethod:r};return this.listenForCharge(n,e)}},LA=function(t,e){var n={source:"checkout",reference:t.transaction,channel:t.channel},i=RT(),o=r({Authorization:"Bearer ".concat(e)},i&&{"Accept-Language":i});return PT.post("".concat(Dd.paystackApiUrl,"offline/qr/generate"),n,{headers:o}).then((function(t){return Wd.parse(t.data)}))};function IA(t){return new Promise((function(e,r){var n=["visa","MPASS_OLTI"];if(n.indexOf(t)<=-1){var i="Invalid channel. Available channels: ".concat(n.join(", "));r(Error(i))}else e()}))}var jA={getQRCode:function(t){var e=this,r=t.channel;return IA(r).then((function(){if(e.qr[r])return e.qr[r];var t={transaction:e.id,channel:r};return LA(t,e.merchant.key).then((function(t){return"success"===t.status&&(e.qr[r]=t),t}))}))},listenForQRCharge:function(t,e){var r=this,n=t.channel;return IA(n).then((function(){if(!r.qr[n])return Promise.reject(Error("Please generate qr code with Transaction.getQRCode()"));var t={channel:r.qr[n].data.channel,paymentMethod:n};return r.listenForCharge(t,e)}))}},NA=function(){function t(){a(this,t)}return u(t,null,[{key:"hasCountryCode",value:function(t){return t&&"+"===t[0]}},{key:"hasOnlyDigits",value:function(t){var e;return t&&(e=t.substring(1),/^\d+$/.test(e))}},{key:"isE164Number",value:function(t){return t&&t.length<17}},{key:"validate",value:function(e){var r=[];return t.hasCountryCode(e)||r.push("Number should include country code prefix"),t.hasOnlyDigits(e)||r.push("Number should contain only digits"),t.isE164Number(e)||r.push("Number should not be longer than 16 digits"),{isValid:0===r.length,errors:r}}}]),t}(),MA=function(t){var e={transaction:t.transaction,phone:t.phone,device:t.device,channel_name:t.channel_name,provider:t.provider,voucher:t.voucher,registration_token:t.registrationToken},n=RT(),i=r({},n&&{"Accept-Language":n});return PT.post("".concat(Dd.paystackApiUrl,"charge/mobile_money"),e,{headers:i}).then((function(t){return Wd.parse(t.data)})).catch((function(t){var e=t.response;return Wd.parse(e.data)}))},_A=function(t){var e=t.transaction,n=t.code,i=RT(),o=r({},i&&{"Accept-Language":i}),a=FT({transaction:e,otp:n}),s=new URL("charge/momo_payin_finalize",Dd.paymentBaseUrl).toString();return PT.post(s,a,{headers:o}).then((function(t){return Wd.parse(t.data)}))};function VA(t){return new Promise((function(e,r){var n=NA.validate(t);if(!n.isValid){var i=t?n.errors[0]:"Please start a mobile money transaction with Transaction.chargeMobileMoney()";r(Error(i))}e(n)}))}var UA={mobileMoneyChargeAPI:function(t){var e=this;return MA(t).then((function(t){return"success"===t.status&&(e.mobileMoney=t,t.data&&t.data.display&&1===t.data.display.otpSentCount&&e.logTokenRequest("mobile money")),t}))},chargeMobileMoney:function(t){var e=this,r=t.phoneNumber,n=t.provider,i=t.voucher,o=t.registrationToken;return VA(r).then((function(){e.logAttempt("mobile money");var t={provider:n,voucher:i,registrationToken:o,transaction:e.id,phone:r,device:e.deviceFingerprint,channel_name:"MOBILE_MONEY_".concat(e.id)};return e.mobileMoneyChargeAPI(t)}))},chargeMpesaOffline:function(t){var e=t.provider,r=t.voucher,n=t.registrationToken;this.logAttempt("mobile money");var i={provider:e,voucher:r,registrationToken:n,transaction:this.id,device:this.deviceFingerprint,channel_name:"MOBILE_MONEY_".concat(this.id)};return this.mobileMoneyChargeAPI(i)},authenticateMobileMoney:function(t){var e=this,r=t.phoneNumber,n=t.provider,i=t.registrationToken;return VA(r).then((function(){e.logMobileMoneyActions(t);var o={provider:n,registrationToken:i,transaction:e.id,phone:r,device:e.deviceFingerprint,channel_name:"MOBILE_MONEY_".concat(e.id)};return MA(o).then((function(t){return"success"===t.status?(e.mobileMoney=t,t.data&&t.data.display&&1===t.data.display.otpSentCount&&e.logTokenRequest("mobile money")):t.errors&&t.errors.data&&"awaiting_registration_token"===t.errors.data.status?e.logTokenAuthenticationFailure(t.message):e.logError(t.message),t}))}))},submitMobileMoneyCode:function(t){var e=this;return _A({code:t.code,transaction:this.id}).then((function(t){return e.logAPIResponse(t,"mobile_money"),t}))},listenForMobileMoneyCharge:function(t){if("success"!==this.mobileMoney.status)return Promise.reject(Error("Please start a mobile money charge with Transaction.chargeMobileMoney()"));var e=this.mobileMoney.data,r=e.channel,n=e.channel_name,i={channel:r||n,paymentMethod:"mobile_money"};return this.listenForCharge(i,t)}},FA=function(t){var e={email:t.email,password:t.password},n=RT(),i=r({},n&&{"Accept-Language":n});return PT.post("".concat(Dd.paystackApiUrl,"login"),e,{headers:i}).then((function(t){return Wd.parse(t.data)}))},qA=function(t){var e=t.account_code,n=t.transaction,i=t.token,o=RT(),a=r({Authorization:"Bearer ".concat(i),"jwt-auth":!0},o&&{"Accept-Language":o}),s={account_code:e,transaction:n};return PT.post("".concat(Dd.paystackApiUrl,"directdebit/initiate"),s,{headers:a}).then((function(t){return Wd.parse(t.data)}))},HA=function(t){var e=t.otp,n=t.transaction,i=t.token,o=RT(),a=r({Authorization:"Bearer ".concat(i),"jwt-auth":!0},o&&{"Accept-Language":o}),s={otp:e,transaction:n};return PT.post("".concat(Dd.paystackApiUrl,"directdebit/validate"),s,{headers:a}).then((function(t){return Wd.parse(t.data)}))},zA=function(t){var e=RT(),n=r({Authorization:"Bearer ".concat(t),"jwt-auth":!0},e&&{"Accept-Language":e});return PT.get("".concat(Dd.paystackApiUrl,"directdebit/account"),{headers:n}).then((function(t){return t.data}))},GA="direct debit",KA={loginToDirectDebitAccount:function(t){var e=this,r=t.email,n={email:r,password:t.password};return Mc(r)?FA(n).then((function(t){if("success"===t.status){var r=t.data,n=r.token,i=r.user.permissions;if(!i||i.length<1)throw Error("You do not have the privileges to perform this action");if(i.find((function(t){return"directdebit-*"===t})))return e.directDebit.token=n,t;throw Error("You do not have the privileges to perform this action")}return t})):Promise.reject(Error("Invalid email"))},chargeDirectDebit:function(t){var e=this;if(!this.directDebit.token)return Promise.reject(Error("Please login with Transaction.loginToDirectDebitAccount() to start a Direct debit charge"));this.logAttempt(GA);var r={account_code:t,transaction:this.id,token:this.directDebit.token};return qA(r).then((function(t){return e.logAPIResponse(t,GA),t.status&&(e.directDebit.chargeResponse=t),t}))},getProvisionedAccounts:function(){var t=this;return zA(this.directDebit.token).then((function(e){t.logAPIResponse(e,GA);var r=e.status,n=e.data;if(r){if(n&&n.length<1)return Promise.reject(Error("You have not provisioned any bank account for Direct Debit yet"));t.directDebit.accounts=e.data}return e}))},authenticateAccount:function(t){var e=this,r={otp:t,transaction:this.id,token:this.directDebit.token};return HA(r).then((function(t){return e.logAPIResponse(t,GA),t}))}},WA=function(t){return{card:yA,bank:PA,ussd:DA,qr:jA,mobile_money:UA,direct_debit:KA,bank_transfer:VT,eft:GT,payattitude:zT,apple_pay:YT,paypal:tE}[t]},XA=function(t){t||"undefined"==typeof navigator||(t=navigator.userAgent);t&&t.headers&&"string"==typeof t.headers["user-agent"]&&(t=t.headers["user-agent"]);return"string"==typeof t&&(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))};var YA=function(t){var e=t||{},r=e.attempts,n=e.authentication,i=e.errors,o=e.history;return{start_time:Math.round(Date.now()/1e3),time_spent:0,attempts:r||0,authentication:n,errors:i||0,success:!1,mobile:XA(),input:[],history:o||[]}},ZA=function(t){return Math.round(Date.now()/1e3)-t},JA=fi,$A=ft,QA=fa,tx=z,ex=k,rx=A.Array,nx=$A("JSON","stringify"),ix=tx(/./.exec),ox=tx("".charAt),ax=tx("".charCodeAt),sx=tx("".replace),ux=tx(1..toString),cx=/[\uD800-\uDFFF]/g,hx=/^[\uD800-\uDBFF]$/,lx=/^[\uDC00-\uDFFF]$/,fx=function(t,e,r){var n=ox(r,e-1),i=ox(r,e+1);return ix(hx,t)&&!ix(lx,i)||ix(lx,t)&&!ix(hx,n)?"\\u"+ux(ax(t,0),16):t},px=ex((function(){return'"\\udf06\\ud834"'!==nx("\udf06\ud834")||'"\\udead"'!==nx("\udead")}));nx&&JA({target:"JSON",stat:!0,forced:px},{stringify:function(t,e,r){for(var n=0,i=arguments.length,o=rx(i);n<i;n++)o[n]=arguments[n];var a=QA(nx,null,o);return"string"==typeof a?sx(a,cx,fx):a}});var dx=function(t,e){var n=e.merchantKey,i=e.log,o=RT(),a=r({Authorization:"Bearer ".concat(n)},o&&{"Accept-Language":o});return PT.post(t,{payload:JSON.stringify(i)},{headers:a}).then((function(t){return t.data}))},gx=function(t,e){var n=e.merchantKey,i=RT(),o=r({Authorization:"Bearer ".concat(n)},i&&{"Accept-Language":i});return PT.post(t,null,{headers:o}).then((function(t){return t.data}))},mx=function(t,e){var n=e.merchantKey,i=e.referrer,o=RT(),a=r({Authorization:"Bearer ".concat(n)},o&&{"Accept-Language":o});return PT.post(t,{referrer:i},{headers:a}).then((function(t){return t.data}))},vx=function(t,e,r){var n=new URL("transaction/update_log/".concat(t),Dd.paystackApiUrl).toString();return dx(n,{merchantKey:e,log:r})},yx=function(t,e){var r=new URL("transaction/set_ip/".concat(t),Dd.paystackApiUrl).toString();return gx(r,{merchantKey:e})},bx=function(t,e,r){var n=new URL("transaction/set_referrer/".concat(t),Dd.paystackApiUrl).toString();return mx(n,{merchantKey:e,referrer:r})},wx={initializeLog:function(t){this.log=YA(t)},getTimeSpent:function(){return this.log.time_spent=ZA(this.log.start_time),this.log.time_spent},logPageOpen:function(){return this.log.history.push({type:"open",message:"Opened checkout",time:this.getTimeSpent()}),this.saveLog()},logChannelSwitch:function(t){return this.log.history.push({type:"action",message:"Set payment method to: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logValidationErrors:function(t){var e=this;return t.forEach((function(t){e.log.history.push({type:"error",message:"Invalid ".concat(t),time:e.getTimeSpent()})})),this.saveLog()},logInput:function(t){var e=this.log.history.find((function(e){return e.message==="Filled this field: ".concat(t)}));return this.log.history.push({type:"input",message:"".concat(e?"Changed":"Filled"," this field: ").concat(t),time:this.getTimeSpent()}),this.saveLog()},logBankSelect:function(t){return this.log.history.push({type:"action",message:"Selected bank: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logSavedCardSelect:function(){return this.log.history.push({type:"action",message:"Selected saved card",time:this.getTimeSpent()}),this.saveLog()},logAuthWindowOpen:function(){return this.log.history.push({type:"action",message:"Third-party authentication window opened",time:this.getTimeSpent()}),this.saveLog()},logAuthWindowClose:function(){return this.log.history.push({type:"action",message:"Third-party authentication window closed",time:this.getTimeSpent()}),this.saveLog()},logAPIResponse:function(t,e){switch(t.status){case"success":return this.logSuccess(e);case"pending":return this.logPending(e);case"failed":return this.logError(t.message);case"auth":return this.logAuth(t.data.auth);default:return!1}},logMobileMoneyActions:function(t){var e=t.numberOfTokenRequests,r=t.registrationToken;e?this.logTokenRequest("mobile money",e):r?this.logTokenSubmitted("mobile money"):this.logAttempt("mobile money")},logAPIResponseMessage:function(t){return this.log.history.push({type:"action",message:t,time:this.getTimeSpent()}),this.saveLog()},logAttempt:function(t){var e="Attempted to pay";return t&&(e+=" with ".concat(t)),this.log.attempts+=1,this.log.history.push({type:"action",message:e,time:this.getTimeSpent()}),this.saveLog()},logTokenRequest:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=0===e?"Waiting for customer to submit OTP":"Customer requested to resend OTP";return this.log.history.push({type:"action",message:r,channel:t,time:this.getTimeSpent()}),this.saveLog()},logTokenSubmitted:function(t){return this.log.history.push({type:"action",message:"Customer submitted OTP",channel:t,time:this.getTimeSpent()}),this.saveLog()},logTokenAuthenticationFailure:function(t){var e=t?"Error: ".concat(t):"Error";return this.log.errors+=1,this.log.history.push({type:"error",message:e,authentication:"failed",time:this.getTimeSpent()}),this.saveLog()},logError:function(t){var e="Error";return t&&(e+=": ".concat(t)),this.log.errors+=1,this.log.history.push({type:"error",message:e,time:this.getTimeSpent()}),this.saveLog()},logAuth:function(t){return this.log.authentication=t,this.log.history.push({type:"auth",message:"Authentication Required: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logSuccess:function(t){var e="Successfully paid";return t&&(e+=" with ".concat(t)),this.log.success=!0,this.log.history.push({type:"success",message:e,time:this.getTimeSpent()}),this.saveLog()},logPending:function(t){var e="Payment in progress";return t&&(e+=" with ".concat(t)),this.log.history.push({type:"pending",message:e,time:this.getTimeSpent()}),this.saveLog()},logPageClose:function(){return this.log.history.push({type:"close",message:"Closed checkout",time:this.getTimeSpent()}),this.saveLog()},logTransactionCurrencySwitch:function(t){var e=t.currency,r=t.isUserAction,n=void 0===r||r?"User switched":"Switched";return this.log.history.push({type:"action",message:"".concat(n," transaction currency to ").concat(e),time:this.getTimeSpent()}),this.saveLog()},saveLog:function(){return vx(this.id,this.merchant.key,this.log)},saveIpAddress:function(){return yx(this.id,this.merchant.key)},saveReferrer:function(t){return bx(this.id,this.merchant.key,t)}},Sx=function(){function t(e){var r=this;a(this,t),this.email=e.email,this.merchant={id:e.merchant_id,logo:e.merchant_logo,name:e.merchant_name,key:e.merchant_key,channelSettings:e.merchant_channel_settings||{}},this.status=e.transaction_status||e.status,this.accessCode=e.access_code,this.amount=e.amount,this.domain=e.domain,this.isTest="test"===e.domain,this.currency=e.currency,this.id=e.id,this.channels=e.channels,this.label=e.label,this.metadata=e.metadata||{},this.cancel_action=e.cancel_action||null,this.channel_options=e.channel_options||null,this.hash=e.hash||null,this.authorizations=e.authorizations,this.remember_card=!1,this.rememberMeEnabled=e.is_remember_me_enabled,this.card={},this.bankAccount={},this.mobileMoney={},this.ussd={},this.bankTransfer={},this.qr={},this.directDebit={},this.deviceFingerprint=e.deviceFingerprint||null,this.customer=e.customer,this.custom_filters=e.custom_filters||null,this.isCharging=!1,this.isListening=!1,this.transactionType=e.transaction_type||null,this.subscription=e.subscription||null,this.planDetails=e.plan_details||null,this.exchangeRate=e.exchange_rate||null,this.savedCardsConfig=e.saved_cards||{},this.savedCardsTempAuthToken=null,this.savedCardsToken=null,this.reference=e.reference,Xd(),this.log=null,Object.assign(this,wx),this.initializeLog(e.log),this.saveIpAddress(),this.channels.forEach((function(t){var e=WA(t);Object.assign(r,e)})),"GHS"===e.currency&&e.elevy_percentage&&(this.elevyPercentage=e.elevy_percentage)}return u(t,[{key:"setMetadata",value:function(t,e){this.metadata[t]=e}},{key:"setDevice",value:function(t){this.deviceFingerprint?ld("Device ID has already been set by Checkout JS so there's no need to set this again"):this.deviceFingerprint=t}},{key:"listenForCharge",value:function(t,e){return Yd(t,this,e)}},{key:"requery",value:function(){return jT(this.id)}},{key:"markAsAbandoned",value:function(){return NT({publicKey:this.merchant.key,transactionId:this.id})}},{key:"verifyStatus",value:function(){return MT({reference:this.reference,publicKey:this.merchant.key}).then((function(t){return t&&t.data}))}}]),t}(),Tx={validate:function(t){var e=function(t){var e=[];return t&&"object"===n(t)?(Object.keys(Uc).forEach((function(r){var n=Uc[r],i=t[r];!n.required||i||t[n.fallback]?i&&!n.isValid(i)&&e.push({field:r,message:"Invalid field: ".concat(r)}):e.push({field:r,message:"Required field: ".concat(r)})})),e):(e.push({message:"Please supply a valid object"}),e)}(t);if(e.length){var r=y(e,1)[0].message;throw new rs(e,r)}},request:function(t){return o(regeneratorRuntime.mark((function e(){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,pd();case 2:return n=e.sent,e.next=5,BT(r(r({},t),{device:n}));case 5:return i=e.sent,e.abrupt("return",i&&Object.seal(new Sx(r(r({},i.data),{deviceFingerprint:n}))));case 7:case"end":return e.stop()}}),e)})))()},requestWithAccessCode:function(t){return o(regeneratorRuntime.mark((function e(){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,pd();case 2:return n=e.sent,e.next=5,DT(t);case 5:return i=e.sent,e.abrupt("return",i&&Object.seal(new Sx(r(r({},i.data),{deviceFingerprint:n}))));case 7:case"end":return e.stop()}}),e)})))()},getByAccessCode:function(t,e){return o(regeneratorRuntime.mark((function n(){var i,o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,pd();case 2:return i=n.sent,n.next=5,LT(t,e);case 5:return o=n.sent,n.abrupt("return",o&&Object.seal(new Sx(r(r({},o.data),{deviceFingerprint:i}))));case 7:case"end":return n.stop()}}),n)})))()},initialize:function(t){return Object.seal(new Sx(t))},verify:function(t){return o(regeneratorRuntime.mark((function e(){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,IT(t);case 2:return r=e.sent,e.abrupt("return",r&&r.data);case 4:case"end":return e.stop()}}),e)})))()}},Ex={},Ax=function(t){var e=new URL("/bank",Dd.paystackApiUrl).toString(),n=RT(),i={params:t,headers:r({},n&&{"Accept-Language":n})};return PT.get(e,i).then((function(t){return t.data}))},xx=function(){var t=new URL("/checkout/resolutions",Dd.paystackApiUrl).toString(),e=RT(),n=r({},e&&{"Accept-Language":e});return PT.get(t,{headers:n}).then((function(t){return t.data}))},kx=function(){var t=new URL("/checkout/celebrations",Dd.paystackApiUrl).toString(),e=RT(),n=r({},e&&{"Accept-Language":e});return PT.get(t,{headers:n}).then((function(t){return t.data}))},Ox=function(t){var e=new URL("/address_verification/states",Dd.paystackApiUrl).toString(),n=RT(),i={params:t,headers:r({},n&&{"Accept-Language":n})};return PT.get(e,i).then((function(t){return t.data}))},Cx=function(t){var e=new URL("/decision/bin/".concat(t),Dd.paystackApiUrl).toString(),n=RT(),i=r({},n&&{"Accept-Language":n});return Ex[t]?Promise.resolve(Ex[t]):PT.get(e,{headers:i}).then((function(e){var r=e.data;return Ex[t]=r,r}))},Px=function(){function t(){a(this,t)}return u(t,null,[{key:"contents",value:function(){return[{key:"banks",usage:"Returns a list of banks that can be used to complete checkout"},{key:"resolutions",usage:"Returns a list of known errors, mapped to their suggested resolutions"},{key:"celebrations",usage:"Returns a list of upcoming celebrations"},{key:"states",usage:"Returns a list of states for a particular country"}]}},{key:"fetch",value:function(t,e){var r;if(this.contents().map((function(t){return t.key})).indexOf(t)<=-1)throw new Error("Please provide a valid config key. Use Toolkit.contents() to see available options.");switch(t){case"banks":r=Ax(e||{pay_with_bank:"1"});break;case"resolutions":r=xx();break;case"celebrations":r=kx();break;case"states":r=Ox(e)}return r}},{key:"resolveCardBin",value:function(t){return Cx(t)}}]),t}(),Rx=function(){function t(e){var r=e.number,n=e.cvv,i=e.month,o=e.year,s=e.pin;a(this,t),this.number=r,this.cvv=n,this.month=i,this.year=o,this.pin=s}return u(t,[{key:"getEncryptedPin",value:function(){return eA.getEncryptedPin(this.pin)}},{key:"getLast4",value:function(){return eA.getLast4(this.number)}},{key:"tokenize",value:function(){return eA.tokenize({number:this.number,cvv:this.cvv,month:this.month,year:this.year})}}],[{key:"getType",value:function(t){return eA.getType(t)}},{key:"validate",value:function(t){var e=t.number,r=t.cvv,n=t.month,i=t.year;return eA.validate({number:e,cvv:r,month:n,year:i})}},{key:"validateNumber",value:function(t){return eA.validateNumber(t)}},{key:"isNumberValid",value:function(t){return eA.isNumberValid(t)}},{key:"validateCVV",value:function(t,e){return eA.validateCVV(t,e)}},{key:"isCvvValid",value:function(t,e){return eA.isCvvValid(t,e)}},{key:"validateExpiry",value:function(t){return eA.validateExpiry(t)}},{key:"isExpiryValid",value:function(t){return eA.isExpiryValid(t)}},{key:"generateTestCard",value:function(e){return new t(eA.findTestCard(e))}}]),t}(),Bx=function(t){var e=t.clientdata,n=t.last4,i=t.preauthorizationId,o=t.publicKey,a=new URL("preauthorization/create",Dd.paystackApiUrl).toString(),s=RT(),u=r({Authorization:"Bearer ".concat(o)},s&&{"Accept-Language":s});return PT.post(a,{clientdata:e,last4:n,preauthorization:i},{headers:u}).then((function(t){return Wd.parse(t.data)}))},Dx="card";function Lx(t,e){return new Promise((function(r,n){var i=Rx.validate(t);if(!i.isValid){var o=e||t.number,a=Object.keys(i.result).filter((function(t){return!1===i.result[t]})),s="Invalid card details: ".concat(a.join(", "));n(Error(o?s:"Please set a valid card with setCard()"))}r()}))}var Ix={setCard:function(t){var e=this;return Lx(t,!0).then((function(){e.card=new Rx(t)}))},reserveFunds:function(t){var e=this,r=t.preauthorizationId,n=t.publicKey,i=t.customFields,o=void 0===i?{}:i;return Lx(this.card).then((function(){e.logAttempt(Dx);var t={clientdata:e.card.tokenize(),last4:e.card.getLast4(),device:e.deviceFingerprint,preauthorizationId:r,publicKey:n,customFields:o};return Bx(t).then((function(t){return e.logAPIResponse(t,Dx),t}))}))},listenFor3DSCharge:function(t){var e={channel:"3DS_".concat(this.id),paymentMethod:Dx};return this.listenForCharge(e,t)}},jx=function(t){var e=RT(),n=r({},e&&{"Accept-Language":e}),i=new URL("preauthorization/verify_access_code/".concat(t),Dd.paystackApiUrl).toString();return PT.get(i,{headers:n}).then((function(t){return t.data}))},Nx=function(t){var e=t.reference,n=t.publicKey,i=RT(),o=r({Authorization:"Bearer ".concat(n)},i&&{"Accept-Language":i}),a=new URL("preauthorization/verify/".concat(e),Dd.paystackApiUrl).toString();return PT.get(a,{headers:o}).then((function(t){return Wd.parse(t.data)}))},Mx=function(t,e,r){var n=new URL("preauthorization/update_log/".concat(t),Dd.paystackApiUrl).toString();return dx(n,{merchantKey:e,log:r})},_x=function(t,e){var r=new URL("preauthorization/set_ip/".concat(t),Dd.paystackApiUrl).toString();return gx(r,{merchantKey:e})},Vx={initializeLog:function(t){this.log=YA(t)},getTimeSpent:function(){return this.log.time_spent=ZA(this.log.start_time),this.log.time_spent},logPageOpen:function(){return this.log.history.push({type:"open",message:"Opened checkout",time:this.getTimeSpent()}),this.saveLog()},logChannelSwitch:function(t){return this.log.history.push({type:"action",message:"Set charge method to: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logValidationErrors:function(t){var e=this;return t.forEach((function(t){e.log.history.push({type:"error",message:"Invalid ".concat(t),time:e.getTimeSpent()})})),this.saveLog()},logInput:function(t){var e=this.log.history.find((function(e){return e.message==="Filled this field: ".concat(t)}));return this.log.history.push({type:"input",message:"".concat(e?"Changed":"Filled"," this field: ").concat(t),time:this.getTimeSpent()}),this.saveLog()},logAuthWindowOpen:function(){return this.log.history.push({type:"action",message:"Third-party authentication window opened",time:this.getTimeSpent()}),this.saveLog()},logAuthWindowClose:function(){return this.log.history.push({type:"action",message:"Third-party authentication window closed",time:this.getTimeSpent()}),this.saveLog()},logAPIResponse:function(t,e){switch(t.status){case"authorized":return this.logAuthorized(e);case"failed":return this.logError(t.message);case"auth":return this.logAuth(t.data.auth);default:return!1}},logAPIResponseMessage:function(t){return this.log.history.push({type:"action",message:t,time:this.getTimeSpent()}),this.saveLog()},logAttempt:function(t){var e="Attempted to charge";return t&&(e+=" with ".concat(t)),this.log.attempts+=1,this.log.history.push({type:"action",message:e,time:this.getTimeSpent()}),this.saveLog()},logAuth:function(t){return this.log.authentication=t,this.log.history.push({type:"auth",message:"Authentication Required: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logAuthorized:function(t){var e="Successfully preauthorized funds";return t&&(e+=" with ".concat(t)),this.log.success=!0,this.log.history.push({type:"authorized",message:e,time:this.getTimeSpent()}),this.saveLog()},logPageClose:function(){return this.log.history.push({type:"close",message:"Closed checkout",time:this.getTimeSpent()}),this.saveLog()},logError:function(t){var e="Error";return t&&(e+=": ".concat(t)),this.log.errors+=1,this.log.history.push({type:"error",message:e,time:this.getTimeSpent()}),this.saveLog()},saveLog:function(){return Mx(this.id,this.merchant.key,this.log)},saveIpAddress:function(){return _x(this.id,this.merchant.key)}},Ux=function(){function t(e){a(this,t),this.id=e.id,this.email=e.email,this.status=e.status,this.reference=e.reference,this.amount=e.amount,this.currency=e.currency,this.metadata=e.metadata||{},this.customer=e.customer,this.channels=e.channels||["card"],this.isListening=!1,this.isTest="test"===e.domain,this.deviceFingerprint=e.deviceFingerprint||null,this.merchant={id:e.merchant_id,logo:e.merchant_logo,name:e.merchant_name,key:e.merchant_key},this.card={},Xd(),this.log=null,Object.assign(this,Vx),this.initializeLog(e.log),this.saveIpAddress(),Object.assign(this,Ix)}return u(t,[{key:"setMetadata",value:function(t,e){this.metadata[t]=e}},{key:"requery",value:function(){var t=this;return Nx({reference:this.reference,publicKey:this.merchant.key}).then((function(e){return t.logAPIResponse(e,"card"),e}))}},{key:"listenForCharge",value:function(t,e){return Yd(t,this,e)}}]),t}(),Fx={initialize:function(t){return Object.seal(new Ux(t))},getByAccessCode:function(t){return o(regeneratorRuntime.mark((function e(){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,pd();case 2:return n=e.sent,e.next=5,jx(t);case 5:return i=e.sent,e.abrupt("return",i&&Object.seal(new Ux(r(r({},i.data),{},{deviceFingerprint:n}))));case 7:case"end":return e.stop()}}),e)})))()}};return t.BankAccount=bA,t.Card=rA,t.Preauthorization=Fx,t.Toolkit=Px,t.Transaction=Tx,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
package/es/checkout.js CHANGED
@@ -18703,19 +18703,21 @@ var CardAPI$1 = {
18703
18703
  },
18704
18704
  sendSavedCardsOTP: function sendSavedCardsOTP(_ref6) {
18705
18705
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
18706
- var transaction, phone, url, language, headers, data, response;
18706
+ var transaction, phone, channels, url, language, headers, data, response;
18707
18707
  return regeneratorRuntime.wrap(function _callee$(_context) {
18708
18708
  while (1) {
18709
18709
  switch (_context.prev = _context.next) {
18710
18710
  case 0:
18711
- transaction = _ref6.transaction, phone = _ref6.phone;
18711
+ transaction = _ref6.transaction, phone = _ref6.phone, channels = _ref6.channels;
18712
18712
  url = new URL('/saved_cards/authorize', configToUse.paystackApiUrl).toString();
18713
18713
  language = getLanguage();
18714
18714
  headers = _objectSpread2({}, language && {
18715
18715
  'Accept-Language': language
18716
18716
  });
18717
- data = _objectSpread2(_objectSpread2({}, phone && {
18717
+ data = _objectSpread2(_objectSpread2(_objectSpread2({}, phone && {
18718
18718
  phone: phone
18719
+ }), channels && {
18720
+ channels: channels
18719
18721
  }), {}, {
18720
18722
  transaction: transaction
18721
18723
  });
@@ -19060,7 +19062,7 @@ var CardCharge = {
19060
19062
  };
19061
19063
  return this.listenForCharge(listenerOptions, callback);
19062
19064
  },
19063
- sendSavedCardsOTP: function sendSavedCardsOTP(phone) {
19065
+ sendSavedCardsOTP: function sendSavedCardsOTP(phone, channels) {
19064
19066
  var _this9 = this;
19065
19067
 
19066
19068
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
@@ -19076,7 +19078,8 @@ var CardCharge = {
19076
19078
  _context.next = 4;
19077
19079
  return CardAPI$1.sendSavedCardsOTP({
19078
19080
  phone: phone,
19079
- transaction: _this9.id
19081
+ transaction: _this9.id,
19082
+ channels: channels
19080
19083
  });
19081
19084
 
19082
19085
  case 4:
@@ -21107,7 +21110,7 @@ var CardPreauthorization = {
21107
21110
  }
21108
21111
  };
21109
21112
 
21110
- var PreauthorisationAPI = {
21113
+ var PreauthorizationAPI = {
21111
21114
  getByAccessCode: function getByAccessCode(accessCode) {
21112
21115
  var language = getLanguage();
21113
21116
 
@@ -21226,8 +21229,8 @@ var AnalyticsFunctions = {
21226
21229
  },
21227
21230
  logAPIResponse: function logAPIResponse(response, channel) {
21228
21231
  switch (response.status) {
21229
- case 'success':
21230
- return this.logSuccess(channel);
21232
+ case 'authorized':
21233
+ return this.logAuthorized(channel);
21231
21234
 
21232
21235
  case 'failed':
21233
21236
  return this.logError(response.message);
@@ -21271,8 +21274,8 @@ var AnalyticsFunctions = {
21271
21274
  });
21272
21275
  return this.saveLog();
21273
21276
  },
21274
- logSuccess: function logSuccess(channel) {
21275
- var message = 'Successfully preauthorised funds';
21277
+ logAuthorized: function logAuthorized(channel) {
21278
+ var message = 'Successfully preauthorized funds';
21276
21279
 
21277
21280
  if (channel) {
21278
21281
  message += " with ".concat(channel);
@@ -21280,7 +21283,7 @@ var AnalyticsFunctions = {
21280
21283
 
21281
21284
  this.log.success = true;
21282
21285
  this.log.history.push({
21283
- type: 'success',
21286
+ type: 'authorized',
21284
21287
  message: message,
21285
21288
  time: this.getTimeSpent()
21286
21289
  });
@@ -21317,6 +21320,8 @@ var AnalyticsFunctions = {
21317
21320
  }
21318
21321
  };
21319
21322
 
21323
+ var PAYMENT_METHOD = 'card';
21324
+
21320
21325
  var PreauthorizationInstance = /*#__PURE__*/function () {
21321
21326
  function PreauthorizationInstance(data) {
21322
21327
  _classCallCheck(this, PreauthorizationInstance);
@@ -21356,9 +21361,15 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
21356
21361
  }, {
21357
21362
  key: "requery",
21358
21363
  value: function requery() {
21359
- return PreauthorisationAPI.requery({
21364
+ var _this = this;
21365
+
21366
+ return PreauthorizationAPI.requery({
21360
21367
  reference: this.reference,
21361
21368
  publicKey: this.merchant.key
21369
+ }).then(function (response) {
21370
+ _this.logAPIResponse(response, PAYMENT_METHOD);
21371
+
21372
+ return response;
21362
21373
  });
21363
21374
  }
21364
21375
  }, {
@@ -21388,7 +21399,7 @@ var Preauthorization = {
21388
21399
  case 2:
21389
21400
  deviceFingerprint = _context.sent;
21390
21401
  _context.next = 5;
21391
- return PreauthorisationAPI.getByAccessCode(accessCode);
21402
+ return PreauthorizationAPI.getByAccessCode(accessCode);
21392
21403
 
21393
21404
  case 5:
21394
21405
  response = _context.sent;
package/lib/checkout.js CHANGED
@@ -18707,19 +18707,21 @@ var CardAPI$1 = {
18707
18707
  },
18708
18708
  sendSavedCardsOTP: function sendSavedCardsOTP(_ref6) {
18709
18709
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
18710
- var transaction, phone, url, language, headers, data, response;
18710
+ var transaction, phone, channels, url, language, headers, data, response;
18711
18711
  return regeneratorRuntime.wrap(function _callee$(_context) {
18712
18712
  while (1) {
18713
18713
  switch (_context.prev = _context.next) {
18714
18714
  case 0:
18715
- transaction = _ref6.transaction, phone = _ref6.phone;
18715
+ transaction = _ref6.transaction, phone = _ref6.phone, channels = _ref6.channels;
18716
18716
  url = new URL('/saved_cards/authorize', configToUse.paystackApiUrl).toString();
18717
18717
  language = getLanguage();
18718
18718
  headers = _objectSpread2({}, language && {
18719
18719
  'Accept-Language': language
18720
18720
  });
18721
- data = _objectSpread2(_objectSpread2({}, phone && {
18721
+ data = _objectSpread2(_objectSpread2(_objectSpread2({}, phone && {
18722
18722
  phone: phone
18723
+ }), channels && {
18724
+ channels: channels
18723
18725
  }), {}, {
18724
18726
  transaction: transaction
18725
18727
  });
@@ -19064,7 +19066,7 @@ var CardCharge = {
19064
19066
  };
19065
19067
  return this.listenForCharge(listenerOptions, callback);
19066
19068
  },
19067
- sendSavedCardsOTP: function sendSavedCardsOTP(phone) {
19069
+ sendSavedCardsOTP: function sendSavedCardsOTP(phone, channels) {
19068
19070
  var _this9 = this;
19069
19071
 
19070
19072
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
@@ -19080,7 +19082,8 @@ var CardCharge = {
19080
19082
  _context.next = 4;
19081
19083
  return CardAPI$1.sendSavedCardsOTP({
19082
19084
  phone: phone,
19083
- transaction: _this9.id
19085
+ transaction: _this9.id,
19086
+ channels: channels
19084
19087
  });
19085
19088
 
19086
19089
  case 4:
@@ -21111,7 +21114,7 @@ var CardPreauthorization = {
21111
21114
  }
21112
21115
  };
21113
21116
 
21114
- var PreauthorisationAPI = {
21117
+ var PreauthorizationAPI = {
21115
21118
  getByAccessCode: function getByAccessCode(accessCode) {
21116
21119
  var language = getLanguage();
21117
21120
 
@@ -21230,8 +21233,8 @@ var AnalyticsFunctions = {
21230
21233
  },
21231
21234
  logAPIResponse: function logAPIResponse(response, channel) {
21232
21235
  switch (response.status) {
21233
- case 'success':
21234
- return this.logSuccess(channel);
21236
+ case 'authorized':
21237
+ return this.logAuthorized(channel);
21235
21238
 
21236
21239
  case 'failed':
21237
21240
  return this.logError(response.message);
@@ -21275,8 +21278,8 @@ var AnalyticsFunctions = {
21275
21278
  });
21276
21279
  return this.saveLog();
21277
21280
  },
21278
- logSuccess: function logSuccess(channel) {
21279
- var message = 'Successfully preauthorised funds';
21281
+ logAuthorized: function logAuthorized(channel) {
21282
+ var message = 'Successfully preauthorized funds';
21280
21283
 
21281
21284
  if (channel) {
21282
21285
  message += " with ".concat(channel);
@@ -21284,7 +21287,7 @@ var AnalyticsFunctions = {
21284
21287
 
21285
21288
  this.log.success = true;
21286
21289
  this.log.history.push({
21287
- type: 'success',
21290
+ type: 'authorized',
21288
21291
  message: message,
21289
21292
  time: this.getTimeSpent()
21290
21293
  });
@@ -21321,6 +21324,8 @@ var AnalyticsFunctions = {
21321
21324
  }
21322
21325
  };
21323
21326
 
21327
+ var PAYMENT_METHOD = 'card';
21328
+
21324
21329
  var PreauthorizationInstance = /*#__PURE__*/function () {
21325
21330
  function PreauthorizationInstance(data) {
21326
21331
  _classCallCheck(this, PreauthorizationInstance);
@@ -21360,9 +21365,15 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
21360
21365
  }, {
21361
21366
  key: "requery",
21362
21367
  value: function requery() {
21363
- return PreauthorisationAPI.requery({
21368
+ var _this = this;
21369
+
21370
+ return PreauthorizationAPI.requery({
21364
21371
  reference: this.reference,
21365
21372
  publicKey: this.merchant.key
21373
+ }).then(function (response) {
21374
+ _this.logAPIResponse(response, PAYMENT_METHOD);
21375
+
21376
+ return response;
21366
21377
  });
21367
21378
  }
21368
21379
  }, {
@@ -21392,7 +21403,7 @@ var Preauthorization = {
21392
21403
  case 2:
21393
21404
  deviceFingerprint = _context.sent;
21394
21405
  _context.next = 5;
21395
- return PreauthorisationAPI.getByAccessCode(accessCode);
21406
+ return PreauthorizationAPI.getByAccessCode(accessCode);
21396
21407
 
21397
21408
  case 5:
21398
21409
  response = _context.sent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paystack/checkout-js",
3
- "version": "1.27.0",
3
+ "version": "1.27.2",
4
4
  "description": "Client-side JS library for billing on Paystack",
5
5
  "main": "lib/checkout.js",
6
6
  "module": "es/checkout.js",