@paystack/checkout-js 2.0.0-dev.1 → 2.0.0-dev.3

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/dist/checkout.js CHANGED
@@ -13,4 +13,4 @@ var Paystack=function(t){"use strict";var e="undefined"!=typeof globalThis?globa
13
13
  * @since jsrsasign 2.1
14
14
  * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
15
15
  */
16
- var Ys={};void 0!==Ys.asn1&&Ys.asn1||(Ys.asn1={}),Ys.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 xs(n,16).xor(t).add(xs.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=Ys.asn1,r=e.DERBoolean,n=e.DERInteger,i=e.DERBitString,a=e.DEROctetString,o=e.DERNull,s=e.DERObjectIdentifier,c=e.DEREnumerated,u=e.DERUTF8String,h=e.DERNumericString,l=e.DERPrintableString,d=e.DERTeletexString,p=e.DERIA5String,f=e.DERUTCTime,g=e.DERGeneralizedTime,m=e.DERSequence,y=e.DERSet,v=e.DERTaggedObject,b=e.ASN1Util.newObject,T=Object.keys(t);if(1!=T.length)throw"key of param shall be only one.";var w=T[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+w+":"))throw"undefined key: "+w;if("bool"==w)return new r(t[w]);if("int"==w)return new n(t[w]);if("bitstr"==w)return new i(t[w]);if("octstr"==w)return new a(t[w]);if("null"==w)return new o(t[w]);if("oid"==w)return new s(t[w]);if("enum"==w)return new c(t[w]);if("utf8str"==w)return new u(t[w]);if("numstr"==w)return new h(t[w]);if("prnstr"==w)return new l(t[w]);if("telstr"==w)return new d(t[w]);if("ia5str"==w)return new p(t[w]);if("utctime"==w)return new f(t[w]);if("gentime"==w)return new g(t[w]);if("seq"==w){for(var S=t[w],A=[],E=0;E<S.length;E++){var x=b(S[E]);A.push(x)}return new m({array:A})}if("set"==w){for(S=t[w],A=[],E=0;E<S.length;E++){x=b(S[E]);A.push(x)}return new y({array:A})}if("tag"==w){var k=t[w];if("[object Array]"===Object.prototype.toString.call(k)&&3==k.length){var C=b(k[2]);return new v({tag:k[0],explicit:k[1],obj:C})}var B={};if(void 0!==k.explicit&&(B.explicit=k.explicit),void 0!==k.tag&&(B.tag=k.tag),void 0===k.obj)throw"obj shall be specified for 'tag'.";return B.obj=b(k.obj),new v(B)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},Ys.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 a=("00000000"+parseInt(t.substr(i,2),16).toString(2)).slice(-8);if(n+=a.substr(1,7),"0"==a.substr(0,1))e=e+"."+new xs(n,2).toString(10),n=""}return e},Ys.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 xs(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var a="",o=0;o<i;o++)a+="0";n=a+n;for(o=0;o<n.length-1;o+=7){var s=n.substr(o,7);o!=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("."),a=40*parseInt(i[0])+parseInt(i[1]);n+=e(a),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);return n},Ys.asn1.ASN1Object=function(){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="+"".length+",v="+this.hV;var t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var r=e.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+r).toString(16)+e},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""}},Ys.asn1.DERAbstractString=function(t){Ys.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))},Js.lang.extend(Ys.asn1.DERAbstractString,Ys.asn1.ASN1Object),Ys.asn1.DERAbstractTime=function(t){Ys.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),a=String(i.getFullYear());"utc"==e&&(a=a.substr(2,2));var o=a+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 c=n(String(s),3);o=o+"."+(c=c.replace(/[0]+$/,""))}}return o+"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,a){var o=new Date(Date.UTC(t,e-1,r,n,i,a,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},Js.lang.extend(Ys.asn1.DERAbstractTime,Ys.asn1.ASN1Object),Ys.asn1.DERAbstractStructured=function(t){Ys.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)},Js.lang.extend(Ys.asn1.DERAbstractStructured,Ys.asn1.ASN1Object),Ys.asn1.DERBoolean=function(){Ys.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},Js.lang.extend(Ys.asn1.DERBoolean,Ys.asn1.ASN1Object),Ys.asn1.DERInteger=function(t){Ys.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=Ys.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new xs(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))},Js.lang.extend(Ys.asn1.DERInteger,Ys.asn1.ASN1Object),Ys.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=Ys.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}Ys.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),a=parseInt(i,2).toString(16);1==a.length&&(a="0"+a),n+=a}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))},Js.lang.extend(Ys.asn1.DERBitString,Ys.asn1.ASN1Object),Ys.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=Ys.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}Ys.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},Js.lang.extend(Ys.asn1.DEROctetString,Ys.asn1.DERAbstractString),Ys.asn1.DERNull=function(){Ys.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Js.lang.extend(Ys.asn1.DERNull,Ys.asn1.ASN1Object),Ys.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 xs(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var a="",o=0;o<i;o++)a+="0";n=a+n;for(o=0;o<n.length-1;o+=7){var s=n.substr(o,7);o!=n.length-7&&(s="1"+s),r+=e(parseInt(s,2))}return r};Ys.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("."),a=40*parseInt(i[0])+parseInt(i[1]);n+=e(a),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=n},this.setValueName=function(t){var e=Ys.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))},Js.lang.extend(Ys.asn1.DERObjectIdentifier,Ys.asn1.ASN1Object),Ys.asn1.DEREnumerated=function(t){Ys.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=Ys.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new xs(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))},Js.lang.extend(Ys.asn1.DEREnumerated,Ys.asn1.ASN1Object),Ys.asn1.DERUTF8String=function(t){Ys.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},Js.lang.extend(Ys.asn1.DERUTF8String,Ys.asn1.DERAbstractString),Ys.asn1.DERNumericString=function(t){Ys.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},Js.lang.extend(Ys.asn1.DERNumericString,Ys.asn1.DERAbstractString),Ys.asn1.DERPrintableString=function(t){Ys.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},Js.lang.extend(Ys.asn1.DERPrintableString,Ys.asn1.DERAbstractString),Ys.asn1.DERTeletexString=function(t){Ys.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},Js.lang.extend(Ys.asn1.DERTeletexString,Ys.asn1.DERAbstractString),Ys.asn1.DERIA5String=function(t){Ys.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},Js.lang.extend(Ys.asn1.DERIA5String,Ys.asn1.DERAbstractString),Ys.asn1.DERUTCTime=function(t){Ys.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))},Js.lang.extend(Ys.asn1.DERUTCTime,Ys.asn1.DERAbstractTime),Ys.asn1.DERGeneralizedTime=function(t){Ys.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))},Js.lang.extend(Ys.asn1.DERGeneralizedTime,Ys.asn1.DERAbstractTime),Ys.asn1.DERSequence=function(t){Ys.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}},Js.lang.extend(Ys.asn1.DERSequence,Ys.asn1.DERAbstractStructured),Ys.asn1.DERSet=function(t){Ys.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)},Js.lang.extend(Ys.asn1.DERSet,Ys.asn1.DERAbstractStructured),Ys.asn1.DERTaggedObject=function(t){Ys.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)))},Js.lang.extend(Ys.asn1.DERTaggedObject,Ys.asn1.ASN1Object);var Qs,tc=(Qs=function(t,e){return Qs=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},Qs(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}Qs(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),ec=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 tc(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)?ds(t):ps.unarmor(t),i=ws.decode(n);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){e=i.sub[1].getHexStringValue(),this.n=Ps(e,16),r=i.sub[2].getHexStringValue(),this.e=parseInt(r,16);var a=i.sub[3].getHexStringValue();this.d=Ps(a,16);var o=i.sub[4].getHexStringValue();this.p=Ps(o,16);var s=i.sub[5].getHexStringValue();this.q=Ps(s,16);var c=i.sub[6].getHexStringValue();this.dmp1=Ps(c,16);var u=i.sub[7].getHexStringValue();this.dmq1=Ps(u,16);var h=i.sub[8].getHexStringValue();this.coeff=Ps(h,16)}else{if(2!==i.sub.length)return!1;if(i.sub[0].sub){var l=i.sub[1].sub[0];e=l.sub[0].getHexStringValue(),this.n=Ps(e,16),r=l.sub[1].getHexStringValue(),this.e=parseInt(r,16)}else e=i.sub[0].getHexStringValue(),this.n=Ps(e,16),r=i.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}},e.prototype.getPrivateBaseKey=function(){var t={array:[new Ys.asn1.DERInteger({int:0}),new Ys.asn1.DERInteger({bigint:this.n}),new Ys.asn1.DERInteger({int:this.e}),new Ys.asn1.DERInteger({bigint:this.d}),new Ys.asn1.DERInteger({bigint:this.p}),new Ys.asn1.DERInteger({bigint:this.q}),new Ys.asn1.DERInteger({bigint:this.dmp1}),new Ys.asn1.DERInteger({bigint:this.dmq1}),new Ys.asn1.DERInteger({bigint:this.coeff})]};return new Ys.asn1.DERSequence(t).getEncodedHex()},e.prototype.getPrivateBaseKeyB64=function(){return us(this.getPrivateBaseKey())},e.prototype.getPublicBaseKey=function(){var t=new Ys.asn1.DERSequence({array:[new Ys.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new Ys.asn1.DERNull]}),e=new Ys.asn1.DERSequence({array:[new Ys.asn1.DERInteger({bigint:this.n}),new Ys.asn1.DERInteger({int:this.e})]}),r=new Ys.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new Ys.asn1.DERSequence({array:[t,r]}).getEncodedHex()},e.prototype.getPublicBaseKeyB64=function(){return us(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}(Xs),rc=process.env.npm_package_version,nc=function(){function t(t){void 0===t&&(t={}),t=t||{},this.default_key_size=t.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 ec(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(hs(t))}catch(t){return!1}},t.prototype.encrypt=function(t){try{return us(this.getKey().encrypt(t))}catch(t){return!1}},t.prototype.sign=function(t,e,r){try{return us(this.getKey().sign(t,e,r))}catch(t){return!1}},t.prototype.verify=function(t,e,r){try{return this.getKey().verify(t,hs(e),r)}catch(t){return!1}},t.prototype.getKey=function(t){if(!this.key){if(this.key=new ec,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=rc,t}();function ic(t){const e=new nc;return e.setPublicKey(na.publicKey),e.encrypt(t)}var ac=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 oc=function(t){return t?JSON.parse(JSON.stringify(t)):null};var sc=function(t){return"string"==typeof t||t instanceof String};var cc=function(t,e){return Array.isArray(e)?function(t,e,r){var n=String(e).length,i=t.substr(0,n),a=parseInt(i,10);return e=parseInt(String(e).substr(0,i.length),10),r=parseInt(String(r).substr(0,i.length),10),a>=e&&a<=r}(t,e[0],e[1]):function(t,e){return(e=String(e)).substring(0,t.length)===t.substring(0,e.length)}(t,e)},uc=oc,hc=cc;var lc,dc=function(t,e,r){var n,i,a,o;for(n=0;n<e.patterns.length;n++)if(i=e.patterns[n],hc(t,i)){o=uc(e),a=Array.isArray(i)?String(i[0]).length:String(i).length,t.length>=a&&(o.matchStrength=a),r.push(o);break}},pc={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,810,[8110,8131],[8132,8151],[8152,8163],[8164,8171]],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}}},fc=oc,gc=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}))},mc=sc,yc=dc,vc={},bc={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"},Tc=[bc.VISA,bc.MASTERCARD,bc.AMERICAN_EXPRESS,bc.DINERS_CLUB,bc.DISCOVER,bc.JCB,bc.UNIONPAY,bc.MAESTRO,bc.ELO,bc.MIR,bc.HIPER,bc.HIPERCARD];function wc(t){return vc[t]||pc[t]}function Sc(t,e){var r=lc.indexOf(t);if(!e&&-1===r)throw new Error('"'+t+'" is not a supported card type.');return r}function Ac(t){var e,r=[];return mc(t)?0===t.length?lc.map((function(t){return fc(wc(t))})):(lc.forEach((function(e){var n=wc(e);yc(t,n,r)})),(e=gc(r))?[e]:r):[]}lc=fc(Tc),Ac.getTypeInfo=function(t){return fc(wc(t))},Ac.removeCard=function(t){var e=Sc(t);lc.splice(e,1)},Ac.addCard=function(t){var e=Sc(t.type,!0);vc[t.type]=t,-1===e&&lc.push(t.type)},Ac.updateCard=function(t,e){var r,n=vc[t]||pc[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=fc(n),Object.keys(r).forEach((function(t){e[t]&&(r[t]=e[t])})),vc[r.type]=r},Ac.changeOrder=function(t,e){var r=Sc(t);lc.splice(r,1),lc.splice(e,0,t)},Ac.resetModifications=function(){lc=fc(Tc),vc={}},Ac.types=bc;var Ec=Ac,xc=ac,kc=Ec;function Cc(t,e,r){return{card:t,isPotentiallyValid:e,isValid:r}}var Bc=function(t,e){var r,n,i,a,o;if(e=e||{},"number"==typeof t&&(t=String(t)),"string"!=typeof t)return Cc(null,!1,!1);if(t=t.replace(/\-|\s/g,""),!/^\d*$/.test(t))return Cc(null,!1,!1);if(0===(r=kc(t)).length)return Cc(null,!1,!1);if(1!==r.length)return Cc(null,!0,!1);if(n=r[0],e.maxLength&&t.length>e.maxLength)return Cc(n,!1,!1);for(i=n.type===kc.types.UNIONPAY&&!0!==e.luhnValidateUnionPay||xc(t),o=Math.max.apply(null,n.lengths),e.maxLength&&(o=Math.min(e.maxLength,o)),a=0;a<n.lengths.length;a++)if(n.lengths[a]===t.length)return Cc(n,t.length<o||i,i);return Cc(n,t.length<o,!1)};function Oc(t,e,r){return{isValid:t,isPotentiallyValid:e,isCurrentYear:r||!1}}var Dc=function(t,e){var r,n,i,a,o;return e=e||19,"string"!=typeof t?Oc(!1,!1):""===t.replace(/\s/g,"")?Oc(!1,!0):/^\d*$/.test(t)?(n=t.length)<2?Oc(!1,!0):(r=(new Date).getFullYear(),3===n?Oc(!1,t.slice(0,2)===String(r).slice(0,2)):n>4?Oc(!1,!1):(t=parseInt(t,10),i=Number(String(r).substr(2,2)),2===n?(o=i===t,a=t>=i&&t<=i+e):4===n&&(o=r===t,a=t>=r&&t<=r+e),Oc(a,a,o))):Oc(!1,!1)},Pc=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},Rc=Dc,Ic=Pc;function Nc(t,e,r){return{isValid:t,isPotentiallyValid:e,isValidForThisYear:r||!1}}var Lc=function(t){var e,r,n=(new Date).getMonth()+1;return"string"!=typeof t?Nc(!1,!1):""===t.replace(/\s/g,"")||"0"===t?Nc(!1,!0):/^\d*$/.test(t)?(e=parseInt(t,10),isNaN(t)?Nc(!1,!1):Nc(r=e>0&&e<13,r,r&&e>=n)):Nc(!1,!1)},Mc=function(t){var e,r,n,i,a;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)),Ic(t)?{month:t[0]||"",year:t.slice(1).join()}:(n=t,r=0===(a=Number(n[0]))?2:a>1||1===a&&Number(n[1])>2?1:1===a?(i=n.substr(1),Rc(i).isPotentiallyValid?1:2):5===n.length?1:n.length>5?2:1,{month:e=t.substr(0,r),year:t.substr(e.length)})},_c=Lc,Vc=Dc;function jc(t,e,r,n){return{isValid:t,isPotentiallyValid:e,month:r,year:n}}function Uc(t,e){return{isValid:t,isPotentiallyValid:e}}function Fc(t,e){return{isValid:t,isPotentiallyValid:e}}var qc={number:Bc,expirationDate:function(t,e){var r,n,i,a;if("string"==typeof t)t=t.replace(/^(\d\d) (\d\d(\d\d)?)$/,"$1/$2"),r=Mc(t);else{if(null===t||"object"!=typeof t)return jc(!1,!1,null,null);r={month:String(t.month),year:String(t.year)}}if(n=_c(r.month),i=Vc(r.year,e),n.isValid){if(i.isCurrentYear)return jc(a=n.isValidForThisYear,a,r.month,r.year);if(i.isValid)return jc(!0,!0,r.month,r.year)}return n.isPotentiallyValid&&i.isPotentiallyValid?jc(!1,!0,null,null):jc(!1,!1,null,null)},expirationMonth:Lc,expirationYear:Dc,cvv:function(t,e){return e=(e=e||3)instanceof Array?e:[e],"string"!=typeof t?Uc(!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)?Uc(!0,!0):t.length<Math.min.apply(null,e)?Uc(!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)?Uc(!1,!1):Uc(!0,!0):Uc(!1,!1)},postalCode:function(t,e){var r;return r=(e=e||{}).minLength||3,"string"!=typeof t?Fc(!1,!1):t.length<r?Fc(!1,!0):Fc(!0,!0)},creditCardType:Ec},Hc=[{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"}];qc.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}}),qc.creditCardType.changeOrder("verve",0);class $c{constructor(t){let{number:e,cvv:r,month:n,year:i,pin:a}=t;this.number=e,this.cvv=r,this.month=n,this.year=i,this.pin=a}getEncryptedPin(){return this.pin?ic(this.pin):void 0}getLast4(){return this.number.substring(this.number.length-4)}tokenize(){return ic(`${this.number}*${this.cvv}*${this.month}*${this.year}`)}static getType(t){const e=qc.number(t);return e&&e.card?{type:e.card.type,maxLength:Math.max(...e.card.lengths),minLength:Math.min(...e.card.lengths)}:{type:null,maxLength:0}}static validate(t){let{number:e,cvv:r,month:n,year:i}=t;const{type:a}=$c.getType(e),o={number:$c.isNumberValid(e),expiry:$c.isExpiryValid({month:n,year:i}),cvv:$c.isCvvValid(r,a)};return{isValid:Object.values(o).every((t=>!0===t)),result:o}}static validateNumber(t){return qc.number(t)}static isNumberValid(t){return $c.validateNumber(t).isValid}static validateCVV(t,e){const r="american-express"===e?4:3;return qc.cvv(t,r)}static isCvvValid(t,e){return $c.validateCVV(t,e).isValid}static validateExpiry(t){if("object"==typeof t){const{month:e,year:r}=t;return qc.expirationMonth(e)&&qc.expirationYear(r)}return qc.expirationDate(t)}static isExpiryValid(t){return $c.validateExpiry(t).isValid}static generateTestCard(t){const e=t||"default",r=Hc.find((t=>t.type===e));return new $c(r)}}const zc={charge(t){let{clientdata:e,last4:r,pin:n,trans:i,device:a,rememberCard:o,transactionType:s,subscription:c,customFields:u}=t;const h=`${na.paymentBaseUrl}charge/`,l=Vo(),d={"Content-Type":"application/x-www-form-urlencoded",...l&&{"Accept-Language":l}},p={clientdata:e,last4:r,trans:i,device:a,offset:(new Date).getTimezoneOffset(),remember_card:o,...s&&{transaction_type:s},...c&&{subscription:c},...u&&u};n&&(p.handle=n);const f=Ho(p);return _o.post(h,f,{headers:d}).then((t=>aa.parse(t.data)))},resumeCardCharge(t){let{device:e,accessCode:r,pin:n}=t;const i=`${na.paymentBaseUrl}charge/resume/${r}`,a=Vo(),o={"Content-Type":"application/x-www-form-urlencoded",...a&&{"Accept-Language":a}},s={device:e,...n&&{handle:n}},c=Ho(s);return _o.post(i,c,{headers:o}).then((t=>aa.parse(t.data)))},chargeRememberedCard(t){let{last4:e,trans:r,device:n,authorizationCode:i,cvv:a,pin:o,transactionType:s,subscription:c}=t;const u=`${na.paymentBaseUrl}charge/`,h=Vo(),l={"Content-Type":"application/x-www-form-urlencoded",...h&&{"Accept-Language":h}},d={last4:e,trans:r,device:n,cvv:a,handle:o,authorization_code:i,...s&&{transaction_type:s},...c&&{subscription:c}},p=Ho(d);return _o.post(u,p,{headers:l}).then((t=>aa.parse(t.data)))},authenticate(t,e){const r=`${na.paymentBaseUrl}charge/validate`,n={trans:t,token:e},i=Vo(),a={...i&&{"Accept-Language":i}},o=Ho(n);return _o.post(r,o,{headers:a}).then((t=>aa.parse(t.data)))},verifyAddress(t){let{address:e,city:r,state:n,zipCode:i,transactionId:a}=t;const o=`${na.paymentBaseUrl}charge/avs`,s=Vo(),c={"Content-Type":"application/x-www-form-urlencoded",...s&&{"Accept-Language":s}},u=Ho({city:r,state:n,address:e,zip_code:i,trans:a});return _o.post(o,u,{headers:c}).then((t=>aa.parse(t.data)))},forgetRememberedCard(t){let{authorizationId:e,publicKey:r}=t;const n=Vo(),i={Authorization:`Bearer ${r}`,...n&&{"Accept-Language":n}},a={authorization_id:e},o=`${na.paystackApiUrl}rememberme/forget_card`;return _o.post(o,a,{headers:i}).then((t=>aa.parse(t.data)))}},Gc="card";function Kc(t,e){return new Promise(((r,n)=>{const i=$c.validate(t);if(!i.isValid){const r=e||t.number,a=`Invalid card details: ${Object.keys(i.result).filter((t=>!1===i.result[t])).join(", ")}`;n(Error(r?a:"Please set a valid card with Transaction.setCard()"))}r()}))}var Wc={setCard(t){return Kc(t,!0).then((()=>{this.card=new $c(t)}))},rememberCard(){this.remember_card=!0},chargeCard(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Kc(this.card).then((()=>{this.logAttempt(Gc);const e={clientdata:this.card.tokenize(),last4:this.card.getLast4(),pin:this.card.getEncryptedPin(),trans:this.id,device:this.deviceFingerprint,rememberCard:this.remember_card,transactionType:this.transactionType,subscription:this.subscription,customFields:t};return zc.charge(e).then((t=>(this.logAPIResponse(t,Gc),t)))}))},chargeRememberedCard(t){let{cvv:e,authorizationCode:r,cardLast4:n,pin:i}=t;this.logAttempt(Gc);const a=ic(i),o={authorizationCode:r,cvv:e,last4:n,trans:this.id,device:this.deviceFingerprint,pin:a,transactionType:this.transactionType,subscription:this.subscription};return zc.chargeRememberedCard(o).then((t=>(this.logAPIResponse(t,Gc),t)))},resumeCardCharge(t){let{accessCode:e,pin:r}=t;const n={...r&&{pin:ic(r)},accessCode:e,device:this.deviceFingerprint};return zc.resumeCardCharge(n).then((t=>(this.logAPIResponse(t,Gc),t)))},forgetRememberedCard(t){const e={authorizationId:t,publicKey:this.merchant.key};return zc.forgetRememberedCard(e).then((t=>(this.logAPIResponse(t,Gc),t)))},authenticateCard(t){return zc.authenticate(this.id,t).then((t=>(this.logAPIResponse(t,Gc),t)))},verifyAddress(t){let{address:e,city:r,state:n,zipCode:i}=t;const a={city:r,state:n,address:e,zipCode:i,transactionId:this.id};return zc.verifyAddress(a).then((t=>(this.logAPIResponse(t,Gc),t)))},listenFor3DSCharge(t){const e={channel:`3DS_${this.id}`,paymentMethod:Gc};return this.listenForCharge(e,t)}};class Xc{constructor(t){let{bankId:e,accountType:r,accountNumber:n}=t;this.bankId=e,this.accountType=r,this.accountNumber=n}static validate(t){let{bankId:e,accountType:r,accountNumber:n}=t;const i=[];return e&&"number"==typeof e||i.push("Invalid bankId. Please check for supported banks with BankAccount.supportedBanks()"),Xc.types.indexOf(r)>-1?"nuban"!==r||Xc.isValidNubanAccount(n)||i.push("Invalid account number. Nuban accounts must be 10 digit numbers"):i.push("Invalid bank type. Please check BankAccount.types for the list of valid bank types"),{isValid:0===i.length,errors:i}}static isValidNubanAccount(t){if(!t)return!1;return("number"==typeof t||/^\d+$/.test(t))&&10===t.length}static supportedBanks(){const t=`${na.paymentBaseUrl}bank?pay_with_bank=true`,e=Vo(),r={...e&&{"Accept-Language":e}};return _o.post(t,{headers:r}).then((t=>t.data))}}Xc.types=["nuban"];const Zc={verify(t){let{bankId:e,transactionId:r,accountNumber:n,device:i}=t;const a=`${na.paymentBaseUrl}bank/charge_account/${e}/${r}`,o=Vo(),s={"Content-Type":"application/x-www-form-urlencoded",...o&&{"Accept-Language":o}},c=Ho({account_number:n,device:i});return _o.post(a,c,{headers:s}).then((t=>aa.parse(t.data)))},register(t){let{bankId:e,transactionId:r,accountNumber:n,birthday:i}=t;const a=`${na.paymentBaseUrl}bank/charge_account/${e}/${r}`,o=Vo(),s={"Content-Type":"application/x-www-form-urlencoded",...o&&{"Accept-Language":o}},c=Ho({account_number:n,birthday:i});return _o.post(a,c,{headers:s}).then((t=>aa.parse(t.data)))},authenticate(t){let{bankId:e,transactionId:r,token:n,device:i}=t;const a=`${na.paymentBaseUrl}bank/validate_token/${e}/${r}`,o=Vo(),s={"Content-Type":"application/x-www-form-urlencoded",...o&&{"Accept-Language":o}},c=Ho({device:i,token:n});return _o.post(a,c,{headers:s}).then((t=>aa.parse(t.data)))}},Jc="bank account";function Yc(t,e){return new Promise(((r,n)=>{const i=Xc.validate(t);if(!i.isValid){const r=e||t.accountNumber?i.errors[0]:"Please set a valid bank account with Transaction.setBank()";n(Error(r))}r()}))}const Qc={charge(t){let{bankId:e,transactionId:r,phoneNumber:n,token:i,accountNumber:a}=t;const o=`${na.paymentBaseUrl}bank/digitalbankmandate/${e}/${r}`,s=Vo(),c={"Content-Type":"application/x-www-form-urlencoded",...s&&{"Accept-Language":s}},u={..."sterling-bank"==={16:"sterling-bank",62:"kuda-bank"}[e]?{account_number:a}:{phone_number:n},token:i},h=Ho(u);return _o.post(o,h,{headers:c}).then((t=>aa.parse(t.data)))}},tu="bank",eu={chargeDigitalBankMandate(t){let{phoneNumber:e,token:r,bankId:n,accountNumber:i}=t;const a={transactionId:this.id,phoneNumber:e,token:r,bankId:n,accountNumber:i};return Qc.charge(a).then((t=>(this.logAPIResponse(t,tu),t)))},listenForDigitalBankMandateCharge(t){const e={paymentMethod:tu,channel:arguments.length>1&&void 0!==arguments[1]?arguments[1]:""};return this.listenForCharge(e,t)}},ru={...{setBankAccount(t){return Yc(t,!0).then((()=>{this.bankAccount=new Xc(t)}))},chargeBankAccount(){return Yc(this.bankAccount).then((()=>{this.logAttempt(Jc);const t={bankId:this.bankAccount.bankId,transactionId:this.id,accountNumber:this.bankAccount.accountNumber,device:this.deviceFingerprint};return Zc.verify(t).then((t=>(this.logAPIResponse(t,Jc),t)))}))},registerBankAccount(t){return Yc(this.bankAccount).then((()=>{const e={bankId:this.bankAccount.bankId,transactionId:this.id,accountNumber:this.bankAccount.accountNumber,birthday:t};return Zc.register(e).then((t=>(this.logAPIResponse(t,Jc),t)))}))},authenticateBankAccount(t){return Yc(this.bankAccount).then((()=>{const e={bankId:this.bankAccount.bankId,transactionId:this.id,token:t,device:this.deviceFingerprint};return Zc.authenticate(e).then((t=>(this.logAPIResponse(t,Jc),t)))}))}},...{getIbankUrl(t){let{bankId:e}=t;return new Promise(((t,r)=>{e||r(Error("Please send bankId"));const n=`${na.paymentBaseUrl}bank/ibank/${e}/${this.id}`;t(aa.success({url:n}))}))},listenForIbankCharge(t){const e={channel:`IBANK_${this.id}`,paymentMethod:"ibank"};return this.listenForCharge(e,t)}},...eu},nu={generateShortcode(t,e){const r=Vo(),n={Authorization:`Bearer ${e}`,...r&&{"Accept-Language":r}};return _o.post(`${na.paystackApiUrl}checkout/ussd/reference`,t,{headers:n}).then((t=>aa.parse(t.data)))},generatePWTUSSDShortcode(t,e){const r=Vo(),n={Authorization:`Bearer ${e}`,...r&&{"Accept-Language":r}};return _o.post(`${na.paystackApiUrl}checkout/pay_with_transfer_ussd`,t,{headers:n}).then((t=>aa.parse(t.data)))}};var iu={getUSSDShortcode(t){let{channel:e}=t;const r={transaction:this.id,channel:e};return nu.generateShortcode(r,this.merchant.key).then((t=>("success"===t.status&&(this.ussd[e]=t),t)))},getPWTUSSDShortcode(t){let{bankSlug:e,fulfilLateNotification:r=!1}=t;const n={transaction_id:this.id,fulfil_late_notification:r,bank_slug:e};return nu.generatePWTUSSDShortcode(n,this.merchant.key).then((t=>("success"===t.status&&(this.ussd[e]=t),t)))},listenForPWTUSSDCharge(t,e){let{bankSlug:r}=t;if(!this.ussd[r])return Promise.reject(Error("Please generate a ussd shortcode with Transaction.getPWTUSSDShortcode()"));const{data:n}=this.ussd[r],i={channel:n.pusher_channel,paymentMethod:"ussd"};return this.listenForCharge(i,e)},listenForUSSDCharge(t,e){let{channel:r}=t;if(!this.ussd[r])return Promise.reject(Error("Please generate a ussd shortcode with Transaction.getUSSDShortcode()"));const{data:n}=this.ussd[r],i={channel:n.channel,paymentMethod:r};return this.listenForCharge(i,e)}};const au={generateQrCode(t,e){let{transaction:r,channel:n}=t;const i={source:"checkout",reference:r,channel:n},a=Vo(),o={Authorization:`Bearer ${e}`,...a&&{"Accept-Language":a}};return _o.post(`${na.paystackApiUrl}offline/qr/generate`,i,{headers:o}).then((t=>aa.parse(t.data)))}};function ou(t){return new Promise(((e,r)=>{const n=["visa","MPASS_OLTI"];if(n.indexOf(t)<=-1){const t=`Invalid channel. Available channels: ${n.join(", ")}`;r(Error(t))}else e()}))}var su={getQRCode(t){let{channel:e}=t;return ou(e).then((()=>{if(this.qr[e])return this.qr[e];const t={transaction:this.id,channel:e};return au.generateQrCode(t,this.merchant.key).then((t=>("success"===t.status&&(this.qr[e]=t),t)))}))},listenForQRCharge(t,e){let{channel:r}=t;return ou(r).then((()=>{if(!this.qr[r])return Promise.reject(Error("Please generate qr code with Transaction.getQRCode()"));const{data:t}=this.qr[r],n={channel:t.channel,paymentMethod:r};return this.listenForCharge(n,e)}))}};class cu{static hasCountryCode(t){return t&&"+"===t[0]}static hasOnlyDigits(t){return t&&(e=t.substring(1),/^\d+$/.test(e));var e}static isE164Number(t){return t&&t.length<17}static validate(t){const e=[];return cu.hasCountryCode(t)||e.push("Number should include country code prefix"),cu.hasOnlyDigits(t)||e.push("Number should contain only digits"),cu.isE164Number(t)||e.push("Number should not be longer than 16 digits"),{isValid:0===e.length,errors:e}}}const uu={charge(t){let{transaction:e,phone:r,device:n,channel_name:i,provider:a,voucher:o,registrationToken:s}=t;const c={transaction:e,phone:r,device:n,channel_name:i,provider:a,voucher:o,registration_token:s},u=Vo(),h={...u&&{"Accept-Language":u}};return _o.post(`${na.paystackApiUrl}charge/mobile_money`,c,{headers:h}).then((t=>aa.parse(t.data)))}};var hu={chargeMobileMoney(t){let{phoneNumber:e,provider:r,voucher:n,registrationToken:i}=t;return function(t){return new Promise(((e,r)=>{const n=cu.validate(t);if(!n.isValid){const e=t?n.errors[0]:"Please start a mobile money transaction with Transaction.chargeMobileMoney()";r(Error(e))}e(n)}))}(e).then((()=>{this.logAttempt("mobile money");const t={provider:r,voucher:n,registrationToken:i,transaction:this.id,phone:e,device:this.deviceFingerprint,channel_name:`MOBILE_MONEY_${this.id}`};return uu.charge(t).then((t=>("success"===t.status&&(this.mobileMoney=t),t)))}))},listenForMobileMoneyCharge(t){if("success"!==this.mobileMoney.status)return Promise.reject(Error("Please start a mobile money charge with Transaction.chargeMobileMoney()"));const{channel:e,channel_name:r}=this.mobileMoney.data,n={channel:e||r,paymentMethod:"mobile_money"};return this.listenForCharge(n,t)}};const lu={verify(t,e){const r=`${na.paystackApiUrl}checkout/pay_with_phone/verify`,n=Vo(),i={Authorization:`Bearer ${e}`,...n&&{"Accept-Language":n}};return _o.post(r,{phone:t},{headers:i}).then((t=>t.data))},deleteCard(t,e,r){const n=`${na.paystackApiUrl}checkout/pay_with_phone/remove_card`,i=Vo(),a={Authorization:`Bearer ${e}`,...i&&{"Accept-Language":i}};return _o.post(n,{phone:t,id:r},{headers:a}).then((t=>t.data))},authenticateOtp(t,e,r,n){const i=`${na.paystackApiUrl}checkout/pay_with_phone/validate_otp`,a=Vo(),o={Authorization:`Bearer ${e}`,...a&&{"Accept-Language":a}};return _o.post(i,{phone:t,otp:r,transaction:n},{headers:o}).then((t=>t.data))},authenticatePin(t,e,r,n){const i=`${na.paystackApiUrl}checkout/pay_with_phone/validate_pin`,a=Vo(),o={Authorization:`Bearer ${e}`,...a&&{"Accept-Language":a}};return _o.post(i,{phone:t,pin:r,transaction:n},{headers:o}).then((t=>t.data))},setPin(t,e,r,n,i){const a=Vo(),o=`${na.paystackApiUrl}checkout/pay_with_phone/set_pin`,s={Authorization:`Bearer ${e}`,...a&&{"Accept-Language":a}};return _o.post(o,{phone:t,token:r,transaction:n,pin:i},{headers:s}).then((t=>t.data))},charge(t,e,r,n,i,a){const o=`${na.paystackApiUrl}checkout/pay_with_phone/charge`,s=Vo(),c={Authorization:`Bearer ${e}`,...s&&{"Accept-Language":s}};return _o.post(o,{id:t,token:r,cvv:i,transaction:n,phone:a},{headers:c}).then((t=>t.data))},enrollPhoneNumber(t,e,r){const n=`${na.paystackApiUrl}checkout/pay_with_phone/enroll`,i=Vo(),a={Authorization:`Bearer ${e}`,...i&&{"Accept-Language":i}};return _o.post(n,{phone:t,transaction:r},{headers:a}).then((t=>t.data))}};function du(t){return new Promise(((e,r)=>{const n=cu.validate(t);if(!n.isValid){const e=t?n.errors[0]:"Please set a valid customer with Transaction.setCustomer()";r(Error(e))}e(n)}))}var pu={setCustomer(t){let{phoneNumber:e}=t;return du(e).then((()=>{this.customer=e}))},verifyCustomer(){return du(this.customer).then((()=>lu.verify(this.customer,this.merchant.key)))},deleteSavedCard(t){return du(this.customer).then((()=>lu.deleteCard(this.customer,this.merchant.key,t)))},authenticateCustomerOtp(t){return du(this.customer).then((()=>lu.authenticateOtp(this.customer,this.merchant.key,t,this.id)))},authenticateCustomerPin(t){return du(this.customer).then((()=>lu.authenticatePin(this.customer,this.merchant.key,t,this.id)))},setCustomerPin(t){let{pin:e,token:r}=t;return du(this.customer).then((()=>lu.setPin(this.customer,this.merchant.key,r,this.id,e)))},chargeSavedCard(t){let{cardId:e,token:r,cvv:n}=t;return du(this.customer).then((()=>lu.charge(e,this.merchant.key,r,this.id,n,this.customer)))},enrollPhoneNumber(t){return du(this.customer).then((()=>lu.enrollPhoneNumber(t,this.merchant.key,this.id)))}};const fu={loginToDirectDebitAccount(t){let{email:e,password:r}=t;const n={email:e,password:r},i=Vo(),a={...i&&{"Accept-Language":i}};return _o.post(`${na.paystackApiUrl}login`,n,{headers:a}).then((t=>aa.parse(t.data)))},charge(t){let{account_code:e,transaction:r,token:n}=t;const i=Vo(),a={Authorization:`Bearer ${n}`,"jwt-auth":!0,...i&&{"Accept-Language":i}},o={account_code:e,transaction:r};return _o.post(`${na.paystackApiUrl}directdebit/initiate`,o,{headers:a}).then((t=>aa.parse(t.data)))},authenticate(t){let{otp:e,transaction:r,token:n}=t;const i=Vo(),a={Authorization:`Bearer ${n}`,"jwt-auth":!0,...i&&{"Accept-Language":i}},o={otp:e,transaction:r};return _o.post(`${na.paystackApiUrl}directdebit/validate`,o,{headers:a}).then((t=>aa.parse(t.data)))},getProvisionedAccounts(t){const e=Vo(),r={Authorization:`Bearer ${t}`,"jwt-auth":!0,...e&&{"Accept-Language":e}};return _o.get(`${na.paystackApiUrl}directdebit/account`,{headers:r}).then((t=>t.data))}},gu="direct debit";var mu={loginToDirectDebitAccount(t){let{email:e,password:r}=t;const n={email:e,password:r};return qi(e)?fu.loginToDirectDebitAccount(n).then((t=>{if("success"===t.status){const{data:{token:e,user:{permissions:r}}}=t;if(!r||r.length<1)throw Error("You do not have the privileges to perform this action");if(r.find((t=>"directdebit-*"===t)))return this.directDebit.token=e,t;throw Error("You do not have the privileges to perform this action")}return t})):Promise.reject(Error("Invalid email"))},chargeDirectDebit(t){if(!this.directDebit.token)return Promise.reject(Error("Please login with Transaction.loginToDirectDebitAccount() to start a Direct debit charge"));this.logAttempt(gu);const e={account_code:t,transaction:this.id,token:this.directDebit.token};return fu.charge(e).then((t=>(this.logAPIResponse(t,gu),t.status&&(this.directDebit.chargeResponse=t),t)))},getProvisionedAccounts(){return fu.getProvisionedAccounts(this.directDebit.token).then((t=>{this.logAPIResponse(t,gu);const{status:e,data:r}=t;if(e){if(r&&r.length<1)return Promise.reject(Error("You have not provisioned any bank account for Direct Debit yet"));this.directDebit.accounts=t.data}return t}))},authenticateAccount(t){const e={otp:t,transaction:this.id,token:this.directDebit.token};return fu.authenticate(e).then((t=>(this.logAPIResponse(t,gu),t)))}},yu={get:t=>({card:Wc,bank:ru,ussd:iu,qr:su,mobile_money:hu,phone:pu,direct_debit:mu,bank_transfer:Fo,eft:Ko,payattitude:Go,apple_pay:Zo,paypal:Qo}[t])},vu=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)))};const bu={saveLog(t,e,r){const n=`${na.paystackApiUrl}transaction/update_log/${t}`,i=Vo(),a={Authorization:`Bearer ${e}`,...i&&{"Accept-Language":i}};return _o.post(n,{payload:JSON.stringify(r)},{headers:a}).then((t=>t.data))},getIp(){const t=Vo(),e={...t&&{"Accept-Language":t}};return _o.get("https://api.paystack.co/decision/ip",{headers:e}).then((t=>t.data.data.ip_address))},saveIp(t,e){const r=`${na.paystackApiUrl}transaction/set_ip/${t}`,n=Vo(),i={Authorization:`Bearer ${e}`,...n&&{"Accept-Language":n}};return _o.post(r,null,{headers:i}).then((t=>t.data))},saveReferrer(t,e,r){const n=`${na.paystackApiUrl}transaction/set_referrer/${t}`,i=Vo(),a={Authorization:`Bearer ${e}`,...i&&{"Accept-Language":i}};return _o.post(n,{referrer:r},{headers:a}).then((t=>t.data))}};var Tu={initializeLog(t){const{attempts:e,authentication:r,errors:n,history:i}=t||{};this.log={start_time:Math.round(Date.now()/1e3),time_spent:0,attempts:e||0,authentication:r,errors:n||0,success:!1,mobile:vu(),input:[],history:i||[]}},getTimeSpent(){const t=Math.round(Date.now()/1e3);return this.log.time_spent=t-this.log.start_time,this.log.time_spent},logPageOpen(){return this.log.history.push({type:"open",message:"Opened checkout",time:this.getTimeSpent()}),this.saveLog()},logChannelSwitch(t){return this.log.history.push({type:"action",message:`Set payment method to: ${t}`,time:this.getTimeSpent()}),this.saveLog()},logValidationErrors(t){return t.forEach((t=>{this.log.history.push({type:"error",message:`Invalid ${t}`,time:this.getTimeSpent()})})),this.saveLog()},logInput(t){const e=this.log.history.find((e=>e.message===`Filled this field: ${t}`));return this.log.history.push({type:"input",message:`${e?"Changed":"Filled"} this field: ${t}`,time:this.getTimeSpent()}),this.saveLog()},logBankSelect(t){return this.log.history.push({type:"action",message:`Selected bank: ${t}`,time:this.getTimeSpent()}),this.saveLog()},logAuthWindowOpen(){return this.log.history.push({type:"action",message:"Third-party authentication window opened",time:this.getTimeSpent()}),this.saveLog()},logAuthWindowClose(){return this.log.history.push({type:"action",message:"Third-party authentication window closed",time:this.getTimeSpent()}),this.saveLog()},logAPIResponse(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}},logAPIResponseMessage(t){return this.log.history.push({type:"action",message:t,time:this.getTimeSpent()}),this.saveLog()},logAttempt(t){let e="Attempted to pay";return t&&(e+=` with ${t}`),this.log.attempts+=1,this.log.history.push({type:"action",message:e,time:this.getTimeSpent()}),this.saveLog()},logError(t){let e="Error";return t&&(e+=`: ${t}`),this.log.errors+=1,this.log.history.push({type:"error",message:e,time:this.getTimeSpent()}),this.saveLog()},logAuth(t){return this.log.authentication=t,this.log.history.push({type:"auth",message:`Authentication Required: ${t}`,time:this.getTimeSpent()}),this.saveLog()},logSuccess(t){let e="Successfully paid";return t&&(e+=` with ${t}`),this.log.success=!0,this.log.history.push({type:"success",message:e,time:this.getTimeSpent()}),this.saveLog()},logPending(t){let e="Payment in progress";return t&&(e+=` with ${t}`),this.log.history.push({type:"pending",message:e,time:this.getTimeSpent()}),this.saveLog()},logPageClose(){return this.log.history.push({type:"close",message:"Closed checkout",time:this.getTimeSpent()}),this.saveLog()},saveLog(){return bu.saveLog(this.id,this.merchant.key,this.log)},saveIpAddress(){return bu.saveIp(this.id,this.merchant.key)},saveReferrer(t){return bu.saveReferrer(this.id,this.merchant.key,t)}};class wu{constructor(t){this.email=t.email,this.merchant={id:t.merchant_id,logo:t.merchant_logo,name:t.merchant_name,key:t.merchant_key,channelSettings:t.merchant_channel_settings||{}},this.status=t.transaction_status||t.status,this.accessCode=t.access_code,this.amount=t.amount,this.domain=t.domain,this.isTest="test"===t.domain,this.currency=t.currency,this.id=t.id,this.channels=["apple_pay"].concat(t.channels),this.label=t.label,this.metadata=t.metadata||{},this.cancel_action=t.cancel_action||null,this.channel_options=t.channel_options||null,this.hash=t.hash||null,this.authorizations=t.authorizations,this.remember_card=!1,this.rememberMeEnabled=t.is_remember_me_enabled,this.card={},this.bankAccount={},this.mobileMoney={},this.ussd={},this.bankTransfer={},this.qr={},this.directDebit={},this.deviceFingerprint=t.deviceFingerprint||null,this.customer=t.customer,this.custom_filters=t.custom_filters||null,this.isCharging=!1,this.isListening=!1,this.transactionType=t.transaction_type||null,this.elevyPercentage=t.elevy_percentage||null,this.subscription=t.subscription||null,this.planDetails=t.plan_details||null,window?new Promise(((t,e)=>{const r=new XMLHttpRequest;r.open("GET",na.pusherUrl),r.onload=()=>{if(r.status>=200&&r.status<300){const e=document.createElement("script");e.appendChild(document.createTextNode(r.responseText)),document.head.appendChild(e),t()}else e(r.statusText)},r.onerror=()=>e(r.statusText),r.send(null)})):Promise.reject(new Error("Window object not available")),this.log=null,Object.assign(this,Tu),this.initializeLog(t.log),this.saveIpAddress(),this.channels.forEach((t=>{const e=yu.get(t);Object.assign(this,e)})),this.channels.includes("ussd")&&!this.channels.includes("bank_transfer")&&Object.assign(this,yu.get("bank_transfer")),"GHS"===t.currency&&t.elevy_percentage&&(this.elevyPercentage=t.elevy_percentage)}setMetadata(t,e){this.metadata[t]=e}setDevice(t){this.deviceFingerprint?Ji("Device ID has already been set by Checkout JS so there's no need to set this again"):this.deviceFingerprint=t}listenForCharge(t,e){const{channel:r,paymentMethod:n}=t;let i;window&&window.Pusher&&(i=new window.Pusher(na.pusherKey,{cluster:"eu",disableStats:!0}));const a={status:"error",message:"We could not listen for charge response. Use transaction.requery() to check the status."},o=()=>{i.unsubscribe(r)};if(!i)return e({status:"error",message:"We could not listen for charge response."},ia);const s=i.subscribe(r);s.bind("pusher:subscription_succeeded",(()=>{this.isListening=!0})),s.bind("pusher:subscription_error",(()=>{this.isListening=!1,e(a,ia)})),s.bind("response",(t=>{const r=aa.parse(t);this.logAPIResponse(r,n),e(r,o)}))}requery(){return jo.requery(this.id)}markAsAbandoned(){return jo.markAsAbandoned({publicKey:this.merchant.key,transactionId:this.id})}}const Su={validate(t){const e=function(t){const e=[];return t&&"object"==typeof t?(Object.keys(zi).forEach((r=>{const n=zi[r],i=t[r];!n.required||i||t[n.fallback]?i&&!n.isValid(i)&&e.push({field:r,message:`Invalid field: ${r}`}):e.push({field:r,message:`Required field: ${r}`})})),e):(e.push({message:"Please supply a valid object"}),e)}(t);if(e.length){const[{message:t}]=e;throw new Fi(e,t)}},async request(t){const e=await Yi(),r=await jo.requestInline({...t,device:e});return r&&Object.seal(new wu({...r.data,deviceFingerprint:e}))},async requestWithAccessCode(t){const e=await Yi(),r=await jo.requestStandard(t);return r&&Object.seal(new wu({...r.data,deviceFingerprint:e}))},async getByAccessCode(t,e){const r=await Yi(),n=await jo.getByAccessCode(t,e);return n&&Object.seal(new wu({...n.data,deviceFingerprint:r}))},initialize:t=>Object.seal(new wu(t)),async verify(t){const e=await jo.verify(t);return e&&e.data}},Au={fetchBanks(t){const e=`${na.paystackApiUrl}bank`,r=Vo(),n={params:t,headers:{...r&&{"Accept-Language":r}}};return _o.get(e,n).then((t=>t.data))},fetchResolutions(){const t=`${na.paystackApiUrl}checkout/resolutions`,e=Vo(),r={...e&&{"Accept-Language":e}};return _o.get(t,{headers:r}).then((t=>t.data))},fetchCelebrations(){const t=`${na.paystackApiUrl}checkout/celebrations`,e=Vo(),r={...e&&{"Accept-Language":e}};return _o.get(t,{headers:r}).then((t=>t.data))},fetchStates(t){const e=`${na.paystackApiUrl}address_verification/states`,r=Vo(),n={params:t,headers:{...r&&{"Accept-Language":r}}};return _o.get(e,n).then((t=>t.data))}};return t.BankAccount=Xc,t.Card=$c,t.Toolkit=class{static contents(){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"}]}static fetch(t,e){if(this.contents().map((t=>t.key)).indexOf(t)<=-1)throw new Error("Please provide a valid config key. Use Toolkit.contents() to see available options.");let r;switch(t){case"banks":r=Au.fetchBanks(e||{pay_with_bank:"1"});break;case"resolutions":r=Au.fetchResolutions();break;case"celebrations":r=Au.fetchCelebrations();break;case"states":r=Au.fetchStates(e)}return r}},t.Transaction=Su,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
16
+ var Ys={};void 0!==Ys.asn1&&Ys.asn1||(Ys.asn1={}),Ys.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 xs(n,16).xor(t).add(xs.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=Ys.asn1,r=e.DERBoolean,n=e.DERInteger,i=e.DERBitString,a=e.DEROctetString,o=e.DERNull,s=e.DERObjectIdentifier,c=e.DEREnumerated,u=e.DERUTF8String,h=e.DERNumericString,l=e.DERPrintableString,d=e.DERTeletexString,p=e.DERIA5String,f=e.DERUTCTime,g=e.DERGeneralizedTime,m=e.DERSequence,y=e.DERSet,v=e.DERTaggedObject,b=e.ASN1Util.newObject,T=Object.keys(t);if(1!=T.length)throw"key of param shall be only one.";var w=T[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+w+":"))throw"undefined key: "+w;if("bool"==w)return new r(t[w]);if("int"==w)return new n(t[w]);if("bitstr"==w)return new i(t[w]);if("octstr"==w)return new a(t[w]);if("null"==w)return new o(t[w]);if("oid"==w)return new s(t[w]);if("enum"==w)return new c(t[w]);if("utf8str"==w)return new u(t[w]);if("numstr"==w)return new h(t[w]);if("prnstr"==w)return new l(t[w]);if("telstr"==w)return new d(t[w]);if("ia5str"==w)return new p(t[w]);if("utctime"==w)return new f(t[w]);if("gentime"==w)return new g(t[w]);if("seq"==w){for(var S=t[w],A=[],E=0;E<S.length;E++){var x=b(S[E]);A.push(x)}return new m({array:A})}if("set"==w){for(S=t[w],A=[],E=0;E<S.length;E++){x=b(S[E]);A.push(x)}return new y({array:A})}if("tag"==w){var k=t[w];if("[object Array]"===Object.prototype.toString.call(k)&&3==k.length){var C=b(k[2]);return new v({tag:k[0],explicit:k[1],obj:C})}var B={};if(void 0!==k.explicit&&(B.explicit=k.explicit),void 0!==k.tag&&(B.tag=k.tag),void 0===k.obj)throw"obj shall be specified for 'tag'.";return B.obj=b(k.obj),new v(B)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},Ys.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 a=("00000000"+parseInt(t.substr(i,2),16).toString(2)).slice(-8);if(n+=a.substr(1,7),"0"==a.substr(0,1))e=e+"."+new xs(n,2).toString(10),n=""}return e},Ys.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 xs(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var a="",o=0;o<i;o++)a+="0";n=a+n;for(o=0;o<n.length-1;o+=7){var s=n.substr(o,7);o!=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("."),a=40*parseInt(i[0])+parseInt(i[1]);n+=e(a),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);return n},Ys.asn1.ASN1Object=function(){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="+"".length+",v="+this.hV;var t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var r=e.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+r).toString(16)+e},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""}},Ys.asn1.DERAbstractString=function(t){Ys.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))},Js.lang.extend(Ys.asn1.DERAbstractString,Ys.asn1.ASN1Object),Ys.asn1.DERAbstractTime=function(t){Ys.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),a=String(i.getFullYear());"utc"==e&&(a=a.substr(2,2));var o=a+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 c=n(String(s),3);o=o+"."+(c=c.replace(/[0]+$/,""))}}return o+"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,a){var o=new Date(Date.UTC(t,e-1,r,n,i,a,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},Js.lang.extend(Ys.asn1.DERAbstractTime,Ys.asn1.ASN1Object),Ys.asn1.DERAbstractStructured=function(t){Ys.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)},Js.lang.extend(Ys.asn1.DERAbstractStructured,Ys.asn1.ASN1Object),Ys.asn1.DERBoolean=function(){Ys.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},Js.lang.extend(Ys.asn1.DERBoolean,Ys.asn1.ASN1Object),Ys.asn1.DERInteger=function(t){Ys.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=Ys.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new xs(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))},Js.lang.extend(Ys.asn1.DERInteger,Ys.asn1.ASN1Object),Ys.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=Ys.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}Ys.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),a=parseInt(i,2).toString(16);1==a.length&&(a="0"+a),n+=a}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))},Js.lang.extend(Ys.asn1.DERBitString,Ys.asn1.ASN1Object),Ys.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=Ys.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}Ys.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},Js.lang.extend(Ys.asn1.DEROctetString,Ys.asn1.DERAbstractString),Ys.asn1.DERNull=function(){Ys.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Js.lang.extend(Ys.asn1.DERNull,Ys.asn1.ASN1Object),Ys.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 xs(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var a="",o=0;o<i;o++)a+="0";n=a+n;for(o=0;o<n.length-1;o+=7){var s=n.substr(o,7);o!=n.length-7&&(s="1"+s),r+=e(parseInt(s,2))}return r};Ys.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("."),a=40*parseInt(i[0])+parseInt(i[1]);n+=e(a),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=n},this.setValueName=function(t){var e=Ys.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))},Js.lang.extend(Ys.asn1.DERObjectIdentifier,Ys.asn1.ASN1Object),Ys.asn1.DEREnumerated=function(t){Ys.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=Ys.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new xs(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))},Js.lang.extend(Ys.asn1.DEREnumerated,Ys.asn1.ASN1Object),Ys.asn1.DERUTF8String=function(t){Ys.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},Js.lang.extend(Ys.asn1.DERUTF8String,Ys.asn1.DERAbstractString),Ys.asn1.DERNumericString=function(t){Ys.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},Js.lang.extend(Ys.asn1.DERNumericString,Ys.asn1.DERAbstractString),Ys.asn1.DERPrintableString=function(t){Ys.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},Js.lang.extend(Ys.asn1.DERPrintableString,Ys.asn1.DERAbstractString),Ys.asn1.DERTeletexString=function(t){Ys.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},Js.lang.extend(Ys.asn1.DERTeletexString,Ys.asn1.DERAbstractString),Ys.asn1.DERIA5String=function(t){Ys.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},Js.lang.extend(Ys.asn1.DERIA5String,Ys.asn1.DERAbstractString),Ys.asn1.DERUTCTime=function(t){Ys.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))},Js.lang.extend(Ys.asn1.DERUTCTime,Ys.asn1.DERAbstractTime),Ys.asn1.DERGeneralizedTime=function(t){Ys.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))},Js.lang.extend(Ys.asn1.DERGeneralizedTime,Ys.asn1.DERAbstractTime),Ys.asn1.DERSequence=function(t){Ys.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}},Js.lang.extend(Ys.asn1.DERSequence,Ys.asn1.DERAbstractStructured),Ys.asn1.DERSet=function(t){Ys.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)},Js.lang.extend(Ys.asn1.DERSet,Ys.asn1.DERAbstractStructured),Ys.asn1.DERTaggedObject=function(t){Ys.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)))},Js.lang.extend(Ys.asn1.DERTaggedObject,Ys.asn1.ASN1Object);var Qs,tc=(Qs=function(t,e){return Qs=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},Qs(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}Qs(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),ec=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 tc(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)?ds(t):ps.unarmor(t),i=ws.decode(n);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){e=i.sub[1].getHexStringValue(),this.n=Ps(e,16),r=i.sub[2].getHexStringValue(),this.e=parseInt(r,16);var a=i.sub[3].getHexStringValue();this.d=Ps(a,16);var o=i.sub[4].getHexStringValue();this.p=Ps(o,16);var s=i.sub[5].getHexStringValue();this.q=Ps(s,16);var c=i.sub[6].getHexStringValue();this.dmp1=Ps(c,16);var u=i.sub[7].getHexStringValue();this.dmq1=Ps(u,16);var h=i.sub[8].getHexStringValue();this.coeff=Ps(h,16)}else{if(2!==i.sub.length)return!1;if(i.sub[0].sub){var l=i.sub[1].sub[0];e=l.sub[0].getHexStringValue(),this.n=Ps(e,16),r=l.sub[1].getHexStringValue(),this.e=parseInt(r,16)}else e=i.sub[0].getHexStringValue(),this.n=Ps(e,16),r=i.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}},e.prototype.getPrivateBaseKey=function(){var t={array:[new Ys.asn1.DERInteger({int:0}),new Ys.asn1.DERInteger({bigint:this.n}),new Ys.asn1.DERInteger({int:this.e}),new Ys.asn1.DERInteger({bigint:this.d}),new Ys.asn1.DERInteger({bigint:this.p}),new Ys.asn1.DERInteger({bigint:this.q}),new Ys.asn1.DERInteger({bigint:this.dmp1}),new Ys.asn1.DERInteger({bigint:this.dmq1}),new Ys.asn1.DERInteger({bigint:this.coeff})]};return new Ys.asn1.DERSequence(t).getEncodedHex()},e.prototype.getPrivateBaseKeyB64=function(){return us(this.getPrivateBaseKey())},e.prototype.getPublicBaseKey=function(){var t=new Ys.asn1.DERSequence({array:[new Ys.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new Ys.asn1.DERNull]}),e=new Ys.asn1.DERSequence({array:[new Ys.asn1.DERInteger({bigint:this.n}),new Ys.asn1.DERInteger({int:this.e})]}),r=new Ys.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new Ys.asn1.DERSequence({array:[t,r]}).getEncodedHex()},e.prototype.getPublicBaseKeyB64=function(){return us(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}(Xs),rc=process.env.npm_package_version,nc=function(){function t(t){void 0===t&&(t={}),t=t||{},this.default_key_size=t.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 ec(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(hs(t))}catch(t){return!1}},t.prototype.encrypt=function(t){try{return us(this.getKey().encrypt(t))}catch(t){return!1}},t.prototype.sign=function(t,e,r){try{return us(this.getKey().sign(t,e,r))}catch(t){return!1}},t.prototype.verify=function(t,e,r){try{return this.getKey().verify(t,hs(e),r)}catch(t){return!1}},t.prototype.getKey=function(t){if(!this.key){if(this.key=new ec,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=rc,t}();function ic(t){const e=new nc;return e.setPublicKey(na.publicKey),e.encrypt(t)}var ac=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 oc=function(t){return t?JSON.parse(JSON.stringify(t)):null};var sc=function(t){return"string"==typeof t||t instanceof String};var cc=function(t,e){return Array.isArray(e)?function(t,e,r){var n=String(e).length,i=t.substr(0,n),a=parseInt(i,10);return e=parseInt(String(e).substr(0,i.length),10),r=parseInt(String(r).substr(0,i.length),10),a>=e&&a<=r}(t,e[0],e[1]):function(t,e){return(e=String(e)).substring(0,t.length)===t.substring(0,e.length)}(t,e)},uc=oc,hc=cc;var lc,dc=function(t,e,r){var n,i,a,o;for(n=0;n<e.patterns.length;n++)if(i=e.patterns[n],hc(t,i)){o=uc(e),a=Array.isArray(i)?String(i[0]).length:String(i).length,t.length>=a&&(o.matchStrength=a),r.push(o);break}},pc={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,810,[8110,8131],[8132,8151],[8152,8163],[8164,8171]],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}}},fc=oc,gc=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}))},mc=sc,yc=dc,vc={},bc={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"},Tc=[bc.VISA,bc.MASTERCARD,bc.AMERICAN_EXPRESS,bc.DINERS_CLUB,bc.DISCOVER,bc.JCB,bc.UNIONPAY,bc.MAESTRO,bc.ELO,bc.MIR,bc.HIPER,bc.HIPERCARD];function wc(t){return vc[t]||pc[t]}function Sc(t,e){var r=lc.indexOf(t);if(!e&&-1===r)throw new Error('"'+t+'" is not a supported card type.');return r}function Ac(t){var e,r=[];return mc(t)?0===t.length?lc.map((function(t){return fc(wc(t))})):(lc.forEach((function(e){var n=wc(e);yc(t,n,r)})),(e=gc(r))?[e]:r):[]}lc=fc(Tc),Ac.getTypeInfo=function(t){return fc(wc(t))},Ac.removeCard=function(t){var e=Sc(t);lc.splice(e,1)},Ac.addCard=function(t){var e=Sc(t.type,!0);vc[t.type]=t,-1===e&&lc.push(t.type)},Ac.updateCard=function(t,e){var r,n=vc[t]||pc[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=fc(n),Object.keys(r).forEach((function(t){e[t]&&(r[t]=e[t])})),vc[r.type]=r},Ac.changeOrder=function(t,e){var r=Sc(t);lc.splice(r,1),lc.splice(e,0,t)},Ac.resetModifications=function(){lc=fc(Tc),vc={}},Ac.types=bc;var Ec=Ac,xc=ac,kc=Ec;function Cc(t,e,r){return{card:t,isPotentiallyValid:e,isValid:r}}var Bc=function(t,e){var r,n,i,a,o;if(e=e||{},"number"==typeof t&&(t=String(t)),"string"!=typeof t)return Cc(null,!1,!1);if(t=t.replace(/\-|\s/g,""),!/^\d*$/.test(t))return Cc(null,!1,!1);if(0===(r=kc(t)).length)return Cc(null,!1,!1);if(1!==r.length)return Cc(null,!0,!1);if(n=r[0],e.maxLength&&t.length>e.maxLength)return Cc(n,!1,!1);for(i=n.type===kc.types.UNIONPAY&&!0!==e.luhnValidateUnionPay||xc(t),o=Math.max.apply(null,n.lengths),e.maxLength&&(o=Math.min(e.maxLength,o)),a=0;a<n.lengths.length;a++)if(n.lengths[a]===t.length)return Cc(n,t.length<o||i,i);return Cc(n,t.length<o,!1)};function Oc(t,e,r){return{isValid:t,isPotentiallyValid:e,isCurrentYear:r||!1}}var Dc=function(t,e){var r,n,i,a,o;return e=e||19,"string"!=typeof t?Oc(!1,!1):""===t.replace(/\s/g,"")?Oc(!1,!0):/^\d*$/.test(t)?(n=t.length)<2?Oc(!1,!0):(r=(new Date).getFullYear(),3===n?Oc(!1,t.slice(0,2)===String(r).slice(0,2)):n>4?Oc(!1,!1):(t=parseInt(t,10),i=Number(String(r).substr(2,2)),2===n?(o=i===t,a=t>=i&&t<=i+e):4===n&&(o=r===t,a=t>=r&&t<=r+e),Oc(a,a,o))):Oc(!1,!1)},Pc=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},Rc=Dc,Ic=Pc;function Nc(t,e,r){return{isValid:t,isPotentiallyValid:e,isValidForThisYear:r||!1}}var Lc=function(t){var e,r,n=(new Date).getMonth()+1;return"string"!=typeof t?Nc(!1,!1):""===t.replace(/\s/g,"")||"0"===t?Nc(!1,!0):/^\d*$/.test(t)?(e=parseInt(t,10),isNaN(t)?Nc(!1,!1):Nc(r=e>0&&e<13,r,r&&e>=n)):Nc(!1,!1)},Mc=function(t){var e,r,n,i,a;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)),Ic(t)?{month:t[0]||"",year:t.slice(1).join()}:(n=t,r=0===(a=Number(n[0]))?2:a>1||1===a&&Number(n[1])>2?1:1===a?(i=n.substr(1),Rc(i).isPotentiallyValid?1:2):5===n.length?1:n.length>5?2:1,{month:e=t.substr(0,r),year:t.substr(e.length)})},_c=Lc,Vc=Dc;function jc(t,e,r,n){return{isValid:t,isPotentiallyValid:e,month:r,year:n}}function Uc(t,e){return{isValid:t,isPotentiallyValid:e}}function Fc(t,e){return{isValid:t,isPotentiallyValid:e}}var qc={number:Bc,expirationDate:function(t,e){var r,n,i,a;if("string"==typeof t)t=t.replace(/^(\d\d) (\d\d(\d\d)?)$/,"$1/$2"),r=Mc(t);else{if(null===t||"object"!=typeof t)return jc(!1,!1,null,null);r={month:String(t.month),year:String(t.year)}}if(n=_c(r.month),i=Vc(r.year,e),n.isValid){if(i.isCurrentYear)return jc(a=n.isValidForThisYear,a,r.month,r.year);if(i.isValid)return jc(!0,!0,r.month,r.year)}return n.isPotentiallyValid&&i.isPotentiallyValid?jc(!1,!0,null,null):jc(!1,!1,null,null)},expirationMonth:Lc,expirationYear:Dc,cvv:function(t,e){return e=(e=e||3)instanceof Array?e:[e],"string"!=typeof t?Uc(!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)?Uc(!0,!0):t.length<Math.min.apply(null,e)?Uc(!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)?Uc(!1,!1):Uc(!0,!0):Uc(!1,!1)},postalCode:function(t,e){var r;return r=(e=e||{}).minLength||3,"string"!=typeof t?Fc(!1,!1):t.length<r?Fc(!1,!0):Fc(!0,!0)},creditCardType:Ec},Hc=[{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"}];qc.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}}),qc.creditCardType.changeOrder("verve",0);class $c{constructor(t){let{number:e,cvv:r,month:n,year:i,pin:a}=t;this.number=e,this.cvv=r,this.month=n,this.year=i,this.pin=a}getEncryptedPin(){return this.pin?ic(this.pin):void 0}getLast4(){return this.number.substring(this.number.length-4)}tokenize(){return ic(`${this.number}*${this.cvv}*${this.month}*${this.year}`)}static getType(t){const e=qc.number(t);return e&&e.card?{type:e.card.type,maxLength:Math.max(...e.card.lengths),minLength:Math.min(...e.card.lengths)}:{type:null,maxLength:0}}static validate(t){let{number:e,cvv:r,month:n,year:i}=t;const{type:a}=$c.getType(e),o={number:$c.isNumberValid(e),expiry:$c.isExpiryValid({month:n,year:i}),cvv:$c.isCvvValid(r,a)};return{isValid:Object.values(o).every((t=>!0===t)),result:o}}static validateNumber(t){return qc.number(t)}static isNumberValid(t){return $c.validateNumber(t).isValid}static validateCVV(t,e){const r="american-express"===e?4:3;return qc.cvv(t,r)}static isCvvValid(t,e){return $c.validateCVV(t,e).isValid}static validateExpiry(t){if("object"==typeof t){const{month:e,year:r}=t;return qc.expirationMonth(e)&&qc.expirationYear(r)}return qc.expirationDate(t)}static isExpiryValid(t){return $c.validateExpiry(t).isValid}static generateTestCard(t){const e=t||"default",r=Hc.find((t=>t.type===e));return new $c(r)}}const zc={charge(t){let{clientdata:e,last4:r,pin:n,trans:i,device:a,rememberCard:o,transactionType:s,subscription:c,customFields:u}=t;const h=`${na.paymentBaseUrl}charge/`,l=Vo(),d={"Content-Type":"application/x-www-form-urlencoded",...l&&{"Accept-Language":l}},p={clientdata:e,last4:r,trans:i,device:a,offset:(new Date).getTimezoneOffset(),remember_card:o,...s&&{transaction_type:s},...c&&{subscription:c},...u&&u};n&&(p.handle=n);const f=Ho(p);return _o.post(h,f,{headers:d}).then((t=>aa.parse(t.data)))},resumeCardCharge(t){let{device:e,accessCode:r,pin:n}=t;const i=`${na.paymentBaseUrl}charge/resume/${r}`,a=Vo(),o={"Content-Type":"application/x-www-form-urlencoded",...a&&{"Accept-Language":a}},s={device:e,...n&&{handle:n}},c=Ho(s);return _o.post(i,c,{headers:o}).then((t=>aa.parse(t.data)))},chargeRememberedCard(t){let{last4:e,trans:r,device:n,authorizationCode:i,cvv:a,pin:o,transactionType:s,subscription:c}=t;const u=`${na.paymentBaseUrl}charge/`,h=Vo(),l={"Content-Type":"application/x-www-form-urlencoded",...h&&{"Accept-Language":h}},d={last4:e,trans:r,device:n,cvv:a,handle:o,authorization_code:i,...s&&{transaction_type:s},...c&&{subscription:c}},p=Ho(d);return _o.post(u,p,{headers:l}).then((t=>aa.parse(t.data)))},authenticate(t,e){const r=`${na.paymentBaseUrl}charge/validate`,n={trans:t,token:e},i=Vo(),a={...i&&{"Accept-Language":i}},o=Ho(n);return _o.post(r,o,{headers:a}).then((t=>aa.parse(t.data)))},verifyAddress(t){let{address:e,city:r,state:n,zipCode:i,transactionId:a}=t;const o=`${na.paymentBaseUrl}charge/avs`,s=Vo(),c={"Content-Type":"application/x-www-form-urlencoded",...s&&{"Accept-Language":s}},u=Ho({city:r,state:n,address:e,zip_code:i,trans:a});return _o.post(o,u,{headers:c}).then((t=>aa.parse(t.data)))},forgetRememberedCard(t){let{authorizationId:e,publicKey:r}=t;const n=Vo(),i={Authorization:`Bearer ${r}`,...n&&{"Accept-Language":n}},a={authorization_id:e},o=`${na.paystackApiUrl}rememberme/forget_card`;return _o.post(o,a,{headers:i}).then((t=>aa.parse(t.data)))}},Gc="card";function Kc(t,e){return new Promise(((r,n)=>{const i=$c.validate(t);if(!i.isValid){const r=e||t.number,a=`Invalid card details: ${Object.keys(i.result).filter((t=>!1===i.result[t])).join(", ")}`;n(Error(r?a:"Please set a valid card with Transaction.setCard()"))}r()}))}var Wc={setCard(t){return Kc(t,!0).then((()=>{this.card=new $c(t)}))},rememberCard(){this.remember_card=!0},chargeCard(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Kc(this.card).then((()=>{this.logAttempt(Gc);const e={clientdata:this.card.tokenize(),last4:this.card.getLast4(),pin:this.card.getEncryptedPin(),trans:this.id,device:this.deviceFingerprint,rememberCard:this.remember_card,transactionType:this.transactionType,subscription:this.subscription,customFields:t};return zc.charge(e).then((t=>(this.logAPIResponse(t,Gc),t)))}))},chargeRememberedCard(t){let{cvv:e,authorizationCode:r,cardLast4:n,pin:i}=t;this.logAttempt(Gc);const a=ic(i),o={authorizationCode:r,cvv:e,last4:n,trans:this.id,device:this.deviceFingerprint,pin:a,transactionType:this.transactionType,subscription:this.subscription};return zc.chargeRememberedCard(o).then((t=>(this.logAPIResponse(t,Gc),t)))},resumeCardCharge(t){let{accessCode:e,pin:r}=t;const n={...r&&{pin:ic(r)},accessCode:e,device:this.deviceFingerprint};return zc.resumeCardCharge(n).then((t=>(this.logAPIResponse(t,Gc),t)))},forgetRememberedCard(t){const e={authorizationId:t,publicKey:this.merchant.key};return zc.forgetRememberedCard(e).then((t=>(this.logAPIResponse(t,Gc),t)))},authenticateCard(t){return zc.authenticate(this.id,t).then((t=>(this.logAPIResponse(t,Gc),t)))},verifyAddress(t){let{address:e,city:r,state:n,zipCode:i}=t;const a={city:r,state:n,address:e,zipCode:i,transactionId:this.id};return zc.verifyAddress(a).then((t=>(this.logAPIResponse(t,Gc),t)))},listenFor3DSCharge(t){const e={channel:`3DS_${this.id}`,paymentMethod:Gc};return this.listenForCharge(e,t)}};class Xc{constructor(t){let{bankId:e,accountType:r,accountNumber:n}=t;this.bankId=e,this.accountType=r,this.accountNumber=n}static validate(t){let{bankId:e,accountType:r,accountNumber:n}=t;const i=[];return e&&"number"==typeof e||i.push("Invalid bankId. Please check for supported banks with BankAccount.supportedBanks()"),Xc.types.indexOf(r)>-1?"nuban"!==r||Xc.isValidNubanAccount(n)||i.push("Invalid account number. Nuban accounts must be 10 digit numbers"):i.push("Invalid bank type. Please check BankAccount.types for the list of valid bank types"),{isValid:0===i.length,errors:i}}static isValidNubanAccount(t){if(!t)return!1;return("number"==typeof t||/^\d+$/.test(t))&&10===t.length}static supportedBanks(){const t=`${na.paymentBaseUrl}bank?pay_with_bank=true`,e=Vo(),r={...e&&{"Accept-Language":e}};return _o.post(t,{headers:r}).then((t=>t.data))}}Xc.types=["nuban"];const Zc={verify(t){let{bankId:e,transactionId:r,accountNumber:n,device:i}=t;const a=`${na.paymentBaseUrl}bank/charge_account/${e}/${r}`,o=Vo(),s={"Content-Type":"application/x-www-form-urlencoded",...o&&{"Accept-Language":o}},c=Ho({account_number:n,device:i});return _o.post(a,c,{headers:s}).then((t=>aa.parse(t.data)))},register(t){let{bankId:e,transactionId:r,accountNumber:n,birthday:i}=t;const a=`${na.paymentBaseUrl}bank/charge_account/${e}/${r}`,o=Vo(),s={"Content-Type":"application/x-www-form-urlencoded",...o&&{"Accept-Language":o}},c=Ho({account_number:n,birthday:i});return _o.post(a,c,{headers:s}).then((t=>aa.parse(t.data)))},authenticate(t){let{bankId:e,transactionId:r,token:n,device:i}=t;const a=`${na.paymentBaseUrl}bank/validate_token/${e}/${r}`,o=Vo(),s={"Content-Type":"application/x-www-form-urlencoded",...o&&{"Accept-Language":o}},c=Ho({device:i,token:n});return _o.post(a,c,{headers:s}).then((t=>aa.parse(t.data)))}},Jc="bank account";function Yc(t,e){return new Promise(((r,n)=>{const i=Xc.validate(t);if(!i.isValid){const r=e||t.accountNumber?i.errors[0]:"Please set a valid bank account with Transaction.setBank()";n(Error(r))}r()}))}const Qc={charge(t){let{bankId:e,transactionId:r,phoneNumber:n,token:i,accountNumber:a}=t;const o=`${na.paymentBaseUrl}bank/digitalbankmandate/${e}/${r}`,s=Vo(),c={"Content-Type":"application/x-www-form-urlencoded",...s&&{"Accept-Language":s}},u={..."sterling-bank"==={16:"sterling-bank",62:"kuda-bank"}[e]?{account_number:a}:{phone_number:n},token:i},h=Ho(u);return _o.post(o,h,{headers:c}).then((t=>aa.parse(t.data)))}},tu="bank",eu={chargeDigitalBankMandate(t){let{phoneNumber:e,token:r,bankId:n,accountNumber:i}=t;const a={transactionId:this.id,phoneNumber:e,token:r,bankId:n,accountNumber:i};return Qc.charge(a).then((t=>(this.logAPIResponse(t,tu),t)))},listenForDigitalBankMandateCharge(t){const e={paymentMethod:tu,channel:arguments.length>1&&void 0!==arguments[1]?arguments[1]:""};return this.listenForCharge(e,t)}},ru={...{setBankAccount(t){return Yc(t,!0).then((()=>{this.bankAccount=new Xc(t)}))},chargeBankAccount(){return Yc(this.bankAccount).then((()=>{this.logAttempt(Jc);const t={bankId:this.bankAccount.bankId,transactionId:this.id,accountNumber:this.bankAccount.accountNumber,device:this.deviceFingerprint};return Zc.verify(t).then((t=>(this.logAPIResponse(t,Jc),t)))}))},registerBankAccount(t){return Yc(this.bankAccount).then((()=>{const e={bankId:this.bankAccount.bankId,transactionId:this.id,accountNumber:this.bankAccount.accountNumber,birthday:t};return Zc.register(e).then((t=>(this.logAPIResponse(t,Jc),t)))}))},authenticateBankAccount(t){return Yc(this.bankAccount).then((()=>{const e={bankId:this.bankAccount.bankId,transactionId:this.id,token:t,device:this.deviceFingerprint};return Zc.authenticate(e).then((t=>(this.logAPIResponse(t,Jc),t)))}))}},...{getIbankUrl(t){let{bankId:e}=t;return new Promise(((t,r)=>{e||r(Error("Please send bankId"));const n=`${na.paymentBaseUrl}bank/ibank/${e}/${this.id}`;t(aa.success({url:n}))}))},listenForIbankCharge(t){const e={channel:`IBANK_${this.id}`,paymentMethod:"ibank"};return this.listenForCharge(e,t)}},...eu},nu={generateShortcode(t,e){const r=Vo(),n={Authorization:`Bearer ${e}`,...r&&{"Accept-Language":r}};return _o.post(`${na.paystackApiUrl}checkout/ussd/reference`,t,{headers:n}).then((t=>aa.parse(t.data)))},generatePWTUSSDShortcode(t,e){const r=Vo(),n={Authorization:`Bearer ${e}`,...r&&{"Accept-Language":r}};return _o.post(`${na.paystackApiUrl}checkout/pay_with_transfer_ussd`,t,{headers:n}).then((t=>aa.parse(t.data)))}};var iu={getUSSDShortcode(t){let{channel:e}=t;const r={transaction:this.id,channel:e};return nu.generateShortcode(r,this.merchant.key).then((t=>("success"===t.status&&(this.ussd[e]=t),t)))},getPWTUSSDShortcode(t){let{bankSlug:e,fulfilLateNotification:r=!1}=t;const n={transaction_id:this.id,fulfil_late_notification:r,bank_slug:e};return nu.generatePWTUSSDShortcode(n,this.merchant.key).then((t=>("success"===t.status&&(this.ussd[e]=t),t)))},listenForPWTUSSDCharge(t,e){let{bankSlug:r}=t;if(!this.ussd[r])return Promise.reject(Error("Please generate a ussd shortcode with Transaction.getPWTUSSDShortcode()"));const{data:n}=this.ussd[r],i={channel:n.pusher_channel,paymentMethod:"ussd"};return this.listenForCharge(i,e)},listenForUSSDCharge(t,e){let{channel:r}=t;if(!this.ussd[r])return Promise.reject(Error("Please generate a ussd shortcode with Transaction.getUSSDShortcode()"));const{data:n}=this.ussd[r],i={channel:n.channel,paymentMethod:r};return this.listenForCharge(i,e)}};const au={generateQrCode(t,e){let{transaction:r,channel:n}=t;const i={source:"checkout",reference:r,channel:n},a=Vo(),o={Authorization:`Bearer ${e}`,...a&&{"Accept-Language":a}};return _o.post(`${na.paystackApiUrl}offline/qr/generate`,i,{headers:o}).then((t=>aa.parse(t.data)))}};function ou(t){return new Promise(((e,r)=>{const n=["visa","MPASS_OLTI"];if(n.indexOf(t)<=-1){const t=`Invalid channel. Available channels: ${n.join(", ")}`;r(Error(t))}else e()}))}var su={getQRCode(t){let{channel:e}=t;return ou(e).then((()=>{if(this.qr[e])return this.qr[e];const t={transaction:this.id,channel:e};return au.generateQrCode(t,this.merchant.key).then((t=>("success"===t.status&&(this.qr[e]=t),t)))}))},listenForQRCharge(t,e){let{channel:r}=t;return ou(r).then((()=>{if(!this.qr[r])return Promise.reject(Error("Please generate qr code with Transaction.getQRCode()"));const{data:t}=this.qr[r],n={channel:t.channel,paymentMethod:r};return this.listenForCharge(n,e)}))}};class cu{static hasCountryCode(t){return t&&"+"===t[0]}static hasOnlyDigits(t){return t&&(e=t.substring(1),/^\d+$/.test(e));var e}static isE164Number(t){return t&&t.length<17}static validate(t){const e=[];return cu.hasCountryCode(t)||e.push("Number should include country code prefix"),cu.hasOnlyDigits(t)||e.push("Number should contain only digits"),cu.isE164Number(t)||e.push("Number should not be longer than 16 digits"),{isValid:0===e.length,errors:e}}}const uu={charge(t){let{transaction:e,phone:r,device:n,channel_name:i,provider:a,voucher:o,registrationToken:s}=t;const c={transaction:e,phone:r,device:n,channel_name:i,provider:a,voucher:o,registration_token:s},u=Vo(),h={...u&&{"Accept-Language":u}};return _o.post(`${na.paystackApiUrl}charge/mobile_money`,c,{headers:h}).then((t=>aa.parse(t.data))).catch((t=>{const e=t.response&&t.response.data;let r={};return e&&(r={...e,errors:e}),aa.parse(r||t)}))}};var hu={chargeMobileMoney(t){let{phoneNumber:e,provider:r,voucher:n,registrationToken:i,numberOfTokenRequests:a}=t;return function(t){return new Promise(((e,r)=>{const n=cu.validate(t);if(!n.isValid){const e=t?n.errors[0]:"Please start a mobile money transaction with Transaction.chargeMobileMoney()";r(Error(e))}e(n)}))}(e).then((()=>{a?this.logTokenRequest("mobile money",a):i?this.logTokenSubmitted("mobile money"):this.logAttempt("mobile money");const t={provider:r,voucher:n,registrationToken:i,transaction:this.id,phone:e,device:this.deviceFingerprint,channel_name:`MOBILE_MONEY_${this.id}`};return uu.charge(t).then((t=>("success"===t.status?(this.mobileMoney=t,t.data&&t.data.display&&1===t.data.display.otpSentCount&&this.logTokenRequest("mobile money")):t.errors&&t.errors.data&&"awaiting_registration_token"===t.errors.data.status?this.logTokenAuthenticationFailure(t.message):this.logError(t.message),t)))}))},listenForMobileMoneyCharge(t){if("success"!==this.mobileMoney.status)return Promise.reject(Error("Please start a mobile money charge with Transaction.chargeMobileMoney()"));const{channel:e,channel_name:r}=this.mobileMoney.data,n={channel:e||r,paymentMethod:"mobile_money"};return this.listenForCharge(n,t)}};const lu={verify(t,e){const r=`${na.paystackApiUrl}checkout/pay_with_phone/verify`,n=Vo(),i={Authorization:`Bearer ${e}`,...n&&{"Accept-Language":n}};return _o.post(r,{phone:t},{headers:i}).then((t=>t.data))},deleteCard(t,e,r){const n=`${na.paystackApiUrl}checkout/pay_with_phone/remove_card`,i=Vo(),a={Authorization:`Bearer ${e}`,...i&&{"Accept-Language":i}};return _o.post(n,{phone:t,id:r},{headers:a}).then((t=>t.data))},authenticateOtp(t,e,r,n){const i=`${na.paystackApiUrl}checkout/pay_with_phone/validate_otp`,a=Vo(),o={Authorization:`Bearer ${e}`,...a&&{"Accept-Language":a}};return _o.post(i,{phone:t,otp:r,transaction:n},{headers:o}).then((t=>t.data))},authenticatePin(t,e,r,n){const i=`${na.paystackApiUrl}checkout/pay_with_phone/validate_pin`,a=Vo(),o={Authorization:`Bearer ${e}`,...a&&{"Accept-Language":a}};return _o.post(i,{phone:t,pin:r,transaction:n},{headers:o}).then((t=>t.data))},setPin(t,e,r,n,i){const a=Vo(),o=`${na.paystackApiUrl}checkout/pay_with_phone/set_pin`,s={Authorization:`Bearer ${e}`,...a&&{"Accept-Language":a}};return _o.post(o,{phone:t,token:r,transaction:n,pin:i},{headers:s}).then((t=>t.data))},charge(t,e,r,n,i,a){const o=`${na.paystackApiUrl}checkout/pay_with_phone/charge`,s=Vo(),c={Authorization:`Bearer ${e}`,...s&&{"Accept-Language":s}};return _o.post(o,{id:t,token:r,cvv:i,transaction:n,phone:a},{headers:c}).then((t=>t.data))},enrollPhoneNumber(t,e,r){const n=`${na.paystackApiUrl}checkout/pay_with_phone/enroll`,i=Vo(),a={Authorization:`Bearer ${e}`,...i&&{"Accept-Language":i}};return _o.post(n,{phone:t,transaction:r},{headers:a}).then((t=>t.data))}};function du(t){return new Promise(((e,r)=>{const n=cu.validate(t);if(!n.isValid){const e=t?n.errors[0]:"Please set a valid customer with Transaction.setCustomer()";r(Error(e))}e(n)}))}var pu={setCustomer(t){let{phoneNumber:e}=t;return du(e).then((()=>{this.customer=e}))},verifyCustomer(){return du(this.customer).then((()=>lu.verify(this.customer,this.merchant.key)))},deleteSavedCard(t){return du(this.customer).then((()=>lu.deleteCard(this.customer,this.merchant.key,t)))},authenticateCustomerOtp(t){return du(this.customer).then((()=>lu.authenticateOtp(this.customer,this.merchant.key,t,this.id)))},authenticateCustomerPin(t){return du(this.customer).then((()=>lu.authenticatePin(this.customer,this.merchant.key,t,this.id)))},setCustomerPin(t){let{pin:e,token:r}=t;return du(this.customer).then((()=>lu.setPin(this.customer,this.merchant.key,r,this.id,e)))},chargeSavedCard(t){let{cardId:e,token:r,cvv:n}=t;return du(this.customer).then((()=>lu.charge(e,this.merchant.key,r,this.id,n,this.customer)))},enrollPhoneNumber(t){return du(this.customer).then((()=>lu.enrollPhoneNumber(t,this.merchant.key,this.id)))}};const fu={loginToDirectDebitAccount(t){let{email:e,password:r}=t;const n={email:e,password:r},i=Vo(),a={...i&&{"Accept-Language":i}};return _o.post(`${na.paystackApiUrl}login`,n,{headers:a}).then((t=>aa.parse(t.data)))},charge(t){let{account_code:e,transaction:r,token:n}=t;const i=Vo(),a={Authorization:`Bearer ${n}`,"jwt-auth":!0,...i&&{"Accept-Language":i}},o={account_code:e,transaction:r};return _o.post(`${na.paystackApiUrl}directdebit/initiate`,o,{headers:a}).then((t=>aa.parse(t.data)))},authenticate(t){let{otp:e,transaction:r,token:n}=t;const i=Vo(),a={Authorization:`Bearer ${n}`,"jwt-auth":!0,...i&&{"Accept-Language":i}},o={otp:e,transaction:r};return _o.post(`${na.paystackApiUrl}directdebit/validate`,o,{headers:a}).then((t=>aa.parse(t.data)))},getProvisionedAccounts(t){const e=Vo(),r={Authorization:`Bearer ${t}`,"jwt-auth":!0,...e&&{"Accept-Language":e}};return _o.get(`${na.paystackApiUrl}directdebit/account`,{headers:r}).then((t=>t.data))}},gu="direct debit";var mu={loginToDirectDebitAccount(t){let{email:e,password:r}=t;const n={email:e,password:r};return qi(e)?fu.loginToDirectDebitAccount(n).then((t=>{if("success"===t.status){const{data:{token:e,user:{permissions:r}}}=t;if(!r||r.length<1)throw Error("You do not have the privileges to perform this action");if(r.find((t=>"directdebit-*"===t)))return this.directDebit.token=e,t;throw Error("You do not have the privileges to perform this action")}return t})):Promise.reject(Error("Invalid email"))},chargeDirectDebit(t){if(!this.directDebit.token)return Promise.reject(Error("Please login with Transaction.loginToDirectDebitAccount() to start a Direct debit charge"));this.logAttempt(gu);const e={account_code:t,transaction:this.id,token:this.directDebit.token};return fu.charge(e).then((t=>(this.logAPIResponse(t,gu),t.status&&(this.directDebit.chargeResponse=t),t)))},getProvisionedAccounts(){return fu.getProvisionedAccounts(this.directDebit.token).then((t=>{this.logAPIResponse(t,gu);const{status:e,data:r}=t;if(e){if(r&&r.length<1)return Promise.reject(Error("You have not provisioned any bank account for Direct Debit yet"));this.directDebit.accounts=t.data}return t}))},authenticateAccount(t){const e={otp:t,transaction:this.id,token:this.directDebit.token};return fu.authenticate(e).then((t=>(this.logAPIResponse(t,gu),t)))}},yu={get:t=>({card:Wc,bank:ru,ussd:iu,qr:su,mobile_money:hu,phone:pu,direct_debit:mu,bank_transfer:Fo,eft:Ko,payattitude:Go,apple_pay:Zo,paypal:Qo}[t])},vu=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)))};const bu={saveLog(t,e,r){const n=`${na.paystackApiUrl}transaction/update_log/${t}`,i=Vo(),a={Authorization:`Bearer ${e}`,...i&&{"Accept-Language":i}};return _o.post(n,{payload:JSON.stringify(r)},{headers:a}).then((t=>t.data))},getIp(){const t=Vo(),e={...t&&{"Accept-Language":t}};return _o.get("https://api.paystack.co/decision/ip",{headers:e}).then((t=>t.data.data.ip_address))},saveIp(t,e){const r=`${na.paystackApiUrl}transaction/set_ip/${t}`,n=Vo(),i={Authorization:`Bearer ${e}`,...n&&{"Accept-Language":n}};return _o.post(r,null,{headers:i}).then((t=>t.data))},saveReferrer(t,e,r){const n=`${na.paystackApiUrl}transaction/set_referrer/${t}`,i=Vo(),a={Authorization:`Bearer ${e}`,...i&&{"Accept-Language":i}};return _o.post(n,{referrer:r},{headers:a}).then((t=>t.data))}};var Tu={initializeLog(t){const{attempts:e,authentication:r,errors:n,history:i}=t||{};this.log={start_time:Math.round(Date.now()/1e3),time_spent:0,attempts:e||0,authentication:r,errors:n||0,success:!1,mobile:vu(),input:[],history:i||[]}},getTimeSpent(){const t=Math.round(Date.now()/1e3);return this.log.time_spent=t-this.log.start_time,this.log.time_spent},logPageOpen(){return this.log.history.push({type:"open",message:"Opened checkout",time:this.getTimeSpent()}),this.saveLog()},logChannelSwitch(t){return this.log.history.push({type:"action",message:`Set payment method to: ${t}`,time:this.getTimeSpent()}),this.saveLog()},logValidationErrors(t){return t.forEach((t=>{this.log.history.push({type:"error",message:`Invalid ${t}`,time:this.getTimeSpent()})})),this.saveLog()},logInput(t){const e=this.log.history.find((e=>e.message===`Filled this field: ${t}`));return this.log.history.push({type:"input",message:`${e?"Changed":"Filled"} this field: ${t}`,time:this.getTimeSpent()}),this.saveLog()},logBankSelect(t){return this.log.history.push({type:"action",message:`Selected bank: ${t}`,time:this.getTimeSpent()}),this.saveLog()},logAuthWindowOpen(){return this.log.history.push({type:"action",message:"Third-party authentication window opened",time:this.getTimeSpent()}),this.saveLog()},logAuthWindowClose(){return this.log.history.push({type:"action",message:"Third-party authentication window closed",time:this.getTimeSpent()}),this.saveLog()},logAPIResponse(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}},logAPIResponseMessage(t){return this.log.history.push({type:"action",message:t,time:this.getTimeSpent()}),this.saveLog()},logAttempt(t){let e="Attempted to pay";return t&&(e+=` with ${t}`),this.log.attempts+=1,this.log.history.push({type:"action",message:e,time:this.getTimeSpent()}),this.saveLog()},logTokenRequest(t){const e=0===(arguments.length>1&&void 0!==arguments[1]?arguments[1]:0)?"Waiting for customer to submit OTP":"Customer requested to resend OTP";return this.log.history.push({type:"action",message:e,channel:t,time:this.getTimeSpent()}),this.saveLog()},logTokenSubmitted(t){return this.log.history.push({type:"action",message:"Customer submitted OTP",channel:t,time:this.getTimeSpent()}),this.saveLog()},logTokenAuthenticationFailure(t){let e="Error";return t&&(e+=`: ${t}`),this.log.errors+=1,this.log.history.push({type:"error",message:e,authentication:"failed",time:this.getTimeSpent()}),this.saveLog()},logError(t){let e="Error";return t&&(e+=`: ${t}`),this.log.errors+=1,this.log.history.push({type:"error",message:e,time:this.getTimeSpent()}),this.saveLog()},logAuth(t){return this.log.authentication=t,this.log.history.push({type:"auth",message:`Authentication Required: ${t}`,time:this.getTimeSpent()}),this.saveLog()},logSuccess(t){let e="Successfully paid";return t&&(e+=` with ${t}`),this.log.success=!0,this.log.history.push({type:"success",message:e,time:this.getTimeSpent()}),this.saveLog()},logPending(t){let e="Payment in progress";return t&&(e+=` with ${t}`),this.log.history.push({type:"pending",message:e,time:this.getTimeSpent()}),this.saveLog()},logPageClose(){return this.log.history.push({type:"close",message:"Closed checkout",time:this.getTimeSpent()}),this.saveLog()},saveLog(){return bu.saveLog(this.id,this.merchant.key,this.log)},saveIpAddress(){return bu.saveIp(this.id,this.merchant.key)},saveReferrer(t){return bu.saveReferrer(this.id,this.merchant.key,t)}};class wu{constructor(t){this.email=t.email,this.merchant={id:t.merchant_id,logo:t.merchant_logo,name:t.merchant_name,key:t.merchant_key,channelSettings:t.merchant_channel_settings||{}},this.status=t.transaction_status||t.status,this.accessCode=t.access_code,this.amount=t.amount,this.domain=t.domain,this.isTest="test"===t.domain,this.currency=t.currency,this.id=t.id,this.channels=["apple_pay"].concat(t.channels),this.label=t.label,this.metadata=t.metadata||{},this.cancel_action=t.cancel_action||null,this.channel_options=t.channel_options||null,this.hash=t.hash||null,this.authorizations=t.authorizations,this.remember_card=!1,this.rememberMeEnabled=t.is_remember_me_enabled,this.card={},this.bankAccount={},this.mobileMoney={},this.ussd={},this.bankTransfer={},this.qr={},this.directDebit={},this.deviceFingerprint=t.deviceFingerprint||null,this.customer=t.customer,this.custom_filters=t.custom_filters||null,this.isCharging=!1,this.isListening=!1,this.transactionType=t.transaction_type||null,this.elevyPercentage=t.elevy_percentage||null,this.subscription=t.subscription||null,this.planDetails=t.plan_details||null,window?new Promise(((t,e)=>{const r=new XMLHttpRequest;r.open("GET",na.pusherUrl),r.onload=()=>{if(r.status>=200&&r.status<300){const e=document.createElement("script");e.appendChild(document.createTextNode(r.responseText)),document.head.appendChild(e),t()}else e(r.statusText)},r.onerror=()=>e(r.statusText),r.send(null)})):Promise.reject(new Error("Window object not available")),this.log=null,Object.assign(this,Tu),this.initializeLog(t.log),this.saveIpAddress(),this.channels.forEach((t=>{const e=yu.get(t);Object.assign(this,e)})),this.channels.includes("ussd")&&!this.channels.includes("bank_transfer")&&Object.assign(this,yu.get("bank_transfer")),"GHS"===t.currency&&t.elevy_percentage&&(this.elevyPercentage=t.elevy_percentage)}setMetadata(t,e){this.metadata[t]=e}setDevice(t){this.deviceFingerprint?Ji("Device ID has already been set by Checkout JS so there's no need to set this again"):this.deviceFingerprint=t}listenForCharge(t,e){const{channel:r,paymentMethod:n}=t;let i;window&&window.Pusher&&(i=new window.Pusher(na.pusherKey,{cluster:"eu",disableStats:!0}));const a={status:"error",message:"We could not listen for charge response. Use transaction.requery() to check the status."},o=()=>{i.unsubscribe(r)};if(!i)return e({status:"error",message:"We could not listen for charge response."},ia);const s=i.subscribe(r);s.bind("pusher:subscription_succeeded",(()=>{this.isListening=!0})),s.bind("pusher:subscription_error",(()=>{this.isListening=!1,e(a,ia)})),s.bind("response",(t=>{const r=aa.parse(t);this.logAPIResponse(r,n),e(r,o)}))}requery(){return jo.requery(this.id)}markAsAbandoned(){return jo.markAsAbandoned({publicKey:this.merchant.key,transactionId:this.id})}}const Su={validate(t){const e=function(t){const e=[];return t&&"object"==typeof t?(Object.keys(zi).forEach((r=>{const n=zi[r],i=t[r];!n.required||i||t[n.fallback]?i&&!n.isValid(i)&&e.push({field:r,message:`Invalid field: ${r}`}):e.push({field:r,message:`Required field: ${r}`})})),e):(e.push({message:"Please supply a valid object"}),e)}(t);if(e.length){const[{message:t}]=e;throw new Fi(e,t)}},async request(t){const e=await Yi(),r=await jo.requestInline({...t,device:e});return r&&Object.seal(new wu({...r.data,deviceFingerprint:e}))},async requestWithAccessCode(t){const e=await Yi(),r=await jo.requestStandard(t);return r&&Object.seal(new wu({...r.data,deviceFingerprint:e}))},async getByAccessCode(t,e){const r=await Yi(),n=await jo.getByAccessCode(t,e);return n&&Object.seal(new wu({...n.data,deviceFingerprint:r}))},initialize:t=>Object.seal(new wu(t)),async verify(t){const e=await jo.verify(t);return e&&e.data}},Au={fetchBanks(t){const e=`${na.paystackApiUrl}bank`,r=Vo(),n={params:t,headers:{...r&&{"Accept-Language":r}}};return _o.get(e,n).then((t=>t.data))},fetchResolutions(){const t=`${na.paystackApiUrl}checkout/resolutions`,e=Vo(),r={...e&&{"Accept-Language":e}};return _o.get(t,{headers:r}).then((t=>t.data))},fetchCelebrations(){const t=`${na.paystackApiUrl}checkout/celebrations`,e=Vo(),r={...e&&{"Accept-Language":e}};return _o.get(t,{headers:r}).then((t=>t.data))},fetchStates(t){const e=`${na.paystackApiUrl}address_verification/states`,r=Vo(),n={params:t,headers:{...r&&{"Accept-Language":r}}};return _o.get(e,n).then((t=>t.data))}};return t.BankAccount=Xc,t.Card=$c,t.Toolkit=class{static contents(){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"}]}static fetch(t,e){if(this.contents().map((t=>t.key)).indexOf(t)<=-1)throw new Error("Please provide a valid config key. Use Toolkit.contents() to see available options.");let r;switch(t){case"banks":r=Au.fetchBanks(e||{pay_with_bank:"1"});break;case"resolutions":r=Au.fetchResolutions();break;case"celebrations":r=Au.fetchCelebrations();break;case"states":r=Au.fetchStates(e)}return r}},t.Transaction=Su,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
package/es/checkout.js CHANGED
@@ -12745,7 +12745,17 @@ const MobileMoneyAPI = {
12745
12745
  };
12746
12746
  return axiosInstance.post(`${configToUse.paystackApiUrl}charge/mobile_money`, params, {
12747
12747
  headers
12748
- }).then(response => ChargeResponses.parse(response.data));
12748
+ }).then(response => ChargeResponses.parse(response.data)).catch(error => {
12749
+ const errorData = error.response && error.response.data;
12750
+ let errorResponse = {};
12751
+ if (errorData) {
12752
+ errorResponse = {
12753
+ ...errorData,
12754
+ errors: errorData
12755
+ };
12756
+ }
12757
+ return ChargeResponses.parse(errorResponse || error);
12758
+ });
12749
12759
  }
12750
12760
  };
12751
12761
 
@@ -12765,10 +12775,17 @@ var MobileMoneyCharge = {
12765
12775
  phoneNumber,
12766
12776
  provider,
12767
12777
  voucher,
12768
- registrationToken
12778
+ registrationToken,
12779
+ numberOfTokenRequests
12769
12780
  } = _ref;
12770
12781
  return validate$1(phoneNumber).then(() => {
12771
- this.logAttempt('mobile money');
12782
+ if (numberOfTokenRequests) {
12783
+ this.logTokenRequest('mobile money', numberOfTokenRequests);
12784
+ } else if (registrationToken) {
12785
+ this.logTokenSubmitted('mobile money');
12786
+ } else {
12787
+ this.logAttempt('mobile money');
12788
+ }
12772
12789
  const params = {
12773
12790
  provider,
12774
12791
  voucher,
@@ -12781,6 +12798,13 @@ var MobileMoneyCharge = {
12781
12798
  return MobileMoneyAPI.charge(params).then(response => {
12782
12799
  if (response.status === 'success') {
12783
12800
  this.mobileMoney = response;
12801
+ if (response.data && response.data.display && response.data.display.otpSentCount === 1) {
12802
+ this.logTokenRequest('mobile money');
12803
+ }
12804
+ } else if (response.errors && response.errors.data && response.errors.data.status === 'awaiting_registration_token') {
12805
+ this.logTokenAuthenticationFailure(response.message);
12806
+ } else {
12807
+ this.logError(response.message);
12784
12808
  }
12785
12809
  return response;
12786
12810
  });
@@ -13352,6 +13376,41 @@ var AnalyticsFunctions = {
13352
13376
  });
13353
13377
  return this.saveLog();
13354
13378
  },
13379
+ logTokenRequest(channel) {
13380
+ let numberOfTokenRequests = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
13381
+ const message = numberOfTokenRequests === 0 ? 'Waiting for customer to submit OTP' : 'Customer requested to resend OTP';
13382
+ this.log.history.push({
13383
+ type: 'action',
13384
+ message,
13385
+ channel,
13386
+ time: this.getTimeSpent()
13387
+ });
13388
+ return this.saveLog();
13389
+ },
13390
+ logTokenSubmitted(channel) {
13391
+ const message = `Customer submitted OTP`;
13392
+ this.log.history.push({
13393
+ type: 'action',
13394
+ message,
13395
+ channel,
13396
+ time: this.getTimeSpent()
13397
+ });
13398
+ return this.saveLog();
13399
+ },
13400
+ logTokenAuthenticationFailure(error) {
13401
+ let message = 'Error';
13402
+ if (error) {
13403
+ message += `: ${error}`;
13404
+ }
13405
+ this.log.errors += 1;
13406
+ this.log.history.push({
13407
+ type: 'error',
13408
+ message,
13409
+ authentication: 'failed',
13410
+ time: this.getTimeSpent()
13411
+ });
13412
+ return this.saveLog();
13413
+ },
13355
13414
  logError(error) {
13356
13415
  let message = 'Error';
13357
13416
  if (error) {
package/lib/checkout.js CHANGED
@@ -12749,7 +12749,17 @@ const MobileMoneyAPI = {
12749
12749
  };
12750
12750
  return axiosInstance.post(`${configToUse.paystackApiUrl}charge/mobile_money`, params, {
12751
12751
  headers
12752
- }).then(response => ChargeResponses.parse(response.data));
12752
+ }).then(response => ChargeResponses.parse(response.data)).catch(error => {
12753
+ const errorData = error.response && error.response.data;
12754
+ let errorResponse = {};
12755
+ if (errorData) {
12756
+ errorResponse = {
12757
+ ...errorData,
12758
+ errors: errorData
12759
+ };
12760
+ }
12761
+ return ChargeResponses.parse(errorResponse || error);
12762
+ });
12753
12763
  }
12754
12764
  };
12755
12765
 
@@ -12769,10 +12779,17 @@ var MobileMoneyCharge = {
12769
12779
  phoneNumber,
12770
12780
  provider,
12771
12781
  voucher,
12772
- registrationToken
12782
+ registrationToken,
12783
+ numberOfTokenRequests
12773
12784
  } = _ref;
12774
12785
  return validate$1(phoneNumber).then(() => {
12775
- this.logAttempt('mobile money');
12786
+ if (numberOfTokenRequests) {
12787
+ this.logTokenRequest('mobile money', numberOfTokenRequests);
12788
+ } else if (registrationToken) {
12789
+ this.logTokenSubmitted('mobile money');
12790
+ } else {
12791
+ this.logAttempt('mobile money');
12792
+ }
12776
12793
  const params = {
12777
12794
  provider,
12778
12795
  voucher,
@@ -12785,6 +12802,13 @@ var MobileMoneyCharge = {
12785
12802
  return MobileMoneyAPI.charge(params).then(response => {
12786
12803
  if (response.status === 'success') {
12787
12804
  this.mobileMoney = response;
12805
+ if (response.data && response.data.display && response.data.display.otpSentCount === 1) {
12806
+ this.logTokenRequest('mobile money');
12807
+ }
12808
+ } else if (response.errors && response.errors.data && response.errors.data.status === 'awaiting_registration_token') {
12809
+ this.logTokenAuthenticationFailure(response.message);
12810
+ } else {
12811
+ this.logError(response.message);
12788
12812
  }
12789
12813
  return response;
12790
12814
  });
@@ -13356,6 +13380,41 @@ var AnalyticsFunctions = {
13356
13380
  });
13357
13381
  return this.saveLog();
13358
13382
  },
13383
+ logTokenRequest(channel) {
13384
+ let numberOfTokenRequests = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
13385
+ const message = numberOfTokenRequests === 0 ? 'Waiting for customer to submit OTP' : 'Customer requested to resend OTP';
13386
+ this.log.history.push({
13387
+ type: 'action',
13388
+ message,
13389
+ channel,
13390
+ time: this.getTimeSpent()
13391
+ });
13392
+ return this.saveLog();
13393
+ },
13394
+ logTokenSubmitted(channel) {
13395
+ const message = `Customer submitted OTP`;
13396
+ this.log.history.push({
13397
+ type: 'action',
13398
+ message,
13399
+ channel,
13400
+ time: this.getTimeSpent()
13401
+ });
13402
+ return this.saveLog();
13403
+ },
13404
+ logTokenAuthenticationFailure(error) {
13405
+ let message = 'Error';
13406
+ if (error) {
13407
+ message += `: ${error}`;
13408
+ }
13409
+ this.log.errors += 1;
13410
+ this.log.history.push({
13411
+ type: 'error',
13412
+ message,
13413
+ authentication: 'failed',
13414
+ time: this.getTimeSpent()
13415
+ });
13416
+ return this.saveLog();
13417
+ },
13359
13418
  logError(error) {
13360
13419
  let message = 'Error';
13361
13420
  if (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paystack/checkout-js",
3
- "version": "2.0.0-dev.1",
3
+ "version": "2.0.0-dev.3",
4
4
  "description": "Client-side JS library for billing on Paystack",
5
5
  "main": "lib/checkout.js",
6
6
  "module": "es/checkout.js",