@paystack/checkout-js 1.42.0-dev.3 → 1.42.0-dev.5
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 +1 -1
- package/es/checkout.js +1 -1
- package/lib/checkout.js +1 -1
- package/package.json +1 -1
package/dist/checkout.js
CHANGED
|
@@ -27,4 +27,4 @@ var Paystack=function(t){"use strict";function e(t,e){var n=Object.keys(t);if(Ob
|
|
|
27
27
|
* @since jsrsasign 2.1
|
|
28
28
|
* @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
|
|
29
29
|
*/
|
|
30
|
-
var pt={};void 0!==pt.asn1&&pt.asn1||(pt.asn1={}),pt.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var n=e.substr(1).length;n%2==1?n+=1:e.match(/^[0-7]/)||(n+=2);for(var r="",i=0;i<n;i++)r+="f";e=new B(r,16).xor(t).add(B.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=pt.asn1,n=e.DERBoolean,r=e.DERInteger,i=e.DERBitString,o=e.DEROctetString,a=e.DERNull,s=e.DERObjectIdentifier,u=e.DEREnumerated,c=e.DERUTF8String,h=e.DERNumericString,l=e.DERPrintableString,f=e.DERTeletexString,p=e.DERIA5String,d=e.DERUTCTime,g=e.DERGeneralizedTime,m=e.DERSequence,v=e.DERSet,y=e.DERTaggedObject,b=e.ASN1Util.newObject,w=Object.keys(t);if(1!=w.length)throw"key of param shall be only one.";var S=w[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+S+":"))throw"undefined key: "+S;if("bool"==S)return new n(t[S]);if("int"==S)return new r(t[S]);if("bitstr"==S)return new i(t[S]);if("octstr"==S)return new o(t[S]);if("null"==S)return new a(t[S]);if("oid"==S)return new s(t[S]);if("enum"==S)return new u(t[S]);if("utf8str"==S)return new c(t[S]);if("numstr"==S)return new h(t[S]);if("prnstr"==S)return new l(t[S]);if("telstr"==S)return new f(t[S]);if("ia5str"==S)return new p(t[S]);if("utctime"==S)return new d(t[S]);if("gentime"==S)return new g(t[S]);if("seq"==S){for(var T=t[S],A=[],E=0;E<T.length;E++){var k=b(T[E]);A.push(k)}return new m({array:A})}if("set"==S){for(T=t[S],A=[],E=0;E<T.length;E++)k=b(T[E]),A.push(k);return new v({array:A})}if("tag"==S){var x=t[S];if("[object Array]"===Object.prototype.toString.call(x)&&3==x.length){var O=b(x[2]);return new y({tag:x[0],explicit:x[1],obj:O})}var R={};if(void 0!==x.explicit&&(R.explicit=x.explicit),void 0!==x.tag&&(R.tag=x.tag),void 0===x.obj)throw"obj shall be specified for 'tag'.";return R.obj=b(x.obj),new y(R)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},pt.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",n=parseInt(t.substr(0,2),16),r=(e=Math.floor(n/40)+"."+n%40,""),i=2;i<t.length;i+=2){var o=("00000000"+parseInt(t.substr(i,2),16).toString(2)).slice(-8);r+=o.substr(1,7),"0"==o.substr(0,1)&&(e=e+"."+new B(r,2).toString(10),r="")}return e},pt.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},n=function(t){var n="",r=new B(t,10).toString(2),i=7-r.length%7;7==i&&(i=0);for(var o="",a=0;a<i;a++)o+="0";for(r=o+r,a=0;a<r.length-1;a+=7){var s=r.substr(a,7);a!=r.length-7&&(s="1"+s),n+=e(parseInt(s,2))}return n};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var r="",i=t.split("."),o=40*parseInt(i[0])+parseInt(i[1]);r+=e(o),i.splice(0,2);for(var a=0;a<i.length;a++)r+=n(i[a]);return r},pt.asn1.ASN1Object=function(){var t="";this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+t.length+",v="+this.hV;var e=this.hV.length/2,n=e.toString(16);if(n.length%2==1&&(n="0"+n),e<128)return n;var r=n.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);return(128+r).toString(16)+n},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},pt.asn1.DERAbstractString=function(t){pt.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},ft.lang.extend(pt.asn1.DERAbstractString,pt.asn1.ASN1Object),pt.asn1.DERAbstractTime=function(t){pt.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,n){var r=this.zeroPadding,i=this.localDateToUTC(t),o=String(i.getFullYear());"utc"==e&&(o=o.substr(2,2));var a=o+r(String(i.getMonth()+1),2)+r(String(i.getDate()),2)+r(String(i.getHours()),2)+r(String(i.getMinutes()),2)+r(String(i.getSeconds()),2);if(!0===n){var s=i.getMilliseconds();if(0!=s){var u=r(String(s),3);a=a+"."+(u=u.replace(/[0]+$/,""))}}return a+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(t)},this.setByDateValue=function(t,e,n,r,i,o){var a=new Date(Date.UTC(t,e-1,n,r,i,o,0));this.setByDate(a)},this.getFreshValueHex=function(){return this.hV}},ft.lang.extend(pt.asn1.DERAbstractTime,pt.asn1.ASN1Object),pt.asn1.DERAbstractStructured=function(t){pt.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},ft.lang.extend(pt.asn1.DERAbstractStructured,pt.asn1.ASN1Object),pt.asn1.DERBoolean=function(){pt.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},ft.lang.extend(pt.asn1.DERBoolean,pt.asn1.ASN1Object),pt.asn1.DERInteger=function(t){pt.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=pt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new B(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},ft.lang.extend(pt.asn1.DERInteger,pt.asn1.ASN1Object),pt.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=pt.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}pt.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var n="0"+t;this.hTLV=null,this.isModified=!0,this.hV=n+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var n=0;n<=e;n++)t+="0";var r="";for(n=0;n<t.length-1;n+=8){var i=t.substr(n,8),o=parseInt(i,2).toString(16);1==o.length&&(o="0"+o),r+=o}this.hTLV=null,this.isModified=!0,this.hV="0"+e+r},this.setByBooleanArray=function(t){for(var e="",n=0;n<t.length;n++)1==t[n]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),n=0;n<t;n++)e[n]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},ft.lang.extend(pt.asn1.DERBitString,pt.asn1.ASN1Object),pt.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=pt.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}pt.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},ft.lang.extend(pt.asn1.DEROctetString,pt.asn1.DERAbstractString),pt.asn1.DERNull=function(){pt.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},ft.lang.extend(pt.asn1.DERNull,pt.asn1.ASN1Object),pt.asn1.DERObjectIdentifier=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},n=function(t){var n="",r=new B(t,10).toString(2),i=7-r.length%7;7==i&&(i=0);for(var o="",a=0;a<i;a++)o+="0";for(r=o+r,a=0;a<r.length-1;a+=7){var s=r.substr(a,7);a!=r.length-7&&(s="1"+s),n+=e(parseInt(s,2))}return n};pt.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var r="",i=t.split("."),o=40*parseInt(i[0])+parseInt(i[1]);r+=e(o),i.splice(0,2);for(var a=0;a<i.length;a++)r+=n(i[a]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=r},this.setValueName=function(t){var e=pt.asn1.x509.OID.name2oid(t);if(""===e)throw"DERObjectIdentifier oidName undefined: "+t;this.setValueOidString(e)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t):void 0!==t.oid?this.setValueOidString(t.oid):void 0!==t.hex?this.setValueHex(t.hex):void 0!==t.name&&this.setValueName(t.name))},ft.lang.extend(pt.asn1.DERObjectIdentifier,pt.asn1.ASN1Object),pt.asn1.DEREnumerated=function(t){pt.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=pt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new B(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},ft.lang.extend(pt.asn1.DEREnumerated,pt.asn1.ASN1Object),pt.asn1.DERUTF8String=function(t){pt.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},ft.lang.extend(pt.asn1.DERUTF8String,pt.asn1.DERAbstractString),pt.asn1.DERNumericString=function(t){pt.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},ft.lang.extend(pt.asn1.DERNumericString,pt.asn1.DERAbstractString),pt.asn1.DERPrintableString=function(t){pt.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},ft.lang.extend(pt.asn1.DERPrintableString,pt.asn1.DERAbstractString),pt.asn1.DERTeletexString=function(t){pt.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},ft.lang.extend(pt.asn1.DERTeletexString,pt.asn1.DERAbstractString),pt.asn1.DERIA5String=function(t){pt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},ft.lang.extend(pt.asn1.DERIA5String,pt.asn1.DERAbstractString),pt.asn1.DERUTCTime=function(t){pt.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{12}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date))},ft.lang.extend(pt.asn1.DERUTCTime,pt.asn1.DERAbstractTime),pt.asn1.DERGeneralizedTime=function(t){pt.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.withMillis=!1,this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{14}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date),!0===t.millis&&(this.withMillis=!0))},ft.lang.extend(pt.asn1.DERGeneralizedTime,pt.asn1.DERAbstractTime),pt.asn1.DERSequence=function(t){pt.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++)t+=this.asn1Array[e].getEncodedHex();return this.hV=t,this.hV}},ft.lang.extend(pt.asn1.DERSequence,pt.asn1.DERAbstractStructured),pt.asn1.DERSet=function(t){pt.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var n=this.asn1Array[e];t.push(n.getEncodedHex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},ft.lang.extend(pt.asn1.DERSet,pt.asn1.DERAbstractStructured),pt.asn1.DERTaggedObject=function(t){pt.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,n){this.hT=e,this.isExplicit=t,this.asn1Object=n,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=n.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.tag&&(this.hT=t.tag),void 0!==t.explicit&&(this.isExplicit=t.explicit),void 0!==t.obj&&(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},ft.lang.extend(pt.asn1.DERTaggedObject,pt.asn1.ASN1Object);var dt=function(t){function e(n){var r=t.call(this)||this;return n&&("string"==typeof n?r.parseKey(n):(e.hasPrivateKeyProperty(n)||e.hasPublicKeyProperty(n))&&r.parsePropertiesFrom(n)),r}return g(e,t),e.prototype.parseKey=function(t){try{var e=0,n=0,r=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?v.decode(t):y.unarmor(t),i=O.decode(r);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){e=i.sub[1].getHexStringValue(),this.n=j(e,16),n=i.sub[2].getHexStringValue(),this.e=parseInt(n,16);var o=i.sub[3].getHexStringValue();this.d=j(o,16);var a=i.sub[4].getHexStringValue();this.p=j(a,16);var s=i.sub[5].getHexStringValue();this.q=j(s,16);var u=i.sub[6].getHexStringValue();this.dmp1=j(u,16);var c=i.sub[7].getHexStringValue();this.dmq1=j(c,16);var h=i.sub[8].getHexStringValue();this.coeff=j(h,16)}else{if(2!==i.sub.length)return!1;var l=i.sub[1].sub[0];e=l.sub[0].getHexStringValue(),this.n=j(e,16),n=l.sub[1].getHexStringValue(),this.e=parseInt(n,16)}return!0}catch(t){return!1}},e.prototype.getPrivateBaseKey=function(){var t={array:[new pt.asn1.DERInteger({int:0}),new pt.asn1.DERInteger({bigint:this.n}),new pt.asn1.DERInteger({int:this.e}),new pt.asn1.DERInteger({bigint:this.d}),new pt.asn1.DERInteger({bigint:this.p}),new pt.asn1.DERInteger({bigint:this.q}),new pt.asn1.DERInteger({bigint:this.dmp1}),new pt.asn1.DERInteger({bigint:this.dmq1}),new pt.asn1.DERInteger({bigint:this.coeff})]};return new pt.asn1.DERSequence(t).getEncodedHex()},e.prototype.getPrivateBaseKeyB64=function(){return l(this.getPrivateBaseKey())},e.prototype.getPublicBaseKey=function(){var t=new pt.asn1.DERSequence({array:[new pt.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new pt.asn1.DERNull]}),e=new pt.asn1.DERSequence({array:[new pt.asn1.DERInteger({bigint:this.n}),new pt.asn1.DERInteger({int:this.e})]}),n=new pt.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new pt.asn1.DERSequence({array:[t,n]}).getEncodedHex()},e.prototype.getPublicBaseKeyB64=function(){return l(this.getPublicBaseKey())},e.wordwrap=function(t,e){if(!t)return t;var n="(.{1,"+(e=e||64)+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(n,"g")).join("\n")},e.prototype.getPrivateKey=function(){var t="-----BEGIN RSA PRIVATE KEY-----\n";return t+=e.wordwrap(this.getPrivateBaseKeyB64())+"\n",t+="-----END RSA PRIVATE KEY-----"},e.prototype.getPublicKey=function(){var t="-----BEGIN PUBLIC KEY-----\n";return t+=e.wordwrap(this.getPublicBaseKeyB64())+"\n",t+="-----END PUBLIC KEY-----"},e.hasPublicKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")},e.hasPrivateKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},e.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)},e}(st),gt=function(){function t(t){t=t||{},this.default_key_size=parseInt(t.default_key_size,10)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null}return t.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new dt(t)},t.prototype.setPrivateKey=function(t){this.setKey(t)},t.prototype.setPublicKey=function(t){this.setKey(t)},t.prototype.decrypt=function(t){try{return this.getKey().decrypt(f(t))}catch(t){return!1}},t.prototype.encrypt=function(t){try{return l(this.getKey().encrypt(t))}catch(t){return!1}},t.prototype.sign=function(t,e,n){try{return l(this.getKey().sign(t,e,n))}catch(t){return!1}},t.prototype.verify=function(t,e,n){try{return this.getKey().verify(t,f(e),n)}catch(t){return!1}},t.prototype.getKey=function(t){if(!this.key){if(this.key=new dt,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},t.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},t.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},t.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},t.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},t.version="3.0.0-rc.1",t}();window.JSEncrypt=gt,t.JSEncrypt=gt,t.default=gt,Object.defineProperty(t,"__esModule",{value:!0})}(e)}(0,xE.exports);var RE=O,CE=H,PE=_s,BE=ot,LE=CE(L.f),IE=CE([].push),DE=function(t){return function(e){for(var n,r=BE(e),i=PE(r),o=i.length,a=0,s=[];o>a;)n=i[a++],RE&&!LE(r,n)||IE(s,t?[n,r[n]]:r[n]);return s}},NE={entries:DE(!0),values:DE(!1)}.values;li({target:"Object",stat:!0},{values:function(t){return NE(t)}});var _E=li,jE=Ts.find,ME=$d,UE="find",VE=!0;UE in[]&&Array(1)[UE]((function(){VE=!1})),_E({target:"Array",proto:!0,forced:VE},{find:function(t){return jE(this,t,arguments.length>1?arguments[1]:void 0)}}),ME(UE);var FE=function(t){for(var e,n=0,r=!1,i=t.length-1;i>=0;)e=parseInt(t.charAt(i),10),r&&(e*=2)>9&&(e=e%10+1),r=!r,n+=e,i--;return n%10==0};var qE=function(t){return t?JSON.parse(JSON.stringify(t)):null};var zE=function(t){return"string"==typeof t||t instanceof String};var HE=function(t,e){return Array.isArray(e)?function(t,e,n){var r=String(e).length,i=t.substr(0,r),o=parseInt(i,10);return e=parseInt(String(e).substr(0,i.length),10),n=parseInt(String(n).substr(0,i.length),10),o>=e&&o<=n}(t,e[0],e[1]):function(t,e){return(e=String(e)).substring(0,t.length)===t.substring(0,e.length)}(t,e)},GE=qE,KE=HE;var WE,XE=function(t,e,n){var r,i,o,a;for(r=0;r<e.patterns.length;r++)if(i=e.patterns[r],KE(t,i)){a=GE(e),o=Array.isArray(i)?String(i[0]).length:String(i).length,t.length>=o&&(a.matchStrength=o),n.push(a);break}},YE={visa:{niceType:"Visa",type:"visa",patterns:[4],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}},mastercard:{niceType:"Mastercard",type:"mastercard",patterns:[[51,55],[2221,2229],[223,229],[23,26],[270,271],2720],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},"american-express":{niceType:"American Express",type:"american-express",patterns:[34,37],gaps:[4,10],lengths:[15],code:{name:"CID",size:4}},"diners-club":{niceType:"Diners Club",type:"diners-club",patterns:[[300,305],36,38,39],gaps:[4,10],lengths:[14,16,19],code:{name:"CVV",size:3}},discover:{niceType:"Discover",type:"discover",patterns:[6011,[644,649],65],gaps:[4,8,12],lengths:[16,19],code:{name:"CID",size:3}},jcb:{niceType:"JCB",type:"jcb",patterns:[2131,1800,[3528,3589]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVV",size:3}},unionpay:{niceType:"UnionPay",type:"unionpay",patterns:[620,[624,626],[62100,62182],[62184,62187],[62185,62197],[62200,62205],[622010,622999],622018,[622019,622999],[62207,62209],[622126,622925],[623,626],6270,6272,6276,[627700,627779],[627781,627799],[6282,6289],6291,6292],gaps:[4,8,12],lengths:[14,15,16,17,18,19],code:{name:"CVN",size:3}},maestro:{niceType:"Maestro",type:"maestro",patterns:[493698,[5e5,506698],[506779,508999],[56,59],63,67,6],gaps:[4,8,12],lengths:[12,13,14,15,16,17,18,19],code:{name:"CVC",size:3}},elo:{niceType:"Elo",type:"elo",patterns:[401178,401179,438935,457631,457632,431274,451416,457393,504175,[506699,506778],[509e3,509999],627780,636297,636368,[650031,650033],[650035,650051],[650405,650439],[650485,650538],[650541,650598],[650700,650718],[650720,650727],[650901,650978],[651652,651679],[655e3,655019],[655021,655058]],gaps:[4,8,12],lengths:[16],code:{name:"CVE",size:3}},mir:{niceType:"Mir",type:"mir",patterns:[[2200,2204]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVP2",size:3}},hiper:{niceType:"Hiper",type:"hiper",patterns:[637095,637568,637599,637609,637612],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},hipercard:{niceType:"Hipercard",type:"hipercard",patterns:[606282],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}}},ZE=qE,JE=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}))},$E=zE,QE=XE,tk={},ek={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"},nk=[ek.VISA,ek.MASTERCARD,ek.AMERICAN_EXPRESS,ek.DINERS_CLUB,ek.DISCOVER,ek.JCB,ek.UNIONPAY,ek.MAESTRO,ek.ELO,ek.MIR,ek.HIPER,ek.HIPERCARD];function rk(t){return tk[t]||YE[t]}function ik(t,e){var n=WE.indexOf(t);if(!e&&-1===n)throw new Error('"'+t+'" is not a supported card type.');return n}function ok(t){var e,n=[];return $E(t)?0===t.length?WE.map((function(t){return ZE(rk(t))})):(WE.forEach((function(e){var r=rk(e);QE(t,r,n)})),(e=JE(n))?[e]:n):[]}WE=ZE(nk),ok.getTypeInfo=function(t){return ZE(rk(t))},ok.removeCard=function(t){var e=ik(t);WE.splice(e,1)},ok.addCard=function(t){var e=ik(t.type,!0);tk[t.type]=t,-1===e&&WE.push(t.type)},ok.updateCard=function(t,e){var n,r=tk[t]||YE[t];if(!r)throw new Error('"'+t+'" is not a recognized type. Use `addCard` instead.');if(e.type&&r.type!==e.type)throw new Error("Cannot overwrite type parameter.");n=ZE(r),Object.keys(n).forEach((function(t){e[t]&&(n[t]=e[t])})),tk[n.type]=n},ok.changeOrder=function(t,e){var n=ik(t);WE.splice(n,1),WE.splice(e,0,t)},ok.resetModifications=function(){WE=ZE(nk),tk={}},ok.types=ek;var ak=ok,sk=FE,uk=ak;function ck(t,e,n){return{card:t,isPotentiallyValid:e,isValid:n}}var hk=function(t,e){var n,r,i,o,a;if(e=e||{},"number"==typeof t&&(t=String(t)),"string"!=typeof t)return ck(null,!1,!1);if(t=t.replace(/\-|\s/g,""),!/^\d*$/.test(t))return ck(null,!1,!1);if(0===(n=uk(t)).length)return ck(null,!1,!1);if(1!==n.length)return ck(null,!0,!1);if(r=n[0],e.maxLength&&t.length>e.maxLength)return ck(r,!1,!1);for(i=r.type===uk.types.UNIONPAY&&!0!==e.luhnValidateUnionPay||sk(t),a=Math.max.apply(null,r.lengths),e.maxLength&&(a=Math.min(e.maxLength,a)),o=0;o<r.lengths.length;o++)if(r.lengths[o]===t.length)return ck(r,t.length<a||i,i);return ck(r,t.length<a,!1)};function lk(t,e,n){return{isValid:t,isPotentiallyValid:e,isCurrentYear:n||!1}}var fk=function(t,e){var n,r,i,o,a;return e=e||19,"string"!=typeof t?lk(!1,!1):""===t.replace(/\s/g,"")?lk(!1,!0):/^\d*$/.test(t)?(r=t.length)<2?lk(!1,!0):(n=(new Date).getFullYear(),3===r?lk(!1,t.slice(0,2)===String(n).slice(0,2)):r>4?lk(!1,!1):(t=parseInt(t,10),i=Number(String(n).substr(2,2)),2===r?(a=i===t,o=t>=i&&t<=i+e):4===r&&(a=n===t,o=t>=n&&t<=n+e),lk(o,o,a))):lk(!1,!1)},pk=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},dk=fk,gk=pk;function mk(t,e,n){return{isValid:t,isPotentiallyValid:e,isValidForThisYear:n||!1}}var vk=function(t){var e,n,r=(new Date).getMonth()+1;return"string"!=typeof t?mk(!1,!1):""===t.replace(/\s/g,"")||"0"===t?mk(!1,!0):/^\d*$/.test(t)?(e=parseInt(t,10),isNaN(t)?mk(!1,!1):mk(n=e>0&&e<13,n,n&&e>=r)):mk(!1,!1)},yk=function(t){var e,n,r,i,o;return/^\d{4}-\d{1,2}$/.test(t)?t=t.split("-").reverse():/\//.test(t)?t=t.split(/\s*\/\s*/g):/\s/.test(t)&&(t=t.split(/ +/g)),gk(t)?{month:t[0]||"",year:t.slice(1).join()}:(r=t,n=0===(o=Number(r[0]))?2:o>1||1===o&&Number(r[1])>2?1:1===o?(i=r.substr(1),dk(i).isPotentiallyValid?1:2):5===r.length?1:r.length>5?2:1,{month:e=t.substr(0,n),year:t.substr(e.length)})},bk=vk,wk=fk;function Sk(t,e,n,r){return{isValid:t,isPotentiallyValid:e,month:n,year:r}}var Tk=3;function Ak(t,e){return{isValid:t,isPotentiallyValid:e}}function Ek(t,e){return{isValid:t,isPotentiallyValid:e}}var kk={number:hk,expirationDate:function(t,e){var n,r,i,o;if("string"==typeof t)t=t.replace(/^(\d\d) (\d\d(\d\d)?)$/,"$1/$2"),n=yk(t);else{if(null===t||"object"!=typeof t)return Sk(!1,!1,null,null);n={month:String(t.month),year:String(t.year)}}if(r=bk(n.month),i=wk(n.year,e),r.isValid){if(i.isCurrentYear)return Sk(o=r.isValidForThisYear,o,n.month,n.year);if(i.isValid)return Sk(!0,!0,n.month,n.year)}return r.isPotentiallyValid&&i.isPotentiallyValid?Sk(!1,!0,null,null):Sk(!1,!1,null,null)},expirationMonth:vk,expirationYear:fk,cvv:function(t,e){return e=(e=e||Tk)instanceof Array?e:[e],"string"!=typeof t?Ak(!1,!1):/^\d*$/.test(t)?function(t,e){for(var n=0;n<t.length;n++)if(e===t[n])return!0;return!1}(e,t.length)?Ak(!0,!0):t.length<Math.min.apply(null,e)?Ak(!1,!0):t.length>function(t){for(var e=Tk,n=0;n<t.length;n++)e=t[n]>e?t[n]:e;return e}(e)?Ak(!1,!1):Ak(!0,!0):Ak(!1,!1)},postalCode:function(t,e){var n;return n=(e=e||{}).minLength||3,"string"!=typeof t?Ek(!1,!1):t.length<n?Ek(!1,!0):Ek(!0,!0)},creditCardType:ak},xk=[{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"}];kk.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}}),kk.creditCardType.changeOrder("verve",0);var Ok={getEncryptedPin:function(t){return t?OE(t):void 0},getLast4:function(t){return t.substring(t.length-4)},tokenize:function(t){var e=t.number,n=t.cvv,r=t.month,i=t.year;return OE("".concat(e,"*").concat(n,"*").concat(r,"*").concat(i))},getType:function(t){var e=kk.number(t);return e&&e.card?{type:e.card.type,maxLength:Math.max.apply(Math,b(e.card.lengths)),minLength:Math.min.apply(Math,b(e.card.lengths))}:{type:null,maxLength:0}},validate:function(t){var e=t.number,n=t.cvv,r=t.month,i=t.year,o=this.getType(e).type,a={number:this.isNumberValid(e),expiry:this.isExpiryValid({month:r,year:i}),cvv:this.isCvvValid(n,o)};return{isValid:Object.values(a).every((function(t){return!0===t})),result:a}},validateNumber:function(t){return kk.number(t)},isNumberValid:function(t){return Ok.validateNumber(t).isValid},validateCVV:function(t,e){var n="american-express"===e?4:3;return kk.cvv(t,n)},isCvvValid:function(t,e){return Ok.validateCVV(t,e).isValid},validateExpiry:function(t){if(null!==t&&"object"===r(t)){var e=t.month,n=t.year;return kk.expirationMonth(e)&&kk.expirationYear(n)}return kk.expirationDate(t)},isExpiryValid:function(t){return Ok.validateExpiry(t).isValid},findTestCard:function(t){var e=t||"default";return xk.find((function(t){return t.type===e}))}},Rk=function(){function t(e){var n=e.number,r=e.cvv,i=e.month,o=e.year,s=e.pin;a(this,t),this.number=n,this.cvv=r,this.month=i,this.year=o,this.pin=s}return u(t,[{key:"getEncryptedPin",value:function(){return Ok.getEncryptedPin(this.pin)}},{key:"getLast4",value:function(){return Ok.getLast4(this.number)}},{key:"tokenize",value:function(){return Ok.tokenize({number:this.number,cvv:this.cvv,month:this.month,year:this.year})}}],[{key:"getType",value:function(t){return Ok.getType(t)}},{key:"validate",value:function(t){var e=t.number,n=t.cvv,r=t.month,i=t.year;return Ok.validate({number:e,cvv:n,month:r,year:i})}},{key:"validateNumber",value:function(t){return Ok.validateNumber(t)}},{key:"isNumberValid",value:function(t){return Ok.isNumberValid(t)}},{key:"validateCVV",value:function(t,e){return Ok.validateCVV(t,e)}},{key:"isCvvValid",value:function(t,e){return Ok.isCvvValid(t,e)}},{key:"validateExpiry",value:function(t){return Ok.validateExpiry(t)}},{key:"isExpiryValid",value:function(t){return Ok.isExpiryValid(t)}},{key:"generateTestCard",value:function(e){return new t(Ok.findTestCard(e))}}]),t}(),Ck=function(t){var e=t.clientdata,r=t.last4,i=t.pin,o=t.trans,a=t.device,s=t.rememberCard,u=t.transactionType,c=t.subscription,h=t.customFields,l="".concat(Kd.paymentBaseUrl,"charge/"),f=$A(),p=n({"Content-Type":"application/x-www-form-urlencoded"},f&&{"Accept-Language":f}),d=n(n(n({clientdata:e,last4:r,trans:o,device:a,offset:(new Date).getTimezoneOffset(),remember_card:s},u&&{transaction_type:u}),c&&{subscription:c}),h&&h);i&&(d.handle=i);var g=fE(d);return JA.post(l,g,{headers:p}).then((function(t){return sg.parse(t.data)}))},Pk=function(t){var e=t.device,r=t.accessCode,i=t.pin,o="".concat(Kd.paymentBaseUrl,"charge/resume/").concat(r),a=$A(),s=n({"Content-Type":"application/x-www-form-urlencoded"},a&&{"Accept-Language":a}),u=n({device:e},i&&{handle:i}),c=fE(u);return JA.post(o,c,{headers:s}).then((function(t){return sg.parse(t.data)}))},Bk=function(t){var e=t.last4,r=t.trans,i=t.device,o=t.authorizationCode,a=t.cvv,s=t.pin,u=t.transactionType,c=t.subscription,h="".concat(Kd.paymentBaseUrl,"charge/"),l=$A(),f=n({"Content-Type":"application/x-www-form-urlencoded"},l&&{"Accept-Language":l}),p=n(n({last4:e,trans:r,device:i,cvv:a,handle:s,authorization_code:o},u&&{transaction_type:u}),c&&{subscription:c}),d=fE(p);return JA.post(h,d,{headers:f}).then((function(t){return sg.parse(t.data)}))},Lk=function(t,e){var r="".concat(Kd.paymentBaseUrl,"charge/validate"),i={trans:t,token:e},o=$A(),a=n({},o&&{"Accept-Language":o}),s=fE(i);return JA.post(r,s,{headers:a}).then((function(t){return sg.parse(t.data)}))},Ik=function(t){var e=t.address,r=t.city,i=t.state,o=t.zipCode,a=t.transactionId,s="".concat(Kd.paymentBaseUrl,"charge/avs"),u=$A(),c=n({"Content-Type":"application/x-www-form-urlencoded"},u&&{"Accept-Language":u}),h=fE({city:r,state:i,address:e,zip_code:o,trans:a});return JA.post(s,h,{headers:c}).then((function(t){return sg.parse(t.data)}))},Dk=function(t){var e=t.authorizationId,r=t.publicKey,i=$A(),o=n({Authorization:"Bearer ".concat(r)},i&&{"Accept-Language":i}),a={authorization_id:e},s="".concat(Kd.paystackApiUrl,"rememberme/forget_card");return JA.post(s,a,{headers:o}).then((function(t){return sg.parse(t.data)}))},Nk=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s,u,c,h,l;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.transaction,i=t.phone,o=t.channels,a=t.email,s=new URL("/saved_cards/authorize",Kd.paystackApiUrl).toString(),u=$A(),c=n({},u&&{"Accept-Language":u}),h=n(n(n(n({},i&&{phone:i}),o&&{channels:o}),a&&{email:a}),{},{transaction:r}),e.next=7,JA.post(s,h,{headers:c});case 7:return l=e.sent,e.abrupt("return",l.data);case 9:case"end":return e.stop()}}),e)})))()},_k=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s,u,c,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.code,i=t.transaction,o=t.token,a=new URL("/saved_cards/authorize/verify",Kd.paystackApiUrl).toString(),s=$A(),u=n({Authorization:"Bearer ".concat(o)},s&&{"Accept-Language":s}),c={code:r,transaction:i},e.next=7,JA.post(a,c,{headers:u});case 7:return h=e.sent,e.abrupt("return",h.data);case 9:case"end":return e.stop()}}),e)})))()},jk=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.token,i=new URL("/saved_cards/cards",Kd.paystackApiUrl).toString(),o=$A(),a=n({Authorization:"Bearer ".concat(r),"jwt-auth":!0},o&&{"Accept-Language":o}),e.next=6,JA.get(i,{headers:a});case 6:return s=e.sent,e.abrupt("return",s.data);case 8:case"end":return e.stop()}}),e)})))()},Mk=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.cardCode,i=t.token,o=new URL("/saved_cards/cards/".concat(r),Kd.paystackApiUrl).toString(),a=$A(),s=n({Authorization:"Bearer ".concat(i),"jwt-auth":!0},a&&{"Accept-Language":a}),e.next=6,JA.delete(o,{headers:s});case 6:return u=e.sent,e.abrupt("return",u.data);case 8:case"end":return e.stop()}}),e)})))()},Uk=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s,u,c,h,l,f;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.token,i=t.device,o=t.cardCode,a=t.transaction,s=t.selectedCurrency,u=new URL("/saved_cards/cards/".concat(o,"/charge"),Kd.paystackApiUrl).toString(),c=$A(),h=n({Authorization:"Bearer ".concat(r),"jwt-auth":!0},c&&{"Accept-Language":c}),l={device:i,transaction:a,selected_currency:s},e.next=7,JA.post(u,l,{headers:h});case 7:return f=e.sent,e.abrupt("return",sg.parse(f.data));case 9:case"end":return e.stop()}}),e)})))()},Vk="card",Fk="saved card",qk="otp";function zk(t,e){return new Promise((function(n,r){var i=Rk.validate(t);if(!i.isValid){var o=e||t.number,a=Object.keys(i.result).filter((function(t){return!1===i.result[t]})),s="Invalid card details: ".concat(a.join(", "));r(Error(o?s:"Please set a valid card with Transaction.setCard()"))}n()}))}var Hk={setCard:function(t){var e=this;return zk(t,!0).then((function(){e.card=new Rk(t)}))},rememberCard:function(){this.remember_card=!0},chargeCard:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return!this.card.number&&this.card.pin?this.chargeCardWithPin(e):zk(this.card).then((function(){t.logAttempt(Vk);var n={clientdata:t.card.tokenize(),last4:t.card.getLast4(),pin:t.card.getEncryptedPin(),trans:t.id,device:t.deviceFingerprint,rememberCard:t.remember_card,transactionType:t.transactionType,subscription:t.subscription,customFields:e};return Ck(n).then((function(e){return t.logAPIResponse(e,Vk),e}))}))},chargeCardWithPin:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logAttempt(Vk);var n={pin:OE(this.card.pin),trans:this.id,device:this.deviceFingerprint,rememberCard:this.remember_card,transactionType:this.transactionType,subscription:this.subscription,customFields:e};return Ck(n).then((function(e){return t.logAPIResponse(e,Vk),e}))},chargeRememberedCard:function(t){var e=this,n=t.cvv,r=t.authorizationCode,i=t.cardLast4,o=t.pin;this.logAttempt(Vk);var a=OE(o),s={authorizationCode:r,cvv:n,last4:i,trans:this.id,device:this.deviceFingerprint,pin:a,transactionType:this.transactionType,subscription:this.subscription};return Bk(s).then((function(t){return e.logAPIResponse(t,Vk),t}))},resumeCardCharge:function(t){var e=this,r=t.accessCode,i=t.pin,o=n(n({},i&&{pin:OE(i)}),{},{accessCode:r,device:this.deviceFingerprint});return Pk(o).then((function(t){return e.logAPIResponse(t,Vk),t}))},forgetRememberedCard:function(t){var e=this,n={authorizationId:t,publicKey:this.merchant.key};return Dk(n).then((function(t){return e.logAPIResponse(t,Vk),t}))},authenticateCard:function(t){var e=this;return Lk(this.id,t).then((function(t){return e.logAPIResponse(t,Vk),t}))},verifyAddress:function(t){var e=this,n=t.address,r={city:t.city,state:t.state,address:n,zipCode:t.zipCode,transactionId:this.id};return Ik(r).then((function(t){return e.logAPIResponse(t,Vk),t}))},listenFor3DSCharge:function(t){var e={channel:"3DS_".concat(this.id),paymentMethod:Vk};return this.listenForCharge(e,t)},sendSavedCardsOTP:function(){var t=arguments,e=this;return o(regeneratorRuntime.mark((function n(){var r,i,o,a,s;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=(r=t.length>0&&void 0!==t[0]?t[0]:{}).phone,o=r.channels,a=r.email,n.prev=1,e.logAuth(qk),n.next=5,Nk({phone:i,transaction:e.id,channels:o,email:a});case 5:return s=n.sent,e.savedCardsTempAuthToken=s.data.token,n.abrupt("return",s);case 10:throw n.prev=10,n.t0=n.catch(1),e.savedCardsTempAuthToken=null,n.t0;case 14:case"end":return n.stop()}}),n,null,[[1,10]])})))()},verifySavedCardsOtp:function(t){var e=this;return o(regeneratorRuntime.mark((function n(){var r,i,o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=t.code,i={code:r,transaction:e.id,token:e.savedCardsTempAuthToken},n.prev=2,n.next=5,_k(i);case 5:return o=n.sent,e.savedCardsToken=o.data.token,n.abrupt("return",o);case 10:throw n.prev=10,n.t0=n.catch(2),e.savedCardsToken=null,n.t0;case 14:case"end":return n.stop()}}),n,null,[[2,10]])})))()},getSavedCards:function(){return jk({token:this.savedCardsToken})},deleteSavedCard:function(t){return Mk({cardCode:t,token:this.savedCardsToken})},chargeSavedCard:function(t){var e=t.cardCode,n=t.selectedCurrency,r=void 0===n?this.currency:n;return this.logAttempt(Fk),Uk({cardCode:e,transaction:this.id,token:this.savedCardsToken,device:this.deviceFingerprint,selectedCurrency:r})}},Gk=function(){function t(e){var n=e.bankId,r=e.accountType,i=e.accountNumber;a(this,t),this.bankId=n,this.accountType=r,this.accountNumber=i}var e;return u(t,null,[{key:"validate",value:function(e){var n=e.bankId,r=e.accountType,i=e.accountNumber,o=[];return n&&"number"==typeof n||o.push("Invalid bankId. Please check for supported banks with BankAccount.supportedBanks()"),t.types.indexOf(r)>-1?"nuban"!==r||t.isValidNubanAccount(i)||o.push("Invalid account number. Nuban accounts must be 10 digit numbers"):o.push("Invalid bank type. Please check BankAccount.types for the list of valid bank types"),{isValid:0===o.length,errors:o}}},{key:"isValidNubanAccount",value:function(t){return!!t&&(("number"==typeof t||/^\d+$/.test(t))&&10===t.length)}},{key:"supportedBanks",value:function(){var t="".concat(Kd.paymentBaseUrl,"bank?pay_with_bank=true"),e=$A(),r=n({},e&&{"Accept-Language":e});return JA.post(t,{headers:r}).then((function(t){return t.data}))}},{key:"resolve",value:(e=o(regeneratorRuntime.mark((function t(e){var r,i,o,a,s,u,c,h;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.transaction,i=e.bankCode,o=e.accountNumber,a=new URL("saved_cards/transaction/".concat(r,"/bank-resolve"),Kd.paystackApiUrl),s=$A(),u=n({},s&&{"Accept-Language":s}),c={bank_code:i,account_number:o},t.next=7,JA.post(a,c,{headers:u});case 7:return h=t.sent,t.abrupt("return",h.data);case 9:case"end":return t.stop()}}),t)}))),function(t){return e.apply(this,arguments)})}]),t}();Gk.types=["nuban"];var Kk=function(t){var e=t.bankId,r=t.transactionId,i=t.accountNumber,o=t.device,a="".concat(Kd.paymentBaseUrl,"bank/charge_account/").concat(e,"/").concat(r),s=$A(),u=n({"Content-Type":"application/x-www-form-urlencoded"},s&&{"Accept-Language":s}),c=fE({account_number:i,device:o});return JA.post(a,c,{headers:u}).then((function(t){return sg.parse(t.data)}))},Wk=function(t){var e=t.bankId,r=t.transactionId,i=t.accountNumber,o=t.birthday,a="".concat(Kd.paymentBaseUrl,"bank/charge_account/").concat(e,"/").concat(r),s=$A(),u=n({"Content-Type":"application/x-www-form-urlencoded"},s&&{"Accept-Language":s}),c=fE({account_number:i,birthday:o});return JA.post(a,c,{headers:u}).then((function(t){return sg.parse(t.data)}))},Xk=function(t){var e=t.bankId,r=t.transactionId,i=t.token,o=t.device,a="".concat(Kd.paymentBaseUrl,"bank/validate_token/").concat(e,"/").concat(r),s=$A(),u=n({"Content-Type":"application/x-www-form-urlencoded"},s&&{"Accept-Language":s}),c=fE({device:o,token:i});return JA.post(a,c,{headers:u}).then((function(t){return sg.parse(t.data)}))},Yk="bank account";function Zk(t,e){return new Promise((function(n,r){var i=Gk.validate(t);if(!i.isValid){var o=e||t.accountNumber?i.errors[0]:"Please set a valid bank account with Transaction.setBank()";r(Error(o))}n()}))}var Jk={getIbankUrl:function(t){var e=this,n=t.bankId;return new Promise((function(t,r){n||r(Error("Please send bankId"));var i="".concat(Kd.paymentBaseUrl,"bank/ibank/").concat(n,"/").concat(e.id);t(sg.success({url:i}))}))},listenForIbankCharge:function(t){var e={channel:"IBANK_".concat(this.id),paymentMethod:"ibank"};return this.listenForCharge(e,t)}},$k=function(t){var e=t.bankId,r=t.transactionId,i=t.phoneNumber,o=t.payId,a=t.walletId,s="".concat(Kd.paymentBaseUrl,"bank/digitalbankmandate/").concat(e,"/").concat(r),u=$A(),c=n({"Content-Type":"application/x-www-form-urlencoded"},u&&{"Accept-Language":u}),h=fE(a?{wallet_id:a}:{phone_number:i,token:o});return JA.post(s,h,{headers:c}).then((function(t){return sg.parse(t.data)}))},Qk="bank",tx={chargeDigitalBankMandate:function(t){var e=this,n=t.phoneNumber,r=t.payId,i=t.bankId,o=t.walletId,a={transactionId:this.id,phoneNumber:n,payId:r,bankId:i,walletId:o};return $k(a).then((function(t){return e.logAPIResponse(t,Qk),t}))},listenForDigitalBankMandateCharge:function(t){var e={paymentMethod:Qk,channel:arguments.length>1&&void 0!==arguments[1]?arguments[1]:""};return this.listenForCharge(e,t)}},ex=n(n(n({},{setBankAccount:function(t){var e=this;return Zk(t,!0).then((function(){e.bankAccount=new Gk(t)}))},chargeBankAccount:function(){var t=this;return Zk(this.bankAccount).then((function(){t.logAttempt(Yk);var e={bankId:t.bankAccount.bankId,transactionId:t.id,accountNumber:t.bankAccount.accountNumber,device:t.deviceFingerprint};return Kk(e).then((function(e){return t.logAPIResponse(e,Yk),e}))}))},registerBankAccount:function(t){var e=this;return Zk(this.bankAccount).then((function(){var n={bankId:e.bankAccount.bankId,transactionId:e.id,accountNumber:e.bankAccount.accountNumber,birthday:t};return Wk(n).then((function(t){return e.logAPIResponse(t,Yk),t}))}))},authenticateBankAccount:function(t){var e=this;return Zk(this.bankAccount).then((function(){var n={bankId:e.bankAccount.bankId,transactionId:e.id,token:t,device:e.deviceFingerprint};return Xk(n).then((function(t){return e.logAPIResponse(t,Yk),t}))}))}}),Jk),tx),nx=function(t,e){var r=$A(),i=n({Authorization:"Bearer ".concat(e)},r&&{"Accept-Language":r});return JA.post("".concat(Kd.paystackApiUrl,"checkout/ussd/reference"),t,{headers:i}).then((function(t){return sg.parse(t.data)}))},rx=function(t,e){var r=$A(),i=n({Authorization:"Bearer ".concat(e)},r&&{"Accept-Language":r});return JA.post("".concat(Kd.paystackApiUrl,"checkout/pay_with_transfer_ussd"),t,{headers:i}).then((function(t){return sg.parse(t.data)}))},ix={getUSSDShortcode:function(t){var e=this,n=t.channel,r={transaction:this.id,channel:n};return nx(r,this.merchant.key).then((function(t){return"success"===t.status&&(e.ussd[n]=t),t}))},getPWTUSSDShortcode:function(t){var e=this,n=t.bankSlug,r=t.fulfilLateNotification,i=void 0!==r&&r,o={transaction_id:this.id,fulfil_late_notification:i,bank_slug:n};return rx(o,this.merchant.key).then((function(t){return"success"===t.status&&(e.ussd[n]=t),t}))},listenForPWTUSSDCharge:function(t,e){var n=t.bankSlug;if(!this.ussd[n])return Promise.reject(Error("Please generate a ussd shortcode with Transaction.getPWTUSSDShortcode()"));var r={channel:this.ussd[n].data.pusher_channel,paymentMethod:"ussd"};return this.listenForCharge(r,e)},listenForUSSDCharge:function(t,e){var n=t.channel;if(!this.ussd[n])return Promise.reject(Error("Please generate a ussd shortcode with Transaction.getUSSDShortcode()"));var r={channel:this.ussd[n].data.channel,paymentMethod:n};return this.listenForCharge(r,e)}},ox=function(t,e){var r={source:"checkout",reference:t.transaction,channel:t.channel},i=$A(),o=n({Authorization:"Bearer ".concat(e)},i&&{"Accept-Language":i});return JA.post("".concat(Kd.paystackApiUrl,"offline/qr/generate"),r,{headers:o}).then((function(t){return sg.parse(t.data)}))};function ax(t){return new Promise((function(e,n){var r=["visa","MPASS_OLTI"];if(r.indexOf(t)<=-1){var i="Invalid channel. Available channels: ".concat(r.join(", "));n(Error(i))}else e()}))}var sx={getQRCode:function(t){var e=this,n=t.channel;return ax(n).then((function(){if(e.qr[n])return e.qr[n];var t={transaction:e.id,channel:n};return ox(t,e.merchant.key).then((function(t){return"success"===t.status&&(e.qr[n]=t),t}))}))},listenForQRCharge:function(t,e){var n=this,r=t.channel;return ax(r).then((function(){if(!n.qr[r])return Promise.reject(Error("Please generate qr code with Transaction.getQRCode()"));var t={channel:n.qr[r].data.channel,paymentMethod:r};return n.listenForCharge(t,e)}))}},ux=function(){function t(){a(this,t)}return u(t,null,[{key:"hasCountryCode",value:function(t){return t&&"+"===t[0]}},{key:"hasOnlyDigits",value:function(t){var e;return t&&(e=t.substring(1),/^\d+$/.test(e))}},{key:"isE164Number",value:function(t){return t&&t.length<17}},{key:"validate",value:function(e){var n=[];return t.hasCountryCode(e)||n.push("Number should include country code prefix"),t.hasOnlyDigits(e)||n.push("Number should contain only digits"),t.isE164Number(e)||n.push("Number should not be longer than 16 digits"),{isValid:0===n.length,errors:n}}}]),t}(),cx=function(t){var e={transaction:t.transaction,phone:t.phone,device:t.device,channel_name:t.channel_name,provider:t.provider,voucher:t.voucher,registration_token:t.registrationToken},r=$A(),i=n({},r&&{"Accept-Language":r});return JA.post("".concat(Kd.paystackApiUrl,"charge/mobile_money"),e,{headers:i}).then((function(t){return sg.parse(t.data)})).catch((function(t){var e=t.response;return sg.parse(e.data)}))},hx=function(t){var e=t.transaction,r=t.code,i=$A(),o=n({},i&&{"Accept-Language":i}),a=fE({transaction:e,otp:r}),s=new URL("charge/momo_payin_finalize",Kd.paymentBaseUrl).toString();return JA.post(s,a,{headers:o}).then((function(t){return sg.parse(t.data)}))};function lx(t){return new Promise((function(e,n){var r=ux.validate(t);if(!r.isValid){var i=t?r.errors[0]:"Please start a mobile money transaction with Transaction.chargeMobileMoney()";n(Error(i))}e(r)}))}var fx={mobileMoneyChargeAPI:function(t){var e=this;return cx(t).then((function(t){return"success"===t.status&&(e.mobileMoney=t,t.data&&t.data.display&&1===t.data.display.otpSentCount&&e.logTokenRequest("mobile money")),t}))},chargeMobileMoney:function(t){var e=this,n=t.phoneNumber,r=t.provider,i=t.voucher,o=t.registrationToken;return lx(n).then((function(){e.logAttempt("mobile money");var t={provider:r,voucher:i,registrationToken:o,transaction:e.id,phone:n,device:e.deviceFingerprint,channel_name:"MOBILE_MONEY_".concat(e.id)};return e.mobileMoneyChargeAPI(t)}))},chargeMpesaOffline:function(t){var e=t.provider,n=t.voucher,r=t.registrationToken;this.logAttempt("mobile money");var i={provider:e,voucher:n,registrationToken:r,transaction:this.id,device:this.deviceFingerprint,channel_name:"MOBILE_MONEY_".concat(this.id)};return this.mobileMoneyChargeAPI(i)},authenticateMobileMoney:function(t){var e=this,n=t.phoneNumber,r=t.provider,i=t.registrationToken;return lx(n).then((function(){e.logMobileMoneyActions(t);var o={provider:r,registrationToken:i,transaction:e.id,phone:n,device:e.deviceFingerprint,channel_name:"MOBILE_MONEY_".concat(e.id)};return cx(o).then((function(t){return"success"===t.status?(e.mobileMoney=t,t.data&&t.data.display&&1===t.data.display.otpSentCount&&e.logTokenRequest("mobile money")):t.errors&&t.errors.data&&"awaiting_registration_token"===t.errors.data.status?e.logTokenAuthenticationFailure(t.message):e.logError(t.message),t}))}))},submitMobileMoneyCode:function(t){var e=this;return hx({code:t.code,transaction:this.id}).then((function(t){return e.logAPIResponse(t,"mobile_money"),t}))},listenForMobileMoneyCharge:function(t){if("success"!==this.mobileMoney.status)return Promise.reject(Error("Please start a mobile money charge with Transaction.chargeMobileMoney()"));var e=this.mobileMoney.data,n=e.channel,r=e.channel_name,i={channel:n||r,paymentMethod:"mobile_money"};return this.listenForCharge(i,t)}},px=function(t){var e={email:t.email,password:t.password},r=$A(),i=n({},r&&{"Accept-Language":r});return JA.post("".concat(Kd.paystackApiUrl,"login"),e,{headers:i}).then((function(t){return sg.parse(t.data)}))},dx=function(t){var e=t.account_code,r=t.transaction,i=t.token,o=$A(),a=n({Authorization:"Bearer ".concat(i),"jwt-auth":!0},o&&{"Accept-Language":o}),s={account_code:e,transaction:r};return JA.post("".concat(Kd.paystackApiUrl,"directdebit/initiate"),s,{headers:a}).then((function(t){return sg.parse(t.data)}))},gx=function(t){var e=t.otp,r=t.transaction,i=t.token,o=$A(),a=n({Authorization:"Bearer ".concat(i),"jwt-auth":!0},o&&{"Accept-Language":o}),s={otp:e,transaction:r};return JA.post("".concat(Kd.paystackApiUrl,"directdebit/validate"),s,{headers:a}).then((function(t){return sg.parse(t.data)}))},mx=function(t){var e=$A(),r=n({Authorization:"Bearer ".concat(t),"jwt-auth":!0},e&&{"Accept-Language":e});return JA.get("".concat(Kd.paystackApiUrl,"directdebit/account"),{headers:r}).then((function(t){return t.data}))},vx="direct debit",yx={loginToDirectDebitAccount:function(t){var e=this,n=t.email,r={email:n,password:t.password};return Jc(n)?px(r).then((function(t){if("success"===t.status){var n=t.data,r=n.token,i=n.user.permissions;if(!i||i.length<1)throw Error("You do not have the privileges to perform this action");if(i.find((function(t){return"directdebit-*"===t})))return e.directDebit.token=r,t;throw Error("You do not have the privileges to perform this action")}return t})):Promise.reject(Error("Invalid email"))},chargeDirectDebit:function(t){var e=this;if(!this.directDebit.token)return Promise.reject(Error("Please login with Transaction.loginToDirectDebitAccount() to start a Direct debit charge"));this.logAttempt(vx);var n={account_code:t,transaction:this.id,token:this.directDebit.token};return dx(n).then((function(t){return e.logAPIResponse(t,vx),t.status&&(e.directDebit.chargeResponse=t),t}))},getProvisionedAccounts:function(){var t=this;return mx(this.directDebit.token).then((function(e){t.logAPIResponse(e,vx);var n=e.status,r=e.data;if(n){if(r&&r.length<1)return Promise.reject(Error("You have not provisioned any bank account for Direct Debit yet"));t.directDebit.accounts=e.data}return e}))},authenticateAccount:function(t){var e=this,n={otp:t,transaction:this.id,token:this.directDebit.token};return gx(n).then((function(t){return e.logAPIResponse(t,vx),t}))}},bx=tr.PROPER,wx=x,Sx=ec,Tx=hc.trim;li({target:"String",proto:!0,forced:function(t){return wx((function(){return!!Sx[t]()||"
"!=="
"[t]()||bx&&Sx[t].name!==t}))}("trim")},{trim:function(){return Tx(this)}});var Ax,Ex="capitec_pay",kx="CELLPHONE",xx="IDNUMBER",Ox="ACCOUNTNUMBER",Rx={combineIdentifierKeyAndIdentifierValue:function(t){var e=t.identifierKey,n=t.identifierValue;return"".concat(e,"*").concat(n)},encryptIdentifierKeyAndIdentifierValue:function(t){var e=t.identifierKey,n=t.identifierValue;return OE(Rx.combineIdentifierKeyAndIdentifierValue(e,n))},validateAccountNumber:function(t){return/^\d{10}$/.test(t)},validateIDNumber:function(t){return/^\d{13}$/.test(t)},validateCellphoneNumber:function(t){return/^0\d{9}$/.test(t)},validateIdentifierKeyAndIdentifierValue:function(t){var e=t.identifierKey,n=t.identifierValue;switch(e){case kx:return Rx.validateCellphoneNumber(n);case xx:return Rx.validateIDNumber(n);case Ox:return Rx.validateAccountNumber(n);default:return!1}}},Cx={authenticate:function(t){var e=t.clientData,r=t.transactionId,i=t.deviceFingerprint,o=t.publicKey,a=new URL("authenticate/",Kd.paystackApiUrl),s=$A(),u=n({Authorization:"Bearer ".concat(o),"Content-Type":"application/x-www-form-urlencoded"},s&&{"Accept-Language":s}),c=fE({clientdata:e,trans:r,device:i});return JA.post(a,c,{headers:u}).then((function(t){return t.data}))},requery:(Ax=o(regeneratorRuntime.mark((function t(e){var r,i,o,a,s,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.transactionId,i=e.publicKey,o=new URL("capitec-pay/requery",Kd.paystackApiUrl),a=$A(),s=n({Authorization:"Bearer ".concat(i)},a&&{"Accept-Language":a}),u={transaction_id:r},t.next=7,JA.get(o,{headers:s,params:u}).then((function(t){return sg.parse(t)}));case 7:return c=t.sent,t.abrupt("return",c);case 9:case"end":return t.stop()}}),t)}))),function(t){return Ax.apply(this,arguments)})},Px="capitec_pay",Bx={validateIdentifier:function(t){var e=t.identifierKey,n=t.identifierValue,r=(void 0===n?"":n).trim();return Rx.validateIdentifierKeyAndIdentifierValue({identifierKey:e,identifierValue:r})},authenticateCapitecPay:function(t){var e=this,n=t.identifierKey,r=t.identifierValue,i=(void 0===r?"":r).trim();if(!Rx.validateIdentifierKeyAndIdentifierValue({identifierKey:n,identifierValue:i}))return Promise.reject(new Error("Invalid identifier key and value"));var o=Rx.encryptIdentifierKeyAndIdentifierValue({identifierKey:n,identifierValue:i});return this.logCapitecPayAccountDetailsSubmission(n),Cx.authenticate({clientData:o,deviceFingerprint:this.deviceFingerprint,transactionId:this.id,publicKey:this.merchant.key}).then((function(t){return e.logCapitecPayAuthenticateResponse(t.status),t}))},requeryCapitecPay:function(){var t=this;return Cx.requery({transactionId:this.id,publicKey:this.merchant.key}).then((function(e){return t.logAPIResponse(e,Px),e}))},listenForCapitecPayCharge:function(t){var e={paymentMethod:Px,channel:arguments.length>1&&void 0!==arguments[1]?arguments[1]:""};return this.listenForCharge(e,t)}},Lx=function(t){return{card:Hk,bank:ex,ussd:ix,qr:sx,mobile_money:fx,direct_debit:yx,bank_transfer:hE,eft:mE,payattitude:gE,apple_pay:wE,paypal:kE,capitec_pay:Bx}[t]},Ix=function(t){t||"undefined"==typeof navigator||(t=navigator.userAgent);t&&t.headers&&"string"==typeof t.headers["user-agent"]&&(t=t.headers["user-agent"]);return"string"==typeof t&&(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))};var Dx=function(t){var e=t||{},n=e.attempts,r=e.authentication,i=e.errors,o=e.history;return{start_time:Math.round(Date.now()/1e3),time_spent:0,attempts:n||0,authentication:r,errors:i||0,success:!1,mobile:Ix(),input:[],history:o||[]}},Nx=function(t){return Math.round(Date.now()/1e3)-t},_x=li,jx=lt,Mx=uo,Ux=H,Vx=x,Fx=E.Array,qx=jx("JSON","stringify"),zx=Ux(/./.exec),Hx=Ux("".charAt),Gx=Ux("".charCodeAt),Kx=Ux("".replace),Wx=Ux(1..toString),Xx=/[\uD800-\uDFFF]/g,Yx=/^[\uD800-\uDBFF]$/,Zx=/^[\uDC00-\uDFFF]$/,Jx=function(t,e,n){var r=Hx(n,e-1),i=Hx(n,e+1);return zx(Yx,t)&&!zx(Zx,i)||zx(Zx,t)&&!zx(Yx,r)?"\\u"+Wx(Gx(t,0),16):t},$x=Vx((function(){return'"\\udf06\\ud834"'!==qx("\udf06\ud834")||'"\\udead"'!==qx("\udead")}));qx&&_x({target:"JSON",stat:!0,forced:$x},{stringify:function(t,e,n){for(var r=0,i=arguments.length,o=Fx(i);r<i;r++)o[r]=arguments[r];var a=Mx(qx,null,o);return"string"==typeof a?Kx(a,Xx,Jx):a}});var Qx=function(t,e){var r=e.merchantKey,i=e.log,o=$A(),a=n({Authorization:"Bearer ".concat(r)},o&&{"Accept-Language":o});return JA.post(t,{payload:JSON.stringify(i)},{headers:a}).then((function(t){return t.data}))},tO=function(t,e){var r=e.merchantKey,i=$A(),o=n({Authorization:"Bearer ".concat(r)},i&&{"Accept-Language":i});return JA.post(t,null,{headers:o}).then((function(t){return t.data}))},eO=function(t,e){var r=e.merchantKey,i=e.referrer,o=$A(),a=n({Authorization:"Bearer ".concat(r)},o&&{"Accept-Language":o});return JA.post(t,{referrer:i},{headers:a}).then((function(t){return t.data}))},nO=function(t,e,n){var r=new URL("transaction/update_log/".concat(t),Kd.paystackApiUrl).toString();return Qx(r,{merchantKey:e,log:n})},rO=function(t,e){var n=new URL("transaction/set_ip/".concat(t),Kd.paystackApiUrl).toString();return tO(n,{merchantKey:e})},iO=function(t,e,n){var r=new URL("transaction/set_referrer/".concat(t),Kd.paystackApiUrl).toString();return eO(r,{merchantKey:e,referrer:n})},oO=n(n({},{logCapitecPayConfirmation:function(t){return this.logHistoryEntry({type:"action",message:"Selected confirm with: ".concat(t),channel:Ex,time:this.getTimeSpent()})},logCapitecPayAuthenticateResponse:function(t){var e=t?"Customer authenticated Capitec Pay account successfully":"Customer failed to authenticate Capitec Pay account";return this.logHistoryEntry({type:"action",message:e,channel:Ex,time:this.getTimeSpent()})},logCapitecPayAccountIdentifierSwitch:function(t){return this.logHistoryEntry({type:"action",message:"Switched account identifier to: ".concat(t),channel:Ex,time:this.getTimeSpent()})},logCapitecPayConfirmedPayment:function(){return this.logHistoryEntry({type:"action",message:"Selected confirm payment",channel:Ex,time:this.getTimeSpent()})},logCapitecPayRetryConfirmation:function(){return this.logHistoryEntry({type:"action",message:"Selected retry payment confirmation",channel:Ex,time:this.getTimeSpent()})}}),{},{initializeLog:function(t){this.log=Dx(t)},getTimeSpent:function(){return this.log.time_spent=Nx(this.log.start_time),this.log.time_spent},logHistoryEntry:function(t){return this.log.history.push(t),this.saveLog()},logPageOpen:function(){return this.log.history.push({type:"open",message:"Opened checkout",time:this.getTimeSpent()}),this.saveLog()},logChannelSwitch:function(t){return this.log.history.push({type:"action",message:"Set payment method to: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logValidationErrors:function(t){var e=this;return t.forEach((function(t){e.log.history.push({type:"error",message:"Invalid ".concat(t),time:e.getTimeSpent()})})),this.saveLog()},logInput:function(t){var e=this.log.history.find((function(e){return e.message==="Filled this field: ".concat(t)}));return this.log.history.push({type:"input",message:"".concat(e?"Changed":"Filled"," this field: ").concat(t),time:this.getTimeSpent()}),this.saveLog()},logBankSelect:function(t){return this.log.history.push({type:"action",message:"Selected bank: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logSavedCardSelect:function(){return this.log.history.push({type:"action",message:"Selected saved card",time:this.getTimeSpent()}),this.saveLog()},logAuthWindowOpen:function(){return this.log.history.push({type:"action",message:"Third-party authentication window opened",time:this.getTimeSpent()}),this.saveLog()},logAuthWindowClose:function(){return this.log.history.push({type:"action",message:"Third-party authentication window closed",time:this.getTimeSpent()}),this.saveLog()},logAPIResponse:function(t,e){switch(t.status){case"success":return this.logSuccess(e);case"pending":return this.logPending(e);case"failed":return this.logError(t.message);case"auth":return this.logAuth(t.data.auth);default:return!1}},logMobileMoneyActions:function(t){var e=t.numberOfTokenRequests,n=t.registrationToken;e?this.logTokenRequest("mobile money",e):n?this.logTokenSubmitted("mobile money"):this.logAttempt("mobile money")},logAPIResponseMessage:function(t){return this.log.history.push({type:"action",message:t,time:this.getTimeSpent()}),this.saveLog()},logAttempt:function(t){var e="Attempted to pay";return t&&(e+=" with ".concat(t)),this.log.attempts+=1,this.log.history.push({type:"action",message:e,time:this.getTimeSpent()}),this.saveLog()},logTokenRequest:function(t){var e=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:function(t){return this.log.history.push({type:"action",message:"Customer submitted OTP",channel:t,time:this.getTimeSpent()}),this.saveLog()},logTokenAuthenticationFailure:function(t){var e=t?"Error: ".concat(t):"Error";return this.log.errors+=1,this.log.history.push({type:"error",message:e,authentication:"failed",time:this.getTimeSpent()}),this.saveLog()},logError:function(t){var e="Error";return t&&(e+=": ".concat(t)),this.log.errors+=1,this.log.history.push({type:"error",message:e,time:this.getTimeSpent()}),this.saveLog()},logAuth:function(t){return this.log.authentication=t,this.log.history.push({type:"auth",message:"Authentication Required: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logSuccess:function(t){var e="Successfully paid";return t&&(e+=" with ".concat(t)),this.log.success=!0,this.log.history.push({type:"success",message:e,time:this.getTimeSpent()}),this.saveLog()},logPending:function(t){var e="Payment in progress";return t&&(e+=" with ".concat(t)),this.log.history.push({type:"pending",message:e,time:this.getTimeSpent()}),this.saveLog()},logPageClose:function(){return this.log.history.push({type:"close",message:"Closed checkout",time:this.getTimeSpent()}),this.saveLog()},logTransactionCurrencySwitch:function(t){var e=t.currency,n=t.isUserAction,r=void 0===n||n?"User switched":"Switched";return this.log.history.push({type:"action",message:"".concat(r," transaction currency to ").concat(e),time:this.getTimeSpent()}),this.saveLog()},saveLog:function(){return nO(this.id,this.merchant.key,this.log)},saveIpAddress:function(){return rO(this.id,this.merchant.key)},saveReferrer:function(t){return iO(this.id,this.merchant.key,t)},setAmountByChannel:function(t){var e;this.amount=(null===(e=this.channelFeesConfig[t])||void 0===e?void 0:e.amount)||this.originalAmount}}),aO=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s,u,c,h,l;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.transaction,i=t.phone,o=t.channels,a=t.email,s=new URL("/saved_cards/authorize",Kd.paystackApiUrl).toString(),u=$A(),c=n({},u&&{"Accept-Language":u}),h=n(n(n(n({},i&&{phone:i}),o&&{channels:o}),a&&{email:a}),{},{transaction:r,is_six_digit_otp:!0}),e.next=7,JA.post(s,h,{headers:c});case 7:return l=e.sent,e.abrupt("return",l.data);case 9:case"end":return e.stop()}}),e)})))()},sO=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s,u,c,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.code,i=t.transaction,o=t.token,a=new URL("/saved_cards/authorize/verify",Kd.paystackApiUrl).toString(),s=$A(),u=n({Authorization:"Bearer ".concat(o)},s&&{"Accept-Language":s}),c={code:r,transaction:i},e.next=7,JA.post(a,c,{headers:u});case 7:return h=e.sent,e.abrupt("return",h.data);case 9:case"end":return e.stop()}}),e)})))()},uO=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.token,i=new URL("/saved_cards/link/payment-instruments",Kd.paystackApiUrl).toString(),o=$A(),a=n({Authorization:"Bearer ".concat(r),"jwt-auth":!0},o&&{"Accept-Language":o}),e.next=6,JA.get(i,{headers:a});case 6:return s=e.sent,e.abrupt("return",s.data);case 8:case"end":return e.stop()}}),e)})))()},cO=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s,u,c,h,l,f;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.token,i=t.device,o=t.instrumentCode,a=t.transaction,s=t.selectedCurrency,u=new URL("/saved_cards/link/".concat(o,"/charge"),Kd.paystackApiUrl).toString(),c=$A(),h=n({Authorization:"Bearer ".concat(r),"jwt-auth":!0},c&&{"Accept-Language":c}),l={device:i,transaction:a,selected_currency:s},e.next=7,JA.post(u,l,{headers:h});case 7:return f=e.sent,e.abrupt("return",sg.parse(f.data));case 9:case"end":return e.stop()}}),e)})))()},hO=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new URL("/saved_cards/direct-debit/pay-with-transfer",Kd.paystackApiUrl).toString(),i=$A(),o=n({Authorization:"Bearer ".concat(t.token)},i&&{"Accept-Language":i}),a={device:t.device,transaction_id:t.transactionId,account_number:t.accountNumber,account_name:t.accountName,bank_code:t.bankCode,currency:t.currency,country_code:t.countryCode,fulfil_late_notification:t.fulfilLateNotification},e.next=6,JA.post(r,a,{headers:o});case 6:return s=e.sent,e.abrupt("return",sg.parse(s.data));case 8:case"end":return e.stop()}}),e)})))()},lO=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new URL("/saved_cards/user/profile/verify",Kd.paystackApiUrl).toString(),i=$A(),o=n({},i&&{"Accept-Language":i}),a={transaction_id:t.transactionId,email:t.email,account_number:t.accountNumber,bank_code:t.bankCode},e.next=6,JA.post(r,a,{headers:o});case 6:return s=e.sent,e.abrupt("return",s.data);case 8:case"end":return e.stop()}}),e)})))()},fO=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new URL("/saved_cards/customer-validation/validate",Kd.paystackApiUrl).toString(),i=$A(),o=n({},i&&{"Accept-Language":i}),a=n(n({bank_code:t.bankCode,account_number:t.accountNumber,email:t.email},t.phoneNumber&&{phone_number:t.phoneNumber}),{},{transaction_id:t.transactionId}),e.next=6,JA.post(r,a,{headers:o});case 6:return s=e.sent,e.abrupt("return",s.data);case 8:case"end":return e.stop()}}),e)})))()},pO={authentication:"vault otp",paymentInstrument:{bank:"linked account",card:"saved card"}},dO={sendLinkOtp:function(t){var e=t.phone,n=t.channels,r=t.email;return this.logAuth(pO.authentication),aO({phone:e,transaction:this.id,channels:n,email:r})},verifyLinkOtp:function(t){var e=t.code,n=t.token;return sO({code:e,transaction:this.id,token:n})},getLinkPaymentInstruments:function(t){var e=t.token;return uO({token:e})},chargeLinkPaymentInstrument:function(t){var e=this,n=t.instrumentCode,r=t.selectedCurrency,i=void 0===r?this.currency:r,o=t.token,a=t.instrumentType,s=pO.paymentInstrument[a]||"vault",u={instrumentCode:n,transaction:this.id,token:o,device:this.deviceFingerprint,selectedCurrency:i};return this.logAttempt(s),cO(u).then((function(t){return e.logAPIResponse(t,s),t}))},generateLinkManagedAccount:function(t){return hO(n(n({},t),{},{device:this.deviceFingerprint,transactionId:this.id}))},listenForLinkBankPayWithTransferCharge:function(t,e){var n={channel:t,paymentMethod:"bank_transfer"};return this.listenForCharge(n,e)},verifyLinkProfile:function(t){return lO(n(n({},t),{},{transactionId:this.id}))},validateLinkCustomerBankAccount:function(t){return fO(n(n({},t),{},{transactionId:this.id}))}},gO=function(){function t(e){var n=this;a(this,t),this.email=e.email,this.merchant={id:e.merchant_id,logo:e.merchant_logo,name:e.merchant_name,key:e.merchant_key,channelSettings:e.merchant_channel_settings||{}},this.status=e.transaction_status||e.status,this.accessCode=e.access_code,this.amount=e.amount,this.originalAmount=e.amount,this.domain=e.domain,this.isTest="test"===e.domain,this.currency=e.currency,this.id=e.id,this.channels=e.channels,this.label=e.label,this.metadata=e.metadata||{},this.cancel_action=e.cancel_action||null,this.channelFeesConfig=e.channel_fees_and_amount||{},this.channel_options=e.channel_options||null,this.hash=e.hash||null,this.authorizations=e.authorizations,this.remember_card=!1,this.rememberMeEnabled=e.is_remember_me_enabled,this.card={},this.bankAccount={},this.mobileMoney={},this.ussd={},this.bankTransfer={},this.qr={},this.directDebit={},this.deviceFingerprint=e.deviceFingerprint||null,this.customer=e.customer,this.custom_filters=e.custom_filters||null,this.isCharging=!1,this.isListening=!1,this.transactionType=e.transaction_type||null,this.subscription=e.subscription||null,this.planDetails=e.plan_details||null,this.exchangeRate=e.exchange_rate||null,this.savedCardsConfig=e.saved_cards||{},this.supportedBanks=e.supported_banks||[],this.savedCardsTempAuthToken=null,this.savedCardsToken=null,this.reference=e.reference,this.linkConfig=e.link_config||{},ug(),this.log=null,Object.assign(this,oO),this.initializeLog(e.log),this.saveIpAddress(),this.channels.forEach((function(t){var e=Lx(t);Object.assign(n,e)})),this.linkConfig.enabled&&Object.assign(this,dO),"GHS"===e.currency&&e.elevy_percentage&&(this.elevyPercentage=e.elevy_percentage)}return u(t,[{key:"setMetadata",value:function(t,e){this.metadata[t]=e}},{key:"setDevice",value:function(t){this.deviceFingerprint?kd("Device ID has already been set by Checkout JS so there's no need to set this again"):this.deviceFingerprint=t}},{key:"listenForCharge",value:function(t,e){return cg(t,this,e)}},{key:"requery",value:function(){return rE(this.id)}},{key:"markAsAbandoned",value:function(){return iE({publicKey:this.merchant.key,transactionId:this.id})}},{key:"verifyStatus",value:function(){return oE({reference:this.reference,publicKey:this.merchant.key}).then((function(t){return t&&t.data}))}},{key:"initializeCustomerSubscriptionAuthorization",value:function(t){return aE(t,this.merchant.key).then((function(t){return t&&t.data}))}}]),t}(),mO={validate:function(t){var e=function(t){var e=[];return t&&"object"===r(t)?(Object.keys(th).forEach((function(n){var r=th[n],i=t[n];!r.required||i||t[r.fallback]?i&&!r.isValid(i)&&e.push({field:n,message:"Invalid field: ".concat(n)}):e.push({field:n,message:"Required field: ".concat(n)})})),e):(e.push({message:"Please supply a valid object"}),e)}(t);if(e.length){var n=y(e,1)[0].message;throw new es(e,n)}},request:function(t){return o(regeneratorRuntime.mark((function e(){var r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Od();case 2:return r=e.sent,e.next=5,QA(n(n({},t),{device:r}));case 5:return i=e.sent,e.abrupt("return",i&&Object.seal(new gO(n(n({},i.data),{deviceFingerprint:r}))));case 7:case"end":return e.stop()}}),e)})))()},createInstance:function(t){return o(regeneratorRuntime.mark((function e(){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Od();case 2:if(r=e.sent,null!=t&&t.access_code){e.next=5;break}throw new Error("This function should be used with transaction data from the API");case 5:return e.abrupt("return",Object.seal(new gO(n(n({},t),{deviceFingerprint:r}))));case 6:case"end":return e.stop()}}),e)})))()},requestWithAccessCode:function(t){return o(regeneratorRuntime.mark((function e(){var r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Od();case 2:return r=e.sent,e.next=5,tE(t);case 5:return i=e.sent,e.abrupt("return",i&&Object.seal(new gO(n(n({},i.data),{deviceFingerprint:r}))));case 7:case"end":return e.stop()}}),e)})))()},getByAccessCode:function(t,e){return o(regeneratorRuntime.mark((function r(){var i,o;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,Od();case 2:return i=r.sent,r.next=5,eE(t,e);case 5:return o=r.sent,r.abrupt("return",o&&Object.seal(new gO(n(n({},o.data),{deviceFingerprint:i}))));case 7:case"end":return r.stop()}}),r)})))()},initialize:function(t){return Object.seal(new gO(t))},verify:function(t){return o(regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,nE(t);case 2:return n=e.sent,e.abrupt("return",n&&n.data);case 4:case"end":return e.stop()}}),e)})))()}},vO={},yO=function(t){var e=new URL("/bank",Kd.paystackApiUrl).toString(),r=$A(),i={params:t,headers:n({},r&&{"Accept-Language":r})};return JA.get(e,i).then((function(t){return t.data}))},bO=function(){var t=new URL("/checkout/resolutions",Kd.paystackApiUrl).toString(),e=$A(),r=n({},e&&{"Accept-Language":e});return JA.get(t,{headers:r}).then((function(t){return t.data}))},wO=function(){var t=new URL("/checkout/celebrations",Kd.paystackApiUrl).toString(),e=$A(),r=n({},e&&{"Accept-Language":e});return JA.get(t,{headers:r}).then((function(t){return t.data}))},SO=function(t){var e=new URL("/address_verification/states",Kd.paystackApiUrl).toString(),r=$A(),i={params:t,headers:n({},r&&{"Accept-Language":r})};return JA.get(e,i).then((function(t){return t.data}))},TO=function(t){var e=new URL("/decision/bin/".concat(t),Kd.paystackApiUrl).toString(),r=$A(),i=n({},r&&{"Accept-Language":r});return vO[t]?Promise.resolve(vO[t]):JA.get(e,{headers:i}).then((function(e){var n=e.data;return vO[t]=n,n}))},AO=function(t){var e=new URL("decision/resolve_ip/".concat(t),Kd.paystackApiUrl).toString(),r=$A(),i=n({},r&&{"Accept-Language":r});return JA.get(e,{headers:i}).then((function(t){return t.data}))},EO=function(){function t(){a(this,t)}return u(t,null,[{key:"contents",value:function(){return[{key:"banks",usage:"Returns a list of banks that can be used to complete checkout"},{key:"resolutions",usage:"Returns a list of known errors, mapped to their suggested resolutions"},{key:"celebrations",usage:"Returns a list of upcoming celebrations"},{key:"states",usage:"Returns a list of states for a particular country"}]}},{key:"fetch",value:function(t,e){var n;if(this.contents().map((function(t){return t.key})).indexOf(t)<=-1)throw new Error("Please provide a valid config key. Use Toolkit.contents() to see available options.");switch(t){case"banks":n=yO(e||{pay_with_bank:"1"});break;case"resolutions":n=bO();break;case"celebrations":n=wO();break;case"states":n=SO(e)}return n}},{key:"resolveCardBin",value:function(t){return TO(t)}},{key:"resolveIPAddress",value:function(t){return AO(t)}}]),t}(),kO=function(){function t(e){var n=e.number,r=e.cvv,i=e.month,o=e.year,s=e.pin;a(this,t),this.number=n,this.cvv=r,this.month=i,this.year=o,this.pin=s}return u(t,[{key:"getEncryptedPin",value:function(){return Ok.getEncryptedPin(this.pin)}},{key:"getLast4",value:function(){return Ok.getLast4(this.number)}},{key:"tokenize",value:function(){return Ok.tokenize({number:this.number,cvv:this.cvv,month:this.month,year:this.year})}}],[{key:"getType",value:function(t){return Ok.getType(t)}},{key:"validate",value:function(t){var e=t.number,n=t.cvv,r=t.month,i=t.year;return Ok.validate({number:e,cvv:n,month:r,year:i})}},{key:"validateNumber",value:function(t){return Ok.validateNumber(t)}},{key:"isNumberValid",value:function(t){return Ok.isNumberValid(t)}},{key:"validateCVV",value:function(t,e){return Ok.validateCVV(t,e)}},{key:"isCvvValid",value:function(t,e){return Ok.isCvvValid(t,e)}},{key:"validateExpiry",value:function(t){return Ok.validateExpiry(t)}},{key:"isExpiryValid",value:function(t){return Ok.isExpiryValid(t)}},{key:"generateTestCard",value:function(e){return new t(Ok.findTestCard(e))}}]),t}(),xO=function(t){var e=t.clientdata,r=t.last4,i=t.preauthorizationId,o=t.publicKey,a=new URL("preauthorization/create",Kd.paystackApiUrl).toString(),s=$A(),u=n({Authorization:"Bearer ".concat(o)},s&&{"Accept-Language":s});return JA.post(a,{clientdata:e,last4:r,preauthorization:i},{headers:u}).then((function(t){return sg.parse(t.data)}))},OO="card";function RO(t,e){return new Promise((function(n,r){var i=kO.validate(t);if(!i.isValid){var o=e||t.number,a=Object.keys(i.result).filter((function(t){return!1===i.result[t]})),s="Invalid card details: ".concat(a.join(", "));r(Error(o?s:"Please set a valid card with setCard()"))}n()}))}var CO={setCard:function(t){var e=this;return RO(t,!0).then((function(){e.card=new kO(t)}))},reserveFunds:function(t){var e=this,n=t.preauthorizationId,r=t.publicKey,i=t.customFields,o=void 0===i?{}:i;return RO(this.card).then((function(){e.logAttempt(OO);var t={clientdata:e.card.tokenize(),last4:e.card.getLast4(),device:e.deviceFingerprint,preauthorizationId:n,publicKey:r,customFields:o};return xO(t).then((function(t){return e.logAPIResponse(t,OO),t}))}))},listenFor3DSCharge:function(t){var e={channel:"3DS_".concat(this.id),paymentMethod:OO};return this.listenForCharge(e,t)}},PO=function(t){var e=$A(),r=n({},e&&{"Accept-Language":e}),i=new URL("preauthorization/verify_access_code/".concat(t),Kd.paystackApiUrl).toString();return JA.get(i,{headers:r}).then((function(t){return t.data}))},BO=function(t){var e=t.reference,r=t.publicKey,i=$A(),o=n({Authorization:"Bearer ".concat(r)},i&&{"Accept-Language":i}),a=new URL("preauthorization/verify/".concat(e),Kd.paystackApiUrl).toString();return JA.get(a,{headers:o}).then((function(t){return sg.parse(t.data)}))},LO=function(t,e,n){var r=new URL("preauthorization/update_log/".concat(t),Kd.paystackApiUrl).toString();return Qx(r,{merchantKey:e,log:n})},IO=function(t,e){var n=new URL("preauthorization/set_ip/".concat(t),Kd.paystackApiUrl).toString();return tO(n,{merchantKey:e})},DO={initializeLog:function(t){this.log=Dx(t)},getTimeSpent:function(){return this.log.time_spent=Nx(this.log.start_time),this.log.time_spent},logPageOpen:function(){return this.log.history.push({type:"open",message:"Opened checkout",time:this.getTimeSpent()}),this.saveLog()},logChannelSwitch:function(t){return this.log.history.push({type:"action",message:"Set charge method to: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logValidationErrors:function(t){var e=this;return t.forEach((function(t){e.log.history.push({type:"error",message:"Invalid ".concat(t),time:e.getTimeSpent()})})),this.saveLog()},logInput:function(t){var e=this.log.history.find((function(e){return e.message==="Filled this field: ".concat(t)}));return this.log.history.push({type:"input",message:"".concat(e?"Changed":"Filled"," this field: ").concat(t),time:this.getTimeSpent()}),this.saveLog()},logAuthWindowOpen:function(){return this.log.history.push({type:"action",message:"Third-party authentication window opened",time:this.getTimeSpent()}),this.saveLog()},logAuthWindowClose:function(){return this.log.history.push({type:"action",message:"Third-party authentication window closed",time:this.getTimeSpent()}),this.saveLog()},logAPIResponse:function(t,e){switch(console.log("api response",t),t.status){case"authorized":return this.logAuthorized(e);case"failed":return this.logError(t.message);case"auth":return this.logAuth(t.data.auth);default:return!1}},logAPIResponseMessage:function(t){return this.log.history.push({type:"action",message:t,time:this.getTimeSpent()}),this.saveLog()},logAttempt:function(t){var e="Attempted to charge";return t&&(e+=" with ".concat(t)),this.log.attempts+=1,this.log.history.push({type:"action",message:e,time:this.getTimeSpent()}),this.saveLog()},logAuth:function(t){return this.log.authentication=t,this.log.history.push({type:"auth",message:"Authentication Required: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logAuthorized:function(t){var e="Successfully preauthorized funds";return t&&(e+=" with ".concat(t)),this.log.success=!0,this.log.history.push({type:"authorized",message:e,time:this.getTimeSpent()}),this.saveLog()},logPageClose:function(){return this.log.history.push({type:"close",message:"Closed checkout",time:this.getTimeSpent()}),this.saveLog()},logError:function(t){var e="Error";return t&&(e+=": ".concat(t)),this.log.errors+=1,this.log.history.push({type:"error",message:e,time:this.getTimeSpent()}),this.saveLog()},saveLog:function(){return LO(this.reference,this.merchant.key,this.log)},saveIpAddress:function(){return IO(this.reference,this.merchant.key)}},NO=function(){function t(e){var n;a(this,t),this.id=e.id,this.email=null===(n=e.customer)||void 0===n?void 0:n.email,this.status=e.status,this.reference=e.reference,this.amount=e.amount,this.currency=e.currency,this.metadata=e.metadata||{},this.customer=e.customer,this.channels=e.channels||["card"],this.isListening=!1,this.isTest="test"===e.domain,this.deviceFingerprint=e.deviceFingerprint||null,this.merchant={id:e.merchant_id,logo:e.merchant_logo,name:e.merchant_name,key:e.merchant_key},this.card={},ug(),this.log=null,Object.assign(this,DO),this.initializeLog(e.log),this.saveIpAddress(),Object.assign(this,CO)}return u(t,[{key:"setMetadata",value:function(t,e){this.metadata[t]=e}},{key:"requery",value:function(){var t=this;return BO({reference:this.reference,publicKey:this.merchant.key}).then((function(e){return t.logAPIResponse(e,"card"),e}))}},{key:"listenForCharge",value:function(t,e){return cg(t,this,e)}}]),t}(),_O={initialize:function(t){return Object.seal(new NO(t))},getByAccessCode:function(t){return o(regeneratorRuntime.mark((function e(){var r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Od();case 2:return r=e.sent,e.next=5,PO(t);case 5:return i=e.sent,e.abrupt("return",i&&Object.seal(new NO(n(n({},i.data),{},{deviceFingerprint:r}))));case 7:case"end":return e.stop()}}),e)})))()}};return t.BankAccount=Gk,t.Card=Rk,t.Preauthorization=_O,t.Toolkit=EO,t.Transaction=mO,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
|
|
30
|
+
var pt={};void 0!==pt.asn1&&pt.asn1||(pt.asn1={}),pt.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var n=e.substr(1).length;n%2==1?n+=1:e.match(/^[0-7]/)||(n+=2);for(var r="",i=0;i<n;i++)r+="f";e=new B(r,16).xor(t).add(B.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=pt.asn1,n=e.DERBoolean,r=e.DERInteger,i=e.DERBitString,o=e.DEROctetString,a=e.DERNull,s=e.DERObjectIdentifier,u=e.DEREnumerated,c=e.DERUTF8String,h=e.DERNumericString,l=e.DERPrintableString,f=e.DERTeletexString,p=e.DERIA5String,d=e.DERUTCTime,g=e.DERGeneralizedTime,m=e.DERSequence,v=e.DERSet,y=e.DERTaggedObject,b=e.ASN1Util.newObject,w=Object.keys(t);if(1!=w.length)throw"key of param shall be only one.";var S=w[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+S+":"))throw"undefined key: "+S;if("bool"==S)return new n(t[S]);if("int"==S)return new r(t[S]);if("bitstr"==S)return new i(t[S]);if("octstr"==S)return new o(t[S]);if("null"==S)return new a(t[S]);if("oid"==S)return new s(t[S]);if("enum"==S)return new u(t[S]);if("utf8str"==S)return new c(t[S]);if("numstr"==S)return new h(t[S]);if("prnstr"==S)return new l(t[S]);if("telstr"==S)return new f(t[S]);if("ia5str"==S)return new p(t[S]);if("utctime"==S)return new d(t[S]);if("gentime"==S)return new g(t[S]);if("seq"==S){for(var T=t[S],A=[],E=0;E<T.length;E++){var k=b(T[E]);A.push(k)}return new m({array:A})}if("set"==S){for(T=t[S],A=[],E=0;E<T.length;E++)k=b(T[E]),A.push(k);return new v({array:A})}if("tag"==S){var x=t[S];if("[object Array]"===Object.prototype.toString.call(x)&&3==x.length){var O=b(x[2]);return new y({tag:x[0],explicit:x[1],obj:O})}var R={};if(void 0!==x.explicit&&(R.explicit=x.explicit),void 0!==x.tag&&(R.tag=x.tag),void 0===x.obj)throw"obj shall be specified for 'tag'.";return R.obj=b(x.obj),new y(R)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},pt.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",n=parseInt(t.substr(0,2),16),r=(e=Math.floor(n/40)+"."+n%40,""),i=2;i<t.length;i+=2){var o=("00000000"+parseInt(t.substr(i,2),16).toString(2)).slice(-8);r+=o.substr(1,7),"0"==o.substr(0,1)&&(e=e+"."+new B(r,2).toString(10),r="")}return e},pt.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},n=function(t){var n="",r=new B(t,10).toString(2),i=7-r.length%7;7==i&&(i=0);for(var o="",a=0;a<i;a++)o+="0";for(r=o+r,a=0;a<r.length-1;a+=7){var s=r.substr(a,7);a!=r.length-7&&(s="1"+s),n+=e(parseInt(s,2))}return n};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var r="",i=t.split("."),o=40*parseInt(i[0])+parseInt(i[1]);r+=e(o),i.splice(0,2);for(var a=0;a<i.length;a++)r+=n(i[a]);return r},pt.asn1.ASN1Object=function(){var t="";this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+t.length+",v="+this.hV;var e=this.hV.length/2,n=e.toString(16);if(n.length%2==1&&(n="0"+n),e<128)return n;var r=n.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);return(128+r).toString(16)+n},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},pt.asn1.DERAbstractString=function(t){pt.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},ft.lang.extend(pt.asn1.DERAbstractString,pt.asn1.ASN1Object),pt.asn1.DERAbstractTime=function(t){pt.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,n){var r=this.zeroPadding,i=this.localDateToUTC(t),o=String(i.getFullYear());"utc"==e&&(o=o.substr(2,2));var a=o+r(String(i.getMonth()+1),2)+r(String(i.getDate()),2)+r(String(i.getHours()),2)+r(String(i.getMinutes()),2)+r(String(i.getSeconds()),2);if(!0===n){var s=i.getMilliseconds();if(0!=s){var u=r(String(s),3);a=a+"."+(u=u.replace(/[0]+$/,""))}}return a+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(t)},this.setByDateValue=function(t,e,n,r,i,o){var a=new Date(Date.UTC(t,e-1,n,r,i,o,0));this.setByDate(a)},this.getFreshValueHex=function(){return this.hV}},ft.lang.extend(pt.asn1.DERAbstractTime,pt.asn1.ASN1Object),pt.asn1.DERAbstractStructured=function(t){pt.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},ft.lang.extend(pt.asn1.DERAbstractStructured,pt.asn1.ASN1Object),pt.asn1.DERBoolean=function(){pt.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},ft.lang.extend(pt.asn1.DERBoolean,pt.asn1.ASN1Object),pt.asn1.DERInteger=function(t){pt.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=pt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new B(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},ft.lang.extend(pt.asn1.DERInteger,pt.asn1.ASN1Object),pt.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=pt.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}pt.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var n="0"+t;this.hTLV=null,this.isModified=!0,this.hV=n+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var n=0;n<=e;n++)t+="0";var r="";for(n=0;n<t.length-1;n+=8){var i=t.substr(n,8),o=parseInt(i,2).toString(16);1==o.length&&(o="0"+o),r+=o}this.hTLV=null,this.isModified=!0,this.hV="0"+e+r},this.setByBooleanArray=function(t){for(var e="",n=0;n<t.length;n++)1==t[n]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),n=0;n<t;n++)e[n]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},ft.lang.extend(pt.asn1.DERBitString,pt.asn1.ASN1Object),pt.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=pt.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}pt.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},ft.lang.extend(pt.asn1.DEROctetString,pt.asn1.DERAbstractString),pt.asn1.DERNull=function(){pt.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},ft.lang.extend(pt.asn1.DERNull,pt.asn1.ASN1Object),pt.asn1.DERObjectIdentifier=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},n=function(t){var n="",r=new B(t,10).toString(2),i=7-r.length%7;7==i&&(i=0);for(var o="",a=0;a<i;a++)o+="0";for(r=o+r,a=0;a<r.length-1;a+=7){var s=r.substr(a,7);a!=r.length-7&&(s="1"+s),n+=e(parseInt(s,2))}return n};pt.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var r="",i=t.split("."),o=40*parseInt(i[0])+parseInt(i[1]);r+=e(o),i.splice(0,2);for(var a=0;a<i.length;a++)r+=n(i[a]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=r},this.setValueName=function(t){var e=pt.asn1.x509.OID.name2oid(t);if(""===e)throw"DERObjectIdentifier oidName undefined: "+t;this.setValueOidString(e)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t):void 0!==t.oid?this.setValueOidString(t.oid):void 0!==t.hex?this.setValueHex(t.hex):void 0!==t.name&&this.setValueName(t.name))},ft.lang.extend(pt.asn1.DERObjectIdentifier,pt.asn1.ASN1Object),pt.asn1.DEREnumerated=function(t){pt.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=pt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new B(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},ft.lang.extend(pt.asn1.DEREnumerated,pt.asn1.ASN1Object),pt.asn1.DERUTF8String=function(t){pt.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},ft.lang.extend(pt.asn1.DERUTF8String,pt.asn1.DERAbstractString),pt.asn1.DERNumericString=function(t){pt.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},ft.lang.extend(pt.asn1.DERNumericString,pt.asn1.DERAbstractString),pt.asn1.DERPrintableString=function(t){pt.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},ft.lang.extend(pt.asn1.DERPrintableString,pt.asn1.DERAbstractString),pt.asn1.DERTeletexString=function(t){pt.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},ft.lang.extend(pt.asn1.DERTeletexString,pt.asn1.DERAbstractString),pt.asn1.DERIA5String=function(t){pt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},ft.lang.extend(pt.asn1.DERIA5String,pt.asn1.DERAbstractString),pt.asn1.DERUTCTime=function(t){pt.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{12}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date))},ft.lang.extend(pt.asn1.DERUTCTime,pt.asn1.DERAbstractTime),pt.asn1.DERGeneralizedTime=function(t){pt.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.withMillis=!1,this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{14}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date),!0===t.millis&&(this.withMillis=!0))},ft.lang.extend(pt.asn1.DERGeneralizedTime,pt.asn1.DERAbstractTime),pt.asn1.DERSequence=function(t){pt.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++)t+=this.asn1Array[e].getEncodedHex();return this.hV=t,this.hV}},ft.lang.extend(pt.asn1.DERSequence,pt.asn1.DERAbstractStructured),pt.asn1.DERSet=function(t){pt.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var n=this.asn1Array[e];t.push(n.getEncodedHex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},ft.lang.extend(pt.asn1.DERSet,pt.asn1.DERAbstractStructured),pt.asn1.DERTaggedObject=function(t){pt.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,n){this.hT=e,this.isExplicit=t,this.asn1Object=n,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=n.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.tag&&(this.hT=t.tag),void 0!==t.explicit&&(this.isExplicit=t.explicit),void 0!==t.obj&&(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},ft.lang.extend(pt.asn1.DERTaggedObject,pt.asn1.ASN1Object);var dt=function(t){function e(n){var r=t.call(this)||this;return n&&("string"==typeof n?r.parseKey(n):(e.hasPrivateKeyProperty(n)||e.hasPublicKeyProperty(n))&&r.parsePropertiesFrom(n)),r}return g(e,t),e.prototype.parseKey=function(t){try{var e=0,n=0,r=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?v.decode(t):y.unarmor(t),i=O.decode(r);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){e=i.sub[1].getHexStringValue(),this.n=j(e,16),n=i.sub[2].getHexStringValue(),this.e=parseInt(n,16);var o=i.sub[3].getHexStringValue();this.d=j(o,16);var a=i.sub[4].getHexStringValue();this.p=j(a,16);var s=i.sub[5].getHexStringValue();this.q=j(s,16);var u=i.sub[6].getHexStringValue();this.dmp1=j(u,16);var c=i.sub[7].getHexStringValue();this.dmq1=j(c,16);var h=i.sub[8].getHexStringValue();this.coeff=j(h,16)}else{if(2!==i.sub.length)return!1;var l=i.sub[1].sub[0];e=l.sub[0].getHexStringValue(),this.n=j(e,16),n=l.sub[1].getHexStringValue(),this.e=parseInt(n,16)}return!0}catch(t){return!1}},e.prototype.getPrivateBaseKey=function(){var t={array:[new pt.asn1.DERInteger({int:0}),new pt.asn1.DERInteger({bigint:this.n}),new pt.asn1.DERInteger({int:this.e}),new pt.asn1.DERInteger({bigint:this.d}),new pt.asn1.DERInteger({bigint:this.p}),new pt.asn1.DERInteger({bigint:this.q}),new pt.asn1.DERInteger({bigint:this.dmp1}),new pt.asn1.DERInteger({bigint:this.dmq1}),new pt.asn1.DERInteger({bigint:this.coeff})]};return new pt.asn1.DERSequence(t).getEncodedHex()},e.prototype.getPrivateBaseKeyB64=function(){return l(this.getPrivateBaseKey())},e.prototype.getPublicBaseKey=function(){var t=new pt.asn1.DERSequence({array:[new pt.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new pt.asn1.DERNull]}),e=new pt.asn1.DERSequence({array:[new pt.asn1.DERInteger({bigint:this.n}),new pt.asn1.DERInteger({int:this.e})]}),n=new pt.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new pt.asn1.DERSequence({array:[t,n]}).getEncodedHex()},e.prototype.getPublicBaseKeyB64=function(){return l(this.getPublicBaseKey())},e.wordwrap=function(t,e){if(!t)return t;var n="(.{1,"+(e=e||64)+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(n,"g")).join("\n")},e.prototype.getPrivateKey=function(){var t="-----BEGIN RSA PRIVATE KEY-----\n";return t+=e.wordwrap(this.getPrivateBaseKeyB64())+"\n",t+="-----END RSA PRIVATE KEY-----"},e.prototype.getPublicKey=function(){var t="-----BEGIN PUBLIC KEY-----\n";return t+=e.wordwrap(this.getPublicBaseKeyB64())+"\n",t+="-----END PUBLIC KEY-----"},e.hasPublicKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")},e.hasPrivateKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},e.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)},e}(st),gt=function(){function t(t){t=t||{},this.default_key_size=parseInt(t.default_key_size,10)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null}return t.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new dt(t)},t.prototype.setPrivateKey=function(t){this.setKey(t)},t.prototype.setPublicKey=function(t){this.setKey(t)},t.prototype.decrypt=function(t){try{return this.getKey().decrypt(f(t))}catch(t){return!1}},t.prototype.encrypt=function(t){try{return l(this.getKey().encrypt(t))}catch(t){return!1}},t.prototype.sign=function(t,e,n){try{return l(this.getKey().sign(t,e,n))}catch(t){return!1}},t.prototype.verify=function(t,e,n){try{return this.getKey().verify(t,f(e),n)}catch(t){return!1}},t.prototype.getKey=function(t){if(!this.key){if(this.key=new dt,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},t.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},t.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},t.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},t.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},t.version="3.0.0-rc.1",t}();window.JSEncrypt=gt,t.JSEncrypt=gt,t.default=gt,Object.defineProperty(t,"__esModule",{value:!0})}(e)}(0,xE.exports);var RE=O,CE=H,PE=_s,BE=ot,LE=CE(L.f),IE=CE([].push),DE=function(t){return function(e){for(var n,r=BE(e),i=PE(r),o=i.length,a=0,s=[];o>a;)n=i[a++],RE&&!LE(r,n)||IE(s,t?[n,r[n]]:r[n]);return s}},NE={entries:DE(!0),values:DE(!1)}.values;li({target:"Object",stat:!0},{values:function(t){return NE(t)}});var _E=li,jE=Ts.find,ME=$d,UE="find",VE=!0;UE in[]&&Array(1)[UE]((function(){VE=!1})),_E({target:"Array",proto:!0,forced:VE},{find:function(t){return jE(this,t,arguments.length>1?arguments[1]:void 0)}}),ME(UE);var FE=function(t){for(var e,n=0,r=!1,i=t.length-1;i>=0;)e=parseInt(t.charAt(i),10),r&&(e*=2)>9&&(e=e%10+1),r=!r,n+=e,i--;return n%10==0};var qE=function(t){return t?JSON.parse(JSON.stringify(t)):null};var zE=function(t){return"string"==typeof t||t instanceof String};var HE=function(t,e){return Array.isArray(e)?function(t,e,n){var r=String(e).length,i=t.substr(0,r),o=parseInt(i,10);return e=parseInt(String(e).substr(0,i.length),10),n=parseInt(String(n).substr(0,i.length),10),o>=e&&o<=n}(t,e[0],e[1]):function(t,e){return(e=String(e)).substring(0,t.length)===t.substring(0,e.length)}(t,e)},GE=qE,KE=HE;var WE,XE=function(t,e,n){var r,i,o,a;for(r=0;r<e.patterns.length;r++)if(i=e.patterns[r],KE(t,i)){a=GE(e),o=Array.isArray(i)?String(i[0]).length:String(i).length,t.length>=o&&(a.matchStrength=o),n.push(a);break}},YE={visa:{niceType:"Visa",type:"visa",patterns:[4],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}},mastercard:{niceType:"Mastercard",type:"mastercard",patterns:[[51,55],[2221,2229],[223,229],[23,26],[270,271],2720],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},"american-express":{niceType:"American Express",type:"american-express",patterns:[34,37],gaps:[4,10],lengths:[15],code:{name:"CID",size:4}},"diners-club":{niceType:"Diners Club",type:"diners-club",patterns:[[300,305],36,38,39],gaps:[4,10],lengths:[14,16,19],code:{name:"CVV",size:3}},discover:{niceType:"Discover",type:"discover",patterns:[6011,[644,649],65],gaps:[4,8,12],lengths:[16,19],code:{name:"CID",size:3}},jcb:{niceType:"JCB",type:"jcb",patterns:[2131,1800,[3528,3589]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVV",size:3}},unionpay:{niceType:"UnionPay",type:"unionpay",patterns:[620,[624,626],[62100,62182],[62184,62187],[62185,62197],[62200,62205],[622010,622999],622018,[622019,622999],[62207,62209],[622126,622925],[623,626],6270,6272,6276,[627700,627779],[627781,627799],[6282,6289],6291,6292],gaps:[4,8,12],lengths:[14,15,16,17,18,19],code:{name:"CVN",size:3}},maestro:{niceType:"Maestro",type:"maestro",patterns:[493698,[5e5,506698],[506779,508999],[56,59],63,67,6],gaps:[4,8,12],lengths:[12,13,14,15,16,17,18,19],code:{name:"CVC",size:3}},elo:{niceType:"Elo",type:"elo",patterns:[401178,401179,438935,457631,457632,431274,451416,457393,504175,[506699,506778],[509e3,509999],627780,636297,636368,[650031,650033],[650035,650051],[650405,650439],[650485,650538],[650541,650598],[650700,650718],[650720,650727],[650901,650978],[651652,651679],[655e3,655019],[655021,655058]],gaps:[4,8,12],lengths:[16],code:{name:"CVE",size:3}},mir:{niceType:"Mir",type:"mir",patterns:[[2200,2204]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVP2",size:3}},hiper:{niceType:"Hiper",type:"hiper",patterns:[637095,637568,637599,637609,637612],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},hipercard:{niceType:"Hipercard",type:"hipercard",patterns:[606282],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}}},ZE=qE,JE=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}))},$E=zE,QE=XE,tk={},ek={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"},nk=[ek.VISA,ek.MASTERCARD,ek.AMERICAN_EXPRESS,ek.DINERS_CLUB,ek.DISCOVER,ek.JCB,ek.UNIONPAY,ek.MAESTRO,ek.ELO,ek.MIR,ek.HIPER,ek.HIPERCARD];function rk(t){return tk[t]||YE[t]}function ik(t,e){var n=WE.indexOf(t);if(!e&&-1===n)throw new Error('"'+t+'" is not a supported card type.');return n}function ok(t){var e,n=[];return $E(t)?0===t.length?WE.map((function(t){return ZE(rk(t))})):(WE.forEach((function(e){var r=rk(e);QE(t,r,n)})),(e=JE(n))?[e]:n):[]}WE=ZE(nk),ok.getTypeInfo=function(t){return ZE(rk(t))},ok.removeCard=function(t){var e=ik(t);WE.splice(e,1)},ok.addCard=function(t){var e=ik(t.type,!0);tk[t.type]=t,-1===e&&WE.push(t.type)},ok.updateCard=function(t,e){var n,r=tk[t]||YE[t];if(!r)throw new Error('"'+t+'" is not a recognized type. Use `addCard` instead.');if(e.type&&r.type!==e.type)throw new Error("Cannot overwrite type parameter.");n=ZE(r),Object.keys(n).forEach((function(t){e[t]&&(n[t]=e[t])})),tk[n.type]=n},ok.changeOrder=function(t,e){var n=ik(t);WE.splice(n,1),WE.splice(e,0,t)},ok.resetModifications=function(){WE=ZE(nk),tk={}},ok.types=ek;var ak=ok,sk=FE,uk=ak;function ck(t,e,n){return{card:t,isPotentiallyValid:e,isValid:n}}var hk=function(t,e){var n,r,i,o,a;if(e=e||{},"number"==typeof t&&(t=String(t)),"string"!=typeof t)return ck(null,!1,!1);if(t=t.replace(/\-|\s/g,""),!/^\d*$/.test(t))return ck(null,!1,!1);if(0===(n=uk(t)).length)return ck(null,!1,!1);if(1!==n.length)return ck(null,!0,!1);if(r=n[0],e.maxLength&&t.length>e.maxLength)return ck(r,!1,!1);for(i=r.type===uk.types.UNIONPAY&&!0!==e.luhnValidateUnionPay||sk(t),a=Math.max.apply(null,r.lengths),e.maxLength&&(a=Math.min(e.maxLength,a)),o=0;o<r.lengths.length;o++)if(r.lengths[o]===t.length)return ck(r,t.length<a||i,i);return ck(r,t.length<a,!1)};function lk(t,e,n){return{isValid:t,isPotentiallyValid:e,isCurrentYear:n||!1}}var fk=function(t,e){var n,r,i,o,a;return e=e||19,"string"!=typeof t?lk(!1,!1):""===t.replace(/\s/g,"")?lk(!1,!0):/^\d*$/.test(t)?(r=t.length)<2?lk(!1,!0):(n=(new Date).getFullYear(),3===r?lk(!1,t.slice(0,2)===String(n).slice(0,2)):r>4?lk(!1,!1):(t=parseInt(t,10),i=Number(String(n).substr(2,2)),2===r?(a=i===t,o=t>=i&&t<=i+e):4===r&&(a=n===t,o=t>=n&&t<=n+e),lk(o,o,a))):lk(!1,!1)},pk=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},dk=fk,gk=pk;function mk(t,e,n){return{isValid:t,isPotentiallyValid:e,isValidForThisYear:n||!1}}var vk=function(t){var e,n,r=(new Date).getMonth()+1;return"string"!=typeof t?mk(!1,!1):""===t.replace(/\s/g,"")||"0"===t?mk(!1,!0):/^\d*$/.test(t)?(e=parseInt(t,10),isNaN(t)?mk(!1,!1):mk(n=e>0&&e<13,n,n&&e>=r)):mk(!1,!1)},yk=function(t){var e,n,r,i,o;return/^\d{4}-\d{1,2}$/.test(t)?t=t.split("-").reverse():/\//.test(t)?t=t.split(/\s*\/\s*/g):/\s/.test(t)&&(t=t.split(/ +/g)),gk(t)?{month:t[0]||"",year:t.slice(1).join()}:(r=t,n=0===(o=Number(r[0]))?2:o>1||1===o&&Number(r[1])>2?1:1===o?(i=r.substr(1),dk(i).isPotentiallyValid?1:2):5===r.length?1:r.length>5?2:1,{month:e=t.substr(0,n),year:t.substr(e.length)})},bk=vk,wk=fk;function Sk(t,e,n,r){return{isValid:t,isPotentiallyValid:e,month:n,year:r}}var Tk=3;function Ak(t,e){return{isValid:t,isPotentiallyValid:e}}function Ek(t,e){return{isValid:t,isPotentiallyValid:e}}var kk={number:hk,expirationDate:function(t,e){var n,r,i,o;if("string"==typeof t)t=t.replace(/^(\d\d) (\d\d(\d\d)?)$/,"$1/$2"),n=yk(t);else{if(null===t||"object"!=typeof t)return Sk(!1,!1,null,null);n={month:String(t.month),year:String(t.year)}}if(r=bk(n.month),i=wk(n.year,e),r.isValid){if(i.isCurrentYear)return Sk(o=r.isValidForThisYear,o,n.month,n.year);if(i.isValid)return Sk(!0,!0,n.month,n.year)}return r.isPotentiallyValid&&i.isPotentiallyValid?Sk(!1,!0,null,null):Sk(!1,!1,null,null)},expirationMonth:vk,expirationYear:fk,cvv:function(t,e){return e=(e=e||Tk)instanceof Array?e:[e],"string"!=typeof t?Ak(!1,!1):/^\d*$/.test(t)?function(t,e){for(var n=0;n<t.length;n++)if(e===t[n])return!0;return!1}(e,t.length)?Ak(!0,!0):t.length<Math.min.apply(null,e)?Ak(!1,!0):t.length>function(t){for(var e=Tk,n=0;n<t.length;n++)e=t[n]>e?t[n]:e;return e}(e)?Ak(!1,!1):Ak(!0,!0):Ak(!1,!1)},postalCode:function(t,e){var n;return n=(e=e||{}).minLength||3,"string"!=typeof t?Ek(!1,!1):t.length<n?Ek(!1,!0):Ek(!0,!0)},creditCardType:ak},xk=[{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"}];kk.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}}),kk.creditCardType.changeOrder("verve",0);var Ok={getEncryptedPin:function(t){return t?OE(t):void 0},getLast4:function(t){return t.substring(t.length-4)},tokenize:function(t){var e=t.number,n=t.cvv,r=t.month,i=t.year;return OE("".concat(e,"*").concat(n,"*").concat(r,"*").concat(i))},getType:function(t){var e=kk.number(t);return e&&e.card?{type:e.card.type,maxLength:Math.max.apply(Math,b(e.card.lengths)),minLength:Math.min.apply(Math,b(e.card.lengths))}:{type:null,maxLength:0}},validate:function(t){var e=t.number,n=t.cvv,r=t.month,i=t.year,o=this.getType(e).type,a={number:this.isNumberValid(e),expiry:this.isExpiryValid({month:r,year:i}),cvv:this.isCvvValid(n,o)};return{isValid:Object.values(a).every((function(t){return!0===t})),result:a}},validateNumber:function(t){return kk.number(t)},isNumberValid:function(t){return Ok.validateNumber(t).isValid},validateCVV:function(t,e){var n="american-express"===e?4:3;return kk.cvv(t,n)},isCvvValid:function(t,e){return Ok.validateCVV(t,e).isValid},validateExpiry:function(t){if(null!==t&&"object"===r(t)){var e=t.month,n=t.year;return kk.expirationMonth(e)&&kk.expirationYear(n)}return kk.expirationDate(t)},isExpiryValid:function(t){return Ok.validateExpiry(t).isValid},findTestCard:function(t){var e=t||"default";return xk.find((function(t){return t.type===e}))}},Rk=function(){function t(e){var n=e.number,r=e.cvv,i=e.month,o=e.year,s=e.pin;a(this,t),this.number=n,this.cvv=r,this.month=i,this.year=o,this.pin=s}return u(t,[{key:"getEncryptedPin",value:function(){return Ok.getEncryptedPin(this.pin)}},{key:"getLast4",value:function(){return Ok.getLast4(this.number)}},{key:"tokenize",value:function(){return Ok.tokenize({number:this.number,cvv:this.cvv,month:this.month,year:this.year})}}],[{key:"getType",value:function(t){return Ok.getType(t)}},{key:"validate",value:function(t){var e=t.number,n=t.cvv,r=t.month,i=t.year;return Ok.validate({number:e,cvv:n,month:r,year:i})}},{key:"validateNumber",value:function(t){return Ok.validateNumber(t)}},{key:"isNumberValid",value:function(t){return Ok.isNumberValid(t)}},{key:"validateCVV",value:function(t,e){return Ok.validateCVV(t,e)}},{key:"isCvvValid",value:function(t,e){return Ok.isCvvValid(t,e)}},{key:"validateExpiry",value:function(t){return Ok.validateExpiry(t)}},{key:"isExpiryValid",value:function(t){return Ok.isExpiryValid(t)}},{key:"generateTestCard",value:function(e){return new t(Ok.findTestCard(e))}}]),t}(),Ck=function(t){var e=t.clientdata,r=t.last4,i=t.pin,o=t.trans,a=t.device,s=t.rememberCard,u=t.transactionType,c=t.subscription,h=t.customFields,l="".concat(Kd.paymentBaseUrl,"charge/"),f=$A(),p=n({"Content-Type":"application/x-www-form-urlencoded"},f&&{"Accept-Language":f}),d=n(n(n({clientdata:e,last4:r,trans:o,device:a,offset:(new Date).getTimezoneOffset(),remember_card:s},u&&{transaction_type:u}),c&&{subscription:c}),h&&h);i&&(d.handle=i);var g=fE(d);return JA.post(l,g,{headers:p}).then((function(t){return sg.parse(t.data)}))},Pk=function(t){var e=t.device,r=t.accessCode,i=t.pin,o="".concat(Kd.paymentBaseUrl,"charge/resume/").concat(r),a=$A(),s=n({"Content-Type":"application/x-www-form-urlencoded"},a&&{"Accept-Language":a}),u=n({device:e},i&&{handle:i}),c=fE(u);return JA.post(o,c,{headers:s}).then((function(t){return sg.parse(t.data)}))},Bk=function(t){var e=t.last4,r=t.trans,i=t.device,o=t.authorizationCode,a=t.cvv,s=t.pin,u=t.transactionType,c=t.subscription,h="".concat(Kd.paymentBaseUrl,"charge/"),l=$A(),f=n({"Content-Type":"application/x-www-form-urlencoded"},l&&{"Accept-Language":l}),p=n(n({last4:e,trans:r,device:i,cvv:a,handle:s,authorization_code:o},u&&{transaction_type:u}),c&&{subscription:c}),d=fE(p);return JA.post(h,d,{headers:f}).then((function(t){return sg.parse(t.data)}))},Lk=function(t,e){var r="".concat(Kd.paymentBaseUrl,"charge/validate"),i={trans:t,token:e},o=$A(),a=n({},o&&{"Accept-Language":o}),s=fE(i);return JA.post(r,s,{headers:a}).then((function(t){return sg.parse(t.data)}))},Ik=function(t){var e=t.address,r=t.city,i=t.state,o=t.zipCode,a=t.transactionId,s="".concat(Kd.paymentBaseUrl,"charge/avs"),u=$A(),c=n({"Content-Type":"application/x-www-form-urlencoded"},u&&{"Accept-Language":u}),h=fE({city:r,state:i,address:e,zip_code:o,trans:a});return JA.post(s,h,{headers:c}).then((function(t){return sg.parse(t.data)}))},Dk=function(t){var e=t.authorizationId,r=t.publicKey,i=$A(),o=n({Authorization:"Bearer ".concat(r)},i&&{"Accept-Language":i}),a={authorization_id:e},s="".concat(Kd.paystackApiUrl,"rememberme/forget_card");return JA.post(s,a,{headers:o}).then((function(t){return sg.parse(t.data)}))},Nk=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s,u,c,h,l;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.transaction,i=t.phone,o=t.channels,a=t.email,s=new URL("/saved_cards/authorize",Kd.paystackApiUrl).toString(),u=$A(),c=n({},u&&{"Accept-Language":u}),h=n(n(n(n({},i&&{phone:i}),o&&{channels:o}),a&&{email:a}),{},{transaction:r}),e.next=7,JA.post(s,h,{headers:c});case 7:return l=e.sent,e.abrupt("return",l.data);case 9:case"end":return e.stop()}}),e)})))()},_k=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s,u,c,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.code,i=t.transaction,o=t.token,a=new URL("/saved_cards/authorize/verify",Kd.paystackApiUrl).toString(),s=$A(),u=n({Authorization:"Bearer ".concat(o)},s&&{"Accept-Language":s}),c={code:r,transaction:i},e.next=7,JA.post(a,c,{headers:u});case 7:return h=e.sent,e.abrupt("return",h.data);case 9:case"end":return e.stop()}}),e)})))()},jk=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.token,i=new URL("/saved_cards/cards",Kd.paystackApiUrl).toString(),o=$A(),a=n({Authorization:"Bearer ".concat(r),"jwt-auth":!0},o&&{"Accept-Language":o}),e.next=6,JA.get(i,{headers:a});case 6:return s=e.sent,e.abrupt("return",s.data);case 8:case"end":return e.stop()}}),e)})))()},Mk=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.cardCode,i=t.token,o=new URL("/saved_cards/cards/".concat(r),Kd.paystackApiUrl).toString(),a=$A(),s=n({Authorization:"Bearer ".concat(i),"jwt-auth":!0},a&&{"Accept-Language":a}),e.next=6,JA.delete(o,{headers:s});case 6:return u=e.sent,e.abrupt("return",u.data);case 8:case"end":return e.stop()}}),e)})))()},Uk=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s,u,c,h,l,f;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.token,i=t.device,o=t.cardCode,a=t.transaction,s=t.selectedCurrency,u=new URL("/saved_cards/cards/".concat(o,"/charge"),Kd.paystackApiUrl).toString(),c=$A(),h=n({Authorization:"Bearer ".concat(r),"jwt-auth":!0},c&&{"Accept-Language":c}),l={device:i,transaction:a,selected_currency:s},e.next=7,JA.post(u,l,{headers:h});case 7:return f=e.sent,e.abrupt("return",sg.parse(f.data));case 9:case"end":return e.stop()}}),e)})))()},Vk="card",Fk="saved card",qk="otp";function zk(t,e){return new Promise((function(n,r){var i=Rk.validate(t);if(!i.isValid){var o=e||t.number,a=Object.keys(i.result).filter((function(t){return!1===i.result[t]})),s="Invalid card details: ".concat(a.join(", "));r(Error(o?s:"Please set a valid card with Transaction.setCard()"))}n()}))}var Hk={setCard:function(t){var e=this;return zk(t,!0).then((function(){e.card=new Rk(t)}))},rememberCard:function(){this.remember_card=!0},chargeCard:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return!this.card.number&&this.card.pin?this.chargeCardWithPin(e):zk(this.card).then((function(){t.logAttempt(Vk);var n={clientdata:t.card.tokenize(),last4:t.card.getLast4(),pin:t.card.getEncryptedPin(),trans:t.id,device:t.deviceFingerprint,rememberCard:t.remember_card,transactionType:t.transactionType,subscription:t.subscription,customFields:e};return Ck(n).then((function(e){return t.logAPIResponse(e,Vk),e}))}))},chargeCardWithPin:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logAttempt(Vk);var n={pin:OE(this.card.pin),trans:this.id,device:this.deviceFingerprint,rememberCard:this.remember_card,transactionType:this.transactionType,subscription:this.subscription,customFields:e};return Ck(n).then((function(e){return t.logAPIResponse(e,Vk),e}))},chargeRememberedCard:function(t){var e=this,n=t.cvv,r=t.authorizationCode,i=t.cardLast4,o=t.pin;this.logAttempt(Vk);var a=OE(o),s={authorizationCode:r,cvv:n,last4:i,trans:this.id,device:this.deviceFingerprint,pin:a,transactionType:this.transactionType,subscription:this.subscription};return Bk(s).then((function(t){return e.logAPIResponse(t,Vk),t}))},resumeCardCharge:function(t){var e=this,r=t.accessCode,i=t.pin,o=n(n({},i&&{pin:OE(i)}),{},{accessCode:r,device:this.deviceFingerprint});return Pk(o).then((function(t){return e.logAPIResponse(t,Vk),t}))},forgetRememberedCard:function(t){var e=this,n={authorizationId:t,publicKey:this.merchant.key};return Dk(n).then((function(t){return e.logAPIResponse(t,Vk),t}))},authenticateCard:function(t){var e=this;return Lk(this.id,t).then((function(t){return e.logAPIResponse(t,Vk),t}))},verifyAddress:function(t){var e=this,n=t.address,r={city:t.city,state:t.state,address:n,zipCode:t.zipCode,transactionId:this.id};return Ik(r).then((function(t){return e.logAPIResponse(t,Vk),t}))},listenFor3DSCharge:function(t){var e={channel:"3DS_".concat(this.id),paymentMethod:Vk};return this.listenForCharge(e,t)},sendSavedCardsOTP:function(){var t=arguments,e=this;return o(regeneratorRuntime.mark((function n(){var r,i,o,a,s;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=(r=t.length>0&&void 0!==t[0]?t[0]:{}).phone,o=r.channels,a=r.email,n.prev=1,e.logAuth(qk),n.next=5,Nk({phone:i,transaction:e.id,channels:o,email:a});case 5:return s=n.sent,e.savedCardsTempAuthToken=s.data.token,n.abrupt("return",s);case 10:throw n.prev=10,n.t0=n.catch(1),e.savedCardsTempAuthToken=null,n.t0;case 14:case"end":return n.stop()}}),n,null,[[1,10]])})))()},verifySavedCardsOtp:function(t){var e=this;return o(regeneratorRuntime.mark((function n(){var r,i,o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=t.code,i={code:r,transaction:e.id,token:e.savedCardsTempAuthToken},n.prev=2,n.next=5,_k(i);case 5:return o=n.sent,e.savedCardsToken=o.data.token,n.abrupt("return",o);case 10:throw n.prev=10,n.t0=n.catch(2),e.savedCardsToken=null,n.t0;case 14:case"end":return n.stop()}}),n,null,[[2,10]])})))()},getSavedCards:function(){return jk({token:this.savedCardsToken})},deleteSavedCard:function(t){return Mk({cardCode:t,token:this.savedCardsToken})},chargeSavedCard:function(t){var e=t.cardCode,n=t.selectedCurrency,r=void 0===n?this.currency:n;return this.logAttempt(Fk),Uk({cardCode:e,transaction:this.id,token:this.savedCardsToken,device:this.deviceFingerprint,selectedCurrency:r})}},Gk=function(){function t(e){var n=e.bankId,r=e.accountType,i=e.accountNumber;a(this,t),this.bankId=n,this.accountType=r,this.accountNumber=i}var e;return u(t,null,[{key:"validate",value:function(e){var n=e.bankId,r=e.accountType,i=e.accountNumber,o=[];return n&&"number"==typeof n||o.push("Invalid bankId. Please check for supported banks with BankAccount.supportedBanks()"),t.types.indexOf(r)>-1?"nuban"!==r||t.isValidNubanAccount(i)||o.push("Invalid account number. Nuban accounts must be 10 digit numbers"):o.push("Invalid bank type. Please check BankAccount.types for the list of valid bank types"),{isValid:0===o.length,errors:o}}},{key:"isValidNubanAccount",value:function(t){return!!t&&(("number"==typeof t||/^\d+$/.test(t))&&10===t.length)}},{key:"supportedBanks",value:function(){var t="".concat(Kd.paymentBaseUrl,"bank?pay_with_bank=true"),e=$A(),r=n({},e&&{"Accept-Language":e});return JA.post(t,{headers:r}).then((function(t){return t.data}))}},{key:"resolve",value:(e=o(regeneratorRuntime.mark((function t(e){var r,i,o,a,s,u,c,h;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.transaction,i=e.bankCode,o=e.accountNumber,a=new URL("saved_cards/transaction/".concat(r,"/bank-resolve"),Kd.paystackApiUrl),s=$A(),u=n({},s&&{"Accept-Language":s}),c={bank_code:i,account_number:o},t.next=7,JA.post(a,c,{headers:u});case 7:return h=t.sent,t.abrupt("return",h.data);case 9:case"end":return t.stop()}}),t)}))),function(t){return e.apply(this,arguments)})}]),t}();Gk.types=["nuban"];var Kk=function(t){var e=t.bankId,r=t.transactionId,i=t.accountNumber,o=t.device,a="".concat(Kd.paymentBaseUrl,"bank/charge_account/").concat(e,"/").concat(r),s=$A(),u=n({"Content-Type":"application/x-www-form-urlencoded"},s&&{"Accept-Language":s}),c=fE({account_number:i,device:o});return JA.post(a,c,{headers:u}).then((function(t){return sg.parse(t.data)}))},Wk=function(t){var e=t.bankId,r=t.transactionId,i=t.accountNumber,o=t.birthday,a="".concat(Kd.paymentBaseUrl,"bank/charge_account/").concat(e,"/").concat(r),s=$A(),u=n({"Content-Type":"application/x-www-form-urlencoded"},s&&{"Accept-Language":s}),c=fE({account_number:i,birthday:o});return JA.post(a,c,{headers:u}).then((function(t){return sg.parse(t.data)}))},Xk=function(t){var e=t.bankId,r=t.transactionId,i=t.token,o=t.device,a="".concat(Kd.paymentBaseUrl,"bank/validate_token/").concat(e,"/").concat(r),s=$A(),u=n({"Content-Type":"application/x-www-form-urlencoded"},s&&{"Accept-Language":s}),c=fE({device:o,token:i});return JA.post(a,c,{headers:u}).then((function(t){return sg.parse(t.data)}))},Yk="bank account";function Zk(t,e){return new Promise((function(n,r){var i=Gk.validate(t);if(!i.isValid){var o=e||t.accountNumber?i.errors[0]:"Please set a valid bank account with Transaction.setBank()";r(Error(o))}n()}))}var Jk={getIbankUrl:function(t){var e=this,n=t.bankId;return new Promise((function(t,r){n||r(Error("Please send bankId"));var i="".concat(Kd.paymentBaseUrl,"bank/ibank/").concat(n,"/").concat(e.id);t(sg.success({url:i}))}))},listenForIbankCharge:function(t){var e={channel:"IBANK_".concat(this.id),paymentMethod:"ibank"};return this.listenForCharge(e,t)}},$k=function(t){var e=t.bankId,r=t.transactionId,i=t.phoneNumber,o=t.payId,a=t.walletId,s="".concat(Kd.paymentBaseUrl,"bank/digitalbankmandate/").concat(e,"/").concat(r),u=$A(),c=n({"Content-Type":"application/x-www-form-urlencoded"},u&&{"Accept-Language":u}),h=fE(a?{wallet_id:a}:{phone_number:i,token:o});return JA.post(s,h,{headers:c}).then((function(t){return sg.parse(t.data)}))},Qk="bank",tx={chargeDigitalBankMandate:function(t){var e=this,n=t.phoneNumber,r=t.payId,i=t.bankId,o=t.walletId,a={transactionId:this.id,phoneNumber:n,payId:r,bankId:i,walletId:o};return $k(a).then((function(t){return e.logAPIResponse(t,Qk),t}))},listenForDigitalBankMandateCharge:function(t){var e={paymentMethod:Qk,channel:arguments.length>1&&void 0!==arguments[1]?arguments[1]:""};return this.listenForCharge(e,t)}},ex=n(n(n({},{setBankAccount:function(t){var e=this;return Zk(t,!0).then((function(){e.bankAccount=new Gk(t)}))},chargeBankAccount:function(){var t=this;return Zk(this.bankAccount).then((function(){t.logAttempt(Yk);var e={bankId:t.bankAccount.bankId,transactionId:t.id,accountNumber:t.bankAccount.accountNumber,device:t.deviceFingerprint};return Kk(e).then((function(e){return t.logAPIResponse(e,Yk),e}))}))},registerBankAccount:function(t){var e=this;return Zk(this.bankAccount).then((function(){var n={bankId:e.bankAccount.bankId,transactionId:e.id,accountNumber:e.bankAccount.accountNumber,birthday:t};return Wk(n).then((function(t){return e.logAPIResponse(t,Yk),t}))}))},authenticateBankAccount:function(t){var e=this;return Zk(this.bankAccount).then((function(){var n={bankId:e.bankAccount.bankId,transactionId:e.id,token:t,device:e.deviceFingerprint};return Xk(n).then((function(t){return e.logAPIResponse(t,Yk),t}))}))}}),Jk),tx),nx=function(t,e){var r=$A(),i=n({Authorization:"Bearer ".concat(e)},r&&{"Accept-Language":r});return JA.post("".concat(Kd.paystackApiUrl,"checkout/ussd/reference"),t,{headers:i}).then((function(t){return sg.parse(t.data)}))},rx=function(t,e){var r=$A(),i=n({Authorization:"Bearer ".concat(e)},r&&{"Accept-Language":r});return JA.post("".concat(Kd.paystackApiUrl,"checkout/pay_with_transfer_ussd"),t,{headers:i}).then((function(t){return sg.parse(t.data)}))},ix={getUSSDShortcode:function(t){var e=this,n=t.channel,r={transaction:this.id,channel:n};return nx(r,this.merchant.key).then((function(t){return"success"===t.status&&(e.ussd[n]=t),t}))},getPWTUSSDShortcode:function(t){var e=this,n=t.bankSlug,r=t.fulfilLateNotification,i=void 0!==r&&r,o={transaction_id:this.id,fulfil_late_notification:i,bank_slug:n};return rx(o,this.merchant.key).then((function(t){return"success"===t.status&&(e.ussd[n]=t),t}))},listenForPWTUSSDCharge:function(t,e){var n=t.bankSlug;if(!this.ussd[n])return Promise.reject(Error("Please generate a ussd shortcode with Transaction.getPWTUSSDShortcode()"));var r={channel:this.ussd[n].data.pusher_channel,paymentMethod:"ussd"};return this.listenForCharge(r,e)},listenForUSSDCharge:function(t,e){var n=t.channel;if(!this.ussd[n])return Promise.reject(Error("Please generate a ussd shortcode with Transaction.getUSSDShortcode()"));var r={channel:this.ussd[n].data.channel,paymentMethod:n};return this.listenForCharge(r,e)}},ox=function(t,e){var r={source:"checkout",reference:t.transaction,channel:t.channel},i=$A(),o=n({Authorization:"Bearer ".concat(e)},i&&{"Accept-Language":i});return JA.post("".concat(Kd.paystackApiUrl,"offline/qr/generate"),r,{headers:o}).then((function(t){return sg.parse(t.data)}))};function ax(t){return new Promise((function(e,n){var r=["visa","MPASS_OLTI"];if(r.indexOf(t)<=-1){var i="Invalid channel. Available channels: ".concat(r.join(", "));n(Error(i))}else e()}))}var sx={getQRCode:function(t){var e=this,n=t.channel;return ax(n).then((function(){if(e.qr[n])return e.qr[n];var t={transaction:e.id,channel:n};return ox(t,e.merchant.key).then((function(t){return"success"===t.status&&(e.qr[n]=t),t}))}))},listenForQRCharge:function(t,e){var n=this,r=t.channel;return ax(r).then((function(){if(!n.qr[r])return Promise.reject(Error("Please generate qr code with Transaction.getQRCode()"));var t={channel:n.qr[r].data.channel,paymentMethod:r};return n.listenForCharge(t,e)}))}},ux=function(){function t(){a(this,t)}return u(t,null,[{key:"hasCountryCode",value:function(t){return t&&"+"===t[0]}},{key:"hasOnlyDigits",value:function(t){var e;return t&&(e=t.substring(1),/^\d+$/.test(e))}},{key:"isE164Number",value:function(t){return t&&t.length<17}},{key:"validate",value:function(e){var n=[];return t.hasCountryCode(e)||n.push("Number should include country code prefix"),t.hasOnlyDigits(e)||n.push("Number should contain only digits"),t.isE164Number(e)||n.push("Number should not be longer than 16 digits"),{isValid:0===n.length,errors:n}}}]),t}(),cx=function(t){var e={transaction:t.transaction,phone:t.phone,device:t.device,channel_name:t.channel_name,provider:t.provider,voucher:t.voucher,registration_token:t.registrationToken},r=$A(),i=n({},r&&{"Accept-Language":r});return JA.post("".concat(Kd.paystackApiUrl,"charge/mobile_money"),e,{headers:i}).then((function(t){return sg.parse(t.data)})).catch((function(t){var e=t.response;return sg.parse(e.data)}))},hx=function(t){var e=t.transaction,r=t.code,i=$A(),o=n({},i&&{"Accept-Language":i}),a=fE({transaction:e,otp:r}),s=new URL("charge/momo_payin_finalize",Kd.paymentBaseUrl).toString();return JA.post(s,a,{headers:o}).then((function(t){return sg.parse(t.data)}))};function lx(t){return new Promise((function(e,n){var r=ux.validate(t);if(!r.isValid){var i=t?r.errors[0]:"Please start a mobile money transaction with Transaction.chargeMobileMoney()";n(Error(i))}e(r)}))}var fx={mobileMoneyChargeAPI:function(t){var e=this;return cx(t).then((function(t){return"success"===t.status&&(e.mobileMoney=t,t.data&&t.data.display&&1===t.data.display.otpSentCount&&e.logTokenRequest("mobile money")),t}))},chargeMobileMoney:function(t){var e=this,n=t.phoneNumber,r=t.provider,i=t.voucher,o=t.registrationToken;return lx(n).then((function(){e.logAttempt("mobile money");var t={provider:r,voucher:i,registrationToken:o,transaction:e.id,phone:n,device:e.deviceFingerprint,channel_name:"MOBILE_MONEY_".concat(e.id)};return e.mobileMoneyChargeAPI(t)}))},chargeMpesaOffline:function(t){var e=t.provider,n=t.voucher,r=t.registrationToken;this.logAttempt("mobile money");var i={provider:e,voucher:n,registrationToken:r,transaction:this.id,device:this.deviceFingerprint,channel_name:"MOBILE_MONEY_".concat(this.id)};return this.mobileMoneyChargeAPI(i)},authenticateMobileMoney:function(t){var e=this,n=t.phoneNumber,r=t.provider,i=t.registrationToken;return lx(n).then((function(){e.logMobileMoneyActions(t);var o={provider:r,registrationToken:i,transaction:e.id,phone:n,device:e.deviceFingerprint,channel_name:"MOBILE_MONEY_".concat(e.id)};return cx(o).then((function(t){return"success"===t.status?(e.mobileMoney=t,t.data&&t.data.display&&1===t.data.display.otpSentCount&&e.logTokenRequest("mobile money")):t.errors&&t.errors.data&&"awaiting_registration_token"===t.errors.data.status?e.logTokenAuthenticationFailure(t.message):e.logError(t.message),t}))}))},submitMobileMoneyCode:function(t){var e=this;return hx({code:t.code,transaction:this.id}).then((function(t){return e.logAPIResponse(t,"mobile_money"),t}))},listenForMobileMoneyCharge:function(t){if("success"!==this.mobileMoney.status)return Promise.reject(Error("Please start a mobile money charge with Transaction.chargeMobileMoney()"));var e=this.mobileMoney.data,n=e.channel,r=e.channel_name,i={channel:n||r,paymentMethod:"mobile_money"};return this.listenForCharge(i,t)}},px=function(t){var e={email:t.email,password:t.password},r=$A(),i=n({},r&&{"Accept-Language":r});return JA.post("".concat(Kd.paystackApiUrl,"login"),e,{headers:i}).then((function(t){return sg.parse(t.data)}))},dx=function(t){var e=t.account_code,r=t.transaction,i=t.token,o=$A(),a=n({Authorization:"Bearer ".concat(i),"jwt-auth":!0},o&&{"Accept-Language":o}),s={account_code:e,transaction:r};return JA.post("".concat(Kd.paystackApiUrl,"directdebit/initiate"),s,{headers:a}).then((function(t){return sg.parse(t.data)}))},gx=function(t){var e=t.otp,r=t.transaction,i=t.token,o=$A(),a=n({Authorization:"Bearer ".concat(i),"jwt-auth":!0},o&&{"Accept-Language":o}),s={otp:e,transaction:r};return JA.post("".concat(Kd.paystackApiUrl,"directdebit/validate"),s,{headers:a}).then((function(t){return sg.parse(t.data)}))},mx=function(t){var e=$A(),r=n({Authorization:"Bearer ".concat(t),"jwt-auth":!0},e&&{"Accept-Language":e});return JA.get("".concat(Kd.paystackApiUrl,"directdebit/account"),{headers:r}).then((function(t){return t.data}))},vx="direct debit",yx={loginToDirectDebitAccount:function(t){var e=this,n=t.email,r={email:n,password:t.password};return Jc(n)?px(r).then((function(t){if("success"===t.status){var n=t.data,r=n.token,i=n.user.permissions;if(!i||i.length<1)throw Error("You do not have the privileges to perform this action");if(i.find((function(t){return"directdebit-*"===t})))return e.directDebit.token=r,t;throw Error("You do not have the privileges to perform this action")}return t})):Promise.reject(Error("Invalid email"))},chargeDirectDebit:function(t){var e=this;if(!this.directDebit.token)return Promise.reject(Error("Please login with Transaction.loginToDirectDebitAccount() to start a Direct debit charge"));this.logAttempt(vx);var n={account_code:t,transaction:this.id,token:this.directDebit.token};return dx(n).then((function(t){return e.logAPIResponse(t,vx),t.status&&(e.directDebit.chargeResponse=t),t}))},getProvisionedAccounts:function(){var t=this;return mx(this.directDebit.token).then((function(e){t.logAPIResponse(e,vx);var n=e.status,r=e.data;if(n){if(r&&r.length<1)return Promise.reject(Error("You have not provisioned any bank account for Direct Debit yet"));t.directDebit.accounts=e.data}return e}))},authenticateAccount:function(t){var e=this,n={otp:t,transaction:this.id,token:this.directDebit.token};return gx(n).then((function(t){return e.logAPIResponse(t,vx),t}))}},bx=tr.PROPER,wx=x,Sx=ec,Tx=hc.trim;li({target:"String",proto:!0,forced:function(t){return wx((function(){return!!Sx[t]()||"
"!=="
"[t]()||bx&&Sx[t].name!==t}))}("trim")},{trim:function(){return Tx(this)}});var Ax,Ex="capitec_pay",kx="CELLPHONE",xx="IDNUMBER",Ox="ACCOUNTNUMBER",Rx={combineIdentifierKeyAndIdentifierValue:function(t){var e=t.identifierKey,n=t.identifierValue;return"".concat(e,"*").concat(n)},encryptIdentifierKeyAndIdentifierValue:function(t){var e=t.identifierKey,n=t.identifierValue;return OE(Rx.combineIdentifierKeyAndIdentifierValue({identifierKey:e,identifierValue:n}))},validateAccountNumber:function(t){return/^\d{10}$/.test(t)},validateIDNumber:function(t){return/^\d{13}$/.test(t)},validateCellphoneNumber:function(t){return/^0\d{9}$/.test(t)},validateIdentifierKeyAndIdentifierValue:function(t){var e=t.identifierKey,n=t.identifierValue;switch(e){case kx:return Rx.validateCellphoneNumber(n);case xx:return Rx.validateIDNumber(n);case Ox:return Rx.validateAccountNumber(n);default:return!1}}},Cx={authenticate:function(t){var e=t.clientData,r=t.transactionId,i=t.deviceFingerprint,o=t.publicKey,a=new URL("capitec-pay/authenticate",Kd.paystackApiUrl),s=$A(),u=n({Authorization:"Bearer ".concat(o),"Content-Type":"application/x-www-form-urlencoded"},s&&{"Accept-Language":s}),c=fE({clientdata:e,trans:r,device:i});return JA.post(a,c,{headers:u}).then((function(t){return t.data}))},requery:(Ax=o(regeneratorRuntime.mark((function t(e){var r,i,o,a,s,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.transactionId,i=e.publicKey,o=new URL("capitec-pay/requery",Kd.paystackApiUrl),a=$A(),s=n({Authorization:"Bearer ".concat(i)},a&&{"Accept-Language":a}),u={transaction_id:r},t.next=7,JA.get(o,{headers:s,params:u}).then((function(t){return sg.parse(t)}));case 7:return c=t.sent,t.abrupt("return",c);case 9:case"end":return t.stop()}}),t)}))),function(t){return Ax.apply(this,arguments)})},Px="capitec_pay",Bx={validateIdentifier:function(t){var e=t.identifierKey,n=t.identifierValue,r=(void 0===n?"":n).trim();return Rx.validateIdentifierKeyAndIdentifierValue({identifierKey:e,identifierValue:r})},authenticateCapitecPay:function(t){var e=this,n=t.identifierKey,r=t.identifierValue,i=(void 0===r?"":r).trim();if(!Rx.validateIdentifierKeyAndIdentifierValue({identifierKey:n,identifierValue:i}))return Promise.reject(new Error("Invalid identifier key and value"));var o=Rx.encryptIdentifierKeyAndIdentifierValue({identifierKey:n,identifierValue:i});return this.logCapitecPayAccountDetailsSubmission(n),Cx.authenticate({clientData:o,deviceFingerprint:this.deviceFingerprint,transactionId:this.id,publicKey:this.merchant.key}).then((function(t){return e.logCapitecPayAuthenticateResponse(t.status),t}))},requeryCapitecPay:function(){var t=this;return Cx.requery({transactionId:this.id,publicKey:this.merchant.key}).then((function(e){return t.logAPIResponse(e,Px),e}))},listenForCapitecPayCharge:function(t){var e={paymentMethod:Px,channel:arguments.length>1&&void 0!==arguments[1]?arguments[1]:""};return this.listenForCharge(e,t)}},Lx=function(t){return{card:Hk,bank:ex,ussd:ix,qr:sx,mobile_money:fx,direct_debit:yx,bank_transfer:hE,eft:mE,payattitude:gE,apple_pay:wE,paypal:kE,capitec_pay:Bx}[t]},Ix=function(t){t||"undefined"==typeof navigator||(t=navigator.userAgent);t&&t.headers&&"string"==typeof t.headers["user-agent"]&&(t=t.headers["user-agent"]);return"string"==typeof t&&(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))};var Dx=function(t){var e=t||{},n=e.attempts,r=e.authentication,i=e.errors,o=e.history;return{start_time:Math.round(Date.now()/1e3),time_spent:0,attempts:n||0,authentication:r,errors:i||0,success:!1,mobile:Ix(),input:[],history:o||[]}},Nx=function(t){return Math.round(Date.now()/1e3)-t},_x=li,jx=lt,Mx=uo,Ux=H,Vx=x,Fx=E.Array,qx=jx("JSON","stringify"),zx=Ux(/./.exec),Hx=Ux("".charAt),Gx=Ux("".charCodeAt),Kx=Ux("".replace),Wx=Ux(1..toString),Xx=/[\uD800-\uDFFF]/g,Yx=/^[\uD800-\uDBFF]$/,Zx=/^[\uDC00-\uDFFF]$/,Jx=function(t,e,n){var r=Hx(n,e-1),i=Hx(n,e+1);return zx(Yx,t)&&!zx(Zx,i)||zx(Zx,t)&&!zx(Yx,r)?"\\u"+Wx(Gx(t,0),16):t},$x=Vx((function(){return'"\\udf06\\ud834"'!==qx("\udf06\ud834")||'"\\udead"'!==qx("\udead")}));qx&&_x({target:"JSON",stat:!0,forced:$x},{stringify:function(t,e,n){for(var r=0,i=arguments.length,o=Fx(i);r<i;r++)o[r]=arguments[r];var a=Mx(qx,null,o);return"string"==typeof a?Kx(a,Xx,Jx):a}});var Qx=function(t,e){var r=e.merchantKey,i=e.log,o=$A(),a=n({Authorization:"Bearer ".concat(r)},o&&{"Accept-Language":o});return JA.post(t,{payload:JSON.stringify(i)},{headers:a}).then((function(t){return t.data}))},tO=function(t,e){var r=e.merchantKey,i=$A(),o=n({Authorization:"Bearer ".concat(r)},i&&{"Accept-Language":i});return JA.post(t,null,{headers:o}).then((function(t){return t.data}))},eO=function(t,e){var r=e.merchantKey,i=e.referrer,o=$A(),a=n({Authorization:"Bearer ".concat(r)},o&&{"Accept-Language":o});return JA.post(t,{referrer:i},{headers:a}).then((function(t){return t.data}))},nO=function(t,e,n){var r=new URL("transaction/update_log/".concat(t),Kd.paystackApiUrl).toString();return Qx(r,{merchantKey:e,log:n})},rO=function(t,e){var n=new URL("transaction/set_ip/".concat(t),Kd.paystackApiUrl).toString();return tO(n,{merchantKey:e})},iO=function(t,e,n){var r=new URL("transaction/set_referrer/".concat(t),Kd.paystackApiUrl).toString();return eO(r,{merchantKey:e,referrer:n})},oO=n(n({},{logCapitecPayConfirmation:function(t){return this.logHistoryEntry({type:"action",message:"Selected confirm with: ".concat(t),channel:Ex,time:this.getTimeSpent()})},logCapitecPayAuthenticateResponse:function(t){var e=t?"Customer authenticated Capitec Pay account successfully":"Customer failed to authenticate Capitec Pay account";return this.logHistoryEntry({type:"action",message:e,channel:Ex,time:this.getTimeSpent()})},logCapitecPayAccountIdentifierSwitch:function(t){return this.logHistoryEntry({type:"action",message:"Switched account identifier to: ".concat(t),channel:Ex,time:this.getTimeSpent()})},logCapitecPayConfirmedPayment:function(){return this.logHistoryEntry({type:"action",message:"Selected confirm payment",channel:Ex,time:this.getTimeSpent()})},logCapitecPayRetryConfirmation:function(){return this.logHistoryEntry({type:"action",message:"Selected retry payment confirmation",channel:Ex,time:this.getTimeSpent()})}}),{},{initializeLog:function(t){this.log=Dx(t)},getTimeSpent:function(){return this.log.time_spent=Nx(this.log.start_time),this.log.time_spent},logHistoryEntry:function(t){return this.log.history.push(t),this.saveLog()},logPageOpen:function(){return this.log.history.push({type:"open",message:"Opened checkout",time:this.getTimeSpent()}),this.saveLog()},logChannelSwitch:function(t){return this.log.history.push({type:"action",message:"Set payment method to: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logValidationErrors:function(t){var e=this;return t.forEach((function(t){e.log.history.push({type:"error",message:"Invalid ".concat(t),time:e.getTimeSpent()})})),this.saveLog()},logInput:function(t){var e=this.log.history.find((function(e){return e.message==="Filled this field: ".concat(t)}));return this.log.history.push({type:"input",message:"".concat(e?"Changed":"Filled"," this field: ").concat(t),time:this.getTimeSpent()}),this.saveLog()},logBankSelect:function(t){return this.log.history.push({type:"action",message:"Selected bank: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logSavedCardSelect:function(){return this.log.history.push({type:"action",message:"Selected saved card",time:this.getTimeSpent()}),this.saveLog()},logAuthWindowOpen:function(){return this.log.history.push({type:"action",message:"Third-party authentication window opened",time:this.getTimeSpent()}),this.saveLog()},logAuthWindowClose:function(){return this.log.history.push({type:"action",message:"Third-party authentication window closed",time:this.getTimeSpent()}),this.saveLog()},logAPIResponse:function(t,e){switch(t.status){case"success":return this.logSuccess(e);case"pending":return this.logPending(e);case"failed":return this.logError(t.message);case"auth":return this.logAuth(t.data.auth);default:return!1}},logMobileMoneyActions:function(t){var e=t.numberOfTokenRequests,n=t.registrationToken;e?this.logTokenRequest("mobile money",e):n?this.logTokenSubmitted("mobile money"):this.logAttempt("mobile money")},logAPIResponseMessage:function(t){return this.log.history.push({type:"action",message:t,time:this.getTimeSpent()}),this.saveLog()},logAttempt:function(t){var e="Attempted to pay";return t&&(e+=" with ".concat(t)),this.log.attempts+=1,this.log.history.push({type:"action",message:e,time:this.getTimeSpent()}),this.saveLog()},logTokenRequest:function(t){var e=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:function(t){return this.log.history.push({type:"action",message:"Customer submitted OTP",channel:t,time:this.getTimeSpent()}),this.saveLog()},logTokenAuthenticationFailure:function(t){var e=t?"Error: ".concat(t):"Error";return this.log.errors+=1,this.log.history.push({type:"error",message:e,authentication:"failed",time:this.getTimeSpent()}),this.saveLog()},logError:function(t){var e="Error";return t&&(e+=": ".concat(t)),this.log.errors+=1,this.log.history.push({type:"error",message:e,time:this.getTimeSpent()}),this.saveLog()},logAuth:function(t){return this.log.authentication=t,this.log.history.push({type:"auth",message:"Authentication Required: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logSuccess:function(t){var e="Successfully paid";return t&&(e+=" with ".concat(t)),this.log.success=!0,this.log.history.push({type:"success",message:e,time:this.getTimeSpent()}),this.saveLog()},logPending:function(t){var e="Payment in progress";return t&&(e+=" with ".concat(t)),this.log.history.push({type:"pending",message:e,time:this.getTimeSpent()}),this.saveLog()},logPageClose:function(){return this.log.history.push({type:"close",message:"Closed checkout",time:this.getTimeSpent()}),this.saveLog()},logTransactionCurrencySwitch:function(t){var e=t.currency,n=t.isUserAction,r=void 0===n||n?"User switched":"Switched";return this.log.history.push({type:"action",message:"".concat(r," transaction currency to ").concat(e),time:this.getTimeSpent()}),this.saveLog()},saveLog:function(){return nO(this.id,this.merchant.key,this.log)},saveIpAddress:function(){return rO(this.id,this.merchant.key)},saveReferrer:function(t){return iO(this.id,this.merchant.key,t)},setAmountByChannel:function(t){var e;this.amount=(null===(e=this.channelFeesConfig[t])||void 0===e?void 0:e.amount)||this.originalAmount}}),aO=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s,u,c,h,l;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.transaction,i=t.phone,o=t.channels,a=t.email,s=new URL("/saved_cards/authorize",Kd.paystackApiUrl).toString(),u=$A(),c=n({},u&&{"Accept-Language":u}),h=n(n(n(n({},i&&{phone:i}),o&&{channels:o}),a&&{email:a}),{},{transaction:r,is_six_digit_otp:!0}),e.next=7,JA.post(s,h,{headers:c});case 7:return l=e.sent,e.abrupt("return",l.data);case 9:case"end":return e.stop()}}),e)})))()},sO=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s,u,c,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.code,i=t.transaction,o=t.token,a=new URL("/saved_cards/authorize/verify",Kd.paystackApiUrl).toString(),s=$A(),u=n({Authorization:"Bearer ".concat(o)},s&&{"Accept-Language":s}),c={code:r,transaction:i},e.next=7,JA.post(a,c,{headers:u});case 7:return h=e.sent,e.abrupt("return",h.data);case 9:case"end":return e.stop()}}),e)})))()},uO=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.token,i=new URL("/saved_cards/link/payment-instruments",Kd.paystackApiUrl).toString(),o=$A(),a=n({Authorization:"Bearer ".concat(r),"jwt-auth":!0},o&&{"Accept-Language":o}),e.next=6,JA.get(i,{headers:a});case 6:return s=e.sent,e.abrupt("return",s.data);case 8:case"end":return e.stop()}}),e)})))()},cO=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s,u,c,h,l,f;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.token,i=t.device,o=t.instrumentCode,a=t.transaction,s=t.selectedCurrency,u=new URL("/saved_cards/link/".concat(o,"/charge"),Kd.paystackApiUrl).toString(),c=$A(),h=n({Authorization:"Bearer ".concat(r),"jwt-auth":!0},c&&{"Accept-Language":c}),l={device:i,transaction:a,selected_currency:s},e.next=7,JA.post(u,l,{headers:h});case 7:return f=e.sent,e.abrupt("return",sg.parse(f.data));case 9:case"end":return e.stop()}}),e)})))()},hO=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new URL("/saved_cards/direct-debit/pay-with-transfer",Kd.paystackApiUrl).toString(),i=$A(),o=n({Authorization:"Bearer ".concat(t.token)},i&&{"Accept-Language":i}),a={device:t.device,transaction_id:t.transactionId,account_number:t.accountNumber,account_name:t.accountName,bank_code:t.bankCode,currency:t.currency,country_code:t.countryCode,fulfil_late_notification:t.fulfilLateNotification},e.next=6,JA.post(r,a,{headers:o});case 6:return s=e.sent,e.abrupt("return",sg.parse(s.data));case 8:case"end":return e.stop()}}),e)})))()},lO=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new URL("/saved_cards/user/profile/verify",Kd.paystackApiUrl).toString(),i=$A(),o=n({},i&&{"Accept-Language":i}),a={transaction_id:t.transactionId,email:t.email,account_number:t.accountNumber,bank_code:t.bankCode},e.next=6,JA.post(r,a,{headers:o});case 6:return s=e.sent,e.abrupt("return",s.data);case 8:case"end":return e.stop()}}),e)})))()},fO=function(t){return o(regeneratorRuntime.mark((function e(){var r,i,o,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new URL("/saved_cards/customer-validation/validate",Kd.paystackApiUrl).toString(),i=$A(),o=n({},i&&{"Accept-Language":i}),a=n(n({bank_code:t.bankCode,account_number:t.accountNumber,email:t.email},t.phoneNumber&&{phone_number:t.phoneNumber}),{},{transaction_id:t.transactionId}),e.next=6,JA.post(r,a,{headers:o});case 6:return s=e.sent,e.abrupt("return",s.data);case 8:case"end":return e.stop()}}),e)})))()},pO={authentication:"vault otp",paymentInstrument:{bank:"linked account",card:"saved card"}},dO={sendLinkOtp:function(t){var e=t.phone,n=t.channels,r=t.email;return this.logAuth(pO.authentication),aO({phone:e,transaction:this.id,channels:n,email:r})},verifyLinkOtp:function(t){var e=t.code,n=t.token;return sO({code:e,transaction:this.id,token:n})},getLinkPaymentInstruments:function(t){var e=t.token;return uO({token:e})},chargeLinkPaymentInstrument:function(t){var e=this,n=t.instrumentCode,r=t.selectedCurrency,i=void 0===r?this.currency:r,o=t.token,a=t.instrumentType,s=pO.paymentInstrument[a]||"vault",u={instrumentCode:n,transaction:this.id,token:o,device:this.deviceFingerprint,selectedCurrency:i};return this.logAttempt(s),cO(u).then((function(t){return e.logAPIResponse(t,s),t}))},generateLinkManagedAccount:function(t){return hO(n(n({},t),{},{device:this.deviceFingerprint,transactionId:this.id}))},listenForLinkBankPayWithTransferCharge:function(t,e){var n={channel:t,paymentMethod:"bank_transfer"};return this.listenForCharge(n,e)},verifyLinkProfile:function(t){return lO(n(n({},t),{},{transactionId:this.id}))},validateLinkCustomerBankAccount:function(t){return fO(n(n({},t),{},{transactionId:this.id}))}},gO=function(){function t(e){var n=this;a(this,t),this.email=e.email,this.merchant={id:e.merchant_id,logo:e.merchant_logo,name:e.merchant_name,key:e.merchant_key,channelSettings:e.merchant_channel_settings||{}},this.status=e.transaction_status||e.status,this.accessCode=e.access_code,this.amount=e.amount,this.originalAmount=e.amount,this.domain=e.domain,this.isTest="test"===e.domain,this.currency=e.currency,this.id=e.id,this.channels=e.channels,this.label=e.label,this.metadata=e.metadata||{},this.cancel_action=e.cancel_action||null,this.channelFeesConfig=e.channel_fees_and_amount||{},this.channel_options=e.channel_options||null,this.hash=e.hash||null,this.authorizations=e.authorizations,this.remember_card=!1,this.rememberMeEnabled=e.is_remember_me_enabled,this.card={},this.bankAccount={},this.mobileMoney={},this.ussd={},this.bankTransfer={},this.qr={},this.directDebit={},this.deviceFingerprint=e.deviceFingerprint||null,this.customer=e.customer,this.custom_filters=e.custom_filters||null,this.isCharging=!1,this.isListening=!1,this.transactionType=e.transaction_type||null,this.subscription=e.subscription||null,this.planDetails=e.plan_details||null,this.exchangeRate=e.exchange_rate||null,this.savedCardsConfig=e.saved_cards||{},this.supportedBanks=e.supported_banks||[],this.savedCardsTempAuthToken=null,this.savedCardsToken=null,this.reference=e.reference,this.linkConfig=e.link_config||{},ug(),this.log=null,Object.assign(this,oO),this.initializeLog(e.log),this.saveIpAddress(),this.channels.forEach((function(t){var e=Lx(t);Object.assign(n,e)})),this.linkConfig.enabled&&Object.assign(this,dO),"GHS"===e.currency&&e.elevy_percentage&&(this.elevyPercentage=e.elevy_percentage)}return u(t,[{key:"setMetadata",value:function(t,e){this.metadata[t]=e}},{key:"setDevice",value:function(t){this.deviceFingerprint?kd("Device ID has already been set by Checkout JS so there's no need to set this again"):this.deviceFingerprint=t}},{key:"listenForCharge",value:function(t,e){return cg(t,this,e)}},{key:"requery",value:function(){return rE(this.id)}},{key:"markAsAbandoned",value:function(){return iE({publicKey:this.merchant.key,transactionId:this.id})}},{key:"verifyStatus",value:function(){return oE({reference:this.reference,publicKey:this.merchant.key}).then((function(t){return t&&t.data}))}},{key:"initializeCustomerSubscriptionAuthorization",value:function(t){return aE(t,this.merchant.key).then((function(t){return t&&t.data}))}}]),t}(),mO={validate:function(t){var e=function(t){var e=[];return t&&"object"===r(t)?(Object.keys(th).forEach((function(n){var r=th[n],i=t[n];!r.required||i||t[r.fallback]?i&&!r.isValid(i)&&e.push({field:n,message:"Invalid field: ".concat(n)}):e.push({field:n,message:"Required field: ".concat(n)})})),e):(e.push({message:"Please supply a valid object"}),e)}(t);if(e.length){var n=y(e,1)[0].message;throw new es(e,n)}},request:function(t){return o(regeneratorRuntime.mark((function e(){var r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Od();case 2:return r=e.sent,e.next=5,QA(n(n({},t),{device:r}));case 5:return i=e.sent,e.abrupt("return",i&&Object.seal(new gO(n(n({},i.data),{deviceFingerprint:r}))));case 7:case"end":return e.stop()}}),e)})))()},createInstance:function(t){return o(regeneratorRuntime.mark((function e(){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Od();case 2:if(r=e.sent,null!=t&&t.access_code){e.next=5;break}throw new Error("This function should be used with transaction data from the API");case 5:return e.abrupt("return",Object.seal(new gO(n(n({},t),{deviceFingerprint:r}))));case 6:case"end":return e.stop()}}),e)})))()},requestWithAccessCode:function(t){return o(regeneratorRuntime.mark((function e(){var r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Od();case 2:return r=e.sent,e.next=5,tE(t);case 5:return i=e.sent,e.abrupt("return",i&&Object.seal(new gO(n(n({},i.data),{deviceFingerprint:r}))));case 7:case"end":return e.stop()}}),e)})))()},getByAccessCode:function(t,e){return o(regeneratorRuntime.mark((function r(){var i,o;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,Od();case 2:return i=r.sent,r.next=5,eE(t,e);case 5:return o=r.sent,r.abrupt("return",o&&Object.seal(new gO(n(n({},o.data),{deviceFingerprint:i}))));case 7:case"end":return r.stop()}}),r)})))()},initialize:function(t){return Object.seal(new gO(t))},verify:function(t){return o(regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,nE(t);case 2:return n=e.sent,e.abrupt("return",n&&n.data);case 4:case"end":return e.stop()}}),e)})))()}},vO={},yO=function(t){var e=new URL("/bank",Kd.paystackApiUrl).toString(),r=$A(),i={params:t,headers:n({},r&&{"Accept-Language":r})};return JA.get(e,i).then((function(t){return t.data}))},bO=function(){var t=new URL("/checkout/resolutions",Kd.paystackApiUrl).toString(),e=$A(),r=n({},e&&{"Accept-Language":e});return JA.get(t,{headers:r}).then((function(t){return t.data}))},wO=function(){var t=new URL("/checkout/celebrations",Kd.paystackApiUrl).toString(),e=$A(),r=n({},e&&{"Accept-Language":e});return JA.get(t,{headers:r}).then((function(t){return t.data}))},SO=function(t){var e=new URL("/address_verification/states",Kd.paystackApiUrl).toString(),r=$A(),i={params:t,headers:n({},r&&{"Accept-Language":r})};return JA.get(e,i).then((function(t){return t.data}))},TO=function(t){var e=new URL("/decision/bin/".concat(t),Kd.paystackApiUrl).toString(),r=$A(),i=n({},r&&{"Accept-Language":r});return vO[t]?Promise.resolve(vO[t]):JA.get(e,{headers:i}).then((function(e){var n=e.data;return vO[t]=n,n}))},AO=function(t){var e=new URL("decision/resolve_ip/".concat(t),Kd.paystackApiUrl).toString(),r=$A(),i=n({},r&&{"Accept-Language":r});return JA.get(e,{headers:i}).then((function(t){return t.data}))},EO=function(){function t(){a(this,t)}return u(t,null,[{key:"contents",value:function(){return[{key:"banks",usage:"Returns a list of banks that can be used to complete checkout"},{key:"resolutions",usage:"Returns a list of known errors, mapped to their suggested resolutions"},{key:"celebrations",usage:"Returns a list of upcoming celebrations"},{key:"states",usage:"Returns a list of states for a particular country"}]}},{key:"fetch",value:function(t,e){var n;if(this.contents().map((function(t){return t.key})).indexOf(t)<=-1)throw new Error("Please provide a valid config key. Use Toolkit.contents() to see available options.");switch(t){case"banks":n=yO(e||{pay_with_bank:"1"});break;case"resolutions":n=bO();break;case"celebrations":n=wO();break;case"states":n=SO(e)}return n}},{key:"resolveCardBin",value:function(t){return TO(t)}},{key:"resolveIPAddress",value:function(t){return AO(t)}}]),t}(),kO=function(){function t(e){var n=e.number,r=e.cvv,i=e.month,o=e.year,s=e.pin;a(this,t),this.number=n,this.cvv=r,this.month=i,this.year=o,this.pin=s}return u(t,[{key:"getEncryptedPin",value:function(){return Ok.getEncryptedPin(this.pin)}},{key:"getLast4",value:function(){return Ok.getLast4(this.number)}},{key:"tokenize",value:function(){return Ok.tokenize({number:this.number,cvv:this.cvv,month:this.month,year:this.year})}}],[{key:"getType",value:function(t){return Ok.getType(t)}},{key:"validate",value:function(t){var e=t.number,n=t.cvv,r=t.month,i=t.year;return Ok.validate({number:e,cvv:n,month:r,year:i})}},{key:"validateNumber",value:function(t){return Ok.validateNumber(t)}},{key:"isNumberValid",value:function(t){return Ok.isNumberValid(t)}},{key:"validateCVV",value:function(t,e){return Ok.validateCVV(t,e)}},{key:"isCvvValid",value:function(t,e){return Ok.isCvvValid(t,e)}},{key:"validateExpiry",value:function(t){return Ok.validateExpiry(t)}},{key:"isExpiryValid",value:function(t){return Ok.isExpiryValid(t)}},{key:"generateTestCard",value:function(e){return new t(Ok.findTestCard(e))}}]),t}(),xO=function(t){var e=t.clientdata,r=t.last4,i=t.preauthorizationId,o=t.publicKey,a=new URL("preauthorization/create",Kd.paystackApiUrl).toString(),s=$A(),u=n({Authorization:"Bearer ".concat(o)},s&&{"Accept-Language":s});return JA.post(a,{clientdata:e,last4:r,preauthorization:i},{headers:u}).then((function(t){return sg.parse(t.data)}))},OO="card";function RO(t,e){return new Promise((function(n,r){var i=kO.validate(t);if(!i.isValid){var o=e||t.number,a=Object.keys(i.result).filter((function(t){return!1===i.result[t]})),s="Invalid card details: ".concat(a.join(", "));r(Error(o?s:"Please set a valid card with setCard()"))}n()}))}var CO={setCard:function(t){var e=this;return RO(t,!0).then((function(){e.card=new kO(t)}))},reserveFunds:function(t){var e=this,n=t.preauthorizationId,r=t.publicKey,i=t.customFields,o=void 0===i?{}:i;return RO(this.card).then((function(){e.logAttempt(OO);var t={clientdata:e.card.tokenize(),last4:e.card.getLast4(),device:e.deviceFingerprint,preauthorizationId:n,publicKey:r,customFields:o};return xO(t).then((function(t){return e.logAPIResponse(t,OO),t}))}))},listenFor3DSCharge:function(t){var e={channel:"3DS_".concat(this.id),paymentMethod:OO};return this.listenForCharge(e,t)}},PO=function(t){var e=$A(),r=n({},e&&{"Accept-Language":e}),i=new URL("preauthorization/verify_access_code/".concat(t),Kd.paystackApiUrl).toString();return JA.get(i,{headers:r}).then((function(t){return t.data}))},BO=function(t){var e=t.reference,r=t.publicKey,i=$A(),o=n({Authorization:"Bearer ".concat(r)},i&&{"Accept-Language":i}),a=new URL("preauthorization/verify/".concat(e),Kd.paystackApiUrl).toString();return JA.get(a,{headers:o}).then((function(t){return sg.parse(t.data)}))},LO=function(t,e,n){var r=new URL("preauthorization/update_log/".concat(t),Kd.paystackApiUrl).toString();return Qx(r,{merchantKey:e,log:n})},IO=function(t,e){var n=new URL("preauthorization/set_ip/".concat(t),Kd.paystackApiUrl).toString();return tO(n,{merchantKey:e})},DO={initializeLog:function(t){this.log=Dx(t)},getTimeSpent:function(){return this.log.time_spent=Nx(this.log.start_time),this.log.time_spent},logPageOpen:function(){return this.log.history.push({type:"open",message:"Opened checkout",time:this.getTimeSpent()}),this.saveLog()},logChannelSwitch:function(t){return this.log.history.push({type:"action",message:"Set charge method to: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logValidationErrors:function(t){var e=this;return t.forEach((function(t){e.log.history.push({type:"error",message:"Invalid ".concat(t),time:e.getTimeSpent()})})),this.saveLog()},logInput:function(t){var e=this.log.history.find((function(e){return e.message==="Filled this field: ".concat(t)}));return this.log.history.push({type:"input",message:"".concat(e?"Changed":"Filled"," this field: ").concat(t),time:this.getTimeSpent()}),this.saveLog()},logAuthWindowOpen:function(){return this.log.history.push({type:"action",message:"Third-party authentication window opened",time:this.getTimeSpent()}),this.saveLog()},logAuthWindowClose:function(){return this.log.history.push({type:"action",message:"Third-party authentication window closed",time:this.getTimeSpent()}),this.saveLog()},logAPIResponse:function(t,e){switch(console.log("api response",t),t.status){case"authorized":return this.logAuthorized(e);case"failed":return this.logError(t.message);case"auth":return this.logAuth(t.data.auth);default:return!1}},logAPIResponseMessage:function(t){return this.log.history.push({type:"action",message:t,time:this.getTimeSpent()}),this.saveLog()},logAttempt:function(t){var e="Attempted to charge";return t&&(e+=" with ".concat(t)),this.log.attempts+=1,this.log.history.push({type:"action",message:e,time:this.getTimeSpent()}),this.saveLog()},logAuth:function(t){return this.log.authentication=t,this.log.history.push({type:"auth",message:"Authentication Required: ".concat(t),time:this.getTimeSpent()}),this.saveLog()},logAuthorized:function(t){var e="Successfully preauthorized funds";return t&&(e+=" with ".concat(t)),this.log.success=!0,this.log.history.push({type:"authorized",message:e,time:this.getTimeSpent()}),this.saveLog()},logPageClose:function(){return this.log.history.push({type:"close",message:"Closed checkout",time:this.getTimeSpent()}),this.saveLog()},logError:function(t){var e="Error";return t&&(e+=": ".concat(t)),this.log.errors+=1,this.log.history.push({type:"error",message:e,time:this.getTimeSpent()}),this.saveLog()},saveLog:function(){return LO(this.reference,this.merchant.key,this.log)},saveIpAddress:function(){return IO(this.reference,this.merchant.key)}},NO=function(){function t(e){var n;a(this,t),this.id=e.id,this.email=null===(n=e.customer)||void 0===n?void 0:n.email,this.status=e.status,this.reference=e.reference,this.amount=e.amount,this.currency=e.currency,this.metadata=e.metadata||{},this.customer=e.customer,this.channels=e.channels||["card"],this.isListening=!1,this.isTest="test"===e.domain,this.deviceFingerprint=e.deviceFingerprint||null,this.merchant={id:e.merchant_id,logo:e.merchant_logo,name:e.merchant_name,key:e.merchant_key},this.card={},ug(),this.log=null,Object.assign(this,DO),this.initializeLog(e.log),this.saveIpAddress(),Object.assign(this,CO)}return u(t,[{key:"setMetadata",value:function(t,e){this.metadata[t]=e}},{key:"requery",value:function(){var t=this;return BO({reference:this.reference,publicKey:this.merchant.key}).then((function(e){return t.logAPIResponse(e,"card"),e}))}},{key:"listenForCharge",value:function(t,e){return cg(t,this,e)}}]),t}(),_O={initialize:function(t){return Object.seal(new NO(t))},getByAccessCode:function(t){return o(regeneratorRuntime.mark((function e(){var r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Od();case 2:return r=e.sent,e.next=5,PO(t);case 5:return i=e.sent,e.abrupt("return",i&&Object.seal(new NO(n(n({},i.data),{},{deviceFingerprint:r}))));case 7:case"end":return e.stop()}}),e)})))()}};return t.BankAccount=Gk,t.Card=Rk,t.Preauthorization=_O,t.Toolkit=EO,t.Transaction=mO,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
|