@paystack/inline-js 2.28.0 → 2.29.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/inline.js CHANGED
@@ -1 +1,2710 @@
1
- var PaystackPop=function(){"use strict";function e(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,a=Array(n);t<n;t++)a[t]=e[t];return a}function n(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function t(e,n){for(var t=0;t<n.length;t++){var a=n[t];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,u(a.key),a)}}function a(e,n,a){return n&&t(e.prototype,n),a&&t(e,a),Object.defineProperty(e,"prototype",{writable:!1}),e}function r(e,n,t){return(n=u(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,a)}return t}function i(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?o(Object(t),!0).forEach(function(n){r(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):o(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function s(e,n){if(null==e)return{};var t,a,r=function(e,n){if(null==e)return{};var t={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(-1!==n.indexOf(a))continue;t[a]=e[a]}return t}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)t=o[a],-1===n.indexOf(t)&&{}.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}function c(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var a,r,o,i,s=[],c=!0,l=!1;try{if(o=(t=t.call(e)).next,0===n){if(Object(t)!==t)return;c=!1}else for(;!(c=(a=o.call(t)).done)&&(s.push(a.value),s.length!==n);c=!0);}catch(e){l=!0,r=e}finally{try{if(!c&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw r}}return s}}(e,n)||p(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(n){return function(n){if(Array.isArray(n))return e(n)}(n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||p(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e){var n=function(e,n){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var a=t.call(e,n||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(e,"string");return"symbol"==typeof n?n:n+""}function d(e){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d(e)}function p(n,t){if(n){if("string"==typeof n)return e(n,t);var a={}.toString.call(n).slice(8,-1);return"Object"===a&&n.constructor&&(a=n.constructor.name),"Map"===a||"Set"===a?Array.from(n):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?e(n,t):void 0}}var h={cookieTestUrl:"https://legacy-staging.paystack.co/test-iframe/start.html",publishableKey:"uFmz/uE/SDT6GupOrSEXIZXGByjQ0zFkPyc9LqKHFqnTI0WPN3JS5kQPo/j9or0TOXlqMQj2lzHn/UGsQT4XeQ==",publicKey:"-----BEGIN PUBLIC KEY-----\r\nMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALhZs/7hP0g0+hrqTq0hFyGVxgco0NMx\r\nZD8nPS6ihxap0yNFjzdyUuZED6P4/aK9Ezl5ajEI9pcx5/1BrEE+F3kCAwEAAQ==\r\n-----END PUBLIC KEY-----",applePayVersion:6,applePayValidateSessionPath:"applepay/validate-session/",applePayChargePath:"applepay/charge",googlePayChargePath:"googlepay/charge"},m=i(i({},h),{},{environment:"dev",checkoutUrl:"http://localhost:8081/",paymentBaseUrl:"https://legacy-staging.paystack.co/",paystackApiUrl:"https://studio-api.paystack.co/",siteUrl:"https://paystack.com",pusherKey:"1c7b262ee18455815893",pusherUrl:"http://localhost:8081/static/vendor/pusher.min.js"}),y=i(i({},h),{},{environment:"staging",checkoutUrl:"https://checkout-studio.paystack.com/",paymentBaseUrl:"https://legacy-staging.paystack.co/",paystackApiUrl:"https://studio-api.paystack.co/",siteUrl:"https://beta.paystack.com",pusherKey:"1c7b262ee18455815893",pusherUrl:"https://checkout-studio.paystack.com/static/vendor/pusher.min.js"}),f={dev:m,staging:y,production:i(i({},h),{},{environment:"production",checkoutUrl:"https://checkout.paystack.com/",paymentBaseUrl:"https://standard.paystack.co/",paystackApiUrl:"https://api.paystack.co/",siteUrl:"https://paystack.com",pusherKey:"8e4b9b7ca3418bd5cdc8",pusherUrl:"https://checkout.paystack.com/static/vendor/pusher.min.js"})}.production||y;function g(e,n){var t=[];return Object.keys(e).forEach(function(a){var r=n?"".concat(n,"[").concat(a,"]"):a,o=e[r];t.push(null!==o&&"object"===("undefined"==typeof v?"undefined":d(v))?g(o,r):"".concat(encodeURIComponent(a),"=").concat(encodeURIComponent(o)))}),t.join("&")}var b="50px",w="vertical",k="light",C="apple_pay",P="google_pay",A="card",S="success",_="failed",E="auth",q="test",x="production",T="CANCELED",I="DEVELOPER_ERROR",O="MERCHANT_ACCOUNT_ERROR",M="NG",j={XOF:"CI",GHS:"GH",KES:"KE",NGN:M,ZAR:"ZA",EGP:"EG"};function z(){return document.currentScript||(e=document.getElementsByTagName("script"))[e.length-1];var e}function N(){var e=[],n=z();if(n){var t=Array.prototype.slice.call(n.attributes);e=Object.keys(t).filter(function(e){var n=t[e].nodeName;return n&&n.indexOf("data")>-1}).map(function(e){return t[e].nodeName})}return e}var V={height:b,width:"auto",borderRadius:"3px",padding:"10px",locale:"en",type:"pay"},L=function(e){return e&&"object"===d(e)?Object.keys(V).reduce(function(n,t){return i(i({},n),{},r({},t,e[t]||V[t]))},{}):V};function U(e,n){var t=document.createElement("style");t.type="text/css",t.textContent=n,e.appendChild(t)}var R=function(){return Number(parseFloat((arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)/100).toFixed(2))},B=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=n.container,a=n.integrity;return new Promise(function(n,r){if(e){var o=document.createElement("script");o.src=e,a&&(o.crossOrigin="anonymous",o.integrity=a),o.addEventListener("load",function(){n(!0)}),o.addEventListener("error",function(){o.remove(),r(!1)}),t?t.appendChild(o):document.head.appendChild(o)}else r("No script url")})},D=function(e,n){var t,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){return null},r=new Promise(function(e){t=setTimeout(function(){try{e(a())}catch(n){e(null)}},n)});return Promise.race([e,r]).finally(function(){return clearTimeout(t)})},G=["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"],F=window&&window.navigator&&(window.navigator.platform||window.navigator.userAgentData&&window.navigator.userAgentData.platform),W=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.platform,t=e.userAgent,a=void 0===t?window&&window.navigator&&window.navigator.userAgent:t;return{devicePlatform:n||F,deviceUserAgent:a}},K=function(){var e=W(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),n=e.devicePlatform,t=e.deviceUserAgent;return G.includes(n)||t.includes("Mac")&&"ontouchend"in document},J=null,H=null,Q={headers:{accept:"application/json, text/plain, */*","accept-language":"en-GB,en-US;q=0.9,en;q=0.8","content-type":"application/x-www-form-urlencoded","sec-ch-ua-mobile":"?0","sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"cross-site"},referrerPolicy:"no-referrer-when-downgrade",method:"POST",mode:"cors",credentials:"omit"};function Z(e){return Object.keys(e).reduce(function(n,t){var a=encodeURIComponent(t),r=encodeURIComponent(e[t]),o="".concat(a,"=").concat(r);return[].concat(l(n),[o])},[]).join("&")}var X=function(e){return{biannually:"BIANNUAL PLAN",annually:"ANNUAL PLAN"}[e]||"".concat(e.toUpperCase()," PLAN")},Y=function(){try{return Boolean(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=W(e).devicePlatform;return K(e)||Boolean(n&&/Mac/i.test(n))}()&&(function(){var e=W(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).deviceUserAgent;return Boolean(e&&!/Android/.test(e)&&!/EdgiOS/.test(e)&&/Version\/[\d.]+.*Safari/.test(e))}()||function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=W(e).deviceUserAgent;return Boolean(n)&&K(e)&&!/Safari\//.test(n)}())&&window.isSecureContext&&window.ApplePaySession&&!window.ApplePaySession.isNotWebkit&&window.ApplePaySession.supportsVersion(f.applePayVersion))}catch(e){return!1}},$=function(){if(!H){var e=window.onbeforeunload;H=B("https://applepay.cdn-apple.com/jsapi/v1.3.8/apple-pay-sdk.js",{integrity:"sha384-u/9mOkmShCO0v+dqCAZFhiutJuORfzvuyM5i+676iy7mLSWS6rlllHrIt15f/mqH"}).then(function(){var n,t;return n=e,t=window.onbeforeunload,window.ApplePaySession&&window.ApplePaySession.isNotWebkit&&t!==n&&"function"==typeof n&&"function"==typeof t&&(window.onbeforeunload=function(e){var a;try{a=t.call(window,e)}catch(e){a=void 0}var r=n.call(window,e);return void 0!==r?r:a}),!0}).catch(function(){return H=null,!1})}return H},ee=function(e){return $().then(function(n){return(n?function(e){return Promise.resolve().then(function(){return"function"!=typeof window.ApplePaySession.applePayCapabilities?null:window.ApplePaySession.applePayCapabilities(e)}).then(function(e){return(e||{}).paymentCredentialStatus||null}).catch(function(){return null})}(e):Promise.resolve(null)).then(function(e){return{status:e,sdkLoaded:n}})})},ne=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window.location.hostname;return Array.isArray(e)&&e.some(function(e){return function(e){return String(e).toLowerCase().replace(/\/+$/,"")}(e)===n.toLowerCase()})},te=function(e){var n;return null==e||null===(n=e.channel_settings)||void 0===n||null===(n=n.apple_pay)||void 0===n?void 0:n.merchant_identifier},ae=function(e){try{var n=e||{},t=(null===J&&(J=Y()),J),a=te(n);return function(e,n){var t=e.channels||[],a=e.channel_settings&&e.channel_settings.apple_pay||{};return t.includes(C)&&Boolean(te(e))&&(ne(a.domains)||n)}(n,t)?D(ee(a),1e4).catch(function(){return null}).then(function(e){return{status:e&&e.status||null,hasNativeSupport:t,sdkLoaded:Boolean(e&&e.sdkLoaded)}}):Promise.resolve({status:null,hasNativeSupport:t,sdkLoaded:!1})}catch(e){return Promise.resolve({status:null,hasNativeSupport:!1,sdkLoaded:!1})}},re=function(e,n){var t=(e&&e.channel_fees_and_amount||{})[n],a=t&&t.amount;return null==a?e&&e.amount:a},oe=console?console.warn||console.log:function(){};function ie(e,n,t){oe('"'.concat(e,'" has been deprecated, please use "').concat(n,'". ').concat(t||""))}var se=["PAN_ONLY"],ce=null,le=null,ue=function(e){var n=e&&e.response,t=n&&n.channel_settings;return t&&t[P]||null},de=function(e){return(e&&e.allowed_card_auth_methods||[]).filter(function(e){return!se.includes(e)})},pe=function(e){var n=!!e&&e.domain===q;return f.environment!==x||n?"TEST":"PRODUCTION"},he=function(e){return ce&&le===e||(ce=new window.google.payments.api.PaymentsClient({environment:e}),le=e),ce},me=function(){return!!(window.google&&window.google.payments&&window.google.payments.api&&window.google.payments.api.PaymentsClient)},ye=function(e){return{apiVersion:e.api_version.major,apiVersionMinor:e.api_version.minor}},fe=function(e,n){return{type:"CARD",parameters:i({allowedAuthMethods:n,allowedCardNetworks:e.allowed_card_networks,billingAddressRequired:!0,billingAddressParameters:e.billing_address_parameters,assuranceDetailsRequired:!0},e.allowed_issuer_country_codes&&e.allowed_issuer_country_codes.length&&{allowedIssuerCountryCodes:e.allowed_issuer_country_codes})}},ge=function(e){var n=e.registered_merchant_info||{};return{merchantId:n.merchantId,merchantName:n.merchantName,merchantOrigin:n.merchantOrigin}},ve=function(e){var n=ue(e);if(!n)return Promise.resolve(null);var t=de(n);return t.length&&n.tokenization_specification&&me()?(function(e){var n=e.registered_merchant_info&&e.registered_merchant_info.merchantOrigin,t=window.location.hostname;n&&n!==t&&oe('Google Pay: the registered merchantOrigin ("'.concat(n,'") does not match this page ("').concat(t,'"). Google may reject the payment sheet. Update the domain in Dashboard > Developers > Google Pay.'))}(n),Promise.resolve().then(function(){return he(pe(e.response)).isReadyToPay(i(i({},ye(n)),{},{allowedPaymentMethods:[fe(n,t)],existingPaymentMethodRequired:!0}))}).then(function(e){return!!e.result}).catch(function(){return null})):Promise.resolve(null)},be=["height","width","borderRadius","buttonRadius"];function we(e){var n=document.createElement("iframe");return n.setAttribute("frameBorder","0"),n.setAttribute("allowtransparency","true"),n.id=e,n.style.display="none",n}function ke(e){return e.querySelector("apple-pay-button")||e.querySelector("#apple-pay-button")}function Ce(e){return document.querySelector("#".concat(e))}function Pe(e){return e.querySelector("#google-pay-button-container")}function Ae(e,n){if(e){var t=e.querySelector("#google-pay-button"),a=e.querySelector("#google-pay-loading-button");t&&a&&(t.style.display=n?"none":"",a.style.display=n?"flex":"none")}}function Se(e,n){var t=n.transaction,a=n.styles,r=void 0===a?{}:a,o=n.onClick,c=r.googlePay||{},l=c.height,u=c.width,d=c.borderRadius,p=c.buttonRadius,h=s(c,be),m=ue(t),y=function(e,n){var t=parseFloat(void 0!==e?e:n);return t>=0?t:3}(d,p);U(e,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.height,t=e.width;return"\n #google-pay-button-container {\n width: ".concat(t||"auto",";\n height: ").concat(n||b,";\n overflow: hidden;\n }\n #google-pay-button-container:empty {\n display: none;\n }\n #google-pay-button-container > div,\n #google-pay-button-container button,\n #google-pay-button-container iframe {\n width: 100%;\n max-width: 100%;\n height: 100%;\n min-width: 100%;\n }\n #google-pay-button-container button {\n outline: none !important;\n }\n")}({height:l,width:u}));var f=h.buttonColor||(r.theme===k?"white":"black");U(e,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.borderRadius,t="white"===e.buttonColor;return"\n #google-pay-loading-button {\n width: 100%;\n height: 100%;\n border: ".concat(t?"1px solid #3C4043":"none",";\n border-radius: ").concat(void 0===n?3:n,"px;\n background: ").concat(t?"#ffffff":"#000000",";\n cursor: default;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n #google-pay-loading-button__spinner {\n width: 18px;\n height: 18px;\n border: 2px solid ").concat(t?"rgba(60, 64, 67, 0.25)":"rgba(255, 255, 255, 0.35)",";\n border-top-color: ").concat(t?"#3c4043":"#ffffff",";\n border-radius: 50%;\n animation: google-pay-spin 0.8s linear infinite;\n }\n @keyframes google-pay-spin {\n to { transform: rotate(360deg); }\n }\n")}({borderRadius:y,buttonColor:f}));var g=document.createElement("div");g.id="google-pay-button-container";var v=he(pe(t.response)).createButton(i(i({buttonColor:f,buttonType:"pay",buttonRadius:y,buttonSizeMode:"fill"},h),{},{onClick:o,allowedPaymentMethods:[fe(m,de(m))]}));e.appendChild(g);var w=document.createElement("div");w.id="google-pay-button",w.appendChild(v),g.appendChild(w);var C=document.createElement("button");C.id="google-pay-loading-button",C.type="button",C.disabled=!0,C.setAttribute("aria-busy","true"),C.style.display="none";var P=document.createElement("span");return P.id="google-pay-loading-button__spinner",C.appendChild(P),g.appendChild(C),g}function _e(e,n,t){var a=n.sdkLoaded,r=n.hasNativeSupport;return a?function(e,n){var t=n.styles,a=n.theme,r=n.onClick;U(e,function(e){var n=e.height,t=e.width,a=e.borderRadius,r=e.padding;return"\n apple-pay-button {\n --apple-pay-button-width: ".concat(t,";\n --apple-pay-button-height: ").concat(n,";\n --apple-pay-button-border-radius: ").concat(a,";\n --apple-pay-button-padding: ").concat(r,";\n --apple-pay-button-box-sizing: border-box;\n width: ").concat(t,";\n }\n")}(t));var o=document.createElement("apple-pay-button");return o.setAttribute("buttonstyle",a===k?"white":"black"),o.setAttribute("type",t.type),o.setAttribute("locale",t.locale),r&&(o.onclick=r),e.appendChild(o),o}(e,t):r?function(e,n){var t=n.styles,a=n.theme,r=n.onClick;U(e,function(e){var n=e.height,t=e.width,a=e.borderRadius,r=e.padding,o=e.type,i=e.locale;return"\n @supports (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n -webkit-appearance: -apple-pay-button;\n width: ".concat(t,";\n height: ").concat(n,";\n border-radius: ").concat(a,";\n padding: ").concat(r,";\n -apple-pay-button-type: ").concat(o,";\n -webkit-locale: ").concat(i,";\n }\n .apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n .apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n .apple-pay-button-white-with-line {\n -apple-pay-button-style: white-outline;\n }\n }\n\n @supports not (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n background-size: 100% 60%;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n border-radius: 5px;\n padding: 0px;\n box-sizing: border-box;\n min-width: 200px;\n min-height: 32px;\n max-height: 64px;\n }\n .apple-pay-button-black {\n background-image: -webkit-named-image(apple-pay-logo-white);\n background-color: black;\n }\n .apple-pay-button-white {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n }\n .apple-pay-button-white-with-line {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n border: .5px solid black;\n }\n }\n")}(t));var o=document.createElement("button");o.classList.add("apple-pay-button",a===k?"apple-pay-button-white":"apple-pay-button-black"),o.id="apple-pay-button";var i=document.createElement("span");return i.classList.add("logo"),o.appendChild(i),r&&(o.onclick=r),e.appendChild(o),o}(e,t):(oe("Apple Pay: the Apple Pay SDK did not load, so no Apple Pay button is shown."),null)}function Ee(e,n){var t,a,r=n.transaction,o=n.styles,i=void 0===o?{}:o,s=n.onClickApplePayButton,l=n.onClickGooglePayButton;if(!e)return Promise.reject("Container to mount elements was not provided");!function(e){for(;e.firstChild;)e.removeChild(e.firstChild)}(e),U(e,(t=i.orientation,"\n #paystack-payment-request-inner-wrapper {\n display: flex;\n flex-direction: ".concat((a=t===w)?"column":"row",";\n gap: 8px;\n width: 100%;\n max-width: 100%;\n }\n\n #paystack-payment-request-inner-wrapper > * {\n min-width: 0;\n ").concat(a?"":"flex: 1 1 0;","\n }\n\n #paystack-payment-request-inner-wrapper > apple-pay-button,\n #paystack-payment-request-inner-wrapper > #apple-pay-button {\n order: 1;\n }\n #paystack-payment-request-inner-wrapper > #google-pay-button-container {\n order: 2;\n }\n")));var u=document.createElement("div");u.id="paystack-payment-request-inner-wrapper",u.style.display="none",e.appendChild(u);var d={styles:L(i.applePay),theme:i.theme,onClick:s},p=r.response&&r.response.channels||[],h=ae(r.response).then(function(e){return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=n.status,a=n.hasNativeSupport;return!(!e.includes(C)||(!t||"applePayUnsupported"===t)&&!0!==a)}(p,e)?_e(u,e,d):(p.includes(C)&&oe("Apple Pay: this device, browser or page cannot pay with Apple Pay here."),null)}).catch(function(){return null}),m=function(e){if(!((e&&e.response||{}).channels||[]).includes(P))return Promise.resolve(null);var n=ue(e);if(n&&!n.registered_merchant_info)return oe("Google Pay: this business has no Google Pay merchant profile, so no Google Pay button is shown. Add one in Dashboard > Developers > Google Pay."),Promise.resolve(null);var t=me()?Promise.resolve(!0):B("https://pay.google.com/gp/p/js/pay.js").then(function(){return me()});return D(t.catch(function(){return!1}).then(function(n){return n?ve(e):null}),1e4)}(r).then(function(e){return e?Se(u,{transaction:r,styles:i,onClick:l}):null}).catch(function(){return null});return Promise.all([h,m]).then(function(e){var n=c(e,2),t=n[0],a=n[1];return t||a?(u.style.display="",{applePay:!!t,googlePay:!!a}):null})}var qe=[{value:"key",required:!0,types:["string"]},{value:"amount",required:!0,or:["plan","planCode"],types:["string","number"]},{value:"currency",required:!1,types:["string"]},{value:"email",required:!0,or:["customerCode"],types:["string"]},{value:"label",required:!1,types:["string"]},{value:"firstName",required:!1,types:["string"]},{value:"lastName",required:!1,types:["string"]},{value:"reference",required:!1,types:["string"]},{value:"phone",required:!1,types:["string"]},{value:"customerCode",required:!1,override:"email",types:["string"]},{value:"channels",required:!1,types:["array"]},{value:"paymentRequest",required:!1,types:["string","number"]},{value:"paymentPage",required:!1,types:["string"]},{value:"hash",required:!1,types:["string"]},{value:"container",required:!1,types:["string"]},{value:"metadata",required:!1,types:["object"]},{value:"subaccountCode",required:!1,types:["string"]},{value:"bearer",required:!1,types:["string"]},{value:"transactionCharge",required:!1,types:["string","number"]},{value:"planCode",required:!1,override:"amount",types:["string"]},{value:"subscriptionCount",required:!1,types:["number"]},{value:"planInterval",required:!1,types:["string"]},{value:"subscriptionLimit",required:!1,types:["number"]},{value:"subscriptionStartDate",required:!1,types:["string"]},{value:"accessCode",required:!1,types:["string"]},{value:"onError",required:!1,types:["function"]},{value:"onLoad",required:!1,types:["function"]},{value:"onSuccess",required:!1,types:["function"]},{value:"onCancel",required:!1,types:["function"]},{value:"callback",required:!1,types:["function"]},{value:"onClose",required:!1,types:["function"]},{value:"onBankTransferConfirmationPending",required:!1,types:["function"]},{value:"firstname",required:!1,types:["string"]},{value:"lastname",required:!1,types:["string"]},{value:"customer_code",required:!1,types:["string"]},{value:"payment_request",required:!1,types:["string","number"]},{value:"subaccount",required:!1,types:["string"]},{value:"transaction_charge",required:!1,types:["number","string"]},{value:"plan",required:!1,types:["string"]},{value:"quantity",required:!1,types:["number"]},{value:"interval",required:!1,types:["string"]},{value:"invoice_limit",required:!1,types:["number","string"]},{value:"start_date",required:!1,types:["string"]},{value:"payment_page",required:!1,types:["number","string"]},{value:"order_id",required:!1,types:["number"]},{value:"ref",required:!1,types:["string"]},{value:"card",required:!1,types:["string"]},{value:"bank",required:!1,types:["string"]},{value:"split",required:!1,types:["object"]},{value:"split_code",required:!1,types:["string"]},{value:"transaction_type",required:!1,types:["string"]},{value:"subscription",required:!1,types:["number"]},{value:"language",required:!1,types:["string"]},{value:"connect_account",required:!1,types:["string"]},{value:"connect_split",required:!1,types:["array"]}];function xe(e){return(null==e?void 0:e.length)>500?e.split("?")[0]:e}function Te(e){var n,t,a,r,o=i({},e);o.metadata=e.metadata||{},o.metadata.referrer=(n=window.location,t=n.href,a=void 0===t?"":t,r=n.ancestorOrigins,[a].concat(l(void 0===r?[]:r)).map(xe).join(",")),o.metadata=JSON.stringify(o.metadata),o.mode="popup",e.split&&"string"!=typeof e.split&&(o.split=JSON.stringify(o.split));return void 0!==o.card&&["false",!1].indexOf(o.card)>-1&&(o.channels=["bank"],delete o.card),void 0!==o.bank&&["false",!1].indexOf(o.bank)>-1&&(o.channels=["card"],delete o.bank),[{to:"firstname",from:"firstName"},{to:"lastname",from:"lastName"},{to:"customer_code",from:"customerCode"},{to:"payment_request",from:"paymentRequest"},{to:"subaccount",from:"subaccountCode"},{to:"transaction_charge",from:"transactionCharge"},{to:"plan",from:"planCode"},{to:"quantity",from:"subscriptionCount"},{to:"interval",from:"planInterval"},{to:"invoice_limit",from:"subscriptionLimit"},{to:"start_date",from:"subscriptionStartDate"},{to:"ref",from:"reference"}].forEach(function(e){o[e.from]&&(o[e.to]=o[e.from],delete o[e.from])}),Object.values(e).forEach(function(n,t){if("function"==typeof n){var a=Object.keys(e)[t];delete o[a]}}),o}var Ie,Oe=function(e,n,t){var a="".concat(f.paystackApiUrl,"transaction/update_log/").concat(e),r={Authorization:"Bearer ".concat(n)};return fetch(a,{method:"POST",body:JSON.stringify({payload:JSON.stringify(t)}),headers:r})},Me=function(e,n){var t="".concat(f.paystackApiUrl,"transaction/set_ip/").concat(e),a={Authorization:"Bearer ".concat(n)};return fetch(t,{method:"POST",headers:a})},je={initializeLog:function(e){var n=e||{},t=n.attempts,a=n.authentication,r=n.errors,o=n.history;this.log={start_time:Math.round(Date.now()/1e3),time_spent:0,attempts:t||0,authentication:a,errors:r||0,success:!1,mobile:K(),input:[],history:o||[]}},getTimeSpent:function(){var e=Math.round(Date.now()/1e3);return this.log.time_spent=e-this.log.start_time,this.log.time_spent},logAPIResponse:function(e,n){switch(e.status){case S:return this.logApiSuccess(n);case _:return this.logApiError(e.message);default:return!1}},logValidationResponse:function(e){return this.log.history.push({type:"action",message:e,time:this.getTimeSpent()}),this.saveLog()},logAttempt:function(e){var n="Attempted to pay";return e&&(n+=" with ".concat(e)),this.log.attempts+=1,this.log.history.push({type:"action",message:n,time:this.getTimeSpent()}),this.saveLog()},logApiError:function(e){var n="Error";return e&&(n+=": ".concat(e)),this.log.errors+=1,this.log.history.push({type:"error",message:n,time:this.getTimeSpent()}),this.saveLog()},logApiSuccess:function(e){var n="Successfully paid";return e&&(n+=" with ".concat(e)),this.log.success=!0,this.log.history.push({type:"success",message:n,time:this.getTimeSpent()}),this.saveLog()},saveLog:function(){try{if(this.response)return Oe(this.id,this.response.merchant_key,this.log)}catch(e){}},saveIpAddress:function(){try{if(this.response)return Me(this.id,this.response.merchant_key)}catch(e){}}},ze=["language","connect_account"],Ne={requestInline:function(){var e=this,n=this.urlParameters,t=n.language,a=n.connect_account,r=s(n,ze),o=i({"Content-Type":"application/json"},t&&{"Accept-Language":t});return(this.accessCode?fetch(new URL("transaction/verify_access_code/".concat(this.accessCode),f.paystackApiUrl).toString(),{headers:o}):fetch(new URL("/checkout/request_inline",f.paystackApiUrl).toString(),{method:"POST",body:JSON.stringify(r),headers:i(i({},o),a&&{"x-connect-account":a})})).then(function(e){return e.json()}).then(function(n){if(!1===n.status)throw new Error(n.message);return e.response=n.data,e.id=n.data.id,e.status=n.data.transaction_status,e.accessCode=n.data.access_code,e.log=null,Object.assign(e,je),e.initializeLog(n.data.log),e.saveIpAddress(),n.data})}},Ve=function(){return a(function e(t){n(this,e),function(e){function n(e,n){this.message=e,this.issues=n||[]}if(!e||"object"!==d(e))throw new n("Transaction parameters should be a non-empty object");var t=e;if("accessCode"in t)return{accessCode:t.accessCode};Object.keys(t).forEach(function(e){void 0!==qe.find(function(n){return n.value===e})||delete t[e]});var a=Object.keys(t),r=[];if(qe.filter(function(e){return e.required}).forEach(function(e){var n=!t[e.value],a=e.or?e.or.some(function(e){return t[e]}):null;n&&!a&&r.push({message:"Required parameter missing: ".concat(e.value)})}),a.forEach(function(e){var n=t[e],a=qe.find(function(n){return n.value===e}),o=d(n);"object"===o&&Array.isArray(n)&&(o="array"),a.types.indexOf(o)<=-1&&r.push({message:"Invalid parameter type: ".concat(e),validTypes:a.types})}),a.forEach(function(e){var n=qe.find(function(n){return n.value===e});n.override&&delete t[n.override]}),r.length)throw new n("Invalid transaction parameters",r)}(t),this.parameters=t,this.urlParameters=Te(t),this.id=null,this.status=null,this.accessCode=t.accessCode||null,this.authorizationUrl=null,this.errors=[],this.response=null,this.isActive=!0;var a=t.onError,r=t.onLoad,o=t.onSuccess,i=t.onCancel,s=t.callback,c=t.onClose,l=t.onBankTransferConfirmationPending;this.callbacks={onError:a,onLoad:r,onSuccess:o,onCancel:i,onBankTransferConfirmationPending:l},this.deprecatedCallbacks={callback:s,onClose:c},Object.assign(this,Ne)},[{key:"onSetupError",value:function(e){this.logError(e),this.callbacks.onError&&this.callbacks.onError(e)}},{key:"onLoad",value:function(e){var n=e.id,t=e.customer,a=e.accessCode;Object.assign(this,{id:n,customer:t,accessCode:a}),this.authorizationUrl="".concat(f.checkoutUrl).concat(a),this.callbacks.onLoad&&this.callbacks.onLoad({id:n,customer:t,accessCode:a})}},{key:"onSuccess",value:function(e){this.isActive=!1,this.response=e,this.status=e.status,this.callbacks.onSuccess&&this.callbacks.onSuccess(e),this.deprecatedCallbacks.callback&&this.deprecatedCallbacks.callback(e)}},{key:"setStatus",value:function(e){this.status=e}},{key:"onCancel",value:function(){this.callbacks.onCancel&&this.callbacks.onCancel(),this.deprecatedCallbacks.onClose&&this.deprecatedCallbacks.onClose()}},{key:"cancel",value:function(){this.isActive=!1,this.onCancel()}},{key:"onBankTransferConfirmationPending",value:function(){this.cancel(),this.callbacks.onBankTransferConfirmationPending&&this.callbacks.onBankTransferConfirmationPending()}},{key:"logError",value:function(e){this.errors.push(e)}}])}(),Le=["preload","inlineTransaction","transactionData"],Ue=["container","styles","onElementsMount"],Re=["data"];function Be(e,n){if(!e.length)return null;var t=e.filter(function(e){var t,a,r,o,i=!e.status||"abandoned"===e.status,s=(t=e.parameters,a=n,r=Object.keys(t).sort().join("")===Object.keys(a).sort().join(""),o=Object.values(t).sort().join("")===Object.values(a).sort().join(""),r&&o);return i&&s});return t.length?t[t.length-1]:null}function De(e){var n=e.checkoutIframe,t=e.urlParameters;n&&t&&n.contentWindow.postMessage({type:"inline:url",path:"newTransaction",params:t},"*")}var Ge="trackPaymentError",Fe="trackPaymentAttempt",We="trackPaymentCompletion";function Ke(e){throw oe(e),new Error(e)}var Je,He,Qe=function(){function e(t){var a,r;n(this,e),this.id=function(){for(var e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=0;t<5;t+=1)e+=n.charAt(Math.floor(62*Math.random()));return e}(),this.transactions=[],this.isOpen=!1,this.isLoaded=!1,this.isCharging=!1,this.isDeprecatedApi=t&&t.isDeprecatedApi,t&&t.isEmbed?this.isEmbed=!0:t&&t.isPaymentRequest&&(t.container&&Ce(t.container)||Ke("A container is required to mount the payment request button"),this.paymentRequestContainer=Ce(t.container),this.paymentRequestTransaction=null),this.backgroundIframe=function(e){var n=we("inline-background-".concat(e));n.style.cssText="\n z-index: 999999999999999;\n background: transparent;\n background: rgba(0, 0, 0, 0.75);\n border: 0px none transparent;\n overflow-x: hidden;\n overflow-y: hidden;\n margin: 0;\n padding: 0;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n position: fixed;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n transition: opacity 0.3s;\n -webkit-transition: opacity 0.3s;\n visibility: hidden;\n display: none;\n",n.style.colorScheme="light",document.body.appendChild(n);var t=n.contentWindow.document;return t.open(),t.write('\n <!DOCTYPE html>\n <html lang="en">\n\n <head>\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <meta http-equiv="X-UA-Compatible" content="ie=edge">\n <title>Paystack Popup Loader</title>\n <style>\n .app-loader {\n margin: 200px 0;\n text-align: center;\n color: white;\n }\n @keyframes app-loader__spinner {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n @-webkit-keyframes app-loader__spinner {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n .app-loader__spinner {\n position: relative;\n display: inline-block;\n }\n .app-loader__spinner div {\n left: 95px;\n top: 35px;\n position: absolute;\n -webkit-animation: app-loader__spinner linear 1s infinite;\n animation: app-loader__spinner linear 1s infinite;\n background: white;\n width: 10px;\n height: 30px;\n border-radius: 40%;\n -webkit-transform-origin: 5px 65px;\n transform-origin: 5px 65px;\n }\n .app-loader__spinner div:nth-child(1) {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n -webkit-animation-delay: -0.916666666666667s;\n animation-delay: -0.916666666666667s;\n }\n .app-loader__spinner div:nth-child(2) {\n -webkit-transform: rotate(30deg);\n transform: rotate(30deg);\n -webkit-animation-delay: -0.833333333333333s;\n animation-delay: -0.833333333333333s;\n }\n .app-loader__spinner div:nth-child(3) {\n -webkit-transform: rotate(60deg);\n transform: rotate(60deg);\n -webkit-animation-delay: -0.75s;\n animation-delay: -0.75s;\n }\n .app-loader__spinner div:nth-child(4) {\n -webkit-transform: rotate(90deg);\n transform: rotate(90deg);\n -webkit-animation-delay: -0.666666666666667s;\n animation-delay: -0.666666666666667s;\n }\n .app-loader__spinner div:nth-child(5) {\n -webkit-transform: rotate(120deg);\n transform: rotate(120deg);\n -webkit-animation-delay: -0.583333333333333s;\n animation-delay: -0.583333333333333s;\n }\n .app-loader__spinner div:nth-child(6) {\n -webkit-transform: rotate(150deg);\n transform: rotate(150deg);\n -webkit-animation-delay: -0.5s;\n animation-delay: -0.5s;\n }\n .app-loader__spinner div:nth-child(7) {\n -webkit-transform: rotate(180deg);\n transform: rotate(180deg);\n -webkit-animation-delay: -0.416666666666667s;\n animation-delay: -0.416666666666667s;\n }\n .app-loader__spinner div:nth-child(8) {\n -webkit-transform: rotate(210deg);\n transform: rotate(210deg);\n -webkit-animation-delay: -0.333333333333333s;\n animation-delay: -0.333333333333333s;\n }\n .app-loader__spinner div:nth-child(9) {\n -webkit-transform: rotate(240deg);\n transform: rotate(240deg);\n -webkit-animation-delay: -0.25s;\n animation-delay: -0.25s;\n }\n .app-loader__spinner div:nth-child(10) {\n -webkit-transform: rotate(270deg);\n transform: rotate(270deg);\n -webkit-animation-delay: -0.166666666666667s;\n animation-delay: -0.166666666666667s;\n }\n .app-loader__spinner div:nth-child(11) {\n -webkit-transform: rotate(300deg);\n transform: rotate(300deg);\n -webkit-animation-delay: -0.083333333333333s;\n animation-delay: -0.083333333333333s;\n }\n .app-loader__spinner div:nth-child(12) {\n -webkit-transform: rotate(330deg);\n transform: rotate(330deg);\n -webkit-animation-delay: 0s;\n animation-delay: 0s;\n }\n .app-loader__spinner {\n width: 40px;\n height: 40px;\n -webkit-transform: translate(-20px, -20px) scale(0.2) translate(20px, 20px);\n transform: translate(-20px, -20px) scale(0.2) translate(20px, 20px);\n }\n </style>\n </head>\n\n <body>\n <div id="app-loader" class="app-loader">\n <div id="spinner" class="app-loader__spinner">\n <div></div><div></div><div></div><div></div><div></div><div></div><div>\n </div><div></div><div></div><div></div><div></div><div></div>\n </div>\n </div>\n </body>\n\n </html>\n'),t.close(),n}(this.id),this.checkoutIframe=(a=this.id,(r=we("inline-checkout-".concat(a))).src="".concat(f.checkoutUrl,"popup?precheckout=true"),r.style.cssText="\n z-index: 999999999999999;\n background: transparent;\n border: 0px none transparent;\n overflow-x: hidden;\n overflow-y: hidden;\n margin: 0;\n padding: 0;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n position: fixed;\n left: 0;\n top: 0;\n width: 100%;\n visibility: hidden;\n display: none;\n height: 100%;\n",r.style.colorScheme="light",r.setAttribute("allowpaymentrequest","true"),r.setAttribute("allow","payment; clipboard-read; clipboard-write"),document.body.appendChild(r),r),this.registerListeners()}return a(e,[{key:"registerListeners",value:function(){var e=this;window.addEventListener("message",function(n){var t="".concat(n.origin,"/")===f.checkoutUrl,a=e.checkoutIframe&&e.checkoutIframe.contentWindow===n.source,r=e.isEmbed;t||a?e.respondToEvent(n):r&&e.respondToEmbedEvents(n)})}},{key:"sendAnalyticsEventToCheckout",value:function(e,n){this.checkoutIframe.contentWindow.postMessage({type:"analytics",action:e,params:n},"*")}},{key:"checkout",value:function(e){this.activeTransaction()&&this.activeTransaction().cancel(),Ie=this;var n=Be(this.transactions,e)||new Ve(e);return new Promise(function(e,t){n.requestInline().then(function(t){Ie.newTransaction({inlineTransaction:n,transactionData:t}),e(n)}).catch(function(e){n.onSetupError({status:!1,message:e.message}),t(e)})})}},{key:"newTransaction",value:function(e){var n=e.preload,t=e.inlineTransaction,a=e.transactionData,r=s(e,Le),o=this.hasMountedPaymentRequestButtons(),i=this.activeTransaction();if(i&&!o&&i!==t&&i.cancel(),t&&a)return this.transactions.includes(t)||this.transactions.push(t),this.isDeprecatedApi||this.open({accessCode:a.access_code,language:t.urlParameters.language},n),t;var c=Be(this.transactions,t?t.parameters:r);if(c)return c.isActive=!0,this.isDeprecatedApi||this.open({accessCode:c.accessCode,language:c.urlParameters.language},n),c;var l=t||new Ve(r),u=l.accessCode?{accessCode:l.accessCode,language:l.urlParameters.language}:l.urlParameters;return this.transactions.push(l),this.isDeprecatedApi||this.open(u,n),l}},{key:"preloadTransaction",value:function(e){var n=this;this.newTransaction(i(i({},e),{},{preload:!0}));return function(){return n.animateCheckoutIn()}}},{key:"paymentRequest",value:function(e){var n,t=this,a=e.container,r=e.styles,o=e.onElementsMount,i=s(e,Ue);return"channels"in i&&(i.channels=(n=i.channels,Array.isArray(n)&&n.includes(P)&&!n.includes(A)?[].concat(l(n),[A]):n)),Ie=this,new Promise(function(n,s){var c=document.querySelector("#".concat(e.loadPaystackCheckoutButton));Ie.activeTransaction()&&Ie.activeTransaction().cancel(),a&&Ce(a)||Ke("A container is required to mount the payment request button"),Ie.paymentRequestContainer=Ce(a);var l=Be(Ie.transactions,i),u=l||new Ve(i);u.requestInline().then(function(e){return l?u.isActive=!0:Ie.transactions.push(u),Ee(Ie.paymentRequestContainer,{transaction:u,styles:r,onClickApplePayButton:function(){return t.startApplePay(u)},onClickGooglePayButton:function(){return t.startGooglePay(u)}}).then(function(e){o&&o(e)}).catch(function(){o&&o(null)}).finally(function(){if(c){var t=Ie.preloadTransaction({inlineTransaction:u,transactionData:e});c.onclick=t}else Ie.hasMountedPaymentRequestButtons()||oe("No payment request button could be mounted on this device. Please consult our documentation at https://developers.paystack.co/docs/paystack-inline to see how to load alternative payment options using 'loadPaystackCheckoutButton'");n(u)})}).catch(function(e){u.onSetupError({status:!1,message:e.message}),s(e)})})}},{key:"hasMountedPaymentRequestButtons",value:function(){return(e=this.paymentRequestContainer,e?[ke(e),Pe(e)].filter(Boolean):[]).length>0;var e}},{key:"startGooglePay",value:function(e){var n=this,t="google pay",a=e||this.activeTransaction();if(e&&!e.isActive)return oe("Google Pay: this button belongs to a transaction that is no longer active."),Promise.resolve();if(a&&a.response){if(this.isCharging)return Promise.resolve();this.isCharging=!0;var r=function(e){try{e()}catch(e){oe("Google Pay: a merchant callback threw. ".concat(e&&e.message||e))}};try{var o={channel:P,currency:a.response.currency,amount:re(a.response,P)};return a.logAttempt(t),this.sendAnalyticsEventToCheckout(Fe,i(i({},o),{},{paymentMethod:t})),he(pe(a.response)).loadPaymentData(function(e){var n=ue(e),t=e.response,a=de(n);return i(i({},ye(n)),{},{allowedPaymentMethods:[i(i({},fe(n,a)),{},{tokenizationSpecification:n.tokenization_specification})],transactionInfo:{totalPriceStatus:"FINAL",checkoutOption:"COMPLETE_IMMEDIATE_PURCHASE",totalPrice:R(re(t,P)).toFixed(2),currencyCode:t.currency,countryCode:j[t.currency]||M},merchantInfo:ge(n),emailRequired:!0})}(a)).then(function(e){return Ae(n.paymentRequestContainer,!0),function(e){var n=e.transactionId,t=e.paymentData,a="".concat(f.paymentBaseUrl).concat(f.googlePayChargePath);return fetch(a,{headers:{"content-type":"application/x-www-form-urlencoded"},method:"POST",mode:"cors",credentials:"omit",body:Z({transaction:n,paymentObject:JSON.stringify(t)})}).then(function(e){return e.json()})}({transactionId:a.id,paymentData:e})}).then(function(e){if(Ae(n.paymentRequestContainer,!1),n.isCharging=!1,a.logAPIResponse(e,t),e.status===S){var c=e.data,l=s(e,Re);return r(function(){return a.onSuccess(i(i({},c),l))}),void n.sendAnalyticsEventToCheckout(We,i(i({},o),{},{timeSpent:a.getTimeSpent()}))}var u=e.status===E?"This card requires additional authentication, which is not supported here. Please use another payment method.":e&&e.message||"Transaction attempt failed";r(function(){return a.onSetupError(i(i({},e),{},{message:u}))}),n.sendAnalyticsEventToCheckout(Ge,{channel:P,message:u})},function(e){if(Ae(n.paymentRequestContainer,!1),n.isCharging=!1,e&&e.statusCode===T)r(function(){return a.onCancel()});else{var t=e&&e.statusCode;t!==I&&t!==O||oe("Google Pay: ".concat(t,". Google rejected the merchant or the origin serving the button. Check that the merchant ID and domain saved in Dashboard > Developers > Google Pay match this page."));var o=e&&(e.statusMessage||e.message)||"Could not complete the Google Pay payment";r(function(){return a.onSetupError({status:!1,message:o})}),n.sendAnalyticsEventToCheckout(Ge,{channel:P,message:o})}}).catch(function(e){n.isCharging=!1,oe("Google Pay: the charge handler failed. ".concat(e&&e.message||e)),r(function(){return a.onSetupError({status:!1,message:"Could not complete the Google Pay payment"})})})}catch(e){return this.isCharging=!1,oe("Google Pay: could not start the charge."),r(function(){return a.onSetupError({status:!1,message:"Could not complete the Google Pay payment"})}),Promise.resolve()}}else Ke("Could not initiate google pay transaction");return Promise.resolve()}},{key:"startApplePay",value:function(e){var n,t,a,r,o,s=this,c="apple pay",l=e||this.activeTransaction();if(!e||e.isActive)if(l&&l.response){if(this.isCharging)return;this.isCharging=!0;try{var u={channel:C,currency:l.response.currency,amount:re(l.response,C)};l.logAttempt(c),this.sendAnalyticsEventToCheckout(Fe,i(i({},u),{},{paymentMethod:c}));var d=(n={currency:l.response.currency,amount:re(l.response,C),merchantName:l.response.merchant_name,merchantCountryCode:l.response.merchant_country_code,interval:l.response.plan_details&&l.response.plan_details.interval},t=n.currency,a=n.amount,r=n.merchantName,o=n.interval,i({countryCode:n.merchantCountryCode||M,currencyCode:t,merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard"],requiredBillingContactFields:["postalAddress","name","phone","email"],total:{label:"".concat(r," - Paystack"),type:"final",amount:String(R(a))}},"string"==typeof o&&""!==o.trim()&&{lineItems:[{label:X(o),amount:String(R(a))}]})),p=new window.ApplePaySession(f.applePayVersion,d);p.onvalidatemerchant=function(e){var n=function(e){var n=e.transactionId,t=e.accessCode,a=e.publicKey,r=e.validationURL,o=e.merchantName,s=e.domainName,c=void 0===s?window&&window.location&&window.location.hostname:s,l="".concat(f.paymentBaseUrl).concat(f.applePayValidateSessionPath),u=Z(i(i(i({transaction:n},t&&{accessCode:t}),a&&{publicKey:a}),{},{sessionUrl:r,displayName:o,domainName:c}));return fetch(l,i(i({},Q),{},{body:u})).then(function(e){return e.json()})}({validationURL:e.validationURL,transactionId:l.id,accessCode:l.accessCode,publicKey:l.parameters.key,merchantName:l.response.merchant_name});n.then(function(e){e.status!==S?(s.isCharging=!1,l.onSetupError(e)):p.completeMerchantValidation(e.data),l.logValidationResponse(e.message)}).catch(function(e){s.isCharging=!1,l.onSetupError(e)})},p.oncancel=function(){s.isCharging=!1,l.onCancel()},p.onpaymentauthorized=function(e){var n=e.payment,t=function(e){var n=e.transactionId,t=e.accessCode,a=e.payment,r="".concat(f.paymentBaseUrl).concat(f.applePayChargePath),o=Z(i(i({transaction:n},t&&{accessCode:t}),{},{paymentObject:JSON.stringify(a)}));return fetch(r,i(i({},Q),{},{body:o})).then(function(e){return e.json()})}({transactionId:l.id,accessCode:l.accessCode,payment:n});t.then(function(e){l.logAPIResponse(e,c),s.isCharging=!1,e.status===S?(p.completePayment(window.ApplePaySession.STATUS_SUCCESS),l.onSuccess(e),s.sendAnalyticsEventToCheckout(We,i(i({},u),{},{timeSpent:l.getTimeSpent()}))):(p.completePayment(window.ApplePaySession.STATUS_FAILURE),l.onSetupError(e),s.sendAnalyticsEventToCheckout(Ge,{channel:C,message:e&&e.message||"Transaction attempt failed"}))}).catch(function(e){s.isCharging=!1,p.completePayment(window.ApplePaySession.STATUS_FAILURE),l.onSetupError(e),s.sendAnalyticsEventToCheckout(Ge,{channel:C,message:e&&e.message||"Error occurred"})})},p.begin()}catch(e){this.isCharging=!1,l.onSetupError(e)}}else Ke("Could not initiate apple pay transaction");else oe("Apple Pay: this button belongs to a transaction that is no longer active.")}},{key:"resumeTransaction",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=n.onSuccess,a=n.onCancel,r=n.onLoad,o=n.onError;return this.newTransaction({accessCode:e,onSuccess:t,onCancel:a,onLoad:r,onError:o})}},{key:"activeTransaction",value:function(){var e=this.transactions.filter(function(e){return e.isActive}),n=e.length?e[e.length-1]:null;return n}},{key:"cancelTransaction",value:function(e){var n=this.transactions.find(function(n){return n.id===e})||this.activeTransaction();n&&(n.cancel(),this.close())}},{key:"respondToEvent",value:function(e){if(e){var n,t,a=this.activeTransaction();try{var r=e.data||e.message,o=r.event,i=r.data;if(o)switch(o){case"loaded:checkout":if(this.isLoaded=!0,a){var s=this.checkoutIframe,c=a.urlParameters,l=a.response;De({checkoutIframe:s,urlParameters:l?{accessCode:l.access_code,language:null==c?void 0:c.language}:c})}break;case"loaded:transaction":n=this.backgroundIframe,(t=n.contentWindow.document)&&(t.getElementById("app-loader").style.display="none"),a.onLoad(i);break;case"error":"setup"===i.type?a.onSetupError(i):a.logError(i);break;case"cancel":case"close":this.close();var u=i&&i.status;u&&a.setStatus(u),this.hasMountedPaymentRequestButtons()||(a.isActive=!1),a.onCancel();break;case"transfer:pending":this.close();var d=i&&i.status;d&&a.setStatus(d),a.onBankTransferConfirmationPending();break;case"success":this.close(),a.onSuccess(i)}}catch(e){}}}},{key:"respondToEmbedEvents",value:function(e){var n,t,a=this.activeTransaction(),r=e.data||e.message;if(r&&("string"==typeof r||r instanceof String)){var o={action:t=(n=r)&&"string"==typeof n?n.split(" ")[0]:null,data:t?n.split(" ").slice(2).join(" "):null};if(o&&"PaystackClose"===o.action)o.data&&a.onSuccess(r);"PaystackTLSClose"===o.action&&a.cancel()}}},{key:"animateCheckoutIn",value:function(){var e,n=this;if(!this.isOpen){var t=this.checkoutIframe,a=this.backgroundIframe;(e={checkoutIframe:t,backgroundIframe:a},new Promise(function(n,t){e||t("No dom element provided");var a=e.checkoutIframe,r=e.backgroundIframe;a&&r||t("No dom element provided"),a.style.display="",a.style.visibility="visible",r.style.display="",r.style.visibility="visible",n()})).then(function(){n.checkoutIframe.contentWindow.postMessage("render","*")}),this.isOpen=!0}}},{key:"open",value:function(e,n){e&&(De({checkoutIframe:this.checkoutIframe,urlParameters:e}),n||this.animateCheckoutIn())}},{key:"close",value:function(){var e=this;if(this.isOpen){var n,t=this.checkoutIframe,a=this.backgroundIframe;(n={checkoutIframe:t,backgroundIframe:a},new Promise(function(e,t){n||t("No dom element provided");var a=n.checkoutIframe,r=n.backgroundIframe;a&&r||t("No dom element provided"),r.style.opacity=0,a.style.display="none",a.style.visibility="hidden",setTimeout(function(){r.style.display="none",r.style.visibility="hidden",r.style.opacity=1,e()},300)})).then(function(){e.checkoutIframe.contentWindow.postMessage("close","*")}),this.isOpen=!1}}},{key:"isLoaded",value:function(){return this.isLoaded}}],[{key:"setup",value:function(n){var t=n&&n.container;Ie||(Ie=new e({isDeprecatedApi:!0,isEmbed:t})),ie("PaystackPop.setup()","new PaystackPop()","Please consult our documentation at https://developers.paystack.co/docs/paystack-inline");var a=Ie.newTransaction(n,"deprecated"),r=a.urlParameters;if(t){var o="".concat(f.siteUrl,"/assets/payment/production/inline.html?").concat(g(r)),i=function(e,n){var t=we("embed-checkout-".concat(e));return t.style.cssText="\n background: transparent;\n background: rgba(0,0,0,0);\n border: 0px none transparent;\n overflow-x: hidden;\n overflow-y: hidden;\n nmargin: 0;\n padding: 0;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n visibility: hidden;\n display: none;\n",t.src=n,t.id=e,t.name=e,t.setAttribute("allowpaymentrequest","true"),t.setAttribute("allow","payment; clipboard-read; clipboard-write"),t}(Ie.id,o);!function(e,n){var t=document.getElementById(e);t.innerHTML="",t.removeAttribute("style"),t.className="paystack-embed-container",t.style.position="relative",t.style.width="100%",t.appendChild(n)}(n.container,i),i.onload=function(){var e;i.contentWindow.postMessage("PaystackOpen ".concat(Ie.id),"*"),e=i,new Promise(function(n,t){e||t("No dom element provided"),e.style.display="",e.style.visibility="visible",n()})}}else a.openIframe=function(){ie("openIframe","open","Please consult our documentation at https://developers.paystack.co/docs/paystack-inline"),Ie.open(r)};return a}}])}();if(Je=N().length>0,He=z()&&"FORM"===z().parentElement.tagName,Je&&He){var Ze,Xe=function(){var e={},n=z();return N().forEach(function(t){var a=n.getAttribute(t),r=t.split("data-")[1].replace(/-([a-z])/g,function(e){return e[1].toUpperCase()});e[r]=a}),function(e){if(e.buttonId&&!document.getElementById(e.buttonId))throw new Error("Please make sure the buttonId is an element available in the DOM");var n=i({},e);n.buttonText=e.buttonText||"Pay",n.buttonVariant="normal",n.buttonWordmarkVariant="normal";var t=["normal","light"];return e.buttonVariant&&t.indexOf(e.buttonVariant)>-1&&(n.buttonVariant=e.buttonVariant),e.buttonWordmarkVariant&&t.indexOf(e.buttonWordmarkVariant)>-1&&(n.buttonWordmarkVariant=e.buttonWordmarkVariant),n}(e)}(),Ye=z().parentElement;Ie||(Ie=new Qe),function(e){var n;if(e.id)(n=document.getElementById(e.id)).setAttribute("data-inline-id",e.id);else{var t=document.createElement("div");t.id="inline-button-".concat(e.inlineId),t.innerHTML=function(e){var n,t,a={normal:'\n <svg id="inline-button-wordmark" width="137" height="13" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M.037 5.095l1.075-.135c-.011-.774-.025-1.944-.013-2.149C1.19 1.364 2.38.134 3.81.013 3.9.006 3.99.002 4.077 0a2.947 2.947 0 0 1 2.046.76c.574.509.95 1.26 1.008 2.007.015.192.01 1.491.01 2.257l1.096.163L8.2 11.44 4.093 12 0 11.346l.037-6.251zm4.106-.514l1.724.256c-.007-.933-.05-2.295-.26-2.654-.319-.545-.846-.867-1.443-.88h-.063c-.607.008-1.138.322-1.458.864-.222.378-.266 1.66-.265 2.637l1.765-.223zM18.228 10.108c-.576 0-1.064-.072-1.464-.216a2.864 2.864 0 0 1-.972-.6 2.552 2.552 0 0 1-.588-.864 4.067 4.067 0 0 1-.252-1.044h1.008c.032.256.088.5.168.732.08.224.204.424.372.6.168.168.388.304.66.408.28.096.636.144 1.068.144.28 0 .536-.036.768-.108.24-.08.448-.192.624-.336.176-.144.312-.316.408-.516.104-.2.156-.42.156-.66 0-.24-.032-.448-.096-.624a1.02 1.02 0 0 0-.336-.468 1.885 1.885 0 0 0-.636-.324 6.4 6.4 0 0 0-1.008-.228 8.79 8.79 0 0 1-1.212-.276 3.246 3.246 0 0 1-.9-.432 1.982 1.982 0 0 1-.564-.672c-.128-.272-.192-.6-.192-.984 0-.328.068-.632.204-.912.136-.288.324-.536.564-.744.248-.208.54-.372.876-.492.336-.12.708-.18 1.116-.18.864 0 1.548.204 2.052.612.512.4.812.984.9 1.752h-.936c-.104-.544-.316-.932-.636-1.164-.32-.24-.78-.36-1.38-.36-.592 0-1.04.132-1.344.396a1.255 1.255 0 0 0-.444.996c0 .208.024.396.072.564.056.16.156.3.3.42.152.12.36.228.624.324a6.72 6.72 0 0 0 1.068.228c.48.072.9.168 1.26.288.36.12.664.276.912.468s.432.428.552.708c.128.28.192.624.192 1.032 0 .36-.076.696-.228 1.008a2.472 2.472 0 0 1-.612.804c-.264.224-.58.4-.948.528-.36.128-.752.192-1.176.192zM25.355 10.108c-.44 0-.848-.076-1.224-.228a2.916 2.916 0 0 1-.96-.636 2.966 2.966 0 0 1-.636-1.008 3.77 3.77 0 0 1-.216-1.308v-.096c0-.472.072-.904.216-1.296.144-.4.344-.74.6-1.02.264-.288.576-.508.936-.66.36-.16.756-.24 1.188-.24.36 0 .708.06 1.044.18.344.112.648.292.912.54.264.248.472.572.624.972.16.392.24.868.24 1.428v.324h-4.728c.024.72.204 1.272.54 1.656.336.376.828.564 1.476.564.984 0 1.54-.364 1.668-1.092h.996c-.112.632-.408 1.112-.888 1.44-.48.32-1.076.48-1.788.48zm1.704-3.852c-.048-.648-.232-1.112-.552-1.392-.312-.28-.728-.42-1.248-.42-.512 0-.932.164-1.26.492-.32.32-.524.76-.612 1.32h3.672zM32.091 10.108c-.44 0-.848-.072-1.224-.216a3.054 3.054 0 0 1-.972-.636 3.12 3.12 0 0 1-.648-1.008 3.626 3.626 0 0 1-.228-1.32v-.096c0-.48.08-.916.24-1.308.16-.4.376-.74.648-1.02.28-.28.604-.496.972-.648.376-.16.772-.24 1.188-.24.328 0 .644.04.948.12.312.08.588.208.828.384.248.168.456.392.624.672.168.28.276.62.324 1.02h-.984c-.08-.496-.284-.848-.612-1.056-.32-.208-.696-.312-1.128-.312a1.93 1.93 0 0 0-.804.168c-.24.112-.452.272-.636.48a2.23 2.23 0 0 0-.42.744 2.991 2.991 0 0 0-.156.996v.096c0 .776.188 1.364.564 1.764.384.392.88.588 1.488.588.224 0 .436-.032.636-.096a1.651 1.651 0 0 0 .96-.768c.112-.192.18-.416.204-.672h.924a2.595 2.595 0 0 1-.276.948 2.386 2.386 0 0 1-.576.744c-.24.208-.52.372-.84.492-.32.12-.668.18-1.044.18zM38.335 10.108a2.83 2.83 0 0 1-.876-.132 1.724 1.724 0 0 1-.684-.42 2.145 2.145 0 0 1-.456-.756c-.112-.304-.168-.672-.168-1.104V3.724h.996v3.924c0 .552.116.956.348 1.212.24.256.608.384 1.104.384.224 0 .44-.036.648-.108.208-.072.392-.18.552-.324.16-.144.288-.324.384-.54.096-.216.144-.464.144-.744V3.724h.996V10h-.996v-.996c-.144.296-.388.556-.732.78-.336.216-.756.324-1.26.324zM43.216 3.724h.996v1.128c.2-.352.452-.64.756-.864.312-.232.748-.356 1.308-.372v.936a4.461 4.461 0 0 0-.852.12 1.647 1.647 0 0 0-.66.324 1.472 1.472 0 0 0-.408.612c-.096.248-.144.564-.144.948V10h-.996V3.724zM50 10.108c-.44 0-.848-.076-1.224-.228a2.916 2.916 0 0 1-.96-.636 2.966 2.966 0 0 1-.636-1.008 3.77 3.77 0 0 1-.216-1.308v-.096c0-.472.072-.904.216-1.296.144-.4.344-.74.6-1.02.264-.288.576-.508.936-.66.36-.16.756-.24 1.188-.24.36 0 .708.06 1.044.18.344.112.648.292.912.54.264.248.472.572.624.972.16.392.24.868.24 1.428v.324h-4.728c.024.72.204 1.272.54 1.656.336.376.828.564 1.476.564.984 0 1.54-.364 1.668-1.092h.996c-.112.632-.408 1.112-.888 1.44-.48.32-1.076.48-1.788.48zm1.704-3.852c-.048-.648-.232-1.112-.552-1.392-.312-.28-.728-.42-1.248-.42-.512 0-.932.164-1.26.492-.32.32-.524.76-.612 1.32h3.672zM56.496 10.108c-.408 0-.788-.068-1.14-.204a2.683 2.683 0 0 1-.9-.612 3.01 3.01 0 0 1-.588-.984 4.01 4.01 0 0 1-.204-1.32v-.096c0-.48.072-.92.216-1.32.144-.4.344-.744.6-1.032.256-.296.564-.524.924-.684.36-.16.756-.24 1.188-.24.528 0 .956.112 1.284.336.328.216.584.476.768.78V.724h.996V10h-.996V8.92c-.088.152-.208.3-.36.444a2.792 2.792 0 0 1-.516.384 2.874 2.874 0 0 1-.6.252c-.216.072-.44.108-.672.108zm.108-.828c.288 0 .56-.048.816-.144.256-.096.476-.24.66-.432.184-.2.328-.448.432-.744.112-.304.168-.656.168-1.056v-.096c0-.808-.18-1.404-.54-1.788-.352-.384-.836-.576-1.452-.576-.624 0-1.112.208-1.464.624-.352.416-.528 1.008-.528 1.776v.096c0 .392.048.736.144 1.032.104.296.24.54.408.732.176.192.38.336.612.432.232.096.48.144.744.144zM67.712 10.108c-.512 0-.948-.112-1.308-.336a2.38 2.38 0 0 1-.816-.804V10h-.996V.724h.996V4.78a1.92 1.92 0 0 1 .348-.432c.152-.144.32-.268.504-.372.192-.112.396-.2.612-.264.216-.064.436-.096.66-.096.408 0 .788.072 1.14.216.352.144.652.352.9.624.256.272.456.604.6.996.144.392.216.832.216 1.32v.096c0 .48-.068.92-.204 1.32a3.103 3.103 0 0 1-.576 1.02 2.583 2.583 0 0 1-.9.672 2.937 2.937 0 0 1-1.176.228zm-.096-.828c.624 0 1.1-.2 1.428-.6.328-.408.492-.996.492-1.764V6.82c0-.4-.052-.748-.156-1.044a2.095 2.095 0 0 0-.42-.732 1.53 1.53 0 0 0-.612-.444 1.798 1.798 0 0 0-.744-.156c-.288 0-.56.048-.816.144a1.71 1.71 0 0 0-.648.444c-.184.192-.328.44-.432.744a3.152 3.152 0 0 0-.156 1.044v.096c0 .8.192 1.396.576 1.788.384.384.88.576 1.488.576zM73.63 9.352l-2.46-5.628h1.068l1.92 4.5 1.74-4.5h1.02l-3.468 8.46h-1.008l1.188-2.832zM87.127 3.669A3.138 3.138 0 0 0 86.1 2.95a3.09 3.09 0 0 0-1.228-.25c-.448 0-.848.086-1.187.26a2.199 2.199 0 0 0-.662.497v-.191a.387.387 0 0 0-.214-.348.323.323 0 0 0-.14-.03h-1.315a.314.314 0 0 0-.254.116.377.377 0 0 0-.1.262v8.97c0 .1.034.188.1.258a.34.34 0 0 0 .254.103h1.341a.342.342 0 0 0 .244-.103.336.336 0 0 0 .11-.259v-3.06c.178.202.417.357.702.464.35.134.72.203 1.093.203.43 0 .848-.082 1.242-.248a3.124 3.124 0 0 0 1.04-.724c.305-.326.545-.709.707-1.128a3.93 3.93 0 0 0 .263-1.477c0-.54-.086-1.037-.263-1.477a3.387 3.387 0 0 0-.706-1.12zm-1.204 3.24c-.073.19-.18.362-.315.51a1.415 1.415 0 0 1-1.065.466c-.2.001-.4-.04-.584-.12a1.484 1.484 0 0 1-.49-.346 1.593 1.593 0 0 1-.32-.51 1.738 1.738 0 0 1-.115-.63c0-.224.04-.435.115-.631a1.532 1.532 0 0 1 .804-.846c.185-.086.386-.13.59-.129.215 0 .414.044.593.13.177.083.338.199.474.341a1.622 1.622 0 0 1 .425 1.135c0 .225-.037.436-.112.63zM95.298 2.89h-1.33a.339.339 0 0 0-.246.11.384.384 0 0 0-.108.266v.166a1.856 1.856 0 0 0-.602-.472 2.525 2.525 0 0 0-1.166-.258 3.227 3.227 0 0 0-2.284.964 3.554 3.554 0 0 0-.734 1.123 3.827 3.827 0 0 0-.275 1.477c0 .54.092 1.037.275 1.477.184.434.427.817.728 1.128a3.146 3.146 0 0 0 2.277.973c.437 0 .834-.088 1.173-.259.25-.13.456-.287.608-.471v.177a.34.34 0 0 0 .11.259.341.341 0 0 0 .244.104h1.33a.324.324 0 0 0 .25-.105.349.349 0 0 0 .102-.258V3.267a.377.377 0 0 0-.1-.262.325.325 0 0 0-.252-.115zM93.502 6.9a1.55 1.55 0 0 1-.312.511c-.136.143-.296.26-.473.344-.178.085-.38.129-.596.129-.207 0-.407-.044-.59-.13a1.501 1.501 0 0 1-.791-.855 1.766 1.766 0 0 1-.112-.62c0-.225.038-.436.112-.632.075-.193.181-.364.314-.504.137-.143.3-.26.478-.342.182-.085.382-.129.59-.129.215 0 .417.044.595.13.178.085.338.2.473.341a1.623 1.623 0 0 1 .424 1.135c0 .215-.037.424-.112.622zM108.567 6.094a2.265 2.265 0 0 0-.654-.402c-.247-.101-.509-.181-.785-.235l-1.014-.204c-.26-.05-.441-.117-.543-.203a.328.328 0 0 1-.136-.264c0-.11.063-.2.189-.282.137-.086.329-.13.566-.13.26 0 .518.053.757.157.243.106.471.226.67.36.295.187.546.162.727-.053l.487-.57a.543.543 0 0 0 .152-.357c0-.128-.064-.245-.185-.351-.207-.184-.533-.378-.971-.568-.437-.192-.987-.29-1.637-.29-.427 0-.82.058-1.168.172-.35.116-.65.276-.893.474-.245.204-.438.44-.57.713a2 2 0 0 0-.198.875c0 .56.167 1.017.496 1.358.328.333.766.56 1.304.67l1.054.232c.3.062.528.132.675.21.129.067.19.163.19.297 0 .12-.061.227-.188.324-.133.104-.342.155-.622.155a1.83 1.83 0 0 1-.831-.19 3.056 3.056 0 0 1-.678-.458.995.995 0 0 0-.307-.17c-.126-.037-.268.003-.431.13l-.583.461c-.169.145-.24.32-.209.522.029.194.19.394.491.62.269.193.614.368 1.029.518.415.151.901.229 1.453.229.444 0 .854-.058 1.215-.172.362-.119.681-.278.941-.48a2.056 2.056 0 0 0 .819-1.663c0-.319-.053-.6-.165-.836a1.843 1.843 0 0 0-.447-.6zM114.383 7.73a.363.363 0 0 0-.295-.192.55.55 0 0 0-.343.113c-.095.062-.198.11-.306.141a.75.75 0 0 1-.426.013.43.43 0 0 1-.181-.093.554.554 0 0 1-.143-.204.92.92 0 0 1-.059-.362v-2.46h1.731c.099 0 .188-.04.266-.117a.368.368 0 0 0 .112-.26V3.268a.369.369 0 0 0-.115-.268.38.38 0 0 0-.263-.109h-1.732V1.216a.354.354 0 0 0-.108-.27.347.347 0 0 0-.243-.104h-1.344a.36.36 0 0 0-.34.226.371.371 0 0 0-.027.148V2.89h-.767a.324.324 0 0 0-.255.115.385.385 0 0 0-.098.262V4.31a.4.4 0 0 0 .212.346c.044.021.092.032.14.03h.768v2.925c0 .39.069.726.2 1.003.132.274.305.504.514.676.217.178.465.31.731.388.27.084.551.126.833.126.385 0 .75-.061 1.094-.18a2.13 2.13 0 0 0 .861-.552c.152-.181.17-.381.046-.581l-.463-.76zM121.672 2.89h-1.329a.339.339 0 0 0-.244.11.39.39 0 0 0-.08.122.394.394 0 0 0-.027.144v.166a1.906 1.906 0 0 0-.605-.472c-.335-.173-.726-.258-1.168-.258-.42 0-.834.083-1.226.249a3.24 3.24 0 0 0-1.055.715 3.528 3.528 0 0 0-.734 1.123 3.79 3.79 0 0 0-.276 1.477c0 .54.092 1.037.275 1.477.184.434.428.817.729 1.128a3.138 3.138 0 0 0 2.273.973 2.59 2.59 0 0 0 1.175-.259c.255-.13.457-.287.612-.471v.177a.34.34 0 0 0 .108.259.343.343 0 0 0 .243.104h1.329a.335.335 0 0 0 .252-.105.364.364 0 0 0 .102-.258V3.267a.38.38 0 0 0-.1-.262.332.332 0 0 0-.115-.087.311.311 0 0 0-.139-.028zM119.876 6.9a1.534 1.534 0 0 1-.786.855 1.362 1.362 0 0 1-.594.129c-.207 0-.405-.044-.588-.13a1.516 1.516 0 0 1-.792-.855 1.757 1.757 0 0 1-.113-.62c0-.225.037-.436.112-.632.073-.187.179-.358.314-.504.138-.143.3-.26.479-.342.184-.086.385-.13.588-.129.217 0 .415.044.594.13.181.085.34.2.472.341.134.143.24.313.314.504a1.73 1.73 0 0 1 0 1.253zM128.978 7.64l-.763-.593c-.146-.118-.284-.15-.404-.1a.742.742 0 0 0-.279.205 2.527 2.527 0 0 1-.583.535c-.192.122-.444.183-.742.183-.219 0-.42-.04-.6-.122a1.423 1.423 0 0 1-.469-.342 1.575 1.575 0 0 1-.308-.51 1.751 1.751 0 0 1-.106-.617c0-.228.034-.438.106-.632.07-.192.173-.363.308-.503.135-.144.295-.26.472-.342.187-.088.391-.132.597-.13.298 0 .547.064.742.187.198.126.396.306.584.534.078.092.17.16.278.206.122.048.259.016.401-.101l.762-.594a.53.53 0 0 0 .201-.269.437.437 0 0 0-.034-.365 3.329 3.329 0 0 0-1.18-1.127c-.504-.291-1.108-.441-1.784-.441a3.519 3.519 0 0 0-2.51 1.033c-.322.322-.576.71-.747 1.137a3.68 3.68 0 0 0-.273 1.407c0 .495.093.968.273 1.402.173.424.427.808.747 1.128a3.527 3.527 0 0 0 2.51 1.034c.676 0 1.28-.149 1.784-.444a3.286 3.286 0 0 0 1.182-1.13.411.411 0 0 0 .055-.173.415.415 0 0 0-.023-.182.624.624 0 0 0-.197-.273zM136.06 9.045l-2.104-3.143 1.801-2.415c.094-.139.119-.272.075-.397-.031-.09-.116-.2-.334-.2h-1.425a.52.52 0 0 0-.234.058.482.482 0 0 0-.209.205L132.191 5.2h-.349V.363a.37.37 0 0 0-.099-.26.352.352 0 0 0-.253-.103h-1.332a.37.37 0 0 0-.337.22.346.346 0 0 0-.027.143V9.29c0 .103.038.193.11.259a.353.353 0 0 0 .254.104h1.333a.328.328 0 0 0 .251-.105.346.346 0 0 0 .075-.119.333.333 0 0 0 .024-.14V6.927h.386l1.571 2.446c.112.187.267.281.46.281h1.491c.226 0 .32-.11.358-.202.054-.13.038-.262-.047-.406zM102.863 2.89h-1.489a.389.389 0 0 0-.298.122.544.544 0 0 0-.13.249l-1.099 4.167h-.268l-1.182-4.167a.66.66 0 0 0-.113-.247.329.329 0 0 0-.264-.124h-1.544c-.199 0-.325.066-.372.193a.588.588 0 0 0-.002.37l1.887 5.865c.03.093.08.17.145.232a.388.388 0 0 0 .281.104h.798l-.066.19-.19.547a.872.872 0 0 1-.29.426.7.7 0 0 1-.442.148.956.956 0 0 1-.4-.09 1.842 1.842 0 0 1-.35-.209.62.62 0 0 0-.335-.115h-.016c-.13 0-.243.074-.334.216l-.474.708c-.193.304-.086.504.039.615.234.224.528.399.875.524.344.125.723.186 1.126.186.682 0 1.252-.187 1.689-.565.435-.376.756-.887.952-1.524l2.188-7.258c.05-.155.05-.284.005-.389-.037-.08-.125-.174-.327-.174z" fill="#011B33"/>\n </svg>',light:'\n <svg id="inline-button-wordmark--white" width="137" height="13" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M.037 5.095l1.075-.135c-.011-.774-.025-1.944-.013-2.149C1.19 1.364 2.38.134 3.81.013 3.9.006 3.99.002 4.077 0a2.947 2.947 0 0 1 2.046.76c.574.509.95 1.26 1.008 2.007.015.192.01 1.491.01 2.257l1.096.163L8.2 11.44 4.093 12 0 11.346l.037-6.251zm4.106-.514l1.724.256c-.007-.933-.05-2.295-.26-2.654-.319-.545-.846-.867-1.443-.88h-.063c-.607.008-1.138.322-1.458.864-.222.378-.266 1.66-.265 2.637l1.765-.223zM18.228 10.108c-.576 0-1.064-.072-1.464-.216a2.864 2.864 0 0 1-.972-.6 2.552 2.552 0 0 1-.588-.864 4.067 4.067 0 0 1-.252-1.044h1.008c.032.256.088.5.168.732.08.224.204.424.372.6.168.168.388.304.66.408.28.096.636.144 1.068.144.28 0 .536-.036.768-.108.24-.08.448-.192.624-.336.176-.144.312-.316.408-.516.104-.2.156-.42.156-.66 0-.24-.032-.448-.096-.624a1.02 1.02 0 0 0-.336-.468 1.885 1.885 0 0 0-.636-.324 6.4 6.4 0 0 0-1.008-.228 8.79 8.79 0 0 1-1.212-.276 3.246 3.246 0 0 1-.9-.432 1.982 1.982 0 0 1-.564-.672c-.128-.272-.192-.6-.192-.984 0-.328.068-.632.204-.912.136-.288.324-.536.564-.744.248-.208.54-.372.876-.492.336-.12.708-.18 1.116-.18.864 0 1.548.204 2.052.612.512.4.812.984.9 1.752h-.936c-.104-.544-.316-.932-.636-1.164-.32-.24-.78-.36-1.38-.36-.592 0-1.04.132-1.344.396a1.255 1.255 0 0 0-.444.996c0 .208.024.396.072.564.056.16.156.3.3.42.152.12.36.228.624.324a6.72 6.72 0 0 0 1.068.228c.48.072.9.168 1.26.288.36.12.664.276.912.468s.432.428.552.708c.128.28.192.624.192 1.032 0 .36-.076.696-.228 1.008a2.472 2.472 0 0 1-.612.804c-.264.224-.58.4-.948.528-.36.128-.752.192-1.176.192zM25.355 10.108c-.44 0-.848-.076-1.224-.228a2.916 2.916 0 0 1-.96-.636 2.966 2.966 0 0 1-.636-1.008 3.77 3.77 0 0 1-.216-1.308v-.096c0-.472.072-.904.216-1.296.144-.4.344-.74.6-1.02.264-.288.576-.508.936-.66.36-.16.756-.24 1.188-.24.36 0 .708.06 1.044.18.344.112.648.292.912.54.264.248.472.572.624.972.16.392.24.868.24 1.428v.324h-4.728c.024.72.204 1.272.54 1.656.336.376.828.564 1.476.564.984 0 1.54-.364 1.668-1.092h.996c-.112.632-.408 1.112-.888 1.44-.48.32-1.076.48-1.788.48zm1.704-3.852c-.048-.648-.232-1.112-.552-1.392-.312-.28-.728-.42-1.248-.42-.512 0-.932.164-1.26.492-.32.32-.524.76-.612 1.32h3.672zM32.091 10.108c-.44 0-.848-.072-1.224-.216a3.054 3.054 0 0 1-.972-.636 3.12 3.12 0 0 1-.648-1.008 3.626 3.626 0 0 1-.228-1.32v-.096c0-.48.08-.916.24-1.308.16-.4.376-.74.648-1.02.28-.28.604-.496.972-.648.376-.16.772-.24 1.188-.24.328 0 .644.04.948.12.312.08.588.208.828.384.248.168.456.392.624.672.168.28.276.62.324 1.02h-.984c-.08-.496-.284-.848-.612-1.056-.32-.208-.696-.312-1.128-.312a1.93 1.93 0 0 0-.804.168c-.24.112-.452.272-.636.48a2.23 2.23 0 0 0-.42.744 2.991 2.991 0 0 0-.156.996v.096c0 .776.188 1.364.564 1.764.384.392.88.588 1.488.588.224 0 .436-.032.636-.096a1.651 1.651 0 0 0 .96-.768c.112-.192.18-.416.204-.672h.924a2.595 2.595 0 0 1-.276.948 2.386 2.386 0 0 1-.576.744c-.24.208-.52.372-.84.492-.32.12-.668.18-1.044.18zM38.335 10.108a2.83 2.83 0 0 1-.876-.132 1.724 1.724 0 0 1-.684-.42 2.145 2.145 0 0 1-.456-.756c-.112-.304-.168-.672-.168-1.104V3.724h.996v3.924c0 .552.116.956.348 1.212.24.256.608.384 1.104.384.224 0 .44-.036.648-.108.208-.072.392-.18.552-.324.16-.144.288-.324.384-.54.096-.216.144-.464.144-.744V3.724h.996V10h-.996v-.996c-.144.296-.388.556-.732.78-.336.216-.756.324-1.26.324zM43.216 3.724h.996v1.128c.2-.352.452-.64.756-.864.312-.232.748-.356 1.308-.372v.936a4.461 4.461 0 0 0-.852.12 1.647 1.647 0 0 0-.66.324 1.472 1.472 0 0 0-.408.612c-.096.248-.144.564-.144.948V10h-.996V3.724zM50 10.108c-.44 0-.848-.076-1.224-.228a2.916 2.916 0 0 1-.96-.636 2.966 2.966 0 0 1-.636-1.008 3.77 3.77 0 0 1-.216-1.308v-.096c0-.472.072-.904.216-1.296.144-.4.344-.74.6-1.02.264-.288.576-.508.936-.66.36-.16.756-.24 1.188-.24.36 0 .708.06 1.044.18.344.112.648.292.912.54.264.248.472.572.624.972.16.392.24.868.24 1.428v.324h-4.728c.024.72.204 1.272.54 1.656.336.376.828.564 1.476.564.984 0 1.54-.364 1.668-1.092h.996c-.112.632-.408 1.112-.888 1.44-.48.32-1.076.48-1.788.48zm1.704-3.852c-.048-.648-.232-1.112-.552-1.392-.312-.28-.728-.42-1.248-.42-.512 0-.932.164-1.26.492-.32.32-.524.76-.612 1.32h3.672zM56.496 10.108c-.408 0-.788-.068-1.14-.204a2.683 2.683 0 0 1-.9-.612 3.01 3.01 0 0 1-.588-.984 4.01 4.01 0 0 1-.204-1.32v-.096c0-.48.072-.92.216-1.32.144-.4.344-.744.6-1.032.256-.296.564-.524.924-.684.36-.16.756-.24 1.188-.24.528 0 .956.112 1.284.336.328.216.584.476.768.78V.724h.996V10h-.996V8.92c-.088.152-.208.3-.36.444a2.792 2.792 0 0 1-.516.384 2.874 2.874 0 0 1-.6.252c-.216.072-.44.108-.672.108zm.108-.828c.288 0 .56-.048.816-.144.256-.096.476-.24.66-.432.184-.2.328-.448.432-.744.112-.304.168-.656.168-1.056v-.096c0-.808-.18-1.404-.54-1.788-.352-.384-.836-.576-1.452-.576-.624 0-1.112.208-1.464.624-.352.416-.528 1.008-.528 1.776v.096c0 .392.048.736.144 1.032.104.296.24.54.408.732.176.192.38.336.612.432.232.096.48.144.744.144zM67.712 10.108c-.512 0-.948-.112-1.308-.336a2.38 2.38 0 0 1-.816-.804V10h-.996V.724h.996V4.78a1.92 1.92 0 0 1 .348-.432c.152-.144.32-.268.504-.372.192-.112.396-.2.612-.264.216-.064.436-.096.66-.096.408 0 .788.072 1.14.216.352.144.652.352.9.624.256.272.456.604.6.996.144.392.216.832.216 1.32v.096c0 .48-.068.92-.204 1.32a3.103 3.103 0 0 1-.576 1.02 2.583 2.583 0 0 1-.9.672 2.937 2.937 0 0 1-1.176.228zm-.096-.828c.624 0 1.1-.2 1.428-.6.328-.408.492-.996.492-1.764V6.82c0-.4-.052-.748-.156-1.044a2.095 2.095 0 0 0-.42-.732 1.53 1.53 0 0 0-.612-.444 1.798 1.798 0 0 0-.744-.156c-.288 0-.56.048-.816.144a1.71 1.71 0 0 0-.648.444c-.184.192-.328.44-.432.744a3.152 3.152 0 0 0-.156 1.044v.096c0 .8.192 1.396.576 1.788.384.384.88.576 1.488.576zM73.63 9.352l-2.46-5.628h1.068l1.92 4.5 1.74-4.5h1.02l-3.468 8.46h-1.008l1.188-2.832zM87.127 3.669A3.138 3.138 0 0 0 86.1 2.95a3.09 3.09 0 0 0-1.228-.25c-.448 0-.848.086-1.187.26a2.199 2.199 0 0 0-.662.497v-.191a.387.387 0 0 0-.214-.348.323.323 0 0 0-.14-.03h-1.315a.314.314 0 0 0-.254.116.377.377 0 0 0-.1.262v8.97c0 .1.034.188.1.258a.34.34 0 0 0 .254.103h1.341a.342.342 0 0 0 .244-.103.336.336 0 0 0 .11-.259v-3.06c.178.202.417.357.702.464.35.134.72.203 1.093.203.43 0 .848-.082 1.242-.248a3.124 3.124 0 0 0 1.04-.724c.305-.326.545-.709.707-1.128a3.93 3.93 0 0 0 .263-1.477c0-.54-.086-1.037-.263-1.477a3.387 3.387 0 0 0-.706-1.12zm-1.204 3.24c-.073.19-.18.362-.315.51a1.415 1.415 0 0 1-1.065.466c-.2.001-.4-.04-.584-.12a1.484 1.484 0 0 1-.49-.346 1.593 1.593 0 0 1-.32-.51 1.738 1.738 0 0 1-.115-.63c0-.224.04-.435.115-.631a1.532 1.532 0 0 1 .804-.846c.185-.086.386-.13.59-.129.215 0 .414.044.593.13.177.083.338.199.474.341a1.622 1.622 0 0 1 .425 1.135c0 .225-.037.436-.112.63zM95.298 2.89h-1.33a.339.339 0 0 0-.246.11.384.384 0 0 0-.108.266v.166a1.856 1.856 0 0 0-.602-.472 2.525 2.525 0 0 0-1.166-.258 3.227 3.227 0 0 0-2.284.964 3.554 3.554 0 0 0-.734 1.123 3.827 3.827 0 0 0-.275 1.477c0 .54.092 1.037.275 1.477.184.434.427.817.728 1.128a3.146 3.146 0 0 0 2.277.973c.437 0 .834-.088 1.173-.259.25-.13.456-.287.608-.471v.177a.34.34 0 0 0 .11.259.341.341 0 0 0 .244.104h1.33a.324.324 0 0 0 .25-.105.349.349 0 0 0 .102-.258V3.267a.377.377 0 0 0-.1-.262.325.325 0 0 0-.252-.115zM93.502 6.9a1.55 1.55 0 0 1-.312.511c-.136.143-.296.26-.473.344-.178.085-.38.129-.596.129-.207 0-.407-.044-.59-.13a1.501 1.501 0 0 1-.791-.855 1.766 1.766 0 0 1-.112-.62c0-.225.038-.436.112-.632.075-.193.181-.364.314-.504.137-.143.3-.26.478-.342.182-.085.382-.129.59-.129.215 0 .417.044.595.13.178.085.338.2.473.341a1.623 1.623 0 0 1 .424 1.135c0 .215-.037.424-.112.622zM108.567 6.094a2.265 2.265 0 0 0-.654-.402c-.247-.101-.509-.181-.785-.235l-1.014-.204c-.26-.05-.441-.117-.543-.203a.328.328 0 0 1-.136-.264c0-.11.063-.2.189-.282.137-.086.329-.13.566-.13.26 0 .518.053.757.157.243.106.471.226.67.36.295.187.546.162.727-.053l.487-.57a.543.543 0 0 0 .152-.357c0-.128-.064-.245-.185-.351-.207-.184-.533-.378-.971-.568-.437-.192-.987-.29-1.637-.29-.427 0-.82.058-1.168.172-.35.116-.65.276-.893.474-.245.204-.438.44-.57.713a2 2 0 0 0-.198.875c0 .56.167 1.017.496 1.358.328.333.766.56 1.304.67l1.054.232c.3.062.528.132.675.21.129.067.19.163.19.297 0 .12-.061.227-.188.324-.133.104-.342.155-.622.155a1.83 1.83 0 0 1-.831-.19 3.056 3.056 0 0 1-.678-.458.995.995 0 0 0-.307-.17c-.126-.037-.268.003-.431.13l-.583.461c-.169.145-.24.32-.209.522.029.194.19.394.491.62.269.193.614.368 1.029.518.415.151.901.229 1.453.229.444 0 .854-.058 1.215-.172.362-.119.681-.278.941-.48a2.056 2.056 0 0 0 .819-1.663c0-.319-.053-.6-.165-.836a1.843 1.843 0 0 0-.447-.6zM114.383 7.73a.363.363 0 0 0-.295-.192.55.55 0 0 0-.343.113c-.095.062-.198.11-.306.141a.75.75 0 0 1-.426.013.43.43 0 0 1-.181-.093.554.554 0 0 1-.143-.204.92.92 0 0 1-.059-.362v-2.46h1.731c.099 0 .188-.04.266-.117a.368.368 0 0 0 .112-.26V3.268a.369.369 0 0 0-.115-.268.38.38 0 0 0-.263-.109h-1.732V1.216a.354.354 0 0 0-.108-.27.347.347 0 0 0-.243-.104h-1.344a.36.36 0 0 0-.34.226.371.371 0 0 0-.027.148V2.89h-.767a.324.324 0 0 0-.255.115.385.385 0 0 0-.098.262V4.31a.4.4 0 0 0 .212.346c.044.021.092.032.14.03h.768v2.925c0 .39.069.726.2 1.003.132.274.305.504.514.676.217.178.465.31.731.388.27.084.551.126.833.126.385 0 .75-.061 1.094-.18a2.13 2.13 0 0 0 .861-.552c.152-.181.17-.381.046-.581l-.463-.76zM121.672 2.89h-1.329a.339.339 0 0 0-.244.11.39.39 0 0 0-.08.122.394.394 0 0 0-.027.144v.166a1.906 1.906 0 0 0-.605-.472c-.335-.173-.726-.258-1.168-.258-.42 0-.834.083-1.226.249a3.24 3.24 0 0 0-1.055.715 3.528 3.528 0 0 0-.734 1.123 3.79 3.79 0 0 0-.276 1.477c0 .54.092 1.037.275 1.477.184.434.428.817.729 1.128a3.138 3.138 0 0 0 2.273.973 2.59 2.59 0 0 0 1.175-.259c.255-.13.457-.287.612-.471v.177a.34.34 0 0 0 .108.259.343.343 0 0 0 .243.104h1.329a.335.335 0 0 0 .252-.105.364.364 0 0 0 .102-.258V3.267a.38.38 0 0 0-.1-.262.332.332 0 0 0-.115-.087.311.311 0 0 0-.139-.028zM119.876 6.9a1.534 1.534 0 0 1-.786.855 1.362 1.362 0 0 1-.594.129c-.207 0-.405-.044-.588-.13a1.516 1.516 0 0 1-.792-.855 1.757 1.757 0 0 1-.113-.62c0-.225.037-.436.112-.632.073-.187.179-.358.314-.504.138-.143.3-.26.479-.342.184-.086.385-.13.588-.129.217 0 .415.044.594.13.181.085.34.2.472.341.134.143.24.313.314.504a1.73 1.73 0 0 1 0 1.253zM128.978 7.64l-.763-.593c-.146-.118-.284-.15-.404-.1a.742.742 0 0 0-.279.205 2.527 2.527 0 0 1-.583.535c-.192.122-.444.183-.742.183-.219 0-.42-.04-.6-.122a1.423 1.423 0 0 1-.469-.342 1.575 1.575 0 0 1-.308-.51 1.751 1.751 0 0 1-.106-.617c0-.228.034-.438.106-.632.07-.192.173-.363.308-.503.135-.144.295-.26.472-.342.187-.088.391-.132.597-.13.298 0 .547.064.742.187.198.126.396.306.584.534.078.092.17.16.278.206.122.048.259.016.401-.101l.762-.594a.53.53 0 0 0 .201-.269.437.437 0 0 0-.034-.365 3.329 3.329 0 0 0-1.18-1.127c-.504-.291-1.108-.441-1.784-.441a3.519 3.519 0 0 0-2.51 1.033c-.322.322-.576.71-.747 1.137a3.68 3.68 0 0 0-.273 1.407c0 .495.093.968.273 1.402.173.424.427.808.747 1.128a3.527 3.527 0 0 0 2.51 1.034c.676 0 1.28-.149 1.784-.444a3.286 3.286 0 0 0 1.182-1.13.411.411 0 0 0 .055-.173.415.415 0 0 0-.023-.182.624.624 0 0 0-.197-.273zM136.06 9.045l-2.104-3.143 1.801-2.415c.094-.139.119-.272.075-.397-.031-.09-.116-.2-.334-.2h-1.425a.52.52 0 0 0-.234.058.482.482 0 0 0-.209.205L132.191 5.2h-.349V.363a.37.37 0 0 0-.099-.26.352.352 0 0 0-.253-.103h-1.332a.37.37 0 0 0-.337.22.346.346 0 0 0-.027.143V9.29c0 .103.038.193.11.259a.353.353 0 0 0 .254.104h1.333a.328.328 0 0 0 .251-.105.346.346 0 0 0 .075-.119.333.333 0 0 0 .024-.14V6.927h.386l1.571 2.446c.112.187.267.281.46.281h1.491c.226 0 .32-.11.358-.202.054-.13.038-.262-.047-.406zM102.863 2.89h-1.489a.389.389 0 0 0-.298.122.544.544 0 0 0-.13.249l-1.099 4.167h-.268l-1.182-4.167a.66.66 0 0 0-.113-.247.329.329 0 0 0-.264-.124h-1.544c-.199 0-.325.066-.372.193a.588.588 0 0 0-.002.37l1.887 5.865c.03.093.08.17.145.232a.388.388 0 0 0 .281.104h.798l-.066.19-.19.547a.872.872 0 0 1-.29.426.7.7 0 0 1-.442.148.956.956 0 0 1-.4-.09 1.842 1.842 0 0 1-.35-.209.62.62 0 0 0-.335-.115h-.016c-.13 0-.243.074-.334.216l-.474.708c-.193.304-.086.504.039.615.234.224.528.399.875.524.344.125.723.186 1.126.186.682 0 1.252-.187 1.689-.565.435-.376.756-.887.952-1.524l2.188-7.258c.05-.155.05-.284.005-.389-.037-.08-.125-.174-.327-.174z" fill="#ffffff"/>\n </svg>\n'};return"\n <style>\n #inline-button-".concat(e.inlineId," {\n position: relative;\n text-align: center;\n display: inline-block;\n }\n #inline-button-").concat(e.inlineId,"__trigger {\n ").concat((n=e.variant||"normal",t={normal:"\n background: linear-gradient(180deg,#44b669 0,#40ad57);\n text-shadow: 1px 1px 1px rgba(0,0,0,.1);\n color: #ffffff;\n ",light:"\n background: white;\n text-shadow: none;\n color: #011b33;\n "},"".concat("\n box-sizing: border-box;\n display: inline-block;\n line-height: 1;\n white-space: nowrap;\n margin: 0 0 10px;\n text-align: center;\n -webkit-appearance: none;\n outline: none;\n font-size: 14px;\n font-weight: 600;\n border-radius: 6px;\n cursor: pointer;\n padding: 16px 24px;\n box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.15);\n transition: all .3s ease;\n border: none;\n min-width: 190px;\n ").concat(t[n])),"\n }\n #inline-button-").concat(e.inlineId,"__trigger:hover {\n box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.2);\n }\n #inline-button-").concat(e.inlineId,'__trigger:active {\n transform: translateY(3px);\n }\n </style>\n <button id="inline-button-').concat(e.inlineId,'__trigger" data-inline-id="').concat(e.inlineId,'">').concat(e.text||"Pay"," ").concat(e.currency||"NGN"," ").concat(e.amount,'</button>\n <div id="inline-button-').concat(e.inlineId,'__wordmark">\n ').concat(a[e.wordmarkVariant||"normal"],"\n </div>\n ")}(e),e.parent.parentNode.insertBefore(t,e.parent.nextSibling),n=c(t.getElementsByTagName("button"),1)[0]}return n}({inlineId:Ie.id,amount:Xe.amount/100,currency:Xe.currency,id:Xe.buttonId,text:Xe.buttonText,variant:Xe.buttonVariant,wordmarkVariant:Xe.buttonWordmarkVariant,parent:z()}).addEventListener("click",function(e){e.preventDefault(),Ze?Ie.resumeTransaction(Ze.accessCode):Ze=Ie.newTransaction(i(i({},Xe),{},{onSuccess:function(e){var n,t,a,r,o,i;n={type:"hidden",name:"reference",value:e.reference,parent:Ye},t=n.type,a=n.value,r=n.name,o=n.parent,(i=document.createElement("input")).type=t,i.value=a,i.name=r,o.appendChild(i),Ye.submit()}}))})}return Qe}();
1
+ var PaystackPop = (function () {
2
+ 'use strict';
3
+
4
+ function _arrayLikeToArray(r, a) {
5
+ (null == a || a > r.length) && (a = r.length);
6
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
7
+ return n;
8
+ }
9
+ function _arrayWithHoles(r) {
10
+ if (Array.isArray(r)) return r;
11
+ }
12
+ function _arrayWithoutHoles(r) {
13
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
14
+ }
15
+ function _classCallCheck(a, n) {
16
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
17
+ }
18
+ function _defineProperties(e, r) {
19
+ for (var t = 0; t < r.length; t++) {
20
+ var o = r[t];
21
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
22
+ }
23
+ }
24
+ function _createClass(e, r, t) {
25
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
26
+ writable: !1
27
+ }), e;
28
+ }
29
+ function _defineProperty(e, r, t) {
30
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
31
+ value: t,
32
+ enumerable: !0,
33
+ configurable: !0,
34
+ writable: !0
35
+ }) : e[r] = t, e;
36
+ }
37
+ function _iterableToArray(r) {
38
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
39
+ }
40
+ function _iterableToArrayLimit(r, l) {
41
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
42
+ if (null != t) {
43
+ var e,
44
+ n,
45
+ i,
46
+ u,
47
+ a = [],
48
+ f = !0,
49
+ o = !1;
50
+ try {
51
+ if (i = (t = t.call(r)).next, 0 === l) {
52
+ if (Object(t) !== t) return;
53
+ f = !1;
54
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
55
+ } catch (r) {
56
+ o = !0, n = r;
57
+ } finally {
58
+ try {
59
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
60
+ } finally {
61
+ if (o) throw n;
62
+ }
63
+ }
64
+ return a;
65
+ }
66
+ }
67
+ function _nonIterableRest() {
68
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
69
+ }
70
+ function _nonIterableSpread() {
71
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
72
+ }
73
+ function ownKeys(e, r) {
74
+ var t = Object.keys(e);
75
+ if (Object.getOwnPropertySymbols) {
76
+ var o = Object.getOwnPropertySymbols(e);
77
+ r && (o = o.filter(function (r) {
78
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
79
+ })), t.push.apply(t, o);
80
+ }
81
+ return t;
82
+ }
83
+ function _objectSpread2(e) {
84
+ for (var r = 1; r < arguments.length; r++) {
85
+ var t = null != arguments[r] ? arguments[r] : {};
86
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
87
+ _defineProperty(e, r, t[r]);
88
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
89
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
90
+ });
91
+ }
92
+ return e;
93
+ }
94
+ function _objectWithoutProperties(e, t) {
95
+ if (null == e) return {};
96
+ var o,
97
+ r,
98
+ i = _objectWithoutPropertiesLoose(e, t);
99
+ if (Object.getOwnPropertySymbols) {
100
+ var n = Object.getOwnPropertySymbols(e);
101
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
102
+ }
103
+ return i;
104
+ }
105
+ function _objectWithoutPropertiesLoose(r, e) {
106
+ if (null == r) return {};
107
+ var t = {};
108
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
109
+ if (-1 !== e.indexOf(n)) continue;
110
+ t[n] = r[n];
111
+ }
112
+ return t;
113
+ }
114
+ function _slicedToArray(r, e) {
115
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
116
+ }
117
+ function _toConsumableArray(r) {
118
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
119
+ }
120
+ function _toPrimitive(t, r) {
121
+ if ("object" != typeof t || !t) return t;
122
+ var e = t[Symbol.toPrimitive];
123
+ if (void 0 !== e) {
124
+ var i = e.call(t, r || "default");
125
+ if ("object" != typeof i) return i;
126
+ throw new TypeError("@@toPrimitive must return a primitive value.");
127
+ }
128
+ return ("string" === r ? String : Number)(t);
129
+ }
130
+ function _toPropertyKey(t) {
131
+ var i = _toPrimitive(t, "string");
132
+ return "symbol" == typeof i ? i : i + "";
133
+ }
134
+ function _typeof(o) {
135
+ "@babel/helpers - typeof";
136
+
137
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
138
+ return typeof o;
139
+ } : function (o) {
140
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
141
+ }, _typeof(o);
142
+ }
143
+ function _unsupportedIterableToArray(r, a) {
144
+ if (r) {
145
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
146
+ var t = {}.toString.call(r).slice(8, -1);
147
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
148
+ }
149
+ }
150
+
151
+ var baseConfig = {
152
+ cookieTestUrl: 'https://legacy-staging.paystack.co/test-iframe/start.html',
153
+ publishableKey: 'uFmz/uE/SDT6GupOrSEXIZXGByjQ0zFkPyc9LqKHFqnTI0WPN3JS5kQPo/j9or0TOXlqMQj2lzHn/UGsQT4XeQ==',
154
+ publicKey: '-----BEGIN PUBLIC KEY-----' + '\r\n' + 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALhZs/7hP0g0+hrqTq0hFyGVxgco0NMx' + '\r\n' + 'ZD8nPS6ihxap0yNFjzdyUuZED6P4/aK9Ezl5ajEI9pcx5/1BrEE+F3kCAwEAAQ==' + '\r\n' + '-----END PUBLIC KEY-----',
155
+ applePayVersion: 6,
156
+ applePayValidateSessionPath: 'applepay/validate-session/',
157
+ applePayChargePath: 'applepay/charge',
158
+ googlePayChargePath: 'googlepay/charge'
159
+ };
160
+ var devConfig = _objectSpread2(_objectSpread2({}, baseConfig), {}, {
161
+ environment: 'dev',
162
+ checkoutUrl: 'http://localhost:8081/',
163
+ paymentBaseUrl: 'https://legacy-staging.paystack.co/',
164
+ paystackApiUrl: 'https://studio-api.paystack.co/',
165
+ siteUrl: 'https://paystack.com',
166
+ pusherKey: '1c7b262ee18455815893',
167
+ pusherUrl: 'http://localhost:8081/static/vendor/pusher.min.js'
168
+ });
169
+ var stagingConfig = _objectSpread2(_objectSpread2({}, baseConfig), {}, {
170
+ environment: 'staging',
171
+ checkoutUrl: 'https://checkout-studio.paystack.com/',
172
+ paymentBaseUrl: 'https://legacy-staging.paystack.co/',
173
+ paystackApiUrl: 'https://studio-api.paystack.co/',
174
+ siteUrl: 'https://beta.paystack.com',
175
+ pusherKey: '1c7b262ee18455815893',
176
+ pusherUrl: 'https://checkout-studio.paystack.com/static/vendor/pusher.min.js'
177
+ });
178
+ var productionConfig = _objectSpread2(_objectSpread2({}, baseConfig), {}, {
179
+ environment: 'production',
180
+ checkoutUrl: 'https://checkout.paystack.com/',
181
+ paymentBaseUrl: 'https://standard.paystack.co/',
182
+ paystackApiUrl: 'https://api.paystack.co/',
183
+ siteUrl: 'https://paystack.com',
184
+ pusherKey: '8e4b9b7ca3418bd5cdc8',
185
+ pusherUrl: 'https://checkout.paystack.com/static/vendor/pusher.min.js'
186
+ });
187
+ var configurations = {
188
+ dev: devConfig,
189
+ staging: stagingConfig,
190
+ production: productionConfig
191
+ };
192
+
193
+ /* eslint-disable */
194
+ var config = configurations['staging'] || stagingConfig;
195
+
196
+ function randomId() {
197
+ var text = '';
198
+ var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
199
+ for (var i = 0; i < 5; i += 1) {
200
+ text += possible.charAt(Math.floor(Math.random() * possible.length));
201
+ }
202
+ return text;
203
+ }
204
+
205
+ function serialize(obj, prefix) {
206
+ var queryString = [];
207
+ Object.keys(obj).forEach(function (key) {
208
+ var updatedKey = prefix ? "".concat(prefix, "[").concat(key, "]") : key;
209
+ var value = obj[updatedKey];
210
+ queryString.push(value !== null && (typeof v === "undefined" ? "undefined" : _typeof(v)) === 'object' ? serialize(value, updatedKey) : "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value)));
211
+ });
212
+ return queryString.join('&');
213
+ }
214
+
215
+ function parseResponse(message) {
216
+ var action = message && typeof message === 'string' ? message.split(' ')[0] : null;
217
+ var data = action ? message.split(' ').slice(2).join(' ') : null;
218
+ return {
219
+ action: action,
220
+ data: data
221
+ };
222
+ }
223
+
224
+ function similarObjects(o1, o2) {
225
+ var equalKeys = Object.keys(o1).sort().join('') === Object.keys(o2).sort().join('');
226
+ var equalValues = Object.values(o1).sort().join('') === Object.values(o2).sort().join('');
227
+ return equalKeys && equalValues;
228
+ }
229
+
230
+ var APPLE_PAY_SDK_SOURCE = 'https://applepay.cdn-apple.com/jsapi/v1.3.8/apple-pay-sdk.js';
231
+ var APPLE_PAY_SDK_INTEGRITY_HASH = 'sha384-u/9mOkmShCO0v+dqCAZFhiutJuORfzvuyM5i+676iy7mLSWS6rlllHrIt15f/mqH';
232
+ var APPLE_PAY_TIMEOUT_MS = 10000;
233
+ var GOOGLE_PAY_SDK_SOURCE = 'https://pay.google.com/gp/p/js/pay.js';
234
+ var PAYMENT_REQUEST_BUTTON_HEIGHT = '50px';
235
+ var GOOGLE_PAY_BUTTON_RADIUS = 3;
236
+ var PAYMENT_REQUEST_BUTTON_ORIENTATION = {
237
+ HORIZONTAL: 'horizontal',
238
+ VERTICAL: 'vertical'
239
+ };
240
+ var PAYMENT_REQUEST_BUTTON_THEME = {
241
+ LIGHT: 'light',
242
+ DARK: 'dark'
243
+ };
244
+ var CHANNELS = {
245
+ APPLE_PAY: 'apple_pay',
246
+ GOOGLE_PAY: 'google_pay',
247
+ CARD: 'card'
248
+ };
249
+ var TRANSACTION_STATUS = {
250
+ SUCCESS: 'success',
251
+ FAILED: 'failed',
252
+ AUTH: 'auth'
253
+ };
254
+ var TRANSACTION_DOMAIN = {
255
+ TEST: 'test',
256
+ LIVE: 'live'
257
+ };
258
+ var ENVIRONMENT = {
259
+ DEV: 'dev',
260
+ STAGING: 'staging',
261
+ PRODUCTION: 'production'
262
+ };
263
+ var GOOGLE_PAY_STATUS_CODE = {
264
+ CANCELED: 'CANCELED',
265
+ DEVELOPER_ERROR: 'DEVELOPER_ERROR',
266
+ MERCHANT_ACCOUNT_ERROR: 'MERCHANT_ACCOUNT_ERROR'
267
+ };
268
+ var GOOGLE_PAY_TIMEOUT_MS = 10000;
269
+ var COUNTRYCODE = {
270
+ COTE_D_IVOIRE: 'CI',
271
+ GHANA: 'GH',
272
+ KENYA: 'KE',
273
+ NIGERIA: 'NG',
274
+ SOUTH_AFRICA: 'ZA',
275
+ EGYPT: 'EG'
276
+ };
277
+ var CURRENCY_COUNTRYCODE_MAPPING = {
278
+ XOF: COUNTRYCODE.COTE_D_IVOIRE,
279
+ GHS: COUNTRYCODE.GHANA,
280
+ KES: COUNTRYCODE.KENYA,
281
+ NGN: COUNTRYCODE.NIGERIA,
282
+ ZAR: COUNTRYCODE.SOUTH_AFRICA,
283
+ EGP: COUNTRYCODE.EGYPT
284
+ };
285
+
286
+ var withCardForGooglePay = function withCardForGooglePay(channels) {
287
+ var needsCard = Array.isArray(channels) && channels.includes(CHANNELS.GOOGLE_PAY) && !channels.includes(CHANNELS.CARD);
288
+ return needsCard ? [].concat(_toConsumableArray(channels), [CHANNELS.CARD]) : channels;
289
+ };
290
+
291
+ /* eslint-env browser */
292
+ function getLastScript() {
293
+ var scripts = document.getElementsByTagName('script');
294
+ return scripts[scripts.length - 1];
295
+ }
296
+ function getSourceScript() {
297
+ return document.currentScript || getLastScript();
298
+ }
299
+ function getDataAttributes() {
300
+ var dataAttributes = [];
301
+ var sourceScript = getSourceScript();
302
+ if (sourceScript) {
303
+ var attributes = Array.prototype.slice.call(sourceScript.attributes);
304
+ dataAttributes = Object.keys(attributes).filter(function (key) {
305
+ var element = attributes[key].nodeName;
306
+ return element && element.indexOf('data') > -1;
307
+ }).map(function (index) {
308
+ return attributes[index].nodeName;
309
+ });
310
+ }
311
+ return dataAttributes;
312
+ }
313
+ function scriptCanUseDataAttributes() {
314
+ var hasDataAttributes = getDataAttributes().length > 0;
315
+ var hasParentForm = getSourceScript() && getSourceScript().parentElement.tagName === 'FORM';
316
+ return hasDataAttributes && hasParentForm;
317
+ }
318
+ function getDataAttributesAsParameters() {
319
+ function convertToCamelCase(value) {
320
+ return value.replace(/-([a-z])/g, function (g) {
321
+ return g[1].toUpperCase();
322
+ });
323
+ }
324
+ function validateLazyParameters(parameters) {
325
+ if (parameters.buttonId && !document.getElementById(parameters.buttonId)) {
326
+ throw new Error('Please make sure the buttonId is an element available in the DOM');
327
+ }
328
+ var updatedParameters = _objectSpread2({}, parameters);
329
+ updatedParameters.buttonText = parameters.buttonText || 'Pay';
330
+ updatedParameters.buttonVariant = 'normal';
331
+ updatedParameters.buttonWordmarkVariant = 'normal';
332
+ var allowedVariants = ['normal', 'light'];
333
+ if (parameters.buttonVariant && allowedVariants.indexOf(parameters.buttonVariant) > -1) {
334
+ updatedParameters.buttonVariant = parameters.buttonVariant;
335
+ }
336
+ if (parameters.buttonWordmarkVariant && allowedVariants.indexOf(parameters.buttonWordmarkVariant) > -1) {
337
+ updatedParameters.buttonWordmarkVariant = parameters.buttonWordmarkVariant;
338
+ }
339
+ return updatedParameters;
340
+ }
341
+ var parameters = {};
342
+ var sourceScript = getSourceScript();
343
+ var dataAttributes = getDataAttributes();
344
+ dataAttributes.forEach(function (attribute) {
345
+ var attributeValue = sourceScript.getAttribute(attribute);
346
+ var attributeSplit = attribute.split('data-');
347
+ var attributeName = convertToCamelCase(attributeSplit[1]);
348
+ parameters[attributeName] = attributeValue;
349
+ });
350
+ return validateLazyParameters(parameters);
351
+ }
352
+
353
+ var secureByPaystack = "\n <svg id=\"inline-button-wordmark\" width=\"137\" height=\"13\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M.037 5.095l1.075-.135c-.011-.774-.025-1.944-.013-2.149C1.19 1.364 2.38.134 3.81.013 3.9.006 3.99.002 4.077 0a2.947 2.947 0 0 1 2.046.76c.574.509.95 1.26 1.008 2.007.015.192.01 1.491.01 2.257l1.096.163L8.2 11.44 4.093 12 0 11.346l.037-6.251zm4.106-.514l1.724.256c-.007-.933-.05-2.295-.26-2.654-.319-.545-.846-.867-1.443-.88h-.063c-.607.008-1.138.322-1.458.864-.222.378-.266 1.66-.265 2.637l1.765-.223zM18.228 10.108c-.576 0-1.064-.072-1.464-.216a2.864 2.864 0 0 1-.972-.6 2.552 2.552 0 0 1-.588-.864 4.067 4.067 0 0 1-.252-1.044h1.008c.032.256.088.5.168.732.08.224.204.424.372.6.168.168.388.304.66.408.28.096.636.144 1.068.144.28 0 .536-.036.768-.108.24-.08.448-.192.624-.336.176-.144.312-.316.408-.516.104-.2.156-.42.156-.66 0-.24-.032-.448-.096-.624a1.02 1.02 0 0 0-.336-.468 1.885 1.885 0 0 0-.636-.324 6.4 6.4 0 0 0-1.008-.228 8.79 8.79 0 0 1-1.212-.276 3.246 3.246 0 0 1-.9-.432 1.982 1.982 0 0 1-.564-.672c-.128-.272-.192-.6-.192-.984 0-.328.068-.632.204-.912.136-.288.324-.536.564-.744.248-.208.54-.372.876-.492.336-.12.708-.18 1.116-.18.864 0 1.548.204 2.052.612.512.4.812.984.9 1.752h-.936c-.104-.544-.316-.932-.636-1.164-.32-.24-.78-.36-1.38-.36-.592 0-1.04.132-1.344.396a1.255 1.255 0 0 0-.444.996c0 .208.024.396.072.564.056.16.156.3.3.42.152.12.36.228.624.324a6.72 6.72 0 0 0 1.068.228c.48.072.9.168 1.26.288.36.12.664.276.912.468s.432.428.552.708c.128.28.192.624.192 1.032 0 .36-.076.696-.228 1.008a2.472 2.472 0 0 1-.612.804c-.264.224-.58.4-.948.528-.36.128-.752.192-1.176.192zM25.355 10.108c-.44 0-.848-.076-1.224-.228a2.916 2.916 0 0 1-.96-.636 2.966 2.966 0 0 1-.636-1.008 3.77 3.77 0 0 1-.216-1.308v-.096c0-.472.072-.904.216-1.296.144-.4.344-.74.6-1.02.264-.288.576-.508.936-.66.36-.16.756-.24 1.188-.24.36 0 .708.06 1.044.18.344.112.648.292.912.54.264.248.472.572.624.972.16.392.24.868.24 1.428v.324h-4.728c.024.72.204 1.272.54 1.656.336.376.828.564 1.476.564.984 0 1.54-.364 1.668-1.092h.996c-.112.632-.408 1.112-.888 1.44-.48.32-1.076.48-1.788.48zm1.704-3.852c-.048-.648-.232-1.112-.552-1.392-.312-.28-.728-.42-1.248-.42-.512 0-.932.164-1.26.492-.32.32-.524.76-.612 1.32h3.672zM32.091 10.108c-.44 0-.848-.072-1.224-.216a3.054 3.054 0 0 1-.972-.636 3.12 3.12 0 0 1-.648-1.008 3.626 3.626 0 0 1-.228-1.32v-.096c0-.48.08-.916.24-1.308.16-.4.376-.74.648-1.02.28-.28.604-.496.972-.648.376-.16.772-.24 1.188-.24.328 0 .644.04.948.12.312.08.588.208.828.384.248.168.456.392.624.672.168.28.276.62.324 1.02h-.984c-.08-.496-.284-.848-.612-1.056-.32-.208-.696-.312-1.128-.312a1.93 1.93 0 0 0-.804.168c-.24.112-.452.272-.636.48a2.23 2.23 0 0 0-.42.744 2.991 2.991 0 0 0-.156.996v.096c0 .776.188 1.364.564 1.764.384.392.88.588 1.488.588.224 0 .436-.032.636-.096a1.651 1.651 0 0 0 .96-.768c.112-.192.18-.416.204-.672h.924a2.595 2.595 0 0 1-.276.948 2.386 2.386 0 0 1-.576.744c-.24.208-.52.372-.84.492-.32.12-.668.18-1.044.18zM38.335 10.108a2.83 2.83 0 0 1-.876-.132 1.724 1.724 0 0 1-.684-.42 2.145 2.145 0 0 1-.456-.756c-.112-.304-.168-.672-.168-1.104V3.724h.996v3.924c0 .552.116.956.348 1.212.24.256.608.384 1.104.384.224 0 .44-.036.648-.108.208-.072.392-.18.552-.324.16-.144.288-.324.384-.54.096-.216.144-.464.144-.744V3.724h.996V10h-.996v-.996c-.144.296-.388.556-.732.78-.336.216-.756.324-1.26.324zM43.216 3.724h.996v1.128c.2-.352.452-.64.756-.864.312-.232.748-.356 1.308-.372v.936a4.461 4.461 0 0 0-.852.12 1.647 1.647 0 0 0-.66.324 1.472 1.472 0 0 0-.408.612c-.096.248-.144.564-.144.948V10h-.996V3.724zM50 10.108c-.44 0-.848-.076-1.224-.228a2.916 2.916 0 0 1-.96-.636 2.966 2.966 0 0 1-.636-1.008 3.77 3.77 0 0 1-.216-1.308v-.096c0-.472.072-.904.216-1.296.144-.4.344-.74.6-1.02.264-.288.576-.508.936-.66.36-.16.756-.24 1.188-.24.36 0 .708.06 1.044.18.344.112.648.292.912.54.264.248.472.572.624.972.16.392.24.868.24 1.428v.324h-4.728c.024.72.204 1.272.54 1.656.336.376.828.564 1.476.564.984 0 1.54-.364 1.668-1.092h.996c-.112.632-.408 1.112-.888 1.44-.48.32-1.076.48-1.788.48zm1.704-3.852c-.048-.648-.232-1.112-.552-1.392-.312-.28-.728-.42-1.248-.42-.512 0-.932.164-1.26.492-.32.32-.524.76-.612 1.32h3.672zM56.496 10.108c-.408 0-.788-.068-1.14-.204a2.683 2.683 0 0 1-.9-.612 3.01 3.01 0 0 1-.588-.984 4.01 4.01 0 0 1-.204-1.32v-.096c0-.48.072-.92.216-1.32.144-.4.344-.744.6-1.032.256-.296.564-.524.924-.684.36-.16.756-.24 1.188-.24.528 0 .956.112 1.284.336.328.216.584.476.768.78V.724h.996V10h-.996V8.92c-.088.152-.208.3-.36.444a2.792 2.792 0 0 1-.516.384 2.874 2.874 0 0 1-.6.252c-.216.072-.44.108-.672.108zm.108-.828c.288 0 .56-.048.816-.144.256-.096.476-.24.66-.432.184-.2.328-.448.432-.744.112-.304.168-.656.168-1.056v-.096c0-.808-.18-1.404-.54-1.788-.352-.384-.836-.576-1.452-.576-.624 0-1.112.208-1.464.624-.352.416-.528 1.008-.528 1.776v.096c0 .392.048.736.144 1.032.104.296.24.54.408.732.176.192.38.336.612.432.232.096.48.144.744.144zM67.712 10.108c-.512 0-.948-.112-1.308-.336a2.38 2.38 0 0 1-.816-.804V10h-.996V.724h.996V4.78a1.92 1.92 0 0 1 .348-.432c.152-.144.32-.268.504-.372.192-.112.396-.2.612-.264.216-.064.436-.096.66-.096.408 0 .788.072 1.14.216.352.144.652.352.9.624.256.272.456.604.6.996.144.392.216.832.216 1.32v.096c0 .48-.068.92-.204 1.32a3.103 3.103 0 0 1-.576 1.02 2.583 2.583 0 0 1-.9.672 2.937 2.937 0 0 1-1.176.228zm-.096-.828c.624 0 1.1-.2 1.428-.6.328-.408.492-.996.492-1.764V6.82c0-.4-.052-.748-.156-1.044a2.095 2.095 0 0 0-.42-.732 1.53 1.53 0 0 0-.612-.444 1.798 1.798 0 0 0-.744-.156c-.288 0-.56.048-.816.144a1.71 1.71 0 0 0-.648.444c-.184.192-.328.44-.432.744a3.152 3.152 0 0 0-.156 1.044v.096c0 .8.192 1.396.576 1.788.384.384.88.576 1.488.576zM73.63 9.352l-2.46-5.628h1.068l1.92 4.5 1.74-4.5h1.02l-3.468 8.46h-1.008l1.188-2.832zM87.127 3.669A3.138 3.138 0 0 0 86.1 2.95a3.09 3.09 0 0 0-1.228-.25c-.448 0-.848.086-1.187.26a2.199 2.199 0 0 0-.662.497v-.191a.387.387 0 0 0-.214-.348.323.323 0 0 0-.14-.03h-1.315a.314.314 0 0 0-.254.116.377.377 0 0 0-.1.262v8.97c0 .1.034.188.1.258a.34.34 0 0 0 .254.103h1.341a.342.342 0 0 0 .244-.103.336.336 0 0 0 .11-.259v-3.06c.178.202.417.357.702.464.35.134.72.203 1.093.203.43 0 .848-.082 1.242-.248a3.124 3.124 0 0 0 1.04-.724c.305-.326.545-.709.707-1.128a3.93 3.93 0 0 0 .263-1.477c0-.54-.086-1.037-.263-1.477a3.387 3.387 0 0 0-.706-1.12zm-1.204 3.24c-.073.19-.18.362-.315.51a1.415 1.415 0 0 1-1.065.466c-.2.001-.4-.04-.584-.12a1.484 1.484 0 0 1-.49-.346 1.593 1.593 0 0 1-.32-.51 1.738 1.738 0 0 1-.115-.63c0-.224.04-.435.115-.631a1.532 1.532 0 0 1 .804-.846c.185-.086.386-.13.59-.129.215 0 .414.044.593.13.177.083.338.199.474.341a1.622 1.622 0 0 1 .425 1.135c0 .225-.037.436-.112.63zM95.298 2.89h-1.33a.339.339 0 0 0-.246.11.384.384 0 0 0-.108.266v.166a1.856 1.856 0 0 0-.602-.472 2.525 2.525 0 0 0-1.166-.258 3.227 3.227 0 0 0-2.284.964 3.554 3.554 0 0 0-.734 1.123 3.827 3.827 0 0 0-.275 1.477c0 .54.092 1.037.275 1.477.184.434.427.817.728 1.128a3.146 3.146 0 0 0 2.277.973c.437 0 .834-.088 1.173-.259.25-.13.456-.287.608-.471v.177a.34.34 0 0 0 .11.259.341.341 0 0 0 .244.104h1.33a.324.324 0 0 0 .25-.105.349.349 0 0 0 .102-.258V3.267a.377.377 0 0 0-.1-.262.325.325 0 0 0-.252-.115zM93.502 6.9a1.55 1.55 0 0 1-.312.511c-.136.143-.296.26-.473.344-.178.085-.38.129-.596.129-.207 0-.407-.044-.59-.13a1.501 1.501 0 0 1-.791-.855 1.766 1.766 0 0 1-.112-.62c0-.225.038-.436.112-.632.075-.193.181-.364.314-.504.137-.143.3-.26.478-.342.182-.085.382-.129.59-.129.215 0 .417.044.595.13.178.085.338.2.473.341a1.623 1.623 0 0 1 .424 1.135c0 .215-.037.424-.112.622zM108.567 6.094a2.265 2.265 0 0 0-.654-.402c-.247-.101-.509-.181-.785-.235l-1.014-.204c-.26-.05-.441-.117-.543-.203a.328.328 0 0 1-.136-.264c0-.11.063-.2.189-.282.137-.086.329-.13.566-.13.26 0 .518.053.757.157.243.106.471.226.67.36.295.187.546.162.727-.053l.487-.57a.543.543 0 0 0 .152-.357c0-.128-.064-.245-.185-.351-.207-.184-.533-.378-.971-.568-.437-.192-.987-.29-1.637-.29-.427 0-.82.058-1.168.172-.35.116-.65.276-.893.474-.245.204-.438.44-.57.713a2 2 0 0 0-.198.875c0 .56.167 1.017.496 1.358.328.333.766.56 1.304.67l1.054.232c.3.062.528.132.675.21.129.067.19.163.19.297 0 .12-.061.227-.188.324-.133.104-.342.155-.622.155a1.83 1.83 0 0 1-.831-.19 3.056 3.056 0 0 1-.678-.458.995.995 0 0 0-.307-.17c-.126-.037-.268.003-.431.13l-.583.461c-.169.145-.24.32-.209.522.029.194.19.394.491.62.269.193.614.368 1.029.518.415.151.901.229 1.453.229.444 0 .854-.058 1.215-.172.362-.119.681-.278.941-.48a2.056 2.056 0 0 0 .819-1.663c0-.319-.053-.6-.165-.836a1.843 1.843 0 0 0-.447-.6zM114.383 7.73a.363.363 0 0 0-.295-.192.55.55 0 0 0-.343.113c-.095.062-.198.11-.306.141a.75.75 0 0 1-.426.013.43.43 0 0 1-.181-.093.554.554 0 0 1-.143-.204.92.92 0 0 1-.059-.362v-2.46h1.731c.099 0 .188-.04.266-.117a.368.368 0 0 0 .112-.26V3.268a.369.369 0 0 0-.115-.268.38.38 0 0 0-.263-.109h-1.732V1.216a.354.354 0 0 0-.108-.27.347.347 0 0 0-.243-.104h-1.344a.36.36 0 0 0-.34.226.371.371 0 0 0-.027.148V2.89h-.767a.324.324 0 0 0-.255.115.385.385 0 0 0-.098.262V4.31a.4.4 0 0 0 .212.346c.044.021.092.032.14.03h.768v2.925c0 .39.069.726.2 1.003.132.274.305.504.514.676.217.178.465.31.731.388.27.084.551.126.833.126.385 0 .75-.061 1.094-.18a2.13 2.13 0 0 0 .861-.552c.152-.181.17-.381.046-.581l-.463-.76zM121.672 2.89h-1.329a.339.339 0 0 0-.244.11.39.39 0 0 0-.08.122.394.394 0 0 0-.027.144v.166a1.906 1.906 0 0 0-.605-.472c-.335-.173-.726-.258-1.168-.258-.42 0-.834.083-1.226.249a3.24 3.24 0 0 0-1.055.715 3.528 3.528 0 0 0-.734 1.123 3.79 3.79 0 0 0-.276 1.477c0 .54.092 1.037.275 1.477.184.434.428.817.729 1.128a3.138 3.138 0 0 0 2.273.973 2.59 2.59 0 0 0 1.175-.259c.255-.13.457-.287.612-.471v.177a.34.34 0 0 0 .108.259.343.343 0 0 0 .243.104h1.329a.335.335 0 0 0 .252-.105.364.364 0 0 0 .102-.258V3.267a.38.38 0 0 0-.1-.262.332.332 0 0 0-.115-.087.311.311 0 0 0-.139-.028zM119.876 6.9a1.534 1.534 0 0 1-.786.855 1.362 1.362 0 0 1-.594.129c-.207 0-.405-.044-.588-.13a1.516 1.516 0 0 1-.792-.855 1.757 1.757 0 0 1-.113-.62c0-.225.037-.436.112-.632.073-.187.179-.358.314-.504.138-.143.3-.26.479-.342.184-.086.385-.13.588-.129.217 0 .415.044.594.13.181.085.34.2.472.341.134.143.24.313.314.504a1.73 1.73 0 0 1 0 1.253zM128.978 7.64l-.763-.593c-.146-.118-.284-.15-.404-.1a.742.742 0 0 0-.279.205 2.527 2.527 0 0 1-.583.535c-.192.122-.444.183-.742.183-.219 0-.42-.04-.6-.122a1.423 1.423 0 0 1-.469-.342 1.575 1.575 0 0 1-.308-.51 1.751 1.751 0 0 1-.106-.617c0-.228.034-.438.106-.632.07-.192.173-.363.308-.503.135-.144.295-.26.472-.342.187-.088.391-.132.597-.13.298 0 .547.064.742.187.198.126.396.306.584.534.078.092.17.16.278.206.122.048.259.016.401-.101l.762-.594a.53.53 0 0 0 .201-.269.437.437 0 0 0-.034-.365 3.329 3.329 0 0 0-1.18-1.127c-.504-.291-1.108-.441-1.784-.441a3.519 3.519 0 0 0-2.51 1.033c-.322.322-.576.71-.747 1.137a3.68 3.68 0 0 0-.273 1.407c0 .495.093.968.273 1.402.173.424.427.808.747 1.128a3.527 3.527 0 0 0 2.51 1.034c.676 0 1.28-.149 1.784-.444a3.286 3.286 0 0 0 1.182-1.13.411.411 0 0 0 .055-.173.415.415 0 0 0-.023-.182.624.624 0 0 0-.197-.273zM136.06 9.045l-2.104-3.143 1.801-2.415c.094-.139.119-.272.075-.397-.031-.09-.116-.2-.334-.2h-1.425a.52.52 0 0 0-.234.058.482.482 0 0 0-.209.205L132.191 5.2h-.349V.363a.37.37 0 0 0-.099-.26.352.352 0 0 0-.253-.103h-1.332a.37.37 0 0 0-.337.22.346.346 0 0 0-.027.143V9.29c0 .103.038.193.11.259a.353.353 0 0 0 .254.104h1.333a.328.328 0 0 0 .251-.105.346.346 0 0 0 .075-.119.333.333 0 0 0 .024-.14V6.927h.386l1.571 2.446c.112.187.267.281.46.281h1.491c.226 0 .32-.11.358-.202.054-.13.038-.262-.047-.406zM102.863 2.89h-1.489a.389.389 0 0 0-.298.122.544.544 0 0 0-.13.249l-1.099 4.167h-.268l-1.182-4.167a.66.66 0 0 0-.113-.247.329.329 0 0 0-.264-.124h-1.544c-.199 0-.325.066-.372.193a.588.588 0 0 0-.002.37l1.887 5.865c.03.093.08.17.145.232a.388.388 0 0 0 .281.104h.798l-.066.19-.19.547a.872.872 0 0 1-.29.426.7.7 0 0 1-.442.148.956.956 0 0 1-.4-.09 1.842 1.842 0 0 1-.35-.209.62.62 0 0 0-.335-.115h-.016c-.13 0-.243.074-.334.216l-.474.708c-.193.304-.086.504.039.615.234.224.528.399.875.524.344.125.723.186 1.126.186.682 0 1.252-.187 1.689-.565.435-.376.756-.887.952-1.524l2.188-7.258c.05-.155.05-.284.005-.389-.037-.08-.125-.174-.327-.174z\" fill=\"#011B33\"/>\n </svg>";
354
+ var secureByPaystackWhite = "\n <svg id=\"inline-button-wordmark--white\" width=\"137\" height=\"13\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M.037 5.095l1.075-.135c-.011-.774-.025-1.944-.013-2.149C1.19 1.364 2.38.134 3.81.013 3.9.006 3.99.002 4.077 0a2.947 2.947 0 0 1 2.046.76c.574.509.95 1.26 1.008 2.007.015.192.01 1.491.01 2.257l1.096.163L8.2 11.44 4.093 12 0 11.346l.037-6.251zm4.106-.514l1.724.256c-.007-.933-.05-2.295-.26-2.654-.319-.545-.846-.867-1.443-.88h-.063c-.607.008-1.138.322-1.458.864-.222.378-.266 1.66-.265 2.637l1.765-.223zM18.228 10.108c-.576 0-1.064-.072-1.464-.216a2.864 2.864 0 0 1-.972-.6 2.552 2.552 0 0 1-.588-.864 4.067 4.067 0 0 1-.252-1.044h1.008c.032.256.088.5.168.732.08.224.204.424.372.6.168.168.388.304.66.408.28.096.636.144 1.068.144.28 0 .536-.036.768-.108.24-.08.448-.192.624-.336.176-.144.312-.316.408-.516.104-.2.156-.42.156-.66 0-.24-.032-.448-.096-.624a1.02 1.02 0 0 0-.336-.468 1.885 1.885 0 0 0-.636-.324 6.4 6.4 0 0 0-1.008-.228 8.79 8.79 0 0 1-1.212-.276 3.246 3.246 0 0 1-.9-.432 1.982 1.982 0 0 1-.564-.672c-.128-.272-.192-.6-.192-.984 0-.328.068-.632.204-.912.136-.288.324-.536.564-.744.248-.208.54-.372.876-.492.336-.12.708-.18 1.116-.18.864 0 1.548.204 2.052.612.512.4.812.984.9 1.752h-.936c-.104-.544-.316-.932-.636-1.164-.32-.24-.78-.36-1.38-.36-.592 0-1.04.132-1.344.396a1.255 1.255 0 0 0-.444.996c0 .208.024.396.072.564.056.16.156.3.3.42.152.12.36.228.624.324a6.72 6.72 0 0 0 1.068.228c.48.072.9.168 1.26.288.36.12.664.276.912.468s.432.428.552.708c.128.28.192.624.192 1.032 0 .36-.076.696-.228 1.008a2.472 2.472 0 0 1-.612.804c-.264.224-.58.4-.948.528-.36.128-.752.192-1.176.192zM25.355 10.108c-.44 0-.848-.076-1.224-.228a2.916 2.916 0 0 1-.96-.636 2.966 2.966 0 0 1-.636-1.008 3.77 3.77 0 0 1-.216-1.308v-.096c0-.472.072-.904.216-1.296.144-.4.344-.74.6-1.02.264-.288.576-.508.936-.66.36-.16.756-.24 1.188-.24.36 0 .708.06 1.044.18.344.112.648.292.912.54.264.248.472.572.624.972.16.392.24.868.24 1.428v.324h-4.728c.024.72.204 1.272.54 1.656.336.376.828.564 1.476.564.984 0 1.54-.364 1.668-1.092h.996c-.112.632-.408 1.112-.888 1.44-.48.32-1.076.48-1.788.48zm1.704-3.852c-.048-.648-.232-1.112-.552-1.392-.312-.28-.728-.42-1.248-.42-.512 0-.932.164-1.26.492-.32.32-.524.76-.612 1.32h3.672zM32.091 10.108c-.44 0-.848-.072-1.224-.216a3.054 3.054 0 0 1-.972-.636 3.12 3.12 0 0 1-.648-1.008 3.626 3.626 0 0 1-.228-1.32v-.096c0-.48.08-.916.24-1.308.16-.4.376-.74.648-1.02.28-.28.604-.496.972-.648.376-.16.772-.24 1.188-.24.328 0 .644.04.948.12.312.08.588.208.828.384.248.168.456.392.624.672.168.28.276.62.324 1.02h-.984c-.08-.496-.284-.848-.612-1.056-.32-.208-.696-.312-1.128-.312a1.93 1.93 0 0 0-.804.168c-.24.112-.452.272-.636.48a2.23 2.23 0 0 0-.42.744 2.991 2.991 0 0 0-.156.996v.096c0 .776.188 1.364.564 1.764.384.392.88.588 1.488.588.224 0 .436-.032.636-.096a1.651 1.651 0 0 0 .96-.768c.112-.192.18-.416.204-.672h.924a2.595 2.595 0 0 1-.276.948 2.386 2.386 0 0 1-.576.744c-.24.208-.52.372-.84.492-.32.12-.668.18-1.044.18zM38.335 10.108a2.83 2.83 0 0 1-.876-.132 1.724 1.724 0 0 1-.684-.42 2.145 2.145 0 0 1-.456-.756c-.112-.304-.168-.672-.168-1.104V3.724h.996v3.924c0 .552.116.956.348 1.212.24.256.608.384 1.104.384.224 0 .44-.036.648-.108.208-.072.392-.18.552-.324.16-.144.288-.324.384-.54.096-.216.144-.464.144-.744V3.724h.996V10h-.996v-.996c-.144.296-.388.556-.732.78-.336.216-.756.324-1.26.324zM43.216 3.724h.996v1.128c.2-.352.452-.64.756-.864.312-.232.748-.356 1.308-.372v.936a4.461 4.461 0 0 0-.852.12 1.647 1.647 0 0 0-.66.324 1.472 1.472 0 0 0-.408.612c-.096.248-.144.564-.144.948V10h-.996V3.724zM50 10.108c-.44 0-.848-.076-1.224-.228a2.916 2.916 0 0 1-.96-.636 2.966 2.966 0 0 1-.636-1.008 3.77 3.77 0 0 1-.216-1.308v-.096c0-.472.072-.904.216-1.296.144-.4.344-.74.6-1.02.264-.288.576-.508.936-.66.36-.16.756-.24 1.188-.24.36 0 .708.06 1.044.18.344.112.648.292.912.54.264.248.472.572.624.972.16.392.24.868.24 1.428v.324h-4.728c.024.72.204 1.272.54 1.656.336.376.828.564 1.476.564.984 0 1.54-.364 1.668-1.092h.996c-.112.632-.408 1.112-.888 1.44-.48.32-1.076.48-1.788.48zm1.704-3.852c-.048-.648-.232-1.112-.552-1.392-.312-.28-.728-.42-1.248-.42-.512 0-.932.164-1.26.492-.32.32-.524.76-.612 1.32h3.672zM56.496 10.108c-.408 0-.788-.068-1.14-.204a2.683 2.683 0 0 1-.9-.612 3.01 3.01 0 0 1-.588-.984 4.01 4.01 0 0 1-.204-1.32v-.096c0-.48.072-.92.216-1.32.144-.4.344-.744.6-1.032.256-.296.564-.524.924-.684.36-.16.756-.24 1.188-.24.528 0 .956.112 1.284.336.328.216.584.476.768.78V.724h.996V10h-.996V8.92c-.088.152-.208.3-.36.444a2.792 2.792 0 0 1-.516.384 2.874 2.874 0 0 1-.6.252c-.216.072-.44.108-.672.108zm.108-.828c.288 0 .56-.048.816-.144.256-.096.476-.24.66-.432.184-.2.328-.448.432-.744.112-.304.168-.656.168-1.056v-.096c0-.808-.18-1.404-.54-1.788-.352-.384-.836-.576-1.452-.576-.624 0-1.112.208-1.464.624-.352.416-.528 1.008-.528 1.776v.096c0 .392.048.736.144 1.032.104.296.24.54.408.732.176.192.38.336.612.432.232.096.48.144.744.144zM67.712 10.108c-.512 0-.948-.112-1.308-.336a2.38 2.38 0 0 1-.816-.804V10h-.996V.724h.996V4.78a1.92 1.92 0 0 1 .348-.432c.152-.144.32-.268.504-.372.192-.112.396-.2.612-.264.216-.064.436-.096.66-.096.408 0 .788.072 1.14.216.352.144.652.352.9.624.256.272.456.604.6.996.144.392.216.832.216 1.32v.096c0 .48-.068.92-.204 1.32a3.103 3.103 0 0 1-.576 1.02 2.583 2.583 0 0 1-.9.672 2.937 2.937 0 0 1-1.176.228zm-.096-.828c.624 0 1.1-.2 1.428-.6.328-.408.492-.996.492-1.764V6.82c0-.4-.052-.748-.156-1.044a2.095 2.095 0 0 0-.42-.732 1.53 1.53 0 0 0-.612-.444 1.798 1.798 0 0 0-.744-.156c-.288 0-.56.048-.816.144a1.71 1.71 0 0 0-.648.444c-.184.192-.328.44-.432.744a3.152 3.152 0 0 0-.156 1.044v.096c0 .8.192 1.396.576 1.788.384.384.88.576 1.488.576zM73.63 9.352l-2.46-5.628h1.068l1.92 4.5 1.74-4.5h1.02l-3.468 8.46h-1.008l1.188-2.832zM87.127 3.669A3.138 3.138 0 0 0 86.1 2.95a3.09 3.09 0 0 0-1.228-.25c-.448 0-.848.086-1.187.26a2.199 2.199 0 0 0-.662.497v-.191a.387.387 0 0 0-.214-.348.323.323 0 0 0-.14-.03h-1.315a.314.314 0 0 0-.254.116.377.377 0 0 0-.1.262v8.97c0 .1.034.188.1.258a.34.34 0 0 0 .254.103h1.341a.342.342 0 0 0 .244-.103.336.336 0 0 0 .11-.259v-3.06c.178.202.417.357.702.464.35.134.72.203 1.093.203.43 0 .848-.082 1.242-.248a3.124 3.124 0 0 0 1.04-.724c.305-.326.545-.709.707-1.128a3.93 3.93 0 0 0 .263-1.477c0-.54-.086-1.037-.263-1.477a3.387 3.387 0 0 0-.706-1.12zm-1.204 3.24c-.073.19-.18.362-.315.51a1.415 1.415 0 0 1-1.065.466c-.2.001-.4-.04-.584-.12a1.484 1.484 0 0 1-.49-.346 1.593 1.593 0 0 1-.32-.51 1.738 1.738 0 0 1-.115-.63c0-.224.04-.435.115-.631a1.532 1.532 0 0 1 .804-.846c.185-.086.386-.13.59-.129.215 0 .414.044.593.13.177.083.338.199.474.341a1.622 1.622 0 0 1 .425 1.135c0 .225-.037.436-.112.63zM95.298 2.89h-1.33a.339.339 0 0 0-.246.11.384.384 0 0 0-.108.266v.166a1.856 1.856 0 0 0-.602-.472 2.525 2.525 0 0 0-1.166-.258 3.227 3.227 0 0 0-2.284.964 3.554 3.554 0 0 0-.734 1.123 3.827 3.827 0 0 0-.275 1.477c0 .54.092 1.037.275 1.477.184.434.427.817.728 1.128a3.146 3.146 0 0 0 2.277.973c.437 0 .834-.088 1.173-.259.25-.13.456-.287.608-.471v.177a.34.34 0 0 0 .11.259.341.341 0 0 0 .244.104h1.33a.324.324 0 0 0 .25-.105.349.349 0 0 0 .102-.258V3.267a.377.377 0 0 0-.1-.262.325.325 0 0 0-.252-.115zM93.502 6.9a1.55 1.55 0 0 1-.312.511c-.136.143-.296.26-.473.344-.178.085-.38.129-.596.129-.207 0-.407-.044-.59-.13a1.501 1.501 0 0 1-.791-.855 1.766 1.766 0 0 1-.112-.62c0-.225.038-.436.112-.632.075-.193.181-.364.314-.504.137-.143.3-.26.478-.342.182-.085.382-.129.59-.129.215 0 .417.044.595.13.178.085.338.2.473.341a1.623 1.623 0 0 1 .424 1.135c0 .215-.037.424-.112.622zM108.567 6.094a2.265 2.265 0 0 0-.654-.402c-.247-.101-.509-.181-.785-.235l-1.014-.204c-.26-.05-.441-.117-.543-.203a.328.328 0 0 1-.136-.264c0-.11.063-.2.189-.282.137-.086.329-.13.566-.13.26 0 .518.053.757.157.243.106.471.226.67.36.295.187.546.162.727-.053l.487-.57a.543.543 0 0 0 .152-.357c0-.128-.064-.245-.185-.351-.207-.184-.533-.378-.971-.568-.437-.192-.987-.29-1.637-.29-.427 0-.82.058-1.168.172-.35.116-.65.276-.893.474-.245.204-.438.44-.57.713a2 2 0 0 0-.198.875c0 .56.167 1.017.496 1.358.328.333.766.56 1.304.67l1.054.232c.3.062.528.132.675.21.129.067.19.163.19.297 0 .12-.061.227-.188.324-.133.104-.342.155-.622.155a1.83 1.83 0 0 1-.831-.19 3.056 3.056 0 0 1-.678-.458.995.995 0 0 0-.307-.17c-.126-.037-.268.003-.431.13l-.583.461c-.169.145-.24.32-.209.522.029.194.19.394.491.62.269.193.614.368 1.029.518.415.151.901.229 1.453.229.444 0 .854-.058 1.215-.172.362-.119.681-.278.941-.48a2.056 2.056 0 0 0 .819-1.663c0-.319-.053-.6-.165-.836a1.843 1.843 0 0 0-.447-.6zM114.383 7.73a.363.363 0 0 0-.295-.192.55.55 0 0 0-.343.113c-.095.062-.198.11-.306.141a.75.75 0 0 1-.426.013.43.43 0 0 1-.181-.093.554.554 0 0 1-.143-.204.92.92 0 0 1-.059-.362v-2.46h1.731c.099 0 .188-.04.266-.117a.368.368 0 0 0 .112-.26V3.268a.369.369 0 0 0-.115-.268.38.38 0 0 0-.263-.109h-1.732V1.216a.354.354 0 0 0-.108-.27.347.347 0 0 0-.243-.104h-1.344a.36.36 0 0 0-.34.226.371.371 0 0 0-.027.148V2.89h-.767a.324.324 0 0 0-.255.115.385.385 0 0 0-.098.262V4.31a.4.4 0 0 0 .212.346c.044.021.092.032.14.03h.768v2.925c0 .39.069.726.2 1.003.132.274.305.504.514.676.217.178.465.31.731.388.27.084.551.126.833.126.385 0 .75-.061 1.094-.18a2.13 2.13 0 0 0 .861-.552c.152-.181.17-.381.046-.581l-.463-.76zM121.672 2.89h-1.329a.339.339 0 0 0-.244.11.39.39 0 0 0-.08.122.394.394 0 0 0-.027.144v.166a1.906 1.906 0 0 0-.605-.472c-.335-.173-.726-.258-1.168-.258-.42 0-.834.083-1.226.249a3.24 3.24 0 0 0-1.055.715 3.528 3.528 0 0 0-.734 1.123 3.79 3.79 0 0 0-.276 1.477c0 .54.092 1.037.275 1.477.184.434.428.817.729 1.128a3.138 3.138 0 0 0 2.273.973 2.59 2.59 0 0 0 1.175-.259c.255-.13.457-.287.612-.471v.177a.34.34 0 0 0 .108.259.343.343 0 0 0 .243.104h1.329a.335.335 0 0 0 .252-.105.364.364 0 0 0 .102-.258V3.267a.38.38 0 0 0-.1-.262.332.332 0 0 0-.115-.087.311.311 0 0 0-.139-.028zM119.876 6.9a1.534 1.534 0 0 1-.786.855 1.362 1.362 0 0 1-.594.129c-.207 0-.405-.044-.588-.13a1.516 1.516 0 0 1-.792-.855 1.757 1.757 0 0 1-.113-.62c0-.225.037-.436.112-.632.073-.187.179-.358.314-.504.138-.143.3-.26.479-.342.184-.086.385-.13.588-.129.217 0 .415.044.594.13.181.085.34.2.472.341.134.143.24.313.314.504a1.73 1.73 0 0 1 0 1.253zM128.978 7.64l-.763-.593c-.146-.118-.284-.15-.404-.1a.742.742 0 0 0-.279.205 2.527 2.527 0 0 1-.583.535c-.192.122-.444.183-.742.183-.219 0-.42-.04-.6-.122a1.423 1.423 0 0 1-.469-.342 1.575 1.575 0 0 1-.308-.51 1.751 1.751 0 0 1-.106-.617c0-.228.034-.438.106-.632.07-.192.173-.363.308-.503.135-.144.295-.26.472-.342.187-.088.391-.132.597-.13.298 0 .547.064.742.187.198.126.396.306.584.534.078.092.17.16.278.206.122.048.259.016.401-.101l.762-.594a.53.53 0 0 0 .201-.269.437.437 0 0 0-.034-.365 3.329 3.329 0 0 0-1.18-1.127c-.504-.291-1.108-.441-1.784-.441a3.519 3.519 0 0 0-2.51 1.033c-.322.322-.576.71-.747 1.137a3.68 3.68 0 0 0-.273 1.407c0 .495.093.968.273 1.402.173.424.427.808.747 1.128a3.527 3.527 0 0 0 2.51 1.034c.676 0 1.28-.149 1.784-.444a3.286 3.286 0 0 0 1.182-1.13.411.411 0 0 0 .055-.173.415.415 0 0 0-.023-.182.624.624 0 0 0-.197-.273zM136.06 9.045l-2.104-3.143 1.801-2.415c.094-.139.119-.272.075-.397-.031-.09-.116-.2-.334-.2h-1.425a.52.52 0 0 0-.234.058.482.482 0 0 0-.209.205L132.191 5.2h-.349V.363a.37.37 0 0 0-.099-.26.352.352 0 0 0-.253-.103h-1.332a.37.37 0 0 0-.337.22.346.346 0 0 0-.027.143V9.29c0 .103.038.193.11.259a.353.353 0 0 0 .254.104h1.333a.328.328 0 0 0 .251-.105.346.346 0 0 0 .075-.119.333.333 0 0 0 .024-.14V6.927h.386l1.571 2.446c.112.187.267.281.46.281h1.491c.226 0 .32-.11.358-.202.054-.13.038-.262-.047-.406zM102.863 2.89h-1.489a.389.389 0 0 0-.298.122.544.544 0 0 0-.13.249l-1.099 4.167h-.268l-1.182-4.167a.66.66 0 0 0-.113-.247.329.329 0 0 0-.264-.124h-1.544c-.199 0-.325.066-.372.193a.588.588 0 0 0-.002.37l1.887 5.865c.03.093.08.17.145.232a.388.388 0 0 0 .281.104h.798l-.066.19-.19.547a.872.872 0 0 1-.29.426.7.7 0 0 1-.442.148.956.956 0 0 1-.4-.09 1.842 1.842 0 0 1-.35-.209.62.62 0 0 0-.335-.115h-.016c-.13 0-.243.074-.334.216l-.474.708c-.193.304-.086.504.039.615.234.224.528.399.875.524.344.125.723.186 1.126.186.682 0 1.252-.187 1.689-.565.435-.376.756-.887.952-1.524l2.188-7.258c.05-.155.05-.284.005-.389-.037-.08-.125-.174-.327-.174z\" fill=\"#ffffff\"/>\n </svg>\n";
355
+
356
+ var loaderHTML = "\n <!DOCTYPE html>\n <html lang=\"en\">\n\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n <title>Paystack Popup Loader</title>\n <style>\n .app-loader {\n margin: 200px 0;\n text-align: center;\n color: white;\n }\n @keyframes app-loader__spinner {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n @-webkit-keyframes app-loader__spinner {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n .app-loader__spinner {\n position: relative;\n display: inline-block;\n }\n .app-loader__spinner div {\n left: 95px;\n top: 35px;\n position: absolute;\n -webkit-animation: app-loader__spinner linear 1s infinite;\n animation: app-loader__spinner linear 1s infinite;\n background: white;\n width: 10px;\n height: 30px;\n border-radius: 40%;\n -webkit-transform-origin: 5px 65px;\n transform-origin: 5px 65px;\n }\n .app-loader__spinner div:nth-child(1) {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n -webkit-animation-delay: -0.916666666666667s;\n animation-delay: -0.916666666666667s;\n }\n .app-loader__spinner div:nth-child(2) {\n -webkit-transform: rotate(30deg);\n transform: rotate(30deg);\n -webkit-animation-delay: -0.833333333333333s;\n animation-delay: -0.833333333333333s;\n }\n .app-loader__spinner div:nth-child(3) {\n -webkit-transform: rotate(60deg);\n transform: rotate(60deg);\n -webkit-animation-delay: -0.75s;\n animation-delay: -0.75s;\n }\n .app-loader__spinner div:nth-child(4) {\n -webkit-transform: rotate(90deg);\n transform: rotate(90deg);\n -webkit-animation-delay: -0.666666666666667s;\n animation-delay: -0.666666666666667s;\n }\n .app-loader__spinner div:nth-child(5) {\n -webkit-transform: rotate(120deg);\n transform: rotate(120deg);\n -webkit-animation-delay: -0.583333333333333s;\n animation-delay: -0.583333333333333s;\n }\n .app-loader__spinner div:nth-child(6) {\n -webkit-transform: rotate(150deg);\n transform: rotate(150deg);\n -webkit-animation-delay: -0.5s;\n animation-delay: -0.5s;\n }\n .app-loader__spinner div:nth-child(7) {\n -webkit-transform: rotate(180deg);\n transform: rotate(180deg);\n -webkit-animation-delay: -0.416666666666667s;\n animation-delay: -0.416666666666667s;\n }\n .app-loader__spinner div:nth-child(8) {\n -webkit-transform: rotate(210deg);\n transform: rotate(210deg);\n -webkit-animation-delay: -0.333333333333333s;\n animation-delay: -0.333333333333333s;\n }\n .app-loader__spinner div:nth-child(9) {\n -webkit-transform: rotate(240deg);\n transform: rotate(240deg);\n -webkit-animation-delay: -0.25s;\n animation-delay: -0.25s;\n }\n .app-loader__spinner div:nth-child(10) {\n -webkit-transform: rotate(270deg);\n transform: rotate(270deg);\n -webkit-animation-delay: -0.166666666666667s;\n animation-delay: -0.166666666666667s;\n }\n .app-loader__spinner div:nth-child(11) {\n -webkit-transform: rotate(300deg);\n transform: rotate(300deg);\n -webkit-animation-delay: -0.083333333333333s;\n animation-delay: -0.083333333333333s;\n }\n .app-loader__spinner div:nth-child(12) {\n -webkit-transform: rotate(330deg);\n transform: rotate(330deg);\n -webkit-animation-delay: 0s;\n animation-delay: 0s;\n }\n .app-loader__spinner {\n width: 40px;\n height: 40px;\n -webkit-transform: translate(-20px, -20px) scale(0.2) translate(20px, 20px);\n transform: translate(-20px, -20px) scale(0.2) translate(20px, 20px);\n }\n </style>\n </head>\n\n <body>\n <div id=\"app-loader\" class=\"app-loader\">\n <div id=\"spinner\" class=\"app-loader__spinner\">\n <div></div><div></div><div></div><div></div><div></div><div></div><div>\n </div><div></div><div></div><div></div><div></div><div></div>\n </div>\n </div>\n </body>\n\n </html>\n";
357
+ var backgroundCSS = "\n z-index: 999999999999999;\n background: transparent;\n background: rgba(0, 0, 0, 0.75);\n border: 0px none transparent;\n overflow-x: hidden;\n overflow-y: hidden;\n margin: 0;\n padding: 0;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n position: fixed;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n transition: opacity 0.3s;\n -webkit-transition: opacity 0.3s;\n visibility: hidden;\n display: none;\n";
358
+ var checkoutCSS = "\n z-index: 999999999999999;\n background: transparent;\n border: 0px none transparent;\n overflow-x: hidden;\n overflow-y: hidden;\n margin: 0;\n padding: 0;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n position: fixed;\n left: 0;\n top: 0;\n width: 100%;\n visibility: hidden;\n display: none;\n height: 100%;\n";
359
+ var embedCSS = "\n background: transparent;\n background: rgba(0,0,0,0);\n border: 0px none transparent;\n overflow-x: hidden;\n overflow-y: hidden;\n nmargin: 0;\n padding: 0;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n visibility: hidden;\n display: none;\n";
360
+ function generateInlineButtonCSS(variant) {
361
+ var baseCSS = "\n box-sizing: border-box;\n display: inline-block;\n line-height: 1;\n white-space: nowrap;\n margin: 0 0 10px;\n text-align: center;\n -webkit-appearance: none;\n outline: none;\n font-size: 14px;\n font-weight: 600;\n border-radius: 6px;\n cursor: pointer;\n padding: 16px 24px;\n box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.15);\n transition: all .3s ease;\n border: none;\n min-width: 190px;\n ";
362
+ var greenCSS = "\n background: linear-gradient(180deg,#44b669 0,#40ad57);\n text-shadow: 1px 1px 1px rgba(0,0,0,.1);\n color: #ffffff;\n ";
363
+ var whiteCSS = "\n background: white;\n text-shadow: none;\n color: #011b33;\n ";
364
+ var colorVariants = {
365
+ normal: greenCSS,
366
+ light: whiteCSS
367
+ };
368
+ return "".concat(baseCSS).concat(colorVariants[variant]);
369
+ }
370
+ function generateInlineButtonHTML(options) {
371
+ var wordmarkVariants = {
372
+ normal: secureByPaystack,
373
+ light: secureByPaystackWhite
374
+ };
375
+ var buttonHTML = "\n <style>\n #inline-button-".concat(options.inlineId, " {\n position: relative;\n text-align: center;\n display: inline-block;\n }\n #inline-button-").concat(options.inlineId, "__trigger {\n ").concat(generateInlineButtonCSS(options.variant || 'normal'), "\n }\n #inline-button-").concat(options.inlineId, "__trigger:hover {\n box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.2);\n }\n #inline-button-").concat(options.inlineId, "__trigger:active {\n transform: translateY(3px);\n }\n </style>\n <button id=\"inline-button-").concat(options.inlineId, "__trigger\" data-inline-id=\"").concat(options.inlineId, "\">").concat(options.text || 'Pay', " ").concat(options.currency || 'NGN', " ").concat(options.amount, "</button>\n <div id=\"inline-button-").concat(options.inlineId, "__wordmark\">\n ").concat(wordmarkVariants[options.wordmarkVariant || 'normal'], "\n </div>\n ");
376
+ return buttonHTML;
377
+ }
378
+ var defaultCustomApplePayStyles = {
379
+ height: PAYMENT_REQUEST_BUTTON_HEIGHT,
380
+ width: 'auto',
381
+ borderRadius: '3px',
382
+ padding: '10px',
383
+ locale: 'en',
384
+ type: 'pay'
385
+ };
386
+ var parseApplePayCustomStyles = function parseApplePayCustomStyles(styles) {
387
+ if (!(styles && _typeof(styles) === 'object')) {
388
+ return defaultCustomApplePayStyles;
389
+ }
390
+ var customStyles = Object.keys(defaultCustomApplePayStyles).reduce(function (newDefaultStyles, key) {
391
+ return _objectSpread2(_objectSpread2({}, newDefaultStyles), {}, _defineProperty({}, key, styles[key] || defaultCustomApplePayStyles[key]));
392
+ }, {});
393
+ return customStyles;
394
+ };
395
+ var generateApplePayCSS = function generateApplePayCSS(_ref) {
396
+ var height = _ref.height,
397
+ width = _ref.width,
398
+ borderRadius = _ref.borderRadius,
399
+ padding = _ref.padding;
400
+ return "\n apple-pay-button {\n --apple-pay-button-width: ".concat(width, ";\n --apple-pay-button-height: ").concat(height, ";\n --apple-pay-button-border-radius: ").concat(borderRadius, ";\n --apple-pay-button-padding: ").concat(padding, ";\n --apple-pay-button-box-sizing: border-box;\n width: ").concat(width, ";\n }\n");
401
+ };
402
+ var generateApplePayFallbackCSS = function generateApplePayFallbackCSS(_ref2) {
403
+ var height = _ref2.height,
404
+ width = _ref2.width,
405
+ borderRadius = _ref2.borderRadius,
406
+ padding = _ref2.padding,
407
+ type = _ref2.type,
408
+ locale = _ref2.locale;
409
+ return "\n @supports (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n -webkit-appearance: -apple-pay-button;\n width: ".concat(width, ";\n height: ").concat(height, ";\n border-radius: ").concat(borderRadius, ";\n padding: ").concat(padding, ";\n -apple-pay-button-type: ").concat(type, ";\n -webkit-locale: ").concat(locale, ";\n }\n .apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n .apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n .apple-pay-button-white-with-line {\n -apple-pay-button-style: white-outline;\n }\n }\n\n @supports not (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n background-size: 100% 60%;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n border-radius: 5px;\n padding: 0px;\n box-sizing: border-box;\n min-width: 200px;\n min-height: 32px;\n max-height: 64px;\n }\n .apple-pay-button-black {\n background-image: -webkit-named-image(apple-pay-logo-white);\n background-color: black;\n }\n .apple-pay-button-white {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n }\n .apple-pay-button-white-with-line {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n border: .5px solid black;\n }\n }\n");
410
+ };
411
+ var generatePaymentRequestInnerWrapperCSS = function generatePaymentRequestInnerWrapperCSS(orientation) {
412
+ var isVertical = orientation === PAYMENT_REQUEST_BUTTON_ORIENTATION.VERTICAL;
413
+ return "\n #paystack-payment-request-inner-wrapper {\n display: flex;\n flex-direction: ".concat(isVertical ? 'column' : 'row', ";\n gap: 8px;\n width: 100%;\n max-width: 100%;\n }\n\n #paystack-payment-request-inner-wrapper > * {\n min-width: 0;\n ").concat(isVertical ? '' : 'flex: 1 1 0;', "\n }\n\n #paystack-payment-request-inner-wrapper > apple-pay-button,\n #paystack-payment-request-inner-wrapper > #apple-pay-button {\n order: 1;\n }\n #paystack-payment-request-inner-wrapper > #google-pay-button-container {\n order: 2;\n }\n");
414
+ };
415
+ var generateGooglePayCSS = function generateGooglePayCSS() {
416
+ var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
417
+ height = _ref3.height,
418
+ width = _ref3.width;
419
+ return "\n #google-pay-button-container {\n width: ".concat(width || 'auto', ";\n height: ").concat(height || PAYMENT_REQUEST_BUTTON_HEIGHT, ";\n overflow: hidden;\n }\n #google-pay-button-container:empty {\n display: none;\n }\n #google-pay-button-container > div,\n #google-pay-button-container button,\n #google-pay-button-container iframe {\n width: 100%;\n max-width: 100%;\n height: 100%;\n min-width: 100%;\n }\n #google-pay-button-container button {\n outline: none !important;\n }\n");
420
+ };
421
+ var generateGooglePayLoadingCSS = function generateGooglePayLoadingCSS() {
422
+ var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
423
+ borderRadius = _ref4.borderRadius,
424
+ buttonColor = _ref4.buttonColor;
425
+ var isWhite = buttonColor === 'white';
426
+ return "\n #google-pay-loading-button {\n width: 100%;\n height: 100%;\n border: ".concat(isWhite ? '1px solid #3C4043' : 'none', ";\n border-radius: ").concat(borderRadius === undefined ? GOOGLE_PAY_BUTTON_RADIUS : borderRadius, "px;\n background: ").concat(isWhite ? '#ffffff' : '#000000', ";\n cursor: default;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n #google-pay-loading-button__spinner {\n width: 18px;\n height: 18px;\n border: 2px solid ").concat(isWhite ? 'rgba(60, 64, 67, 0.25)' : 'rgba(255, 255, 255, 0.35)', ";\n border-top-color: ").concat(isWhite ? '#3c4043' : '#ffffff', ";\n border-radius: 50%;\n animation: google-pay-spin 0.8s linear infinite;\n }\n @keyframes google-pay-spin {\n to { transform: rotate(360deg); }\n }\n");
427
+ };
428
+ function appendCSS(container, css) {
429
+ var style = document.createElement('style');
430
+ style.type = 'text/css';
431
+ style.textContent = css;
432
+ container.appendChild(style);
433
+ }
434
+
435
+ var amountSubunitToBase = function amountSubunitToBase() {
436
+ var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
437
+ return Number(parseFloat(amount / 100).toFixed(2));
438
+ };
439
+
440
+ /* eslint-disable prefer-promise-reject-errors */
441
+ /* eslint-env browser */
442
+
443
+ var loadScript = function loadScript(url) {
444
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
445
+ container = _ref.container,
446
+ integrity = _ref.integrity;
447
+ return new Promise(function (resolve, reject) {
448
+ if (!url) {
449
+ reject('No script url');
450
+ return;
451
+ }
452
+ var script = document.createElement('script');
453
+ script.src = url;
454
+ if (integrity) {
455
+ script.crossOrigin = 'anonymous';
456
+ script.integrity = integrity;
457
+ }
458
+ script.addEventListener('load', function () {
459
+ resolve(true);
460
+ });
461
+ script.addEventListener('error', function () {
462
+ script.remove();
463
+ reject(false);
464
+ });
465
+ if (container) {
466
+ container.appendChild(script);
467
+ } else {
468
+ document.head.appendChild(script);
469
+ }
470
+ });
471
+ };
472
+
473
+ var withTimeoutDelay = function withTimeoutDelay(work, delayInMilliseconds) {
474
+ var onTimeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
475
+ return null;
476
+ };
477
+ var timeout;
478
+ var delay = new Promise(function (resolve) {
479
+ timeout = setTimeout(function () {
480
+ try {
481
+ resolve(onTimeout());
482
+ } catch (error) {
483
+ resolve(null);
484
+ }
485
+ }, delayInMilliseconds);
486
+ });
487
+ return Promise.race([work, delay]).finally(function () {
488
+ return clearTimeout(timeout);
489
+ });
490
+ };
491
+
492
+ /* eslint-env browser */
493
+
494
+ var iOSDevices = ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'];
495
+
496
+ /**
497
+ * navigator.platform is deprecated and will eventually be removed
498
+ * but the recommended alternative `navigator.userAgentData` has limited browser support
499
+ * so it is used as a fallback here.
500
+ */
501
+ var DEVICE_PLATFORM = window && window.navigator && (window.navigator.platform || window.navigator.userAgentData && window.navigator.userAgentData.platform);
502
+ var getDeviceInfo = function getDeviceInfo() {
503
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
504
+ platform = _ref.platform,
505
+ _ref$userAgent = _ref.userAgent,
506
+ userAgent = _ref$userAgent === void 0 ? window && window.navigator && window.navigator.userAgent : _ref$userAgent;
507
+ return {
508
+ devicePlatform: platform || DEVICE_PLATFORM,
509
+ deviceUserAgent: userAgent
510
+ };
511
+ };
512
+ var isIOS = function isIOS() {
513
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
514
+ var _getDeviceInfo = getDeviceInfo(options),
515
+ devicePlatform = _getDeviceInfo.devicePlatform,
516
+ deviceUserAgent = _getDeviceInfo.deviceUserAgent;
517
+ return iOSDevices.includes(devicePlatform) ||
518
+ // iPAD os safari detection. iPad OS uses the same version of safari as Mac OS
519
+ deviceUserAgent.includes('Mac') && 'ontouchend' in document;
520
+ };
521
+ var isSafari = function isSafari() {
522
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
523
+ var _getDeviceInfo2 = getDeviceInfo(options),
524
+ deviceUserAgent = _getDeviceInfo2.deviceUserAgent;
525
+ return Boolean(deviceUserAgent && !/Android/.test(deviceUserAgent) && !/EdgiOS/.test(deviceUserAgent) && /Version\/[\d.]+.*Safari/.test(deviceUserAgent));
526
+ };
527
+
528
+ // Safari and third-party iOS browsers both send a `Safari/` token; an embedded WKWebView sends none.
529
+ var isIOSWebView = function isIOSWebView() {
530
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
531
+ var _getDeviceInfo3 = getDeviceInfo(options),
532
+ deviceUserAgent = _getDeviceInfo3.deviceUserAgent;
533
+ return Boolean(deviceUserAgent) && isIOS(options) && !/Safari\//.test(deviceUserAgent);
534
+ };
535
+ var isAppleOS = function isAppleOS() {
536
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
537
+ var _getDeviceInfo4 = getDeviceInfo(options),
538
+ devicePlatform = _getDeviceInfo4.devicePlatform;
539
+ return isIOS(options) || Boolean(devicePlatform && /Mac/i.test(devicePlatform));
540
+ };
541
+
542
+ var APPLE_PAY_UNSUPPORTED = 'applePayUnsupported';
543
+ var hasNativeSupportCache = null;
544
+ var sdkLoad = null;
545
+ var requestConfig = {
546
+ headers: {
547
+ accept: 'application/json, text/plain, */*',
548
+ 'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
549
+ 'content-type': 'application/x-www-form-urlencoded',
550
+ 'sec-ch-ua-mobile': '?0',
551
+ 'sec-fetch-dest': 'empty',
552
+ 'sec-fetch-mode': 'cors',
553
+ 'sec-fetch-site': 'cross-site'
554
+ },
555
+ referrerPolicy: 'no-referrer-when-downgrade',
556
+ method: 'POST',
557
+ mode: 'cors',
558
+ credentials: 'omit'
559
+ };
560
+ function createFormBody(params) {
561
+ var formBody = Object.keys(params).reduce(function (formBodyArray, key) {
562
+ var encodedKey = encodeURIComponent(key);
563
+ var encodedValue = encodeURIComponent(params[key]);
564
+ var encodedFormBody = "".concat(encodedKey, "=").concat(encodedValue);
565
+ return [].concat(_toConsumableArray(formBodyArray), [encodedFormBody]);
566
+ }, []);
567
+ return formBody.join('&');
568
+ }
569
+ var formatIntervalString = function formatIntervalString(interval) {
570
+ var plans = {
571
+ biannually: 'BIANNUAL PLAN',
572
+ annually: 'ANNUAL PLAN'
573
+ };
574
+ return plans[interval] || "".concat(interval.toUpperCase(), " PLAN");
575
+ };
576
+ var generateApplePaymentRequestObject = function generateApplePaymentRequestObject(_ref) {
577
+ var currency = _ref.currency,
578
+ amount = _ref.amount,
579
+ merchantName = _ref.merchantName,
580
+ interval = _ref.interval,
581
+ merchantCountryCode = _ref.merchantCountryCode;
582
+ return _objectSpread2({
583
+ countryCode: merchantCountryCode || COUNTRYCODE.NIGERIA,
584
+ currencyCode: currency,
585
+ merchantCapabilities: ['supports3DS', 'supportsCredit', 'supportsDebit'],
586
+ supportedNetworks: ['visa', 'masterCard'],
587
+ requiredBillingContactFields: ['postalAddress', 'name', 'phone', 'email'],
588
+ total: {
589
+ label: "".concat(merchantName, " - Paystack"),
590
+ type: 'final',
591
+ amount: String(amountSubunitToBase(amount))
592
+ }
593
+ }, typeof interval === 'string' && interval.trim() !== '' && {
594
+ lineItems: [{
595
+ label: formatIntervalString(interval),
596
+ amount: String(amountSubunitToBase(amount))
597
+ }]
598
+ });
599
+ };
600
+ var validateApplePaySession = function validateApplePaySession(_ref2) {
601
+ var transactionId = _ref2.transactionId,
602
+ accessCode = _ref2.accessCode,
603
+ publicKey = _ref2.publicKey,
604
+ validationURL = _ref2.validationURL,
605
+ merchantName = _ref2.merchantName,
606
+ _ref2$domainName = _ref2.domainName,
607
+ domainName = _ref2$domainName === void 0 ? window && window.location && window.location.hostname : _ref2$domainName;
608
+ var validateSessionUrl = "".concat(config.paymentBaseUrl).concat(config.applePayValidateSessionPath);
609
+
610
+ // createFormBody would send a missing value as the text "undefined"
611
+ var params = _objectSpread2(_objectSpread2(_objectSpread2({
612
+ transaction: transactionId
613
+ }, accessCode && {
614
+ accessCode: accessCode
615
+ }), publicKey && {
616
+ publicKey: publicKey
617
+ }), {}, {
618
+ sessionUrl: validationURL,
619
+ displayName: merchantName,
620
+ domainName: domainName
621
+ });
622
+ var formBody = createFormBody(params);
623
+ var validateSession = fetch(validateSessionUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
624
+ body: formBody
625
+ })).then(function (response) {
626
+ return response.json();
627
+ });
628
+ return validateSession;
629
+ };
630
+ var chargeApplePay = function chargeApplePay(_ref3) {
631
+ var transactionId = _ref3.transactionId,
632
+ accessCode = _ref3.accessCode,
633
+ payment = _ref3.payment;
634
+ var chargeApplePayUrl = "".concat(config.paymentBaseUrl).concat(config.applePayChargePath);
635
+
636
+ // createFormBody would send a missing access code as the text "undefined"
637
+ var params = _objectSpread2(_objectSpread2({
638
+ transaction: transactionId
639
+ }, accessCode && {
640
+ accessCode: accessCode
641
+ }), {}, {
642
+ paymentObject: JSON.stringify(payment)
643
+ });
644
+ var formBody = createFormBody(params);
645
+ var charge = fetch(chargeApplePayUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
646
+ body: formBody
647
+ })).then(function (response) {
648
+ return response.json();
649
+ });
650
+ return charge;
651
+ };
652
+ var deviceSupportsApplePay = function deviceSupportsApplePay() {
653
+ try {
654
+ return Boolean(isAppleOS() && (isSafari() || isIOSWebView()) && window.isSecureContext && window.ApplePaySession && !window.ApplePaySession.isNotWebkit && window.ApplePaySession.supportsVersion(config.applePayVersion));
655
+ } catch (error) {
656
+ return false;
657
+ }
658
+ };
659
+
660
+ /**
661
+ * Off WebKit the SDK installs its own `window.ApplePaySession` whose
662
+ * `supportsVersion()` always returns true, so native support is only
663
+ * trustworthy when read before the SDK loads.
664
+ */
665
+ var getNativeSupport = function getNativeSupport() {
666
+ if (hasNativeSupportCache === null) {
667
+ hasNativeSupportCache = deviceSupportsApplePay();
668
+ }
669
+ return hasNativeSupportCache;
670
+ };
671
+
672
+ /**
673
+ * Off WebKit the SDK assigns `window.onbeforeunload` to close its QR-code
674
+ * window, replacing any handler the merchant page set, such as an
675
+ * unsaved-changes guard. Run both, and return the merchant's result because
676
+ * that is what triggers the browser's "Leave site?" prompt.
677
+ */
678
+ var combineSdkAndMerchantBeforeUnload = function combineSdkAndMerchantBeforeUnload(merchantHandler) {
679
+ var sdkHandler = window.onbeforeunload;
680
+ if (!(window.ApplePaySession && window.ApplePaySession.isNotWebkit) || sdkHandler === merchantHandler || typeof merchantHandler !== 'function' || typeof sdkHandler !== 'function') {
681
+ return;
682
+ }
683
+ window.onbeforeunload = function combinedBeforeUnload(event) {
684
+ var sdkResult;
685
+ try {
686
+ sdkResult = sdkHandler.call(window, event);
687
+ } catch (error) {
688
+ sdkResult = undefined;
689
+ }
690
+ var merchantResult = merchantHandler.call(window, event);
691
+ return merchantResult !== undefined ? merchantResult : sdkResult;
692
+ };
693
+ };
694
+ var loadApplePaySDK = function loadApplePaySDK() {
695
+ if (!sdkLoad) {
696
+ var merchantBeforeUnload = window.onbeforeunload;
697
+ sdkLoad = loadScript(APPLE_PAY_SDK_SOURCE, {
698
+ integrity: APPLE_PAY_SDK_INTEGRITY_HASH
699
+ }).then(function () {
700
+ combineSdkAndMerchantBeforeUnload(merchantBeforeUnload);
701
+ return true;
702
+ }).catch(function () {
703
+ sdkLoad = null;
704
+ return false;
705
+ });
706
+ }
707
+ return sdkLoad;
708
+ };
709
+ var probeApplePayCapabilities = function probeApplePayCapabilities(merchantId) {
710
+ return Promise.resolve().then(function () {
711
+ if (typeof window.ApplePaySession.applePayCapabilities !== 'function') {
712
+ return null;
713
+ }
714
+ return window.ApplePaySession.applePayCapabilities(merchantId);
715
+ }).then(function (capabilities) {
716
+ return (capabilities || {}).paymentCredentialStatus || null;
717
+ }).catch(function () {
718
+ return null;
719
+ });
720
+ };
721
+ var loadThenProbe = function loadThenProbe(merchantId) {
722
+ return loadApplePaySDK().then(function (sdkLoaded) {
723
+ return (sdkLoaded ? probeApplePayCapabilities(merchantId) : Promise.resolve(null)).then(function (status) {
724
+ return {
725
+ status: status,
726
+ sdkLoaded: sdkLoaded
727
+ };
728
+ });
729
+ });
730
+ };
731
+ var normaliseRegisteredDomain = function normaliseRegisteredDomain(domain) {
732
+ return String(domain).toLowerCase().replace(/\/+$/, '');
733
+ };
734
+ var isPageDomainRegisteredWithApple = function isPageDomainRegisteredWithApple(registeredDomains) {
735
+ var hostname = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.location.hostname;
736
+ return Array.isArray(registeredDomains) && registeredDomains.some(function (domain) {
737
+ return normaliseRegisteredDomain(domain) === hostname.toLowerCase();
738
+ });
739
+ };
740
+ var getApplePayMerchantIdentifier = function getApplePayMerchantIdentifier(response) {
741
+ var _response$channel_set;
742
+ return response === null || response === void 0 || (_response$channel_set = response.channel_settings) === null || _response$channel_set === void 0 || (_response$channel_set = _response$channel_set.apple_pay) === null || _response$channel_set === void 0 ? void 0 : _response$channel_set.merchant_identifier;
743
+ };
744
+ var shouldProbe = function shouldProbe(response, hasNativeSupport) {
745
+ var channels = response.channels || [];
746
+ var applePaySettings = response.channel_settings && response.channel_settings.apple_pay || {};
747
+ return channels.includes(CHANNELS.APPLE_PAY) && Boolean(getApplePayMerchantIdentifier(response)) && (isPageDomainRegisteredWithApple(applePaySettings.domains) || hasNativeSupport);
748
+ };
749
+ var resolveApplePayAvailability = function resolveApplePayAvailability(response) {
750
+ try {
751
+ var safeResponse = response || {};
752
+ var hasNativeSupport = getNativeSupport();
753
+ var merchantId = getApplePayMerchantIdentifier(safeResponse);
754
+ if (!shouldProbe(safeResponse, hasNativeSupport)) {
755
+ return Promise.resolve({
756
+ status: null,
757
+ hasNativeSupport: hasNativeSupport,
758
+ sdkLoaded: false
759
+ });
760
+ }
761
+ return withTimeoutDelay(loadThenProbe(merchantId), APPLE_PAY_TIMEOUT_MS).catch(function () {
762
+ return null;
763
+ }).then(function (result) {
764
+ return {
765
+ status: result && result.status || null,
766
+ hasNativeSupport: hasNativeSupport,
767
+ sdkLoaded: Boolean(result && result.sdkLoaded)
768
+ };
769
+ });
770
+ } catch (error) {
771
+ return Promise.resolve({
772
+ status: null,
773
+ hasNativeSupport: false,
774
+ sdkLoaded: false
775
+ });
776
+ }
777
+ };
778
+ var canUseApplePay = function canUseApplePay() {
779
+ var channels = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
780
+ var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
781
+ status = _ref4.status,
782
+ hasNativeSupport = _ref4.hasNativeSupport;
783
+ if (!channels.includes(CHANNELS.APPLE_PAY)) {
784
+ return false;
785
+ }
786
+ if (status && status !== APPLE_PAY_UNSUPPORTED) {
787
+ return true;
788
+ }
789
+ return hasNativeSupport === true;
790
+ };
791
+
792
+ var getChannelAmount = function getChannelAmount(response, channel) {
793
+ var channelFees = (response && response.channel_fees_and_amount || {})[channel];
794
+ var amount = channelFees && channelFees.amount;
795
+ return amount == null ? response && response.amount : amount;
796
+ };
797
+
798
+ // eslint-disable-next-line no-console
799
+ var logWarning = console ? console.warn || console.log : function () {};
800
+ function printDeprecationNotice(oldName, newName, extraMessage) {
801
+ logWarning("\"".concat(oldName, "\" has been deprecated, please use \"").concat(newName, "\". ").concat(extraMessage || ''));
802
+ }
803
+
804
+ /**
805
+ * Never advertised here: a `PAN_ONLY` charge comes back needing a 3DS step-up,
806
+ * and inline-js can't handle it
807
+ */
808
+ var UNSUPPORTED_AUTH_METHODS = ['PAN_ONLY'];
809
+ var paymentsClient = null;
810
+ var paymentsClientEnvironment = null;
811
+ var getGooglePayConfig = function getGooglePayConfig(transaction) {
812
+ var response = transaction && transaction.response;
813
+ var channelSettings = response && response.channel_settings;
814
+ return channelSettings && channelSettings[CHANNELS.GOOGLE_PAY] || null;
815
+ };
816
+ var getSupportedAuthMethods = function getSupportedAuthMethods(googlePayConfig) {
817
+ return (googlePayConfig && googlePayConfig.allowed_card_auth_methods || []).filter(function (authMethod) {
818
+ return !UNSUPPORTED_AUTH_METHODS.includes(authMethod);
819
+ });
820
+ };
821
+ var resolveGooglePayEnvironment = function resolveGooglePayEnvironment(response) {
822
+ var isTest = !!response && response.domain === TRANSACTION_DOMAIN.TEST;
823
+ return config.environment === ENVIRONMENT.PRODUCTION && !isTest ? 'PRODUCTION' : 'TEST';
824
+ };
825
+ var getGooglePayClient = function getGooglePayClient(environment) {
826
+ if (!paymentsClient || paymentsClientEnvironment !== environment) {
827
+ paymentsClient = new window.google.payments.api.PaymentsClient({
828
+ environment: environment
829
+ });
830
+ paymentsClientEnvironment = environment;
831
+ }
832
+ return paymentsClient;
833
+ };
834
+ var hasGooglePaySDKLoaded = function hasGooglePaySDKLoaded() {
835
+ return !!(window.google && window.google.payments && window.google.payments.api && window.google.payments.api.PaymentsClient);
836
+ };
837
+ var buildBaseRequest = function buildBaseRequest(googlePayConfig) {
838
+ return {
839
+ apiVersion: googlePayConfig.api_version.major,
840
+ apiVersionMinor: googlePayConfig.api_version.minor
841
+ };
842
+ };
843
+ var buildCardPaymentMethod = function buildCardPaymentMethod(googlePayConfig, authMethods) {
844
+ return {
845
+ type: 'CARD',
846
+ parameters: _objectSpread2({
847
+ allowedAuthMethods: authMethods,
848
+ allowedCardNetworks: googlePayConfig.allowed_card_networks,
849
+ billingAddressRequired: true,
850
+ billingAddressParameters: googlePayConfig.billing_address_parameters,
851
+ assuranceDetailsRequired: true
852
+ }, googlePayConfig.allowed_issuer_country_codes && googlePayConfig.allowed_issuer_country_codes.length && {
853
+ allowedIssuerCountryCodes: googlePayConfig.allowed_issuer_country_codes
854
+ })
855
+ };
856
+ };
857
+ var buildMerchantInfo = function buildMerchantInfo(googlePayConfig) {
858
+ var merchantInfo = googlePayConfig.registered_merchant_info || {};
859
+ return {
860
+ merchantId: merchantInfo.merchantId,
861
+ merchantName: merchantInfo.merchantName,
862
+ merchantOrigin: merchantInfo.merchantOrigin
863
+ };
864
+ };
865
+ var warnOnOriginMismatch = function warnOnOriginMismatch(googlePayConfig) {
866
+ var registeredOrigin = googlePayConfig.registered_merchant_info && googlePayConfig.registered_merchant_info.merchantOrigin;
867
+ var hostname = window.location.hostname;
868
+ if (registeredOrigin && registeredOrigin !== hostname) {
869
+ logWarning("Google Pay: the registered merchantOrigin (\"".concat(registeredOrigin, "\") does not match this page (\"").concat(hostname, "\"). Google may reject the payment sheet. Update the domain in Dashboard > Developers > Google Pay."));
870
+ }
871
+ };
872
+ var buildPaymentDataRequest = function buildPaymentDataRequest(transaction) {
873
+ var googlePayConfig = getGooglePayConfig(transaction);
874
+ var response = transaction.response;
875
+ var authMethods = getSupportedAuthMethods(googlePayConfig);
876
+ return _objectSpread2(_objectSpread2({}, buildBaseRequest(googlePayConfig)), {}, {
877
+ allowedPaymentMethods: [_objectSpread2(_objectSpread2({}, buildCardPaymentMethod(googlePayConfig, authMethods)), {}, {
878
+ tokenizationSpecification: googlePayConfig.tokenization_specification
879
+ })],
880
+ transactionInfo: {
881
+ totalPriceStatus: 'FINAL',
882
+ checkoutOption: 'COMPLETE_IMMEDIATE_PURCHASE',
883
+ totalPrice: amountSubunitToBase(getChannelAmount(response, CHANNELS.GOOGLE_PAY)).toFixed(2),
884
+ currencyCode: response.currency,
885
+ countryCode: CURRENCY_COUNTRYCODE_MAPPING[response.currency] || COUNTRYCODE.NIGERIA
886
+ },
887
+ merchantInfo: buildMerchantInfo(googlePayConfig),
888
+ emailRequired: true
889
+ });
890
+ };
891
+ var chargeGooglePay = function chargeGooglePay(_ref) {
892
+ var transactionId = _ref.transactionId,
893
+ paymentData = _ref.paymentData;
894
+ var chargeUrl = "".concat(config.paymentBaseUrl).concat(config.googlePayChargePath);
895
+ return fetch(chargeUrl, {
896
+ headers: {
897
+ 'content-type': 'application/x-www-form-urlencoded'
898
+ },
899
+ method: 'POST',
900
+ mode: 'cors',
901
+ credentials: 'omit',
902
+ body: createFormBody({
903
+ transaction: transactionId,
904
+ paymentObject: JSON.stringify(paymentData)
905
+ })
906
+ }).then(function (response) {
907
+ return response.json();
908
+ });
909
+ };
910
+ var canUseGooglePay = function canUseGooglePay(transaction) {
911
+ var googlePayConfig = getGooglePayConfig(transaction);
912
+ if (!googlePayConfig) {
913
+ return Promise.resolve(null);
914
+ }
915
+ var authMethods = getSupportedAuthMethods(googlePayConfig);
916
+ if (!authMethods.length || !googlePayConfig.tokenization_specification || !hasGooglePaySDKLoaded()) {
917
+ return Promise.resolve(null);
918
+ }
919
+ warnOnOriginMismatch(googlePayConfig);
920
+ var readiness = Promise.resolve().then(function () {
921
+ var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response));
922
+ return client.isReadyToPay(_objectSpread2(_objectSpread2({}, buildBaseRequest(googlePayConfig)), {}, {
923
+ allowedPaymentMethods: [buildCardPaymentMethod(googlePayConfig, authMethods)],
924
+ existingPaymentMethodRequired: true
925
+ }));
926
+ }).then(function (_ref2) {
927
+ var result = _ref2.result;
928
+ return !!result;
929
+ }).catch(function () {
930
+ return null;
931
+ });
932
+ return readiness;
933
+ };
934
+ var loadGooglePay = function loadGooglePay(transaction) {
935
+ var response = transaction && transaction.response || {};
936
+ var channels = response.channels || [];
937
+ if (!channels.includes(CHANNELS.GOOGLE_PAY)) {
938
+ return Promise.resolve(null);
939
+ }
940
+ var googlePayConfig = getGooglePayConfig(transaction);
941
+ if (googlePayConfig && !googlePayConfig.registered_merchant_info) {
942
+ logWarning('Google Pay: this business has no Google Pay merchant profile, so no Google Pay button is shown. Add one in Dashboard > Developers > Google Pay.');
943
+ return Promise.resolve(null);
944
+ }
945
+ var loadSdk = hasGooglePaySDKLoaded() ? Promise.resolve(true) : loadScript(GOOGLE_PAY_SDK_SOURCE).then(function () {
946
+ return hasGooglePaySDKLoaded();
947
+ });
948
+ return withTimeoutDelay(loadSdk.catch(function () {
949
+ return false;
950
+ }).then(function (loaded) {
951
+ if (!loaded) {
952
+ return null;
953
+ }
954
+ return canUseGooglePay(transaction);
955
+ }), GOOGLE_PAY_TIMEOUT_MS);
956
+ };
957
+
958
+ var _excluded$2 = ["height", "width", "borderRadius", "buttonRadius"];
959
+
960
+ // Outside production, checkout calls the legacy API on a VPN-only host, so the
961
+ // checkout frame needs Local Network Access delegated from the merchant page.
962
+ function getCheckoutIframeAllow() {
963
+ var features = ['payment', 'clipboard-read', 'clipboard-write'];
964
+ if (config.environment !== ENVIRONMENT.PRODUCTION) {
965
+ features.push('local-network-access');
966
+ }
967
+ return features.join('; ');
968
+ }
969
+ function createIframe(id) {
970
+ var iframe = document.createElement('iframe');
971
+ iframe.setAttribute('frameBorder', '0');
972
+ iframe.setAttribute('allowtransparency', 'true');
973
+ iframe.id = id;
974
+ iframe.style.display = 'none';
975
+ return iframe;
976
+ }
977
+ function mountCheckoutIframe(id) {
978
+ var iframe = createIframe("inline-checkout-".concat(id));
979
+ // `precheckout=true` tells checkout to render the precheckout view itself;
980
+ // without it, checkout assumes an older inline-js that renders its own modal.
981
+ iframe.src = "".concat(config.checkoutUrl, "popup?precheckout=true");
982
+ iframe.style.cssText = checkoutCSS;
983
+ iframe.style.colorScheme = 'light';
984
+ iframe.setAttribute('allowpaymentrequest', 'true');
985
+ iframe.setAttribute('allow', getCheckoutIframeAllow());
986
+ document.body.appendChild(iframe);
987
+ return iframe;
988
+ }
989
+ function mountBackgroundIframe(id) {
990
+ var iframe = createIframe("inline-background-".concat(id));
991
+ iframe.style.cssText = backgroundCSS;
992
+ iframe.style.colorScheme = 'light';
993
+ document.body.appendChild(iframe);
994
+ var bgWindow = iframe.contentWindow.document;
995
+ bgWindow.open();
996
+ bgWindow.write(loaderHTML);
997
+ bgWindow.close();
998
+ return iframe;
999
+ }
1000
+ function mountEmbedCheckoutIframe(id, src) {
1001
+ var iframe = createIframe("embed-checkout-".concat(id));
1002
+ iframe.style.cssText = embedCSS;
1003
+ iframe.src = src;
1004
+ iframe.id = id;
1005
+ iframe.name = id;
1006
+ iframe.setAttribute('allowpaymentrequest', 'true');
1007
+ iframe.setAttribute('allow', getCheckoutIframeAllow());
1008
+ return iframe;
1009
+ }
1010
+ function getApplePayButton(container) {
1011
+ return container.querySelector('apple-pay-button') || container.querySelector('#apple-pay-button');
1012
+ }
1013
+ function appendIframeToContainer(containerId, iframe) {
1014
+ var container = document.getElementById(containerId);
1015
+ container.innerHTML = '';
1016
+ container.removeAttribute('style');
1017
+ container.className = 'paystack-embed-container';
1018
+ container.style.position = 'relative';
1019
+ container.style.width = '100%';
1020
+ container.appendChild(iframe);
1021
+ }
1022
+ function hideLoader(iframe) {
1023
+ var bgWindow = iframe.contentWindow.document;
1024
+ if (bgWindow) {
1025
+ bgWindow.getElementById('app-loader').style.display = 'none';
1026
+ }
1027
+ }
1028
+ function animateCheckoutIn(domElements) {
1029
+ return new Promise(function (resolve, reject) {
1030
+ if (!domElements) {
1031
+ reject('No dom element provided');
1032
+ }
1033
+ var checkoutIframe = domElements.checkoutIframe,
1034
+ backgroundIframe = domElements.backgroundIframe;
1035
+ if (!checkoutIframe || !backgroundIframe) {
1036
+ reject('No dom element provided');
1037
+ }
1038
+ checkoutIframe.style.display = '';
1039
+ checkoutIframe.style.visibility = 'visible';
1040
+ backgroundIframe.style.display = '';
1041
+ backgroundIframe.style.visibility = 'visible';
1042
+ resolve();
1043
+ });
1044
+ }
1045
+ function animateCheckoutOut(domElements) {
1046
+ return new Promise(function (resolve, reject) {
1047
+ if (!domElements) {
1048
+ reject('No dom element provided');
1049
+ }
1050
+ var checkoutIframe = domElements.checkoutIframe,
1051
+ backgroundIframe = domElements.backgroundIframe;
1052
+ if (!checkoutIframe || !backgroundIframe) {
1053
+ reject('No dom element provided');
1054
+ }
1055
+ backgroundIframe.style.opacity = 0;
1056
+ checkoutIframe.style.display = 'none';
1057
+ checkoutIframe.style.visibility = 'hidden';
1058
+ setTimeout(function () {
1059
+ backgroundIframe.style.display = 'none';
1060
+ backgroundIframe.style.visibility = 'hidden';
1061
+ backgroundIframe.style.opacity = 1;
1062
+ resolve();
1063
+ }, 300);
1064
+ });
1065
+ }
1066
+ function mountLazyInlineButton(options) {
1067
+ var inlineButton;
1068
+ if (options.id) {
1069
+ inlineButton = document.getElementById(options.id);
1070
+ inlineButton.setAttribute('data-inline-id', options.id);
1071
+ } else {
1072
+ var inlineDiv = document.createElement('div');
1073
+ inlineDiv.id = "inline-button-".concat(options.inlineId);
1074
+ inlineDiv.innerHTML = generateInlineButtonHTML(options);
1075
+ options.parent.parentNode.insertBefore(inlineDiv, options.parent.nextSibling);
1076
+ var _inlineDiv$getElement = inlineDiv.getElementsByTagName('button');
1077
+ var _inlineDiv$getElement2 = _slicedToArray(_inlineDiv$getElement, 1);
1078
+ inlineButton = _inlineDiv$getElement2[0];
1079
+ }
1080
+ return inlineButton;
1081
+ }
1082
+ function animateEmbedCheckoutIn(checkoutIframe) {
1083
+ return new Promise(function (resolve, reject) {
1084
+ if (!checkoutIframe) {
1085
+ reject('No dom element provided');
1086
+ }
1087
+ // eslint-disable-next-line no-param-reassign
1088
+ checkoutIframe.style.display = '';
1089
+ // eslint-disable-next-line no-param-reassign
1090
+ checkoutIframe.style.visibility = 'visible';
1091
+ resolve();
1092
+ });
1093
+ }
1094
+ function mountInput(options) {
1095
+ var type = options.type,
1096
+ value = options.value,
1097
+ name = options.name,
1098
+ parent = options.parent;
1099
+ var input = document.createElement('input');
1100
+ input.type = type;
1101
+ input.value = value;
1102
+ input.name = name;
1103
+ parent.appendChild(input);
1104
+ }
1105
+ function mountApplePayButton(container, _ref) {
1106
+ var styles = _ref.styles,
1107
+ theme = _ref.theme,
1108
+ onClick = _ref.onClick;
1109
+ appendCSS(container, generateApplePayCSS(styles));
1110
+ var button = document.createElement('apple-pay-button');
1111
+ button.setAttribute('buttonstyle', theme === PAYMENT_REQUEST_BUTTON_THEME.LIGHT ? 'white' : 'black');
1112
+ button.setAttribute('type', styles.type);
1113
+ button.setAttribute('locale', styles.locale);
1114
+ if (onClick) {
1115
+ button.onclick = onClick;
1116
+ }
1117
+ container.appendChild(button);
1118
+ return button;
1119
+ }
1120
+ function mountApplePayFallbackButton(container, _ref2) {
1121
+ var styles = _ref2.styles,
1122
+ theme = _ref2.theme,
1123
+ onClick = _ref2.onClick;
1124
+ appendCSS(container, generateApplePayFallbackCSS(styles));
1125
+ var button = document.createElement('button');
1126
+ button.classList.add('apple-pay-button', theme === PAYMENT_REQUEST_BUTTON_THEME.LIGHT ? 'apple-pay-button-white' : 'apple-pay-button-black');
1127
+ button.id = 'apple-pay-button';
1128
+ var applePayLogo = document.createElement('span');
1129
+ applePayLogo.classList.add('logo');
1130
+ button.appendChild(applePayLogo);
1131
+ if (onClick) {
1132
+ button.onclick = onClick;
1133
+ }
1134
+ container.appendChild(button);
1135
+ return button;
1136
+ }
1137
+ function getPaymentRequestContainer(container) {
1138
+ return document.querySelector("#".concat(container));
1139
+ }
1140
+ function removeAllChildNodes(parent) {
1141
+ while (parent.firstChild) {
1142
+ parent.removeChild(parent.firstChild);
1143
+ }
1144
+ }
1145
+ function getGooglePayButton(container) {
1146
+ return container.querySelector('#google-pay-button-container');
1147
+ }
1148
+ function toggleGooglePayLoadingState(container, isLoading) {
1149
+ if (!container) {
1150
+ return;
1151
+ }
1152
+ var button = container.querySelector('#google-pay-button');
1153
+ var loadingButton = container.querySelector('#google-pay-loading-button');
1154
+ if (!button || !loadingButton) {
1155
+ return;
1156
+ }
1157
+ button.style.display = isLoading ? 'none' : '';
1158
+ loadingButton.style.display = isLoading ? 'flex' : 'none';
1159
+ }
1160
+ var resolveGooglePayButtonRadius = function resolveGooglePayButtonRadius(borderRadius, buttonRadius) {
1161
+ var parsed = parseFloat(borderRadius !== undefined ? borderRadius : buttonRadius);
1162
+ return parsed >= 0 ? parsed : GOOGLE_PAY_BUTTON_RADIUS;
1163
+ };
1164
+ function mountGooglePayButton(container, _ref3) {
1165
+ var transaction = _ref3.transaction,
1166
+ _ref3$styles = _ref3.styles,
1167
+ styles = _ref3$styles === void 0 ? {} : _ref3$styles,
1168
+ onClick = _ref3.onClick;
1169
+ var _ref4 = styles.googlePay || {},
1170
+ height = _ref4.height,
1171
+ width = _ref4.width,
1172
+ borderRadius = _ref4.borderRadius,
1173
+ buttonRadius = _ref4.buttonRadius,
1174
+ googlePayStyles = _objectWithoutProperties(_ref4, _excluded$2);
1175
+ var googlePayConfig = getGooglePayConfig(transaction);
1176
+ var radius = resolveGooglePayButtonRadius(borderRadius, buttonRadius);
1177
+ appendCSS(container, generateGooglePayCSS({
1178
+ height: height,
1179
+ width: width
1180
+ }));
1181
+ var buttonColor = googlePayStyles.buttonColor || (styles.theme === PAYMENT_REQUEST_BUTTON_THEME.LIGHT ? 'white' : 'black');
1182
+ appendCSS(container, generateGooglePayLoadingCSS({
1183
+ borderRadius: radius,
1184
+ buttonColor: buttonColor
1185
+ }));
1186
+ var buttonContainer = document.createElement('div');
1187
+ buttonContainer.id = 'google-pay-button-container';
1188
+ var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response));
1189
+ var button = client.createButton(_objectSpread2(_objectSpread2({
1190
+ buttonColor: buttonColor,
1191
+ buttonType: 'pay',
1192
+ buttonRadius: radius,
1193
+ buttonSizeMode: 'fill'
1194
+ }, googlePayStyles), {}, {
1195
+ onClick: onClick,
1196
+ allowedPaymentMethods: [buildCardPaymentMethod(googlePayConfig, getSupportedAuthMethods(googlePayConfig))]
1197
+ }));
1198
+ container.appendChild(buttonContainer);
1199
+ var buttonWrapper = document.createElement('div');
1200
+ buttonWrapper.id = 'google-pay-button';
1201
+ buttonWrapper.appendChild(button);
1202
+ buttonContainer.appendChild(buttonWrapper);
1203
+ var loadingButton = document.createElement('button');
1204
+ loadingButton.id = 'google-pay-loading-button';
1205
+ loadingButton.type = 'button';
1206
+ loadingButton.disabled = true;
1207
+ loadingButton.setAttribute('aria-busy', 'true');
1208
+ loadingButton.style.display = 'none';
1209
+ var spinner = document.createElement('span');
1210
+ spinner.id = 'google-pay-loading-button__spinner';
1211
+ loadingButton.appendChild(spinner);
1212
+ buttonContainer.appendChild(loadingButton);
1213
+ return buttonContainer;
1214
+ }
1215
+ function getMountedPaymentRequestButtons(container) {
1216
+ if (!container) {
1217
+ return [];
1218
+ }
1219
+ return [getApplePayButton(container), getGooglePayButton(container)].filter(Boolean);
1220
+ }
1221
+ function mountUsableApplePayButton(container, _ref5, options) {
1222
+ var sdkLoaded = _ref5.sdkLoaded,
1223
+ hasNativeSupport = _ref5.hasNativeSupport;
1224
+ if (sdkLoaded) {
1225
+ return mountApplePayButton(container, options);
1226
+ }
1227
+ if (hasNativeSupport) {
1228
+ return mountApplePayFallbackButton(container, options);
1229
+ }
1230
+ logWarning('Apple Pay: the Apple Pay SDK did not load, so no Apple Pay button is shown.');
1231
+ return null;
1232
+ }
1233
+ function mountPaymentRequestButtons(container, _ref6) {
1234
+ var transaction = _ref6.transaction,
1235
+ _ref6$styles = _ref6.styles,
1236
+ styles = _ref6$styles === void 0 ? {} : _ref6$styles,
1237
+ onClickApplePayButton = _ref6.onClickApplePayButton,
1238
+ onClickGooglePayButton = _ref6.onClickGooglePayButton;
1239
+ if (!container) {
1240
+ return Promise.reject('Container to mount elements was not provided');
1241
+ }
1242
+ removeAllChildNodes(container);
1243
+ appendCSS(container, generatePaymentRequestInnerWrapperCSS(styles.orientation));
1244
+ var innerWrapper = document.createElement('div');
1245
+ innerWrapper.id = 'paystack-payment-request-inner-wrapper';
1246
+ innerWrapper.style.display = 'none';
1247
+ container.appendChild(innerWrapper);
1248
+ var applePayOptions = {
1249
+ styles: parseApplePayCustomStyles(styles.applePay),
1250
+ theme: styles.theme,
1251
+ onClick: onClickApplePayButton
1252
+ };
1253
+ var channels = transaction.response && transaction.response.channels || [];
1254
+ var applePayButton = resolveApplePayAvailability(transaction.response).then(function (applePay) {
1255
+ if (canUseApplePay(channels, applePay)) {
1256
+ return mountUsableApplePayButton(innerWrapper, applePay, applePayOptions);
1257
+ }
1258
+ if (channels.includes(CHANNELS.APPLE_PAY)) {
1259
+ logWarning('Apple Pay: this device, browser or page cannot pay with Apple Pay here.');
1260
+ }
1261
+ return null;
1262
+ }).catch(function () {
1263
+ return null;
1264
+ });
1265
+ var googlePayButton = loadGooglePay(transaction).then(function (isReadyToPay) {
1266
+ if (!isReadyToPay) {
1267
+ return null;
1268
+ }
1269
+ return mountGooglePayButton(innerWrapper, {
1270
+ transaction: transaction,
1271
+ styles: styles,
1272
+ onClick: onClickGooglePayButton
1273
+ });
1274
+ }).catch(function () {
1275
+ return null;
1276
+ });
1277
+ return Promise.all([applePayButton, googlePayButton]).then(function (_ref7) {
1278
+ var _ref8 = _slicedToArray(_ref7, 2),
1279
+ applePay = _ref8[0],
1280
+ googlePay = _ref8[1];
1281
+ if (!applePay && !googlePay) {
1282
+ return null;
1283
+ }
1284
+ innerWrapper.style.display = '';
1285
+ return {
1286
+ applePay: !!applePay,
1287
+ googlePay: !!googlePay
1288
+ };
1289
+ });
1290
+ }
1291
+
1292
+ var allParameters = [{
1293
+ value: 'key',
1294
+ required: true,
1295
+ types: ['string']
1296
+ }, {
1297
+ value: 'amount',
1298
+ required: true,
1299
+ or: ['plan', 'planCode'],
1300
+ types: ['string', 'number']
1301
+ }, {
1302
+ value: 'currency',
1303
+ required: false,
1304
+ types: ['string']
1305
+ }, {
1306
+ value: 'email',
1307
+ required: true,
1308
+ or: ['customerCode'],
1309
+ types: ['string']
1310
+ }, {
1311
+ value: 'label',
1312
+ required: false,
1313
+ types: ['string']
1314
+ }, {
1315
+ value: 'firstName',
1316
+ required: false,
1317
+ types: ['string']
1318
+ }, {
1319
+ value: 'lastName',
1320
+ required: false,
1321
+ types: ['string']
1322
+ }, {
1323
+ value: 'reference',
1324
+ required: false,
1325
+ types: ['string']
1326
+ }, {
1327
+ value: 'phone',
1328
+ required: false,
1329
+ types: ['string']
1330
+ }, {
1331
+ value: 'customerCode',
1332
+ required: false,
1333
+ override: 'email',
1334
+ types: ['string']
1335
+ }, {
1336
+ value: 'channels',
1337
+ required: false,
1338
+ types: ['array']
1339
+ }, {
1340
+ value: 'paymentRequest',
1341
+ required: false,
1342
+ types: ['string', 'number']
1343
+ }, {
1344
+ value: 'paymentPage',
1345
+ required: false,
1346
+ types: ['string']
1347
+ }, {
1348
+ value: 'hash',
1349
+ required: false,
1350
+ types: ['string']
1351
+ }, {
1352
+ value: 'container',
1353
+ required: false,
1354
+ types: ['string']
1355
+ }, {
1356
+ value: 'metadata',
1357
+ required: false,
1358
+ types: ['object']
1359
+ }, {
1360
+ value: 'subaccountCode',
1361
+ required: false,
1362
+ types: ['string']
1363
+ }, {
1364
+ value: 'bearer',
1365
+ required: false,
1366
+ types: ['string']
1367
+ }, {
1368
+ value: 'transactionCharge',
1369
+ required: false,
1370
+ types: ['string', 'number']
1371
+ }, {
1372
+ value: 'planCode',
1373
+ required: false,
1374
+ override: 'amount',
1375
+ types: ['string']
1376
+ }, {
1377
+ value: 'subscriptionCount',
1378
+ required: false,
1379
+ types: ['number']
1380
+ }, {
1381
+ value: 'planInterval',
1382
+ required: false,
1383
+ types: ['string']
1384
+ }, {
1385
+ value: 'subscriptionLimit',
1386
+ required: false,
1387
+ types: ['number']
1388
+ }, {
1389
+ value: 'subscriptionStartDate',
1390
+ required: false,
1391
+ types: ['string']
1392
+ }, {
1393
+ value: 'accessCode',
1394
+ required: false,
1395
+ types: ['string']
1396
+ }, {
1397
+ value: 'onError',
1398
+ required: false,
1399
+ types: ['function']
1400
+ }, {
1401
+ value: 'onLoad',
1402
+ required: false,
1403
+ types: ['function']
1404
+ }, {
1405
+ value: 'onSuccess',
1406
+ required: false,
1407
+ types: ['function']
1408
+ }, {
1409
+ value: 'onCancel',
1410
+ required: false,
1411
+ types: ['function']
1412
+ }, {
1413
+ value: 'callback',
1414
+ required: false,
1415
+ types: ['function']
1416
+ }, {
1417
+ value: 'onClose',
1418
+ required: false,
1419
+ types: ['function']
1420
+ }, {
1421
+ value: 'onBankTransferConfirmationPending',
1422
+ required: false,
1423
+ types: ['function']
1424
+ }, {
1425
+ value: 'firstname',
1426
+ required: false,
1427
+ types: ['string']
1428
+ }, {
1429
+ value: 'lastname',
1430
+ required: false,
1431
+ types: ['string']
1432
+ }, {
1433
+ value: 'customer_code',
1434
+ required: false,
1435
+ types: ['string']
1436
+ }, {
1437
+ value: 'payment_request',
1438
+ required: false,
1439
+ types: ['string', 'number']
1440
+ }, {
1441
+ value: 'subaccount',
1442
+ required: false,
1443
+ types: ['string']
1444
+ }, {
1445
+ value: 'transaction_charge',
1446
+ required: false,
1447
+ types: ['number', 'string']
1448
+ }, {
1449
+ value: 'plan',
1450
+ required: false,
1451
+ types: ['string']
1452
+ }, {
1453
+ value: 'quantity',
1454
+ required: false,
1455
+ types: ['number']
1456
+ }, {
1457
+ value: 'interval',
1458
+ required: false,
1459
+ types: ['string']
1460
+ }, {
1461
+ value: 'invoice_limit',
1462
+ required: false,
1463
+ types: ['number', 'string']
1464
+ }, {
1465
+ value: 'start_date',
1466
+ required: false,
1467
+ types: ['string']
1468
+ }, {
1469
+ value: 'payment_page',
1470
+ required: false,
1471
+ types: ['number', 'string']
1472
+ }, {
1473
+ value: 'order_id',
1474
+ required: false,
1475
+ types: ['number']
1476
+ }, {
1477
+ value: 'ref',
1478
+ required: false,
1479
+ types: ['string']
1480
+ }, {
1481
+ value: 'card',
1482
+ required: false,
1483
+ types: ['string']
1484
+ }, {
1485
+ value: 'bank',
1486
+ required: false,
1487
+ types: ['string']
1488
+ }, {
1489
+ value: 'split',
1490
+ required: false,
1491
+ types: ['object']
1492
+ }, {
1493
+ value: 'split_code',
1494
+ required: false,
1495
+ types: ['string']
1496
+ }, {
1497
+ value: 'transaction_type',
1498
+ required: false,
1499
+ types: ['string']
1500
+ }, {
1501
+ value: 'subscription',
1502
+ required: false,
1503
+ types: ['number']
1504
+ }, {
1505
+ value: 'language',
1506
+ required: false,
1507
+ types: ['string']
1508
+ }, {
1509
+ value: 'connect_account',
1510
+ required: false,
1511
+ types: ['string']
1512
+ }, {
1513
+ value: 'connect_split',
1514
+ required: false,
1515
+ types: ['array']
1516
+ }];
1517
+ function validate(args) {
1518
+ function ValidationError(message, issues) {
1519
+ this.message = message;
1520
+ this.issues = issues || [];
1521
+ }
1522
+ if (!args || _typeof(args) !== 'object') {
1523
+ throw new ValidationError('Transaction parameters should be a non-empty object');
1524
+ }
1525
+ var transactionParameters = args;
1526
+
1527
+ // If it's a transaction resumption, move on
1528
+ if ('accessCode' in transactionParameters) {
1529
+ var accessCode = transactionParameters.accessCode;
1530
+ return {
1531
+ accessCode: accessCode
1532
+ };
1533
+ }
1534
+
1535
+ // Filter unneeded parameters
1536
+ Object.keys(transactionParameters).forEach(function (key) {
1537
+ var usedParameter = allParameters.find(function (parameter) {
1538
+ return parameter.value === key;
1539
+ }) !== undefined;
1540
+ if (!usedParameter) {
1541
+ delete transactionParameters[key];
1542
+ }
1543
+ });
1544
+ var transactionKeys = Object.keys(transactionParameters);
1545
+ var validationErrors = [];
1546
+
1547
+ // Check for required parameters
1548
+ var requiredParameters = allParameters.filter(function (param) {
1549
+ return param.required;
1550
+ });
1551
+ requiredParameters.forEach(function (key) {
1552
+ var parameterIsMissing = !transactionParameters[key.value];
1553
+ var parameterHasAlternative = key.or ? key.or.some(function (option) {
1554
+ return transactionParameters[option];
1555
+ }) : null;
1556
+ if (parameterIsMissing && !parameterHasAlternative) {
1557
+ validationErrors.push({
1558
+ message: "Required parameter missing: ".concat(key.value)
1559
+ });
1560
+ }
1561
+ });
1562
+
1563
+ // Check for validity
1564
+ transactionKeys.forEach(function (key) {
1565
+ var parameterValue = transactionParameters[key];
1566
+ var parameterObject = allParameters.find(function (parameter) {
1567
+ return parameter.value === key;
1568
+ });
1569
+ var providedType = _typeof(parameterValue);
1570
+ if (providedType === 'object' && Array.isArray(parameterValue)) {
1571
+ providedType = 'array';
1572
+ }
1573
+ var invalidType = parameterObject.types.indexOf(providedType) <= -1;
1574
+ if (invalidType) {
1575
+ validationErrors.push({
1576
+ message: "Invalid parameter type: ".concat(key),
1577
+ validTypes: parameterObject.types
1578
+ });
1579
+ }
1580
+ });
1581
+
1582
+ // Override keys where necessary
1583
+ transactionKeys.forEach(function (key) {
1584
+ var parameterObject = allParameters.find(function (parameter) {
1585
+ return parameter.value === key;
1586
+ });
1587
+ if (parameterObject.override) {
1588
+ delete transactionParameters[parameterObject.override];
1589
+ }
1590
+ });
1591
+ if (validationErrors.length) {
1592
+ throw new ValidationError('Invalid transaction parameters', validationErrors);
1593
+ }
1594
+ return transactionParameters;
1595
+ }
1596
+
1597
+ /* eslint-env browser */
1598
+ function splitURL(url) {
1599
+ if ((url === null || url === void 0 ? void 0 : url.length) > 500) {
1600
+ return url.split('?')[0];
1601
+ }
1602
+ return url;
1603
+ }
1604
+ function getReferrer() {
1605
+ var _window$location = window.location,
1606
+ _window$location$href = _window$location.href,
1607
+ href = _window$location$href === void 0 ? '' : _window$location$href,
1608
+ _window$location$ance = _window$location.ancestorOrigins,
1609
+ ancestorOrigins = _window$location$ance === void 0 ? [] : _window$location$ance;
1610
+ return [href].concat(_toConsumableArray(ancestorOrigins)).map(splitURL).join(',');
1611
+ }
1612
+
1613
+ function buildQuery(parameters) {
1614
+ var formattedParameters = _objectSpread2({}, parameters);
1615
+ formattedParameters.metadata = parameters.metadata || {};
1616
+ formattedParameters.metadata.referrer = getReferrer();
1617
+ formattedParameters.metadata = JSON.stringify(formattedParameters.metadata);
1618
+ formattedParameters.mode = 'popup';
1619
+ if (parameters.split && typeof parameters.split !== 'string') {
1620
+ formattedParameters.split = JSON.stringify(formattedParameters.split);
1621
+ }
1622
+ var parametersToChange = [{
1623
+ to: 'firstname',
1624
+ from: 'firstName'
1625
+ }, {
1626
+ to: 'lastname',
1627
+ from: 'lastName'
1628
+ }, {
1629
+ to: 'customer_code',
1630
+ from: 'customerCode'
1631
+ }, {
1632
+ to: 'payment_request',
1633
+ from: 'paymentRequest'
1634
+ }, {
1635
+ to: 'subaccount',
1636
+ from: 'subaccountCode'
1637
+ }, {
1638
+ to: 'transaction_charge',
1639
+ from: 'transactionCharge'
1640
+ }, {
1641
+ to: 'plan',
1642
+ from: 'planCode'
1643
+ }, {
1644
+ to: 'quantity',
1645
+ from: 'subscriptionCount'
1646
+ }, {
1647
+ to: 'interval',
1648
+ from: 'planInterval'
1649
+ }, {
1650
+ to: 'invoice_limit',
1651
+ from: 'subscriptionLimit'
1652
+ }, {
1653
+ to: 'start_date',
1654
+ from: 'subscriptionStartDate'
1655
+ }, {
1656
+ to: 'ref',
1657
+ from: 'reference'
1658
+ }];
1659
+
1660
+ // handle very old case of people disabling channels by sending card/bank params
1661
+
1662
+ if (formattedParameters.card !== undefined && ['false', false].indexOf(formattedParameters.card) > -1) {
1663
+ formattedParameters.channels = ['bank'];
1664
+ delete formattedParameters.card;
1665
+ }
1666
+ if (formattedParameters.bank !== undefined && ['false', false].indexOf(formattedParameters.bank) > -1) {
1667
+ formattedParameters.channels = ['card'];
1668
+ delete formattedParameters.bank;
1669
+ }
1670
+ parametersToChange.forEach(function (key) {
1671
+ var hasValue = formattedParameters[key.from];
1672
+ if (hasValue) {
1673
+ formattedParameters[key.to] = formattedParameters[key.from];
1674
+ delete formattedParameters[key.from];
1675
+ }
1676
+ });
1677
+ Object.values(parameters).forEach(function (value, index) {
1678
+ if (typeof value === 'function') {
1679
+ var key = Object.keys(parameters)[index];
1680
+ delete formattedParameters[key];
1681
+ }
1682
+ });
1683
+ return formattedParameters;
1684
+ }
1685
+
1686
+ /* eslint-env browser */
1687
+ var AnalyticsAPI = {
1688
+ saveLog: function saveLog(transactionId, merchantPublicKey, log) {
1689
+ var url = "".concat(config.paystackApiUrl, "transaction/update_log/").concat(transactionId);
1690
+ var headers = {
1691
+ Authorization: "Bearer ".concat(merchantPublicKey)
1692
+ };
1693
+ return fetch(url, {
1694
+ method: 'POST',
1695
+ body: JSON.stringify({
1696
+ payload: JSON.stringify(log)
1697
+ }),
1698
+ headers: headers
1699
+ });
1700
+ },
1701
+ saveIp: function saveIp(transactionId, merchantPublicKey) {
1702
+ var url = "".concat(config.paystackApiUrl, "transaction/set_ip/").concat(transactionId);
1703
+ var headers = {
1704
+ Authorization: "Bearer ".concat(merchantPublicKey)
1705
+ };
1706
+ return fetch(url, {
1707
+ method: 'POST',
1708
+ headers: headers
1709
+ });
1710
+ }
1711
+ };
1712
+
1713
+ var AnalyticsFunctions = {
1714
+ initializeLog: function initializeLog(log) {
1715
+ var _ref = log || {},
1716
+ attempts = _ref.attempts,
1717
+ authentication = _ref.authentication,
1718
+ errors = _ref.errors,
1719
+ history = _ref.history;
1720
+ this.log = {
1721
+ start_time: Math.round(Date.now() / 1000),
1722
+ time_spent: 0,
1723
+ attempts: attempts || 0,
1724
+ authentication: authentication,
1725
+ errors: errors || 0,
1726
+ success: false,
1727
+ mobile: isIOS(),
1728
+ input: [],
1729
+ history: history || []
1730
+ };
1731
+ },
1732
+ getTimeSpent: function getTimeSpent() {
1733
+ var currentTimeInSeconds = Math.round(Date.now() / 1000);
1734
+ this.log.time_spent = currentTimeInSeconds - this.log.start_time;
1735
+ return this.log.time_spent;
1736
+ },
1737
+ logAPIResponse: function logAPIResponse(response, channel) {
1738
+ switch (response.status) {
1739
+ case TRANSACTION_STATUS.SUCCESS:
1740
+ return this.logApiSuccess(channel);
1741
+ case TRANSACTION_STATUS.FAILED:
1742
+ return this.logApiError(response.message);
1743
+ default:
1744
+ return false;
1745
+ }
1746
+ },
1747
+ logValidationResponse: function logValidationResponse(message) {
1748
+ this.log.history.push({
1749
+ type: 'action',
1750
+ message: message,
1751
+ time: this.getTimeSpent()
1752
+ });
1753
+ return this.saveLog();
1754
+ },
1755
+ logAttempt: function logAttempt(channel) {
1756
+ var message = 'Attempted to pay';
1757
+ if (channel) {
1758
+ message += " with ".concat(channel);
1759
+ }
1760
+ this.log.attempts += 1;
1761
+ this.log.history.push({
1762
+ type: 'action',
1763
+ message: message,
1764
+ time: this.getTimeSpent()
1765
+ });
1766
+ return this.saveLog();
1767
+ },
1768
+ logApiError: function logApiError(error) {
1769
+ var message = 'Error';
1770
+ if (error) {
1771
+ message += ": ".concat(error);
1772
+ }
1773
+ this.log.errors += 1;
1774
+ this.log.history.push({
1775
+ type: 'error',
1776
+ message: message,
1777
+ time: this.getTimeSpent()
1778
+ });
1779
+ return this.saveLog();
1780
+ },
1781
+ logApiSuccess: function logApiSuccess(channel) {
1782
+ var message = 'Successfully paid';
1783
+ if (channel) {
1784
+ message += " with ".concat(channel);
1785
+ }
1786
+ this.log.success = true;
1787
+ this.log.history.push({
1788
+ type: 'success',
1789
+ message: message,
1790
+ time: this.getTimeSpent()
1791
+ });
1792
+ return this.saveLog();
1793
+ },
1794
+ saveLog: function saveLog() {
1795
+ try {
1796
+ if (this.response) {
1797
+ return AnalyticsAPI.saveLog(this.id, this.response.merchant_key, this.log);
1798
+ }
1799
+ } catch (error) {
1800
+ // we don't need to do anything since this should not affect the transaction
1801
+ }
1802
+ return undefined;
1803
+ },
1804
+ saveIpAddress: function saveIpAddress() {
1805
+ try {
1806
+ if (this.response) {
1807
+ return AnalyticsAPI.saveIp(this.id, this.response.merchant_key);
1808
+ }
1809
+ } catch (error) {
1810
+ // we don't need to do anything since this should not affect the transaction
1811
+ }
1812
+ return undefined;
1813
+ }
1814
+ };
1815
+
1816
+ var _excluded$1 = ["language", "connect_account"];
1817
+ var TransactionApi = {
1818
+ requestInline: function requestInline() {
1819
+ var inlineTransactionInstance = this;
1820
+ var _this$urlParameters = this.urlParameters,
1821
+ language = _this$urlParameters.language,
1822
+ connectAccount = _this$urlParameters.connect_account,
1823
+ params = _objectWithoutProperties(_this$urlParameters, _excluded$1);
1824
+ var request;
1825
+ var headers = _objectSpread2({
1826
+ 'Content-Type': 'application/json'
1827
+ }, language && {
1828
+ 'Accept-Language': language
1829
+ });
1830
+ if (this.accessCode) {
1831
+ request = fetch(new URL("transaction/verify_access_code/".concat(this.accessCode), config.paystackApiUrl).toString(), {
1832
+ headers: headers
1833
+ });
1834
+ } else {
1835
+ request = fetch(new URL('/checkout/request_inline', config.paystackApiUrl).toString(), {
1836
+ method: 'POST',
1837
+ body: JSON.stringify(params),
1838
+ headers: _objectSpread2(_objectSpread2({}, headers), connectAccount && {
1839
+ 'x-connect-account': connectAccount
1840
+ })
1841
+ });
1842
+ }
1843
+ return request.then(function (res) {
1844
+ return res.json();
1845
+ }).then(function (res) {
1846
+ if (res.status === false) {
1847
+ throw new Error(res.message);
1848
+ }
1849
+ inlineTransactionInstance.response = res.data;
1850
+ inlineTransactionInstance.id = res.data.id;
1851
+ inlineTransactionInstance.status = res.data.transaction_status;
1852
+ inlineTransactionInstance.accessCode = res.data.access_code;
1853
+
1854
+ // Analytics
1855
+ inlineTransactionInstance.log = null;
1856
+ Object.assign(inlineTransactionInstance, AnalyticsFunctions);
1857
+ inlineTransactionInstance.initializeLog(res.data.log);
1858
+ inlineTransactionInstance.saveIpAddress();
1859
+ return res.data;
1860
+ });
1861
+ }
1862
+ };
1863
+
1864
+ var InlineTransaction = /*#__PURE__*/function () {
1865
+ function InlineTransaction(data) {
1866
+ _classCallCheck(this, InlineTransaction);
1867
+ validate(data);
1868
+ this.parameters = data;
1869
+ this.urlParameters = buildQuery(data);
1870
+ this.id = null;
1871
+ this.status = null;
1872
+ this.accessCode = data.accessCode || null;
1873
+ this.authorizationUrl = null;
1874
+ this.errors = [];
1875
+ this.response = null;
1876
+ this.isActive = true;
1877
+ var onError = data.onError,
1878
+ onLoad = data.onLoad,
1879
+ onSuccess = data.onSuccess,
1880
+ onCancel = data.onCancel,
1881
+ callback = data.callback,
1882
+ onClose = data.onClose,
1883
+ onBankTransferConfirmationPending = data.onBankTransferConfirmationPending;
1884
+ this.callbacks = {
1885
+ onError: onError,
1886
+ onLoad: onLoad,
1887
+ onSuccess: onSuccess,
1888
+ onCancel: onCancel,
1889
+ onBankTransferConfirmationPending: onBankTransferConfirmationPending
1890
+ };
1891
+ this.deprecatedCallbacks = {
1892
+ callback: callback,
1893
+ onClose: onClose
1894
+ };
1895
+ Object.assign(this, TransactionApi);
1896
+ }
1897
+ return _createClass(InlineTransaction, [{
1898
+ key: "onSetupError",
1899
+ value: function onSetupError(response) {
1900
+ this.logError(response);
1901
+ if (this.callbacks.onError) {
1902
+ this.callbacks.onError(response);
1903
+ }
1904
+ }
1905
+ }, {
1906
+ key: "onLoad",
1907
+ value: function onLoad(response) {
1908
+ var id = response.id,
1909
+ customer = response.customer,
1910
+ accessCode = response.accessCode;
1911
+ Object.assign(this, {
1912
+ id: id,
1913
+ customer: customer,
1914
+ accessCode: accessCode
1915
+ });
1916
+ this.authorizationUrl = "".concat(config.checkoutUrl).concat(accessCode);
1917
+ if (this.callbacks.onLoad) {
1918
+ this.callbacks.onLoad({
1919
+ id: id,
1920
+ customer: customer,
1921
+ accessCode: accessCode
1922
+ });
1923
+ }
1924
+ }
1925
+ }, {
1926
+ key: "onSuccess",
1927
+ value: function onSuccess(response) {
1928
+ this.isActive = false;
1929
+ this.response = response;
1930
+ this.status = response.status;
1931
+ if (this.callbacks.onSuccess) {
1932
+ this.callbacks.onSuccess(response);
1933
+ }
1934
+ // Added for backwards compatibility
1935
+ if (this.deprecatedCallbacks.callback) {
1936
+ this.deprecatedCallbacks.callback(response);
1937
+ }
1938
+ }
1939
+ }, {
1940
+ key: "setStatus",
1941
+ value: function setStatus(status) {
1942
+ this.status = status;
1943
+ }
1944
+ }, {
1945
+ key: "onCancel",
1946
+ value: function onCancel() {
1947
+ if (this.callbacks.onCancel) {
1948
+ this.callbacks.onCancel();
1949
+ }
1950
+ // Added for backwards compatibility
1951
+ if (this.deprecatedCallbacks.onClose) {
1952
+ this.deprecatedCallbacks.onClose();
1953
+ }
1954
+ }
1955
+ }, {
1956
+ key: "cancel",
1957
+ value: function cancel() {
1958
+ this.isActive = false;
1959
+ this.onCancel();
1960
+ }
1961
+ }, {
1962
+ key: "onBankTransferConfirmationPending",
1963
+ value: function onBankTransferConfirmationPending() {
1964
+ this.cancel();
1965
+ if (this.callbacks.onBankTransferConfirmationPending) {
1966
+ this.callbacks.onBankTransferConfirmationPending();
1967
+ }
1968
+ }
1969
+ }, {
1970
+ key: "logError",
1971
+ value: function logError(error) {
1972
+ this.errors.push(error);
1973
+ }
1974
+ }]);
1975
+ }();
1976
+
1977
+ var _excluded = ["preload", "inlineTransaction", "transactionData"],
1978
+ _excluded2 = ["container", "styles", "onElementsMount"],
1979
+ _excluded3 = ["data"];
1980
+ var inlineInstance;
1981
+ var CHECKOUT_ORIGIN = new URL(config.checkoutUrl).origin;
1982
+ var SITE_ORIGIN = new URL(config.siteUrl).origin;
1983
+ function postToCheckout(checkoutIframe, message) {
1984
+ checkoutIframe.contentWindow.postMessage(message, CHECKOUT_ORIGIN);
1985
+ }
1986
+ function findResumableTransaction(transactions, parameters) {
1987
+ if (!transactions.length) {
1988
+ return null;
1989
+ }
1990
+ var similarAbandonedTransactions = transactions.filter(function (transaction) {
1991
+ var isAbandoned = !transaction.status || transaction.status === 'abandoned';
1992
+ var hasSimilarParameters = similarObjects(transaction.parameters, parameters);
1993
+ return isAbandoned && hasSimilarParameters;
1994
+ });
1995
+ var resumableTransaction = similarAbandonedTransactions.length ? similarAbandonedTransactions[similarAbandonedTransactions.length - 1] : null;
1996
+ return resumableTransaction;
1997
+ }
1998
+ function notifyIframeToUpdateURL(options) {
1999
+ var checkoutIframe = options.checkoutIframe,
2000
+ urlParameters = options.urlParameters;
2001
+ if (!checkoutIframe || !urlParameters) {
2002
+ return;
2003
+ }
2004
+ postToCheckout(checkoutIframe, {
2005
+ type: 'inline:url',
2006
+ path: 'newTransaction',
2007
+ params: urlParameters
2008
+ });
2009
+ }
2010
+ var analyticsActions = {
2011
+ TRACK_PAYMENT_ERROR: 'trackPaymentError',
2012
+ TRACK_PAYMENT_ATTEMPT: 'trackPaymentAttempt',
2013
+ TRACK_PAYMENT_COMPLETION: 'trackPaymentCompletion'
2014
+ };
2015
+ function handleError(message) {
2016
+ logWarning(message);
2017
+ throw new Error(message);
2018
+ }
2019
+ var Inline = /*#__PURE__*/function () {
2020
+ function Inline(params) {
2021
+ _classCallCheck(this, Inline);
2022
+ this.id = randomId();
2023
+ this.transactions = [];
2024
+ this.isOpen = false;
2025
+ this.isLoaded = false;
2026
+ this.isCharging = false;
2027
+ this.isDeprecatedApi = params && params.isDeprecatedApi; // track deprecatedApi
2028
+ this.embedIframes = [];
2029
+ if (params && params.isEmbed) {
2030
+ this.isEmbed = true;
2031
+ } else if (params && params.isPaymentRequest) {
2032
+ if (!(params.container && getPaymentRequestContainer(params.container))) {
2033
+ handleError('A container is required to mount the payment request button');
2034
+ }
2035
+ this.paymentRequestContainer = getPaymentRequestContainer(params.container);
2036
+ this.paymentRequestTransaction = null;
2037
+ }
2038
+ this.backgroundIframe = mountBackgroundIframe(this.id);
2039
+ this.checkoutIframe = mountCheckoutIframe(this.id);
2040
+ this.registerListeners();
2041
+ }
2042
+ return _createClass(Inline, [{
2043
+ key: "registerListeners",
2044
+ value: function registerListeners() {
2045
+ var _this = this;
2046
+ window.addEventListener('message', function (event) {
2047
+ var isFromThisCheckout = event.origin === CHECKOUT_ORIGIN && _this.checkoutIframe && _this.checkoutIframe.contentWindow === event.source;
2048
+ var isFromThisEmbed = event.origin === SITE_ORIGIN && _this.embedIframes.some(function (iframe) {
2049
+ return iframe.contentWindow === event.source;
2050
+ });
2051
+ if (isFromThisCheckout) {
2052
+ _this.respondToEvent(event);
2053
+ } else if (isFromThisEmbed) {
2054
+ _this.respondToEmbedEvents(event);
2055
+ }
2056
+ });
2057
+ }
2058
+ }, {
2059
+ key: "sendAnalyticsEventToCheckout",
2060
+ value: function sendAnalyticsEventToCheckout(action, params) {
2061
+ postToCheckout(this.checkoutIframe, {
2062
+ type: 'analytics',
2063
+ action: action,
2064
+ params: params
2065
+ });
2066
+ }
2067
+ }, {
2068
+ key: "checkout",
2069
+ value: function checkout(params) {
2070
+ if (this.activeTransaction()) {
2071
+ this.activeTransaction().cancel();
2072
+ }
2073
+ inlineInstance = this;
2074
+ var resumableTransaction = findResumableTransaction(this.transactions, params);
2075
+ var transaction = resumableTransaction || new InlineTransaction(params);
2076
+ return new Promise(function (resolve, reject) {
2077
+ transaction.requestInline().then(function (response) {
2078
+ inlineInstance.newTransaction({
2079
+ inlineTransaction: transaction,
2080
+ transactionData: response
2081
+ });
2082
+ resolve(transaction);
2083
+ }).catch(function (error) {
2084
+ transaction.onSetupError({
2085
+ status: false,
2086
+ message: error.message
2087
+ });
2088
+ reject(error);
2089
+ });
2090
+ });
2091
+ }
2092
+ }, {
2093
+ key: "newTransaction",
2094
+ value: function newTransaction(_ref) {
2095
+ var preload = _ref.preload,
2096
+ inlineTransaction = _ref.inlineTransaction,
2097
+ transactionData = _ref.transactionData,
2098
+ options = _objectWithoutProperties(_ref, _excluded);
2099
+ var hasPaymentRequestButtons = this.hasMountedPaymentRequestButtons();
2100
+ var activeTransaction = this.activeTransaction();
2101
+ if (activeTransaction && !hasPaymentRequestButtons && activeTransaction !== inlineTransaction) {
2102
+ activeTransaction.cancel();
2103
+ }
2104
+ if (inlineTransaction && transactionData) {
2105
+ if (!this.transactions.includes(inlineTransaction)) {
2106
+ this.transactions.push(inlineTransaction);
2107
+ }
2108
+ if (!this.isDeprecatedApi) {
2109
+ // TODO: reintroduce this when we resolve checkout caching issues
2110
+ // this.open({ transactionData }, preload);
2111
+ this.open({
2112
+ accessCode: transactionData.access_code,
2113
+ language: inlineTransaction.urlParameters.language
2114
+ }, preload);
2115
+ }
2116
+ return inlineTransaction;
2117
+ }
2118
+ var resumableTransaction = findResumableTransaction(this.transactions, inlineTransaction ? inlineTransaction.parameters : options);
2119
+ if (resumableTransaction) {
2120
+ resumableTransaction.isActive = true;
2121
+ if (!this.isDeprecatedApi) {
2122
+ // We could potentially optimize this also by checking if there is a `response` property on `resumableTransaction`
2123
+ this.open({
2124
+ accessCode: resumableTransaction.accessCode,
2125
+ language: resumableTransaction.urlParameters.language
2126
+ }, preload);
2127
+ }
2128
+ return resumableTransaction;
2129
+ }
2130
+ var transaction = inlineTransaction || new InlineTransaction(options);
2131
+ var params = transaction.accessCode ? {
2132
+ accessCode: transaction.accessCode,
2133
+ language: transaction.urlParameters.language
2134
+ } : transaction.urlParameters;
2135
+ this.transactions.push(transaction);
2136
+ if (!this.isDeprecatedApi) {
2137
+ this.open(params, preload);
2138
+ }
2139
+ return transaction;
2140
+ }
2141
+ }, {
2142
+ key: "preloadTransaction",
2143
+ value: function preloadTransaction(options) {
2144
+ var _this2 = this;
2145
+ this.newTransaction(_objectSpread2(_objectSpread2({}, options), {}, {
2146
+ preload: true
2147
+ }));
2148
+ var loadPopup = function loadPopup() {
2149
+ return _this2.animateCheckoutIn();
2150
+ };
2151
+ return loadPopup;
2152
+ }
2153
+ }, {
2154
+ key: "paymentRequest",
2155
+ value: function paymentRequest(parameters) {
2156
+ var _this3 = this;
2157
+ var container = parameters.container,
2158
+ styles = parameters.styles,
2159
+ onElementsMount = parameters.onElementsMount,
2160
+ transactionParams = _objectWithoutProperties(parameters, _excluded2);
2161
+ if ('channels' in transactionParams) {
2162
+ transactionParams.channels = withCardForGooglePay(transactionParams.channels);
2163
+ }
2164
+ inlineInstance = this;
2165
+ return new Promise(function (resolve, reject) {
2166
+ var loadPaystackCheckoutButton = document.querySelector("#".concat(parameters.loadPaystackCheckoutButton));
2167
+ if (inlineInstance.activeTransaction()) {
2168
+ inlineInstance.activeTransaction().cancel();
2169
+ }
2170
+ if (!(container && getPaymentRequestContainer(container))) {
2171
+ handleError('A container is required to mount the payment request button');
2172
+ }
2173
+ inlineInstance.paymentRequestContainer = getPaymentRequestContainer(container);
2174
+ var resumableTransaction = findResumableTransaction(inlineInstance.transactions, transactionParams);
2175
+ var transaction = resumableTransaction || new InlineTransaction(transactionParams);
2176
+ transaction.requestInline().then(function (response) {
2177
+ if (resumableTransaction) {
2178
+ transaction.isActive = true;
2179
+ } else {
2180
+ inlineInstance.transactions.push(transaction);
2181
+ }
2182
+ return mountPaymentRequestButtons(inlineInstance.paymentRequestContainer, {
2183
+ transaction: transaction,
2184
+ styles: styles,
2185
+ onClickApplePayButton: function onClickApplePayButton() {
2186
+ return _this3.startApplePay(transaction);
2187
+ },
2188
+ onClickGooglePayButton: function onClickGooglePayButton() {
2189
+ return _this3.startGooglePay(transaction);
2190
+ }
2191
+ }).then(function (mountedElements) {
2192
+ if (onElementsMount) {
2193
+ onElementsMount(mountedElements);
2194
+ }
2195
+ }).catch(function () {
2196
+ if (onElementsMount) {
2197
+ onElementsMount(null);
2198
+ }
2199
+ }).finally(function () {
2200
+ if (loadPaystackCheckoutButton) {
2201
+ var loadPopup = inlineInstance.preloadTransaction({
2202
+ inlineTransaction: transaction,
2203
+ transactionData: response
2204
+ });
2205
+ loadPaystackCheckoutButton.onclick = loadPopup;
2206
+ } else if (!inlineInstance.hasMountedPaymentRequestButtons()) {
2207
+ logWarning("No payment request button could be mounted on this device. Please consult our documentation at https://developers.paystack.co/docs/paystack-inline to see how to load alternative payment options using 'loadPaystackCheckoutButton'");
2208
+ }
2209
+ resolve(transaction);
2210
+ });
2211
+ }).catch(function (error) {
2212
+ transaction.onSetupError({
2213
+ status: false,
2214
+ message: error.message
2215
+ });
2216
+ reject(error);
2217
+ });
2218
+ });
2219
+ }
2220
+ }, {
2221
+ key: "hasMountedPaymentRequestButtons",
2222
+ value: function hasMountedPaymentRequestButtons() {
2223
+ return getMountedPaymentRequestButtons(this.paymentRequestContainer).length > 0;
2224
+ }
2225
+ }, {
2226
+ key: "startGooglePay",
2227
+ value: function startGooglePay(inlineTransaction) {
2228
+ var _this4 = this;
2229
+ var paymentMethod = 'google pay';
2230
+ var transaction = inlineTransaction || this.activeTransaction();
2231
+ if (inlineTransaction && !inlineTransaction.isActive) {
2232
+ logWarning('Google Pay: this button belongs to a transaction that is no longer active.');
2233
+ return Promise.resolve();
2234
+ }
2235
+ if (transaction && transaction.response) {
2236
+ if (this.isCharging) {
2237
+ return Promise.resolve();
2238
+ }
2239
+ this.isCharging = true;
2240
+ var notifyMerchant = function notifyMerchant(notify) {
2241
+ try {
2242
+ notify();
2243
+ } catch (error) {
2244
+ logWarning("Google Pay: a merchant callback threw. ".concat(error && error.message || error));
2245
+ }
2246
+ };
2247
+ try {
2248
+ var analyticsPayload = {
2249
+ channel: CHANNELS.GOOGLE_PAY,
2250
+ currency: transaction.response.currency,
2251
+ amount: getChannelAmount(transaction.response, CHANNELS.GOOGLE_PAY)
2252
+ };
2253
+ transaction.logAttempt(paymentMethod);
2254
+ this.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ATTEMPT, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
2255
+ paymentMethod: paymentMethod
2256
+ }));
2257
+ var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response));
2258
+ return client.loadPaymentData(buildPaymentDataRequest(transaction)).then(function (paymentData) {
2259
+ toggleGooglePayLoadingState(_this4.paymentRequestContainer, true);
2260
+ return chargeGooglePay({
2261
+ transactionId: transaction.id,
2262
+ paymentData: paymentData
2263
+ });
2264
+ }).then(function (response) {
2265
+ toggleGooglePayLoadingState(_this4.paymentRequestContainer, false);
2266
+ _this4.isCharging = false;
2267
+ transaction.logAPIResponse(response, paymentMethod);
2268
+ if (response.status === TRANSACTION_STATUS.SUCCESS) {
2269
+ var data = response.data,
2270
+ envelope = _objectWithoutProperties(response, _excluded3);
2271
+ notifyMerchant(function () {
2272
+ return transaction.onSuccess(_objectSpread2(_objectSpread2({}, data), envelope));
2273
+ });
2274
+ _this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
2275
+ timeSpent: transaction.getTimeSpent()
2276
+ }));
2277
+ return;
2278
+ }
2279
+
2280
+ // `auth` means a step-up we cannot render here, so say so rather
2281
+ // than leaving the customer holding a token with nowhere to go.
2282
+ var message = response.status === TRANSACTION_STATUS.AUTH ? 'This card requires additional authentication, which is not supported here. Please use another payment method.' : response && response.message || 'Transaction attempt failed';
2283
+ notifyMerchant(function () {
2284
+ return transaction.onSetupError(_objectSpread2(_objectSpread2({}, response), {}, {
2285
+ message: message
2286
+ }));
2287
+ });
2288
+ _this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
2289
+ channel: CHANNELS.GOOGLE_PAY,
2290
+ message: message
2291
+ });
2292
+ }, function (error) {
2293
+ toggleGooglePayLoadingState(_this4.paymentRequestContainer, false);
2294
+ _this4.isCharging = false;
2295
+ if (error && error.statusCode === GOOGLE_PAY_STATUS_CODE.CANCELED) {
2296
+ notifyMerchant(function () {
2297
+ return transaction.onCancel();
2298
+ });
2299
+ return;
2300
+ }
2301
+ var statusCode = error && error.statusCode;
2302
+ if (statusCode === GOOGLE_PAY_STATUS_CODE.DEVELOPER_ERROR || statusCode === GOOGLE_PAY_STATUS_CODE.MERCHANT_ACCOUNT_ERROR) {
2303
+ logWarning("Google Pay: ".concat(statusCode, ". Google rejected the merchant or the origin serving the button. Check that the merchant ID and domain saved in Dashboard > Developers > Google Pay match this page."));
2304
+ }
2305
+ var message = error && (error.statusMessage || error.message) || 'Could not complete the Google Pay payment';
2306
+ notifyMerchant(function () {
2307
+ return transaction.onSetupError({
2308
+ status: false,
2309
+ message: message
2310
+ });
2311
+ });
2312
+ _this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
2313
+ channel: CHANNELS.GOOGLE_PAY,
2314
+ message: message
2315
+ });
2316
+ }).catch(function (error) {
2317
+ _this4.isCharging = false;
2318
+ logWarning("Google Pay: the charge handler failed. ".concat(error && error.message || error));
2319
+ notifyMerchant(function () {
2320
+ return transaction.onSetupError({
2321
+ status: false,
2322
+ message: 'Could not complete the Google Pay payment'
2323
+ });
2324
+ });
2325
+ });
2326
+ } catch (error) {
2327
+ this.isCharging = false;
2328
+ logWarning('Google Pay: could not start the charge.');
2329
+ notifyMerchant(function () {
2330
+ return transaction.onSetupError({
2331
+ status: false,
2332
+ message: 'Could not complete the Google Pay payment'
2333
+ });
2334
+ });
2335
+ return Promise.resolve();
2336
+ }
2337
+ } else {
2338
+ handleError('Could not initiate google pay transaction');
2339
+ }
2340
+ return Promise.resolve();
2341
+ }
2342
+ }, {
2343
+ key: "startApplePay",
2344
+ value: function startApplePay(inlineTransaction) {
2345
+ var _this5 = this;
2346
+ var paymentMethod = 'apple pay';
2347
+ var transaction = inlineTransaction || this.activeTransaction();
2348
+ if (inlineTransaction && !inlineTransaction.isActive) {
2349
+ logWarning('Apple Pay: this button belongs to a transaction that is no longer active.');
2350
+ return;
2351
+ }
2352
+ if (transaction && transaction.response) {
2353
+ if (this.isCharging) {
2354
+ return;
2355
+ }
2356
+ this.isCharging = true;
2357
+ try {
2358
+ var analyticsPayload = {
2359
+ channel: CHANNELS.APPLE_PAY,
2360
+ currency: transaction.response.currency,
2361
+ amount: getChannelAmount(transaction.response, CHANNELS.APPLE_PAY)
2362
+ };
2363
+ transaction.logAttempt(paymentMethod);
2364
+ this.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ATTEMPT, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
2365
+ paymentMethod: paymentMethod
2366
+ }));
2367
+ var applePayPaymentRequest = generateApplePaymentRequestObject({
2368
+ currency: transaction.response.currency,
2369
+ amount: getChannelAmount(transaction.response, CHANNELS.APPLE_PAY),
2370
+ merchantName: transaction.response.merchant_name,
2371
+ merchantCountryCode: transaction.response.merchant_country_code,
2372
+ interval: transaction.response.plan_details && transaction.response.plan_details.interval
2373
+ });
2374
+ var applePaySession = new window.ApplePaySession(config.applePayVersion, applePayPaymentRequest);
2375
+ applePaySession.onvalidatemerchant = function (_ref2) {
2376
+ var validationURL = _ref2.validationURL;
2377
+ var validateSession = validateApplePaySession({
2378
+ validationURL: validationURL,
2379
+ transactionId: transaction.id,
2380
+ accessCode: transaction.accessCode,
2381
+ publicKey: transaction.parameters.key,
2382
+ merchantName: transaction.response.merchant_name
2383
+ });
2384
+ validateSession.then(function (response) {
2385
+ if (response.status !== TRANSACTION_STATUS.SUCCESS) {
2386
+ _this5.isCharging = false;
2387
+ transaction.onSetupError(response);
2388
+ } else {
2389
+ applePaySession.completeMerchantValidation(response.data);
2390
+ }
2391
+ transaction.logValidationResponse(response.message);
2392
+ }).catch(function (error) {
2393
+ _this5.isCharging = false;
2394
+ transaction.onSetupError(error);
2395
+ });
2396
+ };
2397
+ applePaySession.oncancel = function () {
2398
+ _this5.isCharging = false;
2399
+ transaction.onCancel();
2400
+ };
2401
+ applePaySession.onpaymentauthorized = function (_ref3) {
2402
+ var payment = _ref3.payment;
2403
+ var charge = chargeApplePay({
2404
+ transactionId: transaction.id,
2405
+ accessCode: transaction.accessCode,
2406
+ payment: payment
2407
+ });
2408
+ charge.then(function (response) {
2409
+ transaction.logAPIResponse(response, paymentMethod);
2410
+ _this5.isCharging = false;
2411
+ if (response.status === TRANSACTION_STATUS.SUCCESS) {
2412
+ applePaySession.completePayment(window.ApplePaySession.STATUS_SUCCESS);
2413
+ transaction.onSuccess(response);
2414
+ _this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
2415
+ timeSpent: transaction.getTimeSpent()
2416
+ }));
2417
+ } else {
2418
+ applePaySession.completePayment(window.ApplePaySession.STATUS_FAILURE);
2419
+ transaction.onSetupError(response);
2420
+ _this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
2421
+ channel: CHANNELS.APPLE_PAY,
2422
+ message: response && response.message || 'Transaction attempt failed'
2423
+ });
2424
+ }
2425
+ }).catch(function (error) {
2426
+ _this5.isCharging = false;
2427
+ applePaySession.completePayment(window.ApplePaySession.STATUS_FAILURE);
2428
+ transaction.onSetupError(error);
2429
+ _this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
2430
+ channel: CHANNELS.APPLE_PAY,
2431
+ message: error && error.message || 'Error occurred'
2432
+ });
2433
+ });
2434
+ };
2435
+ applePaySession.begin();
2436
+ } catch (error) {
2437
+ this.isCharging = false;
2438
+ transaction.onSetupError(error);
2439
+ }
2440
+ } else {
2441
+ handleError('Could not initiate apple pay transaction');
2442
+ }
2443
+ }
2444
+ }, {
2445
+ key: "resumeTransaction",
2446
+ value: function resumeTransaction(accessCode) {
2447
+ var callbacks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2448
+ var onSuccess = callbacks.onSuccess,
2449
+ onCancel = callbacks.onCancel,
2450
+ onLoad = callbacks.onLoad,
2451
+ onError = callbacks.onError;
2452
+ return this.newTransaction({
2453
+ accessCode: accessCode,
2454
+ onSuccess: onSuccess,
2455
+ onCancel: onCancel,
2456
+ onLoad: onLoad,
2457
+ onError: onError
2458
+ });
2459
+ }
2460
+ }, {
2461
+ key: "activeTransaction",
2462
+ value: function activeTransaction() {
2463
+ var activeTransactions = this.transactions.filter(function (transaction) {
2464
+ return transaction.isActive;
2465
+ });
2466
+ var activeTransaction = activeTransactions.length ? activeTransactions[activeTransactions.length - 1] : null;
2467
+ return activeTransaction;
2468
+ }
2469
+ }, {
2470
+ key: "cancelTransaction",
2471
+ value: function cancelTransaction(id) {
2472
+ var transaction = this.transactions.find(function (t) {
2473
+ return t.id === id;
2474
+ }) || this.activeTransaction();
2475
+ if (transaction) {
2476
+ transaction.cancel();
2477
+ this.close();
2478
+ }
2479
+ }
2480
+ }, {
2481
+ key: "respondToEvent",
2482
+ value: function respondToEvent(event) {
2483
+ if (!event) {
2484
+ return;
2485
+ }
2486
+ var activeTransaction = this.activeTransaction();
2487
+ try {
2488
+ var actualEvent = event.data || event.message;
2489
+ var eventType = actualEvent.event,
2490
+ eventData = actualEvent.data;
2491
+ if (eventType) {
2492
+ switch (eventType) {
2493
+ case 'loaded:checkout':
2494
+ this.isLoaded = true;
2495
+ if (activeTransaction) {
2496
+ var checkoutIframe = this.checkoutIframe;
2497
+ var urlParameters = activeTransaction.urlParameters,
2498
+ response = activeTransaction.response;
2499
+ // TODO: reintroduce this when we resolve checkout caching issues
2500
+ // const params = response
2501
+ // ? { transactionData: response }
2502
+ // : urlParameters;
2503
+
2504
+ var params = response ? {
2505
+ accessCode: response.access_code,
2506
+ language: urlParameters === null || urlParameters === void 0 ? void 0 : urlParameters.language
2507
+ } : urlParameters;
2508
+ notifyIframeToUpdateURL({
2509
+ checkoutIframe: checkoutIframe,
2510
+ urlParameters: params
2511
+ });
2512
+ }
2513
+ break;
2514
+ case 'loaded:transaction':
2515
+ hideLoader(this.backgroundIframe);
2516
+ activeTransaction.onLoad(eventData);
2517
+ break;
2518
+ case 'error':
2519
+ {
2520
+ var error = eventData;
2521
+ if (error.type === 'setup') {
2522
+ activeTransaction.onSetupError(eventData);
2523
+ } else {
2524
+ activeTransaction.logError(eventData);
2525
+ }
2526
+ break;
2527
+ }
2528
+ case 'cancel':
2529
+ case 'close':
2530
+ {
2531
+ this.close();
2532
+ var status = eventData && eventData.status;
2533
+ if (status) {
2534
+ activeTransaction.setStatus(status);
2535
+ }
2536
+ var hasPaymentRequestButtons = this.hasMountedPaymentRequestButtons();
2537
+ if (!hasPaymentRequestButtons) {
2538
+ activeTransaction.isActive = false;
2539
+ }
2540
+ activeTransaction.onCancel();
2541
+ break;
2542
+ }
2543
+ case 'transfer:pending':
2544
+ {
2545
+ this.close();
2546
+ var _status = eventData && eventData.status;
2547
+ if (_status) {
2548
+ activeTransaction.setStatus(_status);
2549
+ }
2550
+ activeTransaction.onBankTransferConfirmationPending();
2551
+ break;
2552
+ }
2553
+ case 'success':
2554
+ this.close();
2555
+ activeTransaction.onSuccess(eventData);
2556
+ break;
2557
+ default:
2558
+ break;
2559
+ }
2560
+ }
2561
+ } catch (error) {
2562
+ // do nothing
2563
+ }
2564
+ }
2565
+ }, {
2566
+ key: "respondToEmbedEvents",
2567
+ value: function respondToEmbedEvents(event) {
2568
+ var activeTransaction = this.activeTransaction();
2569
+ var eventData = event.data || event.message;
2570
+ if (eventData && (typeof eventData === 'string' || eventData instanceof String)) {
2571
+ var response = parseResponse(eventData);
2572
+ var oldCheckoutCloseResponse = response && response.action === 'PaystackClose';
2573
+ if (oldCheckoutCloseResponse) {
2574
+ var chargeResponse = response.data;
2575
+ if (chargeResponse) {
2576
+ activeTransaction.onSuccess(eventData);
2577
+ }
2578
+ }
2579
+ if (response.action === 'PaystackTLSClose') {
2580
+ activeTransaction.cancel();
2581
+ }
2582
+ }
2583
+ }
2584
+ }, {
2585
+ key: "animateCheckoutIn",
2586
+ value: function animateCheckoutIn$1() {
2587
+ var _this6 = this;
2588
+ if (!this.isOpen) {
2589
+ var checkoutIframe = this.checkoutIframe,
2590
+ backgroundIframe = this.backgroundIframe;
2591
+ animateCheckoutIn({
2592
+ checkoutIframe: checkoutIframe,
2593
+ backgroundIframe: backgroundIframe
2594
+ }).then(function () {
2595
+ postToCheckout(_this6.checkoutIframe, 'render');
2596
+ });
2597
+ this.isOpen = true;
2598
+ }
2599
+ }
2600
+ }, {
2601
+ key: "open",
2602
+ value: function open(urlParameters, preload) {
2603
+ if (!urlParameters) {
2604
+ return;
2605
+ }
2606
+ var checkoutIframe = this.checkoutIframe;
2607
+ notifyIframeToUpdateURL({
2608
+ checkoutIframe: checkoutIframe,
2609
+ urlParameters: urlParameters
2610
+ });
2611
+ if (!preload) {
2612
+ this.animateCheckoutIn();
2613
+ }
2614
+ }
2615
+ }, {
2616
+ key: "close",
2617
+ value: function close() {
2618
+ var _this7 = this;
2619
+ if (!this.isOpen) {
2620
+ return;
2621
+ }
2622
+ var checkoutIframe = this.checkoutIframe,
2623
+ backgroundIframe = this.backgroundIframe;
2624
+ animateCheckoutOut({
2625
+ checkoutIframe: checkoutIframe,
2626
+ backgroundIframe: backgroundIframe
2627
+ }).then(function () {
2628
+ postToCheckout(_this7.checkoutIframe, 'close');
2629
+ });
2630
+ this.isOpen = false;
2631
+ }
2632
+ }, {
2633
+ key: "isLoaded",
2634
+ value: function isLoaded() {
2635
+ return this.isLoaded;
2636
+ }
2637
+ }], [{
2638
+ key: "setup",
2639
+ value: function setup(parameters) {
2640
+ var isDeprecatedApi = true;
2641
+ var isEmbed = parameters && parameters.container;
2642
+ if (!inlineInstance) {
2643
+ inlineInstance = new Inline({
2644
+ isDeprecatedApi: isDeprecatedApi,
2645
+ isEmbed: isEmbed
2646
+ });
2647
+ }
2648
+ printDeprecationNotice('PaystackPop.setup()', 'new PaystackPop()', 'Please consult our documentation at https://developers.paystack.co/docs/paystack-inline');
2649
+ var transaction = inlineInstance.newTransaction(parameters, 'deprecated');
2650
+ var urlParameters = transaction.urlParameters;
2651
+ if (isEmbed) {
2652
+ var inlineUrl = "".concat(config.siteUrl, "/assets/payment/production/inline.html?").concat(serialize(urlParameters));
2653
+ var iframe = mountEmbedCheckoutIframe(inlineInstance.id, inlineUrl);
2654
+ inlineInstance.embedIframes.push(iframe);
2655
+ appendIframeToContainer(parameters.container, iframe);
2656
+ iframe.onload = function onLoad() {
2657
+ iframe.contentWindow.postMessage("PaystackOpen ".concat(inlineInstance.id), SITE_ORIGIN);
2658
+ animateEmbedCheckoutIn(iframe);
2659
+ };
2660
+ } else {
2661
+ // attach openIframe method
2662
+ transaction.openIframe = function () {
2663
+ printDeprecationNotice('openIframe', 'open', 'Please consult our documentation at https://developers.paystack.co/docs/paystack-inline');
2664
+ inlineInstance.open(urlParameters);
2665
+ };
2666
+ }
2667
+ return transaction;
2668
+ }
2669
+ }]);
2670
+ }();
2671
+ if (scriptCanUseDataAttributes()) {
2672
+ var parameters = getDataAttributesAsParameters();
2673
+ var parentForm = getSourceScript().parentElement;
2674
+ if (!inlineInstance) {
2675
+ inlineInstance = new Inline();
2676
+ }
2677
+ var transaction;
2678
+ var inlineButton = mountLazyInlineButton({
2679
+ inlineId: inlineInstance.id,
2680
+ amount: parameters.amount / 100,
2681
+ currency: parameters.currency,
2682
+ id: parameters.buttonId,
2683
+ text: parameters.buttonText,
2684
+ variant: parameters.buttonVariant,
2685
+ wordmarkVariant: parameters.buttonWordmarkVariant,
2686
+ parent: getSourceScript()
2687
+ });
2688
+ inlineButton.addEventListener('click', function (e) {
2689
+ e.preventDefault();
2690
+ if (!transaction) {
2691
+ transaction = inlineInstance.newTransaction(_objectSpread2(_objectSpread2({}, parameters), {}, {
2692
+ onSuccess: function onSuccess(response) {
2693
+ mountInput({
2694
+ type: 'hidden',
2695
+ name: 'reference',
2696
+ value: response.reference,
2697
+ parent: parentForm
2698
+ });
2699
+ parentForm.submit();
2700
+ }
2701
+ }));
2702
+ } else {
2703
+ inlineInstance.resumeTransaction(transaction.accessCode);
2704
+ }
2705
+ });
2706
+ }
2707
+
2708
+ return Inline;
2709
+
2710
+ })();