@eonx/payment-elements
Version:
- [Configuration](#configuration) - [Create payment card](#create-payment-card) - [Capture payment](#capture-payment) - [Pay now](#pay-now) - [Void payment](#void-payment) - [Types](#types) - [Error handling](#error-handling)
2 lines (1 loc) • 33.1 kB
JavaScript
var PaymentElements=function(e){"use strict";var t,n=((t=n||{})[t.KeyRequired=10]="KeyRequired",t[t.UrlRequired=11]="UrlRequired",t[t.UnhandledError=12]="UnhandledError",t[t.KeyExpired=13]="KeyExpired",t),r=(e=>(e[e.ContainerRequired=20]="ContainerRequired",e[e.MountFailed=21]="MountFailed",e[e.IncorrectUrl=22]="IncorrectUrl",e))(r||{}),i=(e=>(e[e.CaptureFailed=40]="CaptureFailed",e[e.IntentIdRequired=41]="IntentIdRequired",e[e.IntentFailed=42]="IntentFailed",e[e.CardRequired=43]="CardRequired",e[e.MultipleCards=44]="MultipleCards",e[e.UnknownGateway=45]="UnknownGateway",e[e.SdkFailed=46]="SdkFailed",e[e.SecureFailed=47]="SecureFailed",e[e.OrderFailed=48]="OrderFailed",e[e.AttachCardFailed=49]="AttachCardFailed",e[e.InitiateAuthWithErrorFailed=50]="InitiateAuthWithErrorFailed",e[e.InitiateAuthProceededFailed=51]="InitiateAuthProceededFailed",e[e.AuthenticatePayerWithErrorFailed=52]="AuthenticatePayerWithErrorFailed",e[e.AuthenticatePayerProceedFailed=53]="AuthenticatePayerProceedFailed",e))(i||{}),a=(e=>(e[e.IntentIdRequired=50]="IntentIdRequired",e))(a||{}),o=(e=>(e[e.Failed=60]="Failed",e))(o||{}),l=(e=>(e[e.IntentIdRequired=70]="IntentIdRequired",e[e.IntentFetchFailed=71]="IntentFetchFailed",e[e.IntentFailed=72]="IntentFailed",e[e.CardFetchFailed=73]="CardFetchFailed",e[e.CardAttachFailed=74]="CardAttachFailed",e[e.NotEnoughComplete=75]="NotEnoughComplete",e[e.AlreadyCaptured=76]="AlreadyCaptured",e[e.CaptureFailed=77]="CaptureFailed",e))(l||{});const c={[n.KeyRequired]:"API key required",[n.UrlRequired]:"Payment API URL not found",[n.UnhandledError]:"Error interacting with Payment API",[n.KeyExpired]:"API key is expired",[r.ContainerRequired]:"HTML container required",[r.MountFailed]:"Failed to render payment UI",[r.IncorrectUrl]:"Invalid payment elements URL",[o.Failed]:"Failed to create payment card",[i.IntentIdRequired]:"Order intent ID has required for capture",[i.IntentFailed]:"Failed to retrieve order intent",[i.CardRequired]:"Payment source required",[i.CaptureFailed]:"Failed to complete payment",[i.MultipleCards]:"Multiple cards are not supported",[i.UnknownGateway]:"Payment gateway has not supported",[i.SdkFailed]:"Failed to load third-party SDK",[i.SecureFailed]:"3D Secure verification failed. Please contact your bank.",[i.OrderFailed]:"Unable to apply payment for your order",[i.AttachCardFailed]:"Failed to attach payment card",[i.InitiateAuthWithErrorFailed]:"3D Secure verification failed. Please contact your bank.",[i.InitiateAuthProceededFailed]:"3D Secure verification failed. Please contact your bank.",[i.AuthenticatePayerWithErrorFailed]:"3D Secure verification failed. Please contact your bank.",[i.AuthenticatePayerProceedFailed]:"3D Secure verification failed. Please contact your bank.",[a.IntentIdRequired]:"Order intent ID has required for void",[l.IntentFailed]:"Failed to verify order",[l.IntentFetchFailed]:"Failed to retrieve order intent",[l.CardFetchFailed]:"Failed to fetch payment card from order intent",[l.IntentIdRequired]:"Order intent ID has required for checkout",[l.CardAttachFailed]:"Failed to attach payment card",[l.CaptureFailed]:"Failed to complete payment"},d=[n.KeyExpired];class s extends Error{constructor(e){const t=e.extends,n=(()=>{const n=null==t?void 0:t.code;return n&&d.includes(n)?n:e.code})();super(e.message||c[n]||"Unhandled error"),this.violations={},this.name="PaymentElementsError",this.code=n,this.data=e.data||(null==t?void 0:t.data),this.violations=e.violations||(null==t?void 0:t.violations)||{},this.description=e.description||(null==t?void 0:t.description)||(null==t?void 0:t.message)||"",this.responseStatus=e.responseStatus||(null==t?void 0:t.responseStatus)}get isCritical(){const e=this.responseStatus&&this.responseStatus>=500,t=[n.UnhandledError,i.CaptureFailed,i.UnknownGateway,i.SdkFailed,i.SecureFailed,i.AttachCardFailed,i.IntentFailed,i.OrderFailed].includes(this.code);return e||t}get hasViolations(){return Object.keys(this.violations).length>0}toString(){return JSON.stringify({name:this.name,violations:this.violations,code:this.code,data:this.data,message:this.message,description:this.description,responseStatus:this.responseStatus})}log(){console.error(this.code||"",this.message,this)}}const u=new class{constructor(){this.baseUrl="",this.apiKey=""}configure(e){this.baseUrl=e.baseUrl||this.baseUrl,this.apiKey=e.apiKey||this.apiKey}async fetch(e){var t,r;const i=e.apiKey||this.apiKey;if(!i)return[new s({code:n.KeyRequired}),null];if(!this.baseUrl)return[new s({code:n.UrlRequired}),null];const a=new URL(e.url,this.baseUrl),o=await window.fetch(a.toString(),{...e,method:e.method||"GET",headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:`Basic ${btoa(i)}`,...e.headers||{}},body:e.bodyRaw?e.bodyRaw:e.body&&"object"==typeof e.body?JSON.stringify(e.body):e.body});let l=null;try{l=await o.json()}catch{}if(o.ok)return[null,l];{const e=(null==l?void 0:l.violations)||{},i={};let a="";return e instanceof Array?a=e[0]:Object.keys(e).forEach((t=>{"string"===e[t]?i[t]=[e[t]]:i[t]=e[t]})),[new s({code:10601===(null==l?void 0:l.code)?n.KeyExpired:n.UnhandledError,message:(null==l?void 0:l.message)||(null==(t=null==l?void 0:l.exception)?void 0:t.message),description:a||(null==(r=null==l?void 0:l.exception)?void 0:r.message),data:l,violations:i,responseStatus:o.status}),null]}}};function h(){return{api:u}}const p=function(e){return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map((function(e){e(n)})),(r=e.get("*"))&&r.slice().map((function(e){e(t,n)}))}}}();var y=(e=>(e.Ready="ui-ready",e.SetHeight="ui-set-height",e.Mounted="ui-mounted",e.DataChanged="ui-data-changed",e.ElementReady="ui-element-ready",e))(y||{}),m=(e=>(e.Success="element-success",e.Error="element-error",e.Process="element-process",e))(m||{}),g=(e=>(e.Submit="sdk-submit",e.EnableSubmit="sdk-submit-enable",e.DisableSubmit="sdk-submit-disable",e.PreFill="sdk-prefill",e.Config="sdk-config",e))(g||{}),f=(e=>(e.SetConfig="set-config",e))(f||{});let v={};const C={uiStagingUrl:"https://sdk-elements.staging.v3.payment-gateway.eonx.com",uiProdUrl:"https://sdk-elements.prod.v3.payment-gateway.eonx.com",apiStagingUrl:"https://api.staging.v3.payment-gateway.eonx.com",apiProdUrl:"https://api.prod.v3.payment-gateway.eonx.com"};function b(){return v.uiUrl?v.uiUrl:v.test?C.uiStagingUrl:C.uiProdUrl}function E(){return v.test?C.apiStagingUrl:C.apiProdUrl}function w(e){var t,n,r;const i=(null==(t=v.themes)?void 0:t.base)||(null==(n=v.themes)?void 0:n["*"])||{},a=e||v.theme||"",o=(null==(r=v.themes)?void 0:r[a])||{};return{name:a,...i,...o,fonts:[...i.fonts||[],...o.fonts||[]],styles:{...i.styles||{},...o.styles||{}}}}function F(){return v.currency||"AUD"}function I(){return!!v.test}function S(){return{setup:C,config:v,getCurrency:F,getPaymentGatewayUrl:E,isTest:I,getUiUrl:b,getTheme:w}}function x(e){const{getUiUrl:t}=S(),n={container:void 0,observer:void 0,handlers:{}};let i=null;try{i=new URL(String(e.url),t())}catch{}const a=function(e,t){const n=document.createElement("iframe");return n.setAttribute("src",e),n.setAttribute("id",`eonx-frame-${Date.now()}`),n.setAttribute("frameborder","0"),n.setAttribute("scrolling","no"),n.setAttribute("allow","payment *"),n.setAttribute("allowtransparency","true"),n.style.setProperty("overflow","hidden","important"),n.style.setProperty("min-width","100%","important"),n.style.setProperty("border","none","important"),n.style.setProperty("padding","0","important"),n.style.setProperty("user-select","none","important"),n.style.setProperty("min-height","100%"),n.style.setProperty("opacity","0"),n.style.setProperty("position","absolute"),t.autoLayout?(n.style.setProperty("height","auto"),n.style.setProperty("margin","-4px","important"),n.style.setProperty("width","calc(100% + 8px)")):(n.style.setProperty("height","100%"),n.style.setProperty("width","100%")),n}((null==i?void 0:i.toString())||"",{autoLayout:!!e.autoLayout});function o(e){const t=n.handlers[m.Error];if(t instanceof Function)return t(e);u()}function l(e){try{const t=JSON.parse(e.data);if(e.origin===(null==i?void 0:i.origin)){const e=n.handlers[t.type];e instanceof Function&&e(t.payload)}}catch{}}function c(e,t){const n=JSON.stringify({frameId:a.id,type:e,payload:t});a.contentWindow&&a.contentWindow.postMessage(n,new URL(String(a.src)).origin)}function d(e,t){t&&(n.handlers[e]=t)}function u(){var e;a.parentElement&&a.parentElement.removeChild(a),window.removeEventListener("message",l),p.off(f.SetConfig,h),null==(e=n.observer)||e.disconnect(),n.container=void 0,n.observer=void 0;for(const t in n.handlers)delete n.handlers[t]}function h(){const{config:e,getTheme:t,getCurrency:n,isTest:r,getPaymentGatewayUrl:i}=S();c(g.Config,{currency:n(),theme:t(),test:r(),paymentGatewayUrl:i(),expiryFullYear:e.expiryFullYear})}return d(y.Ready,(()=>{const{config:t,getTheme:n,getCurrency:r,isTest:i,getPaymentGatewayUrl:o}=S();c(g.Config,{frameId:a.id,origin:window.location.origin,currency:r(),expiryFullYear:t.expiryFullYear,theme:n(e.theme),paymentGatewayUrl:o(),query:e.query,test:i()})})),e.autoLayout&&d(y.SetHeight,(e=>{a.style.setProperty("height",`${e}px`)})),p.on(f.SetConfig,h),{send:c,handle:d,mount:function(e){if(!i)return o(new s({code:r.IncorrectUrl}));const t=e&&"string"==typeof e?document.querySelector(e):e;if(!(t instanceof HTMLElement))return o(new s({code:r.ContainerRequired}));window.addEventListener("message",l),a.addEventListener("error",(e=>{o(new s({code:r.MountFailed,data:e}))}),!0),n.container=t,t.innerHTML="",t.append(a),n.observer=new MutationObserver((()=>{n.container&&!document.body.contains(n.container)&&u()})),n.observer.observe(document.body,{childList:!0,subtree:!0})},dispose:u,changeTheme:function(e){const{getTheme:t}=S();c(g.Config,{theme:t(e)})},onSuccess:function(e){!e||d(m.Success,e)},onError:function(e){!e||d(m.Error,(t=>{try{const n=JSON.parse(t);e(new s({code:n.code,violations:n.violations,data:n.data,message:n.message,description:n.description,responseStatus:n.responseStatus}))}catch(n){const i=n;e(new s({code:r.MountFailed,message:t,description:i.message}))}}))},onProcess:function(e){!e||d(m.Process,e)},onMounted:function(e){d(y.Mounted,(()=>{a.style.setProperty("opacity","100%"),a.style.setProperty("position","static"),e instanceof Function&&e()}))},onReady:function(e){d(y.ElementReady,e)}}}function P(e){return e.apiKey&&h().api.configure({apiKey:e.apiKey}),{emitError:function(t){const n=t instanceof s?t:new s(t);e.onError?e.onError(n):n.log()},emitSuccess:function(t){e.onSuccess&&e.onSuccess(t)}}}function M(e){const{api:t}=h();return t.fetch({method:"GET",url:`/order-intents/${e}`})}function U(){const{api:e}=h();return e.fetch({url:"/order-intents?order[createdAt]=desc"})}async function R(e){var t;const{api:n}=h(),{source:r}=e,a={sources:r?[r]:[]},[o,l]=await n.fetch({method:"POST",url:`/order-intents/${e.orderIntentId}/capture`,body:a}),c=(null==(t=null==l?void 0:l.order)?void 0:t.generalStatus)||"";return o||!/completed/.test(c)?[new s({code:i.CaptureFailed,extends:o}),null]:[null,l]}async function A(e){const{api:t}=h();return t.fetch({method:"POST",url:`/order-intents/${e.orderIntentId}/sources`,body:{amount:e.amount,reference:e.reference,type:e.paymentMethodType,consumerOwningEntity:e.consumerOwningEntity,paymentConfig:e.paymentConfig}})}function k(e){const{api:t}=h();return t.fetch({url:"/order-intents",method:"POST",body:e})}function q(e){const{api:t}=h();return t.fetch({url:`/order-intents/${e}/void`,method:"POST"})}function L(e){return(e.sources||[]).find((e=>/fatzebra|tyro|nab/i.test(e.gateway)))}function z(){return{getOrders:U,getOrderDetails:M,captureOrderPayment:R,getCardSourceFromOrder:L,attachSourceToOrder:A,createOrder:k,voidOrder:q}}const O={cardNumberRequired:"Card number is required",invalidCardNumber:"Invalid card number",invalidCardLength:"Invalid card number length",invalidCvvLength:"Invalid CVV length",incompleteCvv:"The security code is incomplete",invalidExpiryDate:"Invalid expiry date",unsupportedCard:"This card is not supported",expiryInPast:"Expiry date is in the past",expiryYearInRange:"Expiry year is out of range",expiryFormatInvalid:`Expiry date must be in format 01/${String((new Date).getFullYear()).slice(2,4)}`,expiryFullFormatInvalid:(()=>{const e=String((new Date).getFullYear());return`Expiry date must be in format 01/${e.slice(2,4)} or 01/${e}`})()},T=[{background:"",type:"maestro",label:"Maestro",patterns:/^(5018|502|503|56|58|639|6220|67)/,format:/(\d{1,4})/g,length:/^(12|13|14|15|16|17|18|19)/,cvcLength:[3],luhn:!0},{type:"forbrugsforeningen",label:"Forbrugsforeningen",patterns:/^600/,format:/(\d{1,4})/g,length:/^16$/,cvcLength:[3],luhn:!0},{type:"dankort",label:"Dankort",patterns:/^5019/,format:/(\d{1,4})/g,length:/^16$/,cvcLength:[3],luhn:!0},{type:"visa",label:"Visa",patterns:/^4/,format:/(\d{1,4})/g,length:/^(13|16)/,cvcLength:[3],luhn:!0,image:"data:image/svg+xml,%3Csvg viewBox='0 0 24 16' xmlns='http://www.w3.org/2000/svg' %3E%3Cg fill='none' fill-rule='nonzero' %3E%3Crect fill='%23FFF' height='15.5' rx='2' stroke='%23000' stroke-opacity='.2' stroke-width='.5' width='23.5' x='.25' y='.25' /%3E%3Cpath d='M2.788 5.914A7.201 7.201 0 0 0 1 5.237l.028-.125h2.737c.371.013.672.125.77.519l.595 2.836.182.854 1.666-4.21h1.799l-2.674 6.167H4.304L2.788 5.914Zm7.312 5.37H8.399l1.064-6.172h1.7L10.1 11.284Zm6.167-6.021-.232 1.333-.153-.066a3.054 3.054 0 0 0-1.268-.236c-.671 0-.972.269-.98.531 0 .29.365.48.96.762.98.44 1.435.979 1.428 1.681-.014 1.28-1.176 2.108-2.96 2.108-.764-.007-1.5-.158-1.898-.328l.238-1.386.224.099c.553.23.917.328 1.596.328.49 0 1.015-.19 1.022-.604 0-.27-.224-.466-.882-.769-.644-.295-1.505-.788-1.491-1.674C11.878 5.84 13.06 5 14.74 5c.658 0 1.19.138 1.526.263Zm2.26 3.834h1.415c-.07-.308-.392-1.786-.392-1.786l-.12-.531c-.083.23-.23.604-.223.59l-.68 1.727Zm2.1-3.985L22 11.284h-1.575s-.154-.71-.203-.926h-2.184l-.357.926h-1.785l2.527-5.66c.175-.4.483-.512.889-.512h1.316Z' fill='%23171E6C' /%3E%3C/g%3E%3C/svg%3E",background:"linear-gradient(270deg, #0b2c59 0%, #2770b6 100%)"},{type:"mastercard",label:"MasterCard",patterns:/^(51|52|53|54|55|22|23|24|25|26|27)/,format:/(\d{1,4})/g,length:/^(13|16)/,cvcLength:[3],luhn:!0,image:"data:image/svg+xml,%3Csvg viewBox='0 0 24 16' xmlns='http://www.w3.org/2000/svg'%3E%3Crect fill='%23252525' height='16' rx='2' width='24'/%3E%3Ccircle cx='9' cy='8' fill='%23eb001b' r='5'/%3E%3Ccircle cx='15' cy='8' fill='%23f79e1b' r='5'/%3E%3Cpath d='M12 4c1.214.912 2 2.364 2 4s-.786 3.088-2 4c-1.214-.912-2-2.364-2-4s.786-3.088 2-4z' fill='%23ff5f00'/%3E%3C/svg%3E",background:"linear-gradient(270deg, #131313 0%, #797979 100%)"},{type:"amex",label:"American Express",patterns:/^(34|37)/,format:/(\d{1,4})(\d{1,6})?(\d{1,5})?/,length:/^15$/,cvcLength:[3,4],luhn:!0,image:"data:image/svg+xml,%3Csvg viewBox='0 0 24 16' xmlns='http://www.w3.org/2000/svg'%3E%3Crect fill='%23016fd0' height='16' rx='2' width='24'/%3E%3Cpath d='M13.764 13.394V7.692l10.148.01v1.574l-1.173 1.254 1.173 1.265v1.608h-1.873l-.995-1.098-.988 1.102z' fill='%23fffffe'/%3E%3Cpath d='M14.442 12.769v-4.45h3.772v1.026h-2.55v.695h2.49v1.008h-2.49v.684h2.55v1.037z' fill='%23016fd0'/%3E%3Cpath d='m18.195 12.769 2.088-2.227-2.088-2.222h1.616l1.275 1.41 1.28-1.41h1.546v.035l-2.043 2.187 2.043 2.164v.063H22.35l-1.298-1.424-1.285 1.424z' fill='%23016fd0'/%3E%3Cpath d='M14.237 2.632h2.446l.86 1.95v-1.95h3.02l.52 1.462.523-1.462h2.306v5.701H11.725z' fill='%23fffffe'/%3E%3Cg fill='%23016fd0'%3E%3Cpath d='m14.7 3.251-1.974 4.446h1.354l.373-.89h2.018l.372.89h1.387L16.265 3.25zm.17 2.558.592-1.415.592 1.415z'/%3E%3Cpath d='M18.212 7.696V3.25l1.903.006.98 2.733.985-2.74h1.832v4.446l-1.179.01V4.653L21.62 7.696h-1.075l-1.136-3.054v3.054z'/%3E%3C/g%3E%3C/svg%3E",background:"linear-gradient(270deg, #44629a 0%, #6093c9 100%)"},{type:"dinersclub",label:"Diners Club International",patterns:/^(30|36|38|39)/,format:/(\d{1,4})(\d{1,6})?(\d{1,4})?/,length:/^14$/,cvcLength:[3],luhn:!0},{type:"discover",label:"Discover",patterns:/^(60|64|65|622)/,format:/(\d{1,4})/g,length:/^16$/,cvcLength:[3],luhn:!0,image:"data:image/svg+xml, %3Csvg viewBox='0 0 24 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M21.997 15.75H22c.955.008 1.74-.773 1.751-1.746V2.006a1.789 1.789 0 0 0-.52-1.25A1.72 1.72 0 0 0 21.997.25H2.001A1.718 1.718 0 0 0 .77.757c-.33.33-.517.779-.521 1.247v11.99c.004.47.191.92.52 1.25.329.328.771.51 1.233.506h19.994Zm0 .5h-.002.002Z' fill='%23FFF' stroke='%23000' stroke-opacity='.2' stroke-width='.5'/%3E%3Cpath d='M12.612 16h9.385A1.986 1.986 0 0 0 24 14.03v-2.358A38.74 38.74 0 0 1 12.612 16Z' fill='%23F27712'/%3E%3Cpath d='M23.172 9.296h-.852l-.96-1.266h-.091v1.266h-.695V6.152H21.6c.803 0 1.266.33 1.266.927 0 .488-.29.802-.81.902l1.116 1.315Zm-1.026-2.193c0-.306-.232-.463-.662-.463h-.215v.952h.199c.446 0 .678-.166.678-.489Zm-4.005-.951h1.97v.53h-1.275v.703h1.225v.538h-1.225v.852h1.274v.53h-1.97V6.152Zm-2.235 3.227L14.4 6.143h.761l.952 2.119.96-2.119h.745L16.295 9.38h-.389Zm-6.298-.008c-1.059 0-1.887-.72-1.887-1.655 0-.91.845-1.647 1.904-1.647.298 0 .546.058.852.19v.729a1.241 1.241 0 0 0-.869-.356c-.662 0-1.167.48-1.167 1.084 0 .637.497 1.092 1.2 1.092.315 0 .555-.1.836-.347v.728a2.13 2.13 0 0 1-.869.182ZM7.506 8.336c0 .613-.505 1.035-1.233 1.035-.53 0-.91-.182-1.233-.596l.455-.389c.157.282.422.422.753.422.315 0 .538-.19.538-.438 0-.141-.066-.249-.207-.331a2.88 2.88 0 0 0-.48-.183c-.653-.206-.877-.43-.877-.868 0-.514.48-.903 1.109-.903.397 0 .753.125 1.051.356l-.364.414a.761.761 0 0 0-.563-.248c-.298 0-.513.149-.513.347 0 .166.124.257.538.398.794.248 1.026.48 1.026.993v-.009ZM4.088 6.152h.695v3.153h-.695V6.152ZM1.854 9.305H.828V6.152h1.026c1.125 0 1.903.645 1.903 1.572 0 .472-.231.919-.637 1.217-.348.248-.737.364-1.274.364h.008Zm.81-2.367c-.23-.182-.496-.248-.95-.248h-.191v2.085h.19c.447 0 .728-.083.952-.248.24-.199.38-.497.38-.803 0-.306-.14-.596-.38-.786Z' fill='%23000'/%3E%3Cpath d='M12.414 6.069c-.91 0-1.655.728-1.655 1.63 0 .96.711 1.68 1.655 1.68a1.64 1.64 0 0 0 1.655-1.655c0-.927-.72-1.655-1.655-1.655Z' fill='%23F27712'/%3E%3C/svg%3E"},{type:"unionpay",label:"UnionPay",patterns:/^(62|88)/,format:/(\d{1,4})/g,length:/^(16|17|18|19)/,cvcLength:[3],luhn:!1,image:"data:image/svg+xml,%3Csvg viewBox='0 0 24 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.546 0h5.794c.808 0 1.311.726 1.123 1.619L8.765 14.368c-.19.89-1 1.616-1.81 1.616H1.164c-.808 0-1.312-.726-1.123-1.616L2.738 1.619C2.927.726 3.736 0 4.546 0' fill='%23dd2423'/%3E%3Cpath d='M9.858 0h6.662c.809 0 .444.726.254 1.619l-2.697 12.749c-.19.89-.13 1.616-.94 1.616H6.474c-.81 0-1.312-.726-1.122-1.616L8.05 1.619C8.241.726 9.05 0 9.858 0' fill='%2316315e'/%3E%3Cpath d='M16.256 0h5.794c.81 0 1.313.726 1.122 1.619l-2.697 12.749c-.19.89-1 1.616-1.81 1.616h-5.791c-.81 0-1.313-.726-1.123-1.616l2.697-12.749C14.637.726 15.446 0 16.256 0' fill='%23036862'/%3E%3Cpath d='M6.059 4.086c-.596.006-.772 0-.828-.015l-.425 2.156c-.086.413-.15.708-.363.898a.612.612 0 0 1-.428.164c-.264 0-.418-.145-.444-.419l-.005-.094.08-.556s.423-1.86.498-2.106a.195.195 0 0 0 .006-.028c-.821.008-.967 0-.977-.015-.005.02-.025.135-.025.135l-.431 2.097-.037.178-.072.582c0 .172.03.313.092.432.196.378.756.435 1.073.435.408 0 .791-.096 1.05-.27.449-.292.566-.749.671-1.155l.049-.208s.434-1.932.508-2.183c.003-.014.004-.022.008-.028zm1.479 1.558c-.105 0-.296.028-.468.121-.063.036-.122.076-.184.117l.056-.224-.03-.037c-.365.081-.447.092-.784.144l-.028.02c-.04.358-.074.626-.22 1.328-.054.259-.112.52-.17.778l.016.033c.346-.02.45-.02.75-.015l.025-.029c.038-.215.043-.265.127-.7.04-.207.123-.66.164-.822a.523.523 0 0 1 .22-.076c.167 0 .147.162.14.226a8.84 8.84 0 0 1-.13.764l-.043.195c-.03.145-.061.285-.09.428l.012.029c.34-.02.444-.02.735-.015l.034-.029c.053-.335.068-.425.161-.914l.047-.225c.091-.44.137-.662.068-.844-.073-.203-.247-.253-.408-.253zm1.652.46c-.18.039-.296.064-.41.08-.115.021-.225.04-.4.066l-.014.014-.013.01c-.018.144-.03.268-.055.414-.02.15-.052.321-.103.567-.04.189-.06.254-.083.32-.022.067-.046.131-.09.316l.01.017.008.016c.164-.009.27-.015.38-.016.11-.004.224 0 .4.001l.015-.013.017-.016c.025-.167.03-.212.045-.293.015-.087.042-.208.107-.531.03-.152.065-.303.097-.458.033-.154.068-.306.1-.458l-.004-.018zm.004-.62c-.164-.107-.453-.073-.647.075-.194.144-.216.35-.052.458.162.104.451.073.644-.076.193-.148.217-.351.055-.457zm.994 2.473c.333 0 .674-.1.93-.4.198-.243.288-.604.32-.753.102-.493.022-.723-.078-.863-.151-.214-.42-.283-.698-.283-.167 0-.565.019-.876.334-.224.228-.327.537-.389.833-.063.302-.135.846.319 1.048.14.066.342.084.472.084zm-.026-1.109c.077-.373.167-.687.398-.687.181 0 .194.233.114.608-.014.083-.08.392-.17.524-.062.097-.136.156-.218.156-.024 0-.169 0-.17-.236a1.76 1.76 0 0 1 .046-.365zm2.107 1.061.026-.029c.037-.215.043-.265.124-.7.041-.207.126-.66.165-.822.075-.038.148-.076.221-.076.167 0 .147.162.14.226-.006.108-.067.46-.131.764l-.04.195c-.03.145-.063.285-.093.428l.013.03c.342-.021.441-.021.734-.016l.035-.029c.051-.336.065-.425.161-.914l.046-.225c.091-.44.138-.662.07-.844-.075-.203-.251-.253-.41-.253-.104 0-.297.028-.468.121a3.058 3.058 0 0 0-.182.117l.052-.224-.028-.037c-.365.081-.448.092-.784.144l-.026.02c-.041.358-.074.626-.22 1.328-.055.259-.112.52-.17.778l.016.033c.346-.02.45-.02.749-.015zm2.509.015.15-.8s.108-.5.115-.519c0 0 .034-.052.068-.073h.05c.475 0 1.01 0 1.43-.34.286-.233.481-.577.569-.996a1.65 1.65 0 0 0 .039-.346c0-.16-.03-.32-.114-.443-.214-.33-.64-.336-1.132-.338l-.243.002c-.63.009-.883.006-.986-.008l-.026.14-.225 1.154-.566 2.563c.55-.008.776-.008.87.004zm.418-2.045.239-1.145.007-.059.004-.045.096.011.506.048c.195.083.276.298.22.578-.052.255-.202.47-.396.574-.16.088-.355.095-.556.095h-.13zm1.494.99c-.064.298-.137.841.315 1.035a.81.81 0 0 0 .404.08c.139-.008.267-.085.386-.195l-.032.136.02.03c.325-.016.426-.016.778-.013l.032-.027c.052-.332.1-.655.234-1.292.065-.305.13-.606.197-.91l-.01-.033c-.364.074-.462.09-.811.144l-.027.024-.01.09a.515.515 0 0 0-.255-.23c-.156-.068-.52.019-.835.334-.22.224-.326.532-.386.827zm.763.018c.078-.366.167-.677.399-.677.146 0 .223.15.208.403l-.042.205c-.023.11-.048.217-.073.325a.823.823 0 0 1-.085.19.387.387 0 0 1-.283.151c-.024 0-.166 0-.171-.232-.002-.115.02-.234.047-.365zm3.987-1.21-.028-.036c-.36.08-.425.093-.756.142l-.024.027-.004.017v-.006c-.247.625-.24.49-.44.982l-.002-.06-.05-1.066-.032-.036c-.377.08-.385.093-.733.142l-.028.027c-.003.013-.003.027-.006.042l.003.006c.043.244.033.19.076.576.02.19.048.38.068.567.034.313.054.468.096.946-.235.426-.291.588-.517.963l.001.003-.159.278c-.018.029-.035.049-.058.057a.22.22 0 0 1-.104.017h-.089l-.13.48.45.009a.549.549 0 0 0 .519-.32l.283-.534h-.005l.03-.038c.19-.45 1.639-3.185 1.639-3.185zm-4.75 6.308h-.191l.706-2.573h.235l.074-.265.007.295c-.008.182.122.344.464.317h.395l.137-.495h-.15c-.085 0-.125-.024-.12-.075l-.007-.3h-.732v.002c-.237.005-.944.025-1.088.067-.173.049-.355.193-.355.193l.071-.265h-.685l-.143.526-.716 2.613h-.139l-.136.492h1.365l-.046.164h.672l.045-.164h.189zm-.56-2.05c-.11.034-.314.135-.314.135l.181-.658h.545l-.132.48s-.168.01-.28.043zm.01.94s-.17.023-.283.051c-.111.037-.32.154-.32.154l.188-.684h.548zm-.305 1.116h-.546l.158-.577h.545zm1.315-1.595h.787l-.113.403h-.797l-.12.44h.698l-.529.82a.223.223 0 0 1-.107.098.293.293 0 0 1-.141.045h-.194l-.133.483h.506c.264 0 .419-.132.534-.305l.362-.546.078.554a.257.257 0 0 0 .13.189c.05.028.103.076.177.083.08.004.137.007.175.007h.249l.15-.54h-.099c-.056 0-.153-.011-.17-.03-.016-.024-.016-.06-.025-.116l-.08-.556h-.322l.141-.185h.797l.122-.441h-.737l.115-.403h.735l.136-.498h-2.19zm-6.648 1.708.184-.673h.755l.138-.5h-.756l.115-.415h.739l.137-.484H9.966l-.134.484h.42l-.112.414h-.421l-.14.51h.42l-.245.89c-.033.117.015.162.046.217a.205.205 0 0 0 .135.109c.074.018.125.029.194.029h.851l.152-.555-.377.058c-.073 0-.275-.01-.253-.084zm.086-3.221-.19.38a.438.438 0 0 1-.112.16c-.03.02-.087.028-.17.028h-.1l-.134.487h.331a.7.7 0 0 0 .34-.097c.064-.037.08-.016.129-.067l.112-.107h1.035l.137-.507h-.757l.132-.277zm1.53 3.23c-.019-.027-.006-.077.021-.18l.283-1.03h1.007c.147-.003.253-.005.321-.01a.617.617 0 0 0 .243-.09.474.474 0 0 0 .176-.179c.043-.066.113-.21.173-.433l.356-1.305-1.045.007s-.321.052-.463.11a1.887 1.887 0 0 0-.347.244l.094-.358h-.645l-.904 3.298a2.21 2.21 0 0 0-.058.277c-.002.06.069.12.115.165.054.045.134.038.21.045.08.007.196.01.354.01h.496l.152-.565-.444.046a.114.114 0 0 1-.096-.052zm.487-1.907h1.057l-.067.232c-.01.005-.032-.012-.14.002h-.915zm.212-.778h1.066l-.077.28s-.502-.006-.583.01c-.354.068-.56.276-.56.276zm.802 1.787a.126.126 0 0 1-.042.071c-.022.016-.057.021-.108.021h-.151l.009-.282H12.7l-.025 1.38c-.001.1.007.158.074.204.066.058.27.065.545.065h.392l.142-.517-.342.02-.113.008c-.016-.007-.03-.014-.047-.032-.015-.016-.039-.006-.035-.106l.003-.354.358-.016c.194 0 .277-.07.347-.136.068-.063.09-.136.115-.234l.06-.313h-.493z' fill='%23fefefe'/%3E%3C/svg%3E"},{type:"jcb",label:"JCB",patterns:/^35/,format:/(\d{1,4})/g,length:/^16$/,cvcLength:[3],luhn:!0,image:"data:image/svg+xml,%3Csvg viewBox='0 0 23 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M.205 16h4.518c1.028 0 2.26-1.195 2.26-2.133V0h-4.52C1.436 0 .205 1.195.205 3.2z' fill='%23047ab1'/%3E%3Cpath d='M2.77 10.816a9.77 9.77 0 0 1-2.565-.341V9.3a4.592 4.592 0 0 0 2.146.619c.87 0 1.356-.576 1.356-1.365V5.333h2.146v3.222c0 1.258-.7 2.261-3.084 2.261z' fill='%23fff'/%3E%3Cpath d='M8.112 16h4.517c1.028 0 2.26-1.195 2.26-2.133V0H10.37C9.343 0 8.11 1.195 8.11 3.2z' fill='%23d42d06'/%3E%3Cpath d='M8.112 6.08c.655-.597 1.784-.97 3.614-.885.994.042 2.033.32 2.033.32v1.184a4.785 4.785 0 0 0-1.954-.608c-1.39-.118-2.236.618-2.236 1.909s.847 2.027 2.236 1.92a4.853 4.853 0 0 0 1.954-.619v1.174s-1.04.288-2.033.33c-1.83.086-2.96-.288-3.614-.885z' fill='%23fff'/%3E%3Cpath d='M16.018 16h4.518c1.028 0 2.259-1.195 2.259-2.133V0h-4.518c-1.028 0-2.26 1.195-2.26 3.2z' fill='%2367b637'/%3E%3Cpath d='M21.665 9.28c0 .853-.7 1.387-1.638 1.387h-4.01V5.333h3.649l.26.011c.824.043 1.434.501 1.434 1.29 0 .62-.418 1.153-1.174 1.28v.033c.835.053 1.48.554 1.48 1.333zm-2.88-3.104a1.087 1.087 0 0 0-.147-.01h-1.355v1.343h1.502a.667.667 0 0 0 .52-.672c0-.362-.238-.608-.52-.661zm.17 2.176a1.028 1.028 0 0 0-.181-.01h-1.491v1.46h1.49l.181-.02c.283-.065.52-.342.52-.715 0-.374-.226-.64-.52-.715z' fill='%23fff'/%3E%3C/svg%3E"}];function D(e){return T.find((t=>t.patterns.test(e)))}function K(e){if(!e)return O.cardNumberRequired;const t=D(e);return t?t.length.test(String(e.length))?!(t.luhn&&!Z(e))||O.invalidCardNumber:O.invalidCardLength:O.unsupportedCard}function V(e,t=""){if(t.length<3)return O.incompleteCvv;if(e){const n=D(e);if(n&&!n.cvcLength.includes(t.length))return O.invalidCvvLength}return!0}function Y(e,t){const n=e?`0${e}`.slice(-2):"MM",r=t?`0${String(t)}`.slice(-2):"YY";return e&&t?`${n}/${r}`:""}function $(e){let t=0,n=0;if("string"==typeof e){e=e.replace(/\//g,""),t=parseInt(e.slice(0,2));const r=(new Date).getFullYear(),i=`${e.slice(2,6)}`;i.length>=2&&(n=2===i.length?parseInt(String(r).slice(0,2)+i):parseInt(i))}else e&&"object"==typeof e&&(t=parseInt(String(e.month)),n=parseInt(String(e.year)));return{month:t||0,year:n||0}}function H(e,t){const n=Date.now(),{year:r,month:i}=$(e),a=i>0&&i<=12,o=[2,4].includes(String(r).length);if(!a||!o)return t?O.expiryFullFormatInvalid:O.expiryFormatInvalid;if((new Date(r,i,-1).getTime()||0)<n)return O.expiryInPast;const l=(new Date).getFullYear();return r>=l&&r<l+50||O.expiryYearInRange}function Z(e){if(/[^0-9-\s]+/.test(e))return!1;let t=0,n=!1;for(let r=(e=e.replace(/\D/g,"")).length-1;r>=0;r--){const i=e.charAt(r);let a=parseInt(i,10);n&&(a*=2)>9&&(a-=9),t+=a,n=!n}return t%10==0}async function N(e){const{api:t}=h();return t.fetch({url:`/credit-cards/${e}`})}function j(e){const t={},n={number:K(e.number),verificationCode:V(e.number,e.cvc),expiry:H({year:e.expiryYear,month:e.expiryMonth})};return Object.keys(n).forEach((e=>{const r=n[e];"string"==typeof r&&(t[e]=[r])})),t}async function G(e){const{api:t}=h(),n=j({number:e.number,cardholder:e.cardholder,expiryYear:e.expiryYear,expiryMonth:e.expiryMonth,cvc:e.verificationCode});if(Object.keys(n).length>0)return[new s({code:o.Failed,violations:n}),null];const[r,i]=await t.fetch({method:"POST",url:"/credit-cards",body:{cardholder:e.cardholder,currency:`/currencies/${e.currency||"AUD"}`,description:e.description||"",number:e.number,verificationCode:e.verificationCode,expiryMonth:e.expiryMonth,expiryYear:(()=>{const t=(new Date).getFullYear();return 2===String(e.expiryYear).length?parseInt(String(t).slice(0,2)+e.expiryYear):e.expiryYear})()}});return r?[new s({code:o.Failed,extends:r}),null]:[null,i]}return e.ApiError=n,e.CapturePaymentError=i,e.CreateCardError=o,e.ElementEvent=m,e.Error=s,e.FrameError=r,e.PayNowError=l,e.PaymentCard=class{constructor(e){this.raw=e,this.isHidden=!0,this.expiryMonth=(null==e?void 0:e.expiryMonth)||0,this.expiryYear=(null==e?void 0:e.expiryYear)||0,this.number=(null==e?void 0:e.pan)||"",this.cardholder=(null==e?void 0:e.cardholder)||""}get mask(){const e=[];for(let t=0;t<16;t++){const n={blockEnd:t%4==3};this.isHidden&&t<12?n.isEmpty=!0:parseInt(this.number[t])>=0?n.value=this.number[t]:n.isEmpty=!0,e.push(n)}return e}get numberByGroups(){var e;return(null==(e=this.number.match(/.{1,4}/g))?void 0:e.join(" "))||""}get expiryString(){return Y(this.expiryMonth,this.expiryYear)}get image(){var e;return(null==(e=this.type)?void 0:e.image)||""}get background(){var e;return(null==(e=this.type)?void 0:e.background)||""}get type(){return D(this.number)}hide(){this.isHidden=!0}show(){this.isHidden=!1}},e.SdkEvent=g,e.UiEvent=y,e.VoidPaymentError=a,e.buildExpiryDateString=Y,e.capturePayment=function(e){const{emitError:t,emitSuccess:a}=P({apiKey:e.apiKey,onError:e.onError,onSuccess:e.onSuccess});let o=null;async function l(n){const{captureOrderPayment:r}=z();n&&e.verificationCode&&(n.verificationCode=e.verificationCode);const[i,o]=await r({source:n,orderIntentId:e.orderIntentId});o?a(o):i&&t(i),c()}function c(){null==o||o.dispose()}return async function(){const{getOrderDetails:a,getCardSourceFromOrder:c}=z(),{orderIntentId:d,apiKey:s}=e;if(!s)return t({code:n.KeyRequired});if(!d)return t({code:i.IntentIdRequired});if(e.attachCard){const[n,r]=await function(){const{attachSourceToOrder:t}=z(),{orderIntentId:n,attachCard:r}=e;return r?t({orderIntentId:n,reference:r.reference,paymentMethodType:r.type,amount:r.amount,consumerOwningEntity:r.consumerOwningEntity,paymentConfig:r.paymentConfig}):[]}();if(n||!r)return t({code:i.AttachCardFailed,extends:n})}const[u,h]=await a(d);if(u||!h)return t({code:i.IntentFailed,extends:u});const p=c(h);h.securityTokenRequired&&p?function(n){var i;o=x({url:"/verify",theme:e.theme,autoLayout:!0,query:{orderIntent:n.orderIntent,sourceToVerify:n.source,apiKey:e.apiKey,isVerificationCodeRequired:!!e.isVerificationCodeRequired&&!e.verificationCode,height:null!=(i=e.height)?i:400,meta:e.meta}}),o.onError((e=>{t(e),null==o||o.dispose()})),o.onSuccess((e=>l(e))),o.onMounted(e.onMounted),e.onVerify?e.onVerify({mount:o.mount,dispose:o.dispose}):t({code:r.ContainerRequired})}({source:p,orderIntent:h}):await l()}().catch(t),{dispose:c,changeTheme:function(e){null==o||o.changeTheme(e)}}},e.configurePaymentElements=function(e){v={...v||{},...e||{}};const{api:t}=h();t.configure({baseUrl:E(),apiKey:(null==v?void 0:v.apiKey)||""}),p.emit(f.SetConfig,v)},e.createPaymentCard=function(e){const t=x({url:"/create-card",theme:e.theme,autoLayout:!0,query:{apiKey:e.apiKey,cardholder:e.cardholder}});return t.onError(e.onError),t.onSuccess(e.onSuccess),t.onMounted(e.onMounted),t.onProcess(e.onProcess),t.mount(e.container),t.handle(y.DataChanged,e.onChange),{prefill:function(e){t.send(g.PreFill,e)},disableSubmit:function(){t.send(g.DisableSubmit)},enableSubmit:function(){t.send(g.EnableSubmit)},submit:function(){t.send(g.Submit)},changeTheme:t.changeTheme,dispose:t.dispose}},e.getCardTypeByNumber=D,e.getPaymentSystem=function(e){const t=D(e);return t?t.type:""},e.luhnCheck=Z,e.parseExpiryDate=$,e.payNow=function(e){var t;const n=e,r=null==(t=n.order)?void 0:t.intentId,i=e.orderIntentId||r,a=e.card||{cardholder:n.cardholder,number:n.number,expiryYear:0,expiryMonth:0},o=x({url:"/pay-now",theme:e.theme,autoLayout:!0,query:{apiKey:e.apiKey,card:a.number?a:void 0,isVerificationCodeRequired:!!e.isVerificationCodeRequired,sourceConfig:e.sourceConfig,isActionsVisible:e.isActionsVisible,orderIntentId:i}});return o.onError(e.onError),o.onSuccess(e.onSuccess),o.onMounted(e.onMounted),o.onProcess(e.onProcess),o.onReady(e.onReady),o.mount(e.container),{changeTheme:o.changeTheme,submit:function(){o.send(g.Submit)},dispose:o.dispose}},e.useCard=function(){return{tokenizeCard:G,validateCard:j,getCardDetails:N}},e.useOrder=z,e.usePaymentApi=h,e.validateCardCvv=V,e.validateCardExpiryDate=H,e.validateCardNumber=K,e.voidPayment=async function(e){if(!e.orderIntentId)throw new s({code:a.IntentIdRequired});const{voidOrder:t}=z();P({apiKey:e.apiKey});const[n,r]=await t(e.orderIntentId);if(n)throw n;return r},Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),e}({});