@adyen/adyen-web 6.26.0 → 6.27.0

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.
Files changed (84) hide show
  1. package/dist/cjs/adyen.css +1 -1
  2. package/dist/cjs/adyen.css.map +1 -1
  3. package/dist/cjs/index.cjs +1 -1
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +14 -15
  6. package/dist/es/adyen.css +1 -1
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/ANCV/ANCV.js +1 -1
  9. package/dist/es/components/ANCV/ANCV.js.map +1 -1
  10. package/dist/es/components/Ach/Ach.js +1 -1
  11. package/dist/es/components/Ach/Ach.js.map +1 -1
  12. package/dist/es/components/Blik/Blik.js +1 -1
  13. package/dist/es/components/Blik/Blik.js.map +1 -1
  14. package/dist/es/components/Card/Card.js +1 -1
  15. package/dist/es/components/Card/Card.js.map +1 -1
  16. package/dist/es/components/Dropin/Dropin.js +1 -1
  17. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  18. package/dist/es/components/Giftcard/Giftcard.js +1 -1
  19. package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
  20. package/dist/es/components/MBWay/MBWay.js +1 -1
  21. package/dist/es/components/MBWay/MBWay.js.map +1 -1
  22. package/dist/es/components/PayByBankPix/PayByBankPix.js +1 -1
  23. package/dist/es/components/PayByBankPix/PayByBankPix.js.map +1 -1
  24. package/dist/es/components/PayTo/PayTo.js +1 -1
  25. package/dist/es/components/PayTo/PayTo.js.map +1 -1
  26. package/dist/es/components/Pix/Pix.js +1 -1
  27. package/dist/es/components/Pix/Pix.js.map +1 -1
  28. package/dist/es/components/UPI/UPI.js +1 -1
  29. package/dist/es/components/UPI/UPI.js.map +1 -1
  30. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  31. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  32. package/dist/es/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js +1 -1
  33. package/dist/es/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js.map +1 -1
  34. package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
  35. package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
  36. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
  37. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  38. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  39. package/dist/es/core/Errors/SRPanel.js +1 -1
  40. package/dist/es/core/Errors/SRPanel.js.map +1 -1
  41. package/dist/es/core/config.js +1 -1
  42. package/dist/es/index.d.ts +14 -15
  43. package/dist/es/utils/Script.js +1 -1
  44. package/dist/es/utils/Script.js.map +1 -1
  45. package/dist/es-legacy/adyen.css +1 -1
  46. package/dist/es-legacy/adyen.css.map +1 -1
  47. package/dist/es-legacy/components/ANCV/ANCV.js +1 -1
  48. package/dist/es-legacy/components/ANCV/ANCV.js.map +1 -1
  49. package/dist/es-legacy/components/Ach/Ach.js +1 -1
  50. package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
  51. package/dist/es-legacy/components/Blik/Blik.js +1 -1
  52. package/dist/es-legacy/components/Blik/Blik.js.map +1 -1
  53. package/dist/es-legacy/components/Card/Card.js +1 -1
  54. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  55. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  56. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  57. package/dist/es-legacy/components/Giftcard/Giftcard.js +1 -1
  58. package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
  59. package/dist/es-legacy/components/MBWay/MBWay.js +1 -1
  60. package/dist/es-legacy/components/MBWay/MBWay.js.map +1 -1
  61. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
  62. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
  63. package/dist/es-legacy/components/PayTo/PayTo.js +1 -1
  64. package/dist/es-legacy/components/PayTo/PayTo.js.map +1 -1
  65. package/dist/es-legacy/components/Pix/Pix.js +1 -1
  66. package/dist/es-legacy/components/Pix/Pix.js.map +1 -1
  67. package/dist/es-legacy/components/UPI/UPI.js +1 -1
  68. package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
  69. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  70. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  71. package/dist/es-legacy/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js +1 -1
  72. package/dist/es-legacy/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js.map +1 -1
  73. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
  74. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
  75. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
  76. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  77. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  78. package/dist/es-legacy/core/Errors/SRPanel.js +1 -1
  79. package/dist/es-legacy/core/Errors/SRPanel.js.map +1 -1
  80. package/dist/es-legacy/core/config.js +1 -1
  81. package/dist/es-legacy/utils/Script.js +1 -1
  82. package/dist/es-legacy/utils/Script.js.map +1 -1
  83. package/package.json +1 -1
  84. package/styles/adyen.css +1 -1
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import r from"./components/ANCVInput.js";import o from"./components/ANCVAwait/config.js";import{Await as s}from"../internal/Await/Await.js";import n from"../../core/Errors/SRPanelProvider.js";import i from"../../core/Errors/AdyenCheckoutError.js";import a from"../internal/PayButton/PayButton.js";import{sanitizeResponse as p,verifyPaymentDidNotFail as h}from"../internal/UIElement/utils.js";function m(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}class l extends e{formatData(){return{paymentMethod:{type:l.type,beneficiaryId:this.state.data?.beneficiaryId}}}submit(){if(!this.isValid)return this.showValidation(),!1;this.createOrder().then(this.makePaymentsCall).then(p).then(h).then(this.handleResponse).catch(this.handleFailedResult)}get isValid(){return!!this.state.isValid}get displayName(){return this.props.name}componentToRender(){return this.props.paymentData?t(n,{srPanel:this.props.modules.srPanel},t(s,{clientKey:this.props.clientKey,paymentData:this.props.paymentData,onError:this.props.onError,onComplete:this.onComplete,brandLogo:this.icon,type:this.constructor.type,messageText:this.props.i18n.get("ancv.confirmPayment"),awaitText:this.props.i18n.get("await.waitForConfirmation"),showCountdownTimer:o.showCountdownTimer,throttleTime:o.THROTTLE_TIME,throttleInterval:o.THROTTLE_INTERVAL,onActionHandled:this.onActionHandled})):t(r,{ref:t=>{this.componentRef=t},...this.props,onSubmit:this.submit,onChange:this.setState,payButton:this.payButton,showPayButton:this.props.showPayButton})}constructor(...e){super(...e),m(this,"onOrderRequest",t=>this.props.onOrderRequest?new Promise((e,r)=>{this.props.onOrderRequest(e,r,t)}):this.props.session?this.props.session.createOrder():void 0),m(this,"createOrder",()=>(this.setStatus("loading"),this.props.order?Promise.resolve():this.onOrderRequest(this.data).then(t=>{const e={order:{orderData:t.orderData,pspReference:t.pspReference}};return this.setState(e),Promise.resolve()}).catch(t=>{t instanceof i?this.handleError(t):this.handleError(new i("ERROR",t))}))),m(this,"payButton",e=>t(a,e))}}m(l,"type","ancv");export{l as ANCVElement,l as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import r from"./components/ANCVInput.js";import o from"./components/ANCVAwait/config.js";import{Await as s}from"../internal/Await/Await.js";import n from"../../core/Errors/AdyenCheckoutError.js";import i from"../internal/PayButton/PayButton.js";import{sanitizeResponse as a,verifyPaymentDidNotFail as p}from"../internal/UIElement/utils.js";function h(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}class m extends e{formatData(){return{paymentMethod:{type:m.type,beneficiaryId:this.state.data?.beneficiaryId}}}submit(){if(!this.isValid)return this.showValidation(),!1;this.createOrder().then(this.makePaymentsCall).then(a).then(p).then(this.handleResponse).catch(this.handleFailedResult)}get isValid(){return!!this.state.isValid}get displayName(){return this.props.name}componentToRender(){return this.props.paymentData?t(s,{clientKey:this.props.clientKey,paymentData:this.props.paymentData,onError:this.props.onError,onComplete:this.onComplete,brandLogo:this.icon,type:this.constructor.type,messageText:this.props.i18n.get("ancv.confirmPayment"),awaitText:this.props.i18n.get("await.waitForConfirmation"),showCountdownTimer:o.showCountdownTimer,throttleTime:o.THROTTLE_TIME,throttleInterval:o.THROTTLE_INTERVAL,onActionHandled:this.onActionHandled}):t(r,{ref:t=>{this.componentRef=t},...this.props,onSubmit:this.submit,onChange:this.setState,payButton:this.payButton,showPayButton:this.props.showPayButton})}constructor(...e){super(...e),h(this,"onOrderRequest",t=>this.props.onOrderRequest?new Promise((e,r)=>{this.props.onOrderRequest(e,r,t)}):this.props.session?this.props.session.createOrder():void 0),h(this,"createOrder",()=>(this.setStatus("loading"),this.props.order?Promise.resolve():this.onOrderRequest(this.data).then(t=>{const e={order:{orderData:t.orderData,pspReference:t.pspReference}};return this.setState(e),Promise.resolve()}).catch(t=>{t instanceof n?this.handleError(t):this.handleError(new n("ERROR",t))}))),h(this,"payButton",e=>t(i,e))}}h(m,"type","ancv");export{m as ANCVElement,m as default};
2
2
  //# sourceMappingURL=ANCV.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ANCV.js","sources":["../../../../src/components/ANCV/ANCV.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport ANCVInput from './components/ANCVInput';\nimport config from './components/ANCVAwait/config';\nimport { Await } from '../../components/internal/Await';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport PayButton from '../internal/PayButton';\nimport { ANCVConfiguration } from './types';\nimport { sanitizeResponse, verifyPaymentDidNotFail } from '../internal/UIElement/utils';\n\nexport class ANCVElement extends UIElement<ANCVConfiguration> {\n public static type = 'ancv';\n\n /**\n * Formats the component data output\n */\n formatData() {\n return {\n paymentMethod: {\n type: ANCVElement.type,\n beneficiaryId: this.state.data?.beneficiaryId\n }\n };\n }\n\n private onOrderRequest = data => {\n if (this.props.onOrderRequest)\n return new Promise((resolve, reject) => {\n this.props.onOrderRequest(resolve, reject, data);\n });\n\n if (this.props.session) {\n return this.props.session.createOrder();\n }\n };\n\n /**\n * Check if order exists, if it does Resolve.\n * Otherwise createOrder and then Resolve.\n */\n public createOrder = (): Promise<void> => {\n this.setStatus('loading');\n\n // allow for multiple ANCV payments, follow giftcard logic and just use order if it exists\n if (this.props.order) {\n return Promise.resolve();\n }\n\n return this.onOrderRequest(this.data)\n .then((order: { orderData: string; pspReference: string }) => {\n const stateOrder = { order: { orderData: order.orderData, pspReference: order.pspReference } };\n this.setState(stateOrder);\n return Promise.resolve();\n })\n .catch(error => {\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', error));\n }\n });\n };\n\n public submit() {\n if (!this.isValid) {\n this.showValidation();\n return false;\n }\n\n this.createOrder()\n .then(this.makePaymentsCall)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch(this.handleFailedResult);\n }\n\n // Reimplement payButton similar to GiftCard to allow to set onClick\n public payButton = props => {\n return <PayButton {...props} />;\n };\n\n get isValid(): boolean {\n return !!this.state.isValid;\n }\n\n get displayName(): string {\n return this.props.name;\n }\n\n protected override componentToRender(): h.JSX.Element {\n if (this.props.paymentData) {\n return (\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <Await\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onError={this.props.onError}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n type={this.constructor['type']}\n messageText={this.props.i18n.get('ancv.confirmPayment')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n showCountdownTimer={config.showCountdownTimer}\n throttleTime={config.THROTTLE_TIME}\n throttleInterval={config.THROTTLE_INTERVAL}\n onActionHandled={this.onActionHandled}\n />\n </SRPanelProvider>\n );\n }\n\n return (\n <ANCVInput\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n onSubmit={this.submit}\n onChange={this.setState}\n payButton={this.payButton}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n}\n\nexport default ANCVElement;\n"],"names":["ANCVElement","UIElement","formatData","paymentMethod","type","beneficiaryId","this","state","data","submit","isValid","showValidation","createOrder","then","makePaymentsCall","sanitizeResponse","verifyPaymentDidNotFail","handleResponse","catch","handleFailedResult","displayName","props","name","componentToRender","paymentData","h","SRPanelProvider","srPanel","modules","Await","clientKey","onError","onComplete","brandLogo","icon","constructor","messageText","i18n","get","awaitText","showCountdownTimer","config","throttleTime","THROTTLE_TIME","throttleInterval","THROTTLE_INTERVAL","onActionHandled","ANCVInput","ref","componentRef","onSubmit","onChange","setState","payButton","showPayButton","super","args","_define_property","onOrderRequest","Promise","resolve","reject","session","setStatus","order","stateOrder","orderData","pspReference","error","AdyenCheckoutError","handleError","PayButton"],"mappings":"ooBAWO,MAAMA,UAAoBC,EAM7BC,UAAAA,GACI,MAAO,CACHC,cAAe,CACXC,KAAMJ,EAAYI,KAClBC,cAAeC,KAAKC,MAAMC,MAAMH,eAG5C,CAwCOI,MAAAA,GACH,IAAKH,KAAKI,QAEN,OADAJ,KAAKK,kBACE,EAGXL,KAAKM,cACAC,KAAKP,KAAKQ,kBACVD,KAAKE,GACLF,KAAKG,GACLH,KAAKP,KAAKW,gBACVC,MAAMZ,K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ElB1C,MAAMkD,IACCA,aAAiBC,EACjB/D,KAAKgE,YAAYF,GAEjB9D,KAAKgE,YAAY,IAAID,EAAmB,QAASD,QAoBjEX,EAAAnD,KAAO+C,YAAYhC,GACRI,EAAC8C,EAAclD,KApE1BoC,EADSzD,EACKI,OAAO"}
1
+ {"version":3,"file":"ANCV.js","sources":["../../../../src/components/ANCV/ANCV.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport ANCVInput from './components/ANCVInput';\nimport config from './components/ANCVAwait/config';\nimport { Await } from '../../components/internal/Await';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport PayButton from '../internal/PayButton';\nimport { ANCVConfiguration } from './types';\nimport { sanitizeResponse, verifyPaymentDidNotFail } from '../internal/UIElement/utils';\n\nexport class ANCVElement extends UIElement<ANCVConfiguration> {\n public static type = 'ancv';\n\n /**\n * Formats the component data output\n */\n formatData() {\n return {\n paymentMethod: {\n type: ANCVElement.type,\n beneficiaryId: this.state.data?.beneficiaryId\n }\n };\n }\n\n private onOrderRequest = data => {\n if (this.props.onOrderRequest)\n return new Promise((resolve, reject) => {\n this.props.onOrderRequest(resolve, reject, data);\n });\n\n if (this.props.session) {\n return this.props.session.createOrder();\n }\n };\n\n /**\n * Check if order exists, if it does Resolve.\n * Otherwise createOrder and then Resolve.\n */\n public createOrder = (): Promise<void> => {\n this.setStatus('loading');\n\n // allow for multiple ANCV payments, follow giftcard logic and just use order if it exists\n if (this.props.order) {\n return Promise.resolve();\n }\n\n return this.onOrderRequest(this.data)\n .then((order: { orderData: string; pspReference: string }) => {\n const stateOrder = { order: { orderData: order.orderData, pspReference: order.pspReference } };\n this.setState(stateOrder);\n return Promise.resolve();\n })\n .catch(error => {\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', error));\n }\n });\n };\n\n public submit() {\n if (!this.isValid) {\n this.showValidation();\n return false;\n }\n\n this.createOrder()\n .then(this.makePaymentsCall)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch(this.handleFailedResult);\n }\n\n // Reimplement payButton similar to GiftCard to allow to set onClick\n public payButton = props => {\n return <PayButton {...props} />;\n };\n\n get isValid(): boolean {\n return !!this.state.isValid;\n }\n\n get displayName(): string {\n return this.props.name;\n }\n\n protected override componentToRender(): h.JSX.Element {\n if (this.props.paymentData) {\n return (\n <Await\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onError={this.props.onError}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n type={this.constructor['type']}\n messageText={this.props.i18n.get('ancv.confirmPayment')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n showCountdownTimer={config.showCountdownTimer}\n throttleTime={config.THROTTLE_TIME}\n throttleInterval={config.THROTTLE_INTERVAL}\n onActionHandled={this.onActionHandled}\n />\n );\n }\n\n return (\n <ANCVInput\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n onSubmit={this.submit}\n onChange={this.setState}\n payButton={this.payButton}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n}\n\nexport default ANCVElement;\n"],"names":["ANCVElement","UIElement","formatData","paymentMethod","type","beneficiaryId","this","state","data","submit","isValid","showValidation","createOrder","then","makePaymentsCall","sanitizeResponse","verifyPaymentDidNotFail","handleResponse","catch","handleFailedResult","displayName","props","name","componentToRender","paymentData","h","Await","clientKey","onError","onComplete","brandLogo","icon","constructor","messageText","i18n","get","awaitText","showCountdownTimer","config","throttleTime","THROTTLE_TIME","throttleInterval","THROTTLE_INTERVAL","onActionHandled","ANCVInput","ref","componentRef","onSubmit","onChange","setState","payButton","showPayButton","super","args","_define_property","onOrderRequest","Promise","resolve","reject","session","setStatus","order","stateOrder","orderData","pspReference","error","AdyenCheckoutError","handleError","PayButton"],"mappings":"glBAUO,MAAMA,UAAoBC,EAM7BC,UAAAA,GACI,MAAO,CACHC,cAAe,CACXC,KAAMJ,EA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KiD,eAAejD,KAAKE,MAC3BK,KAAMgD,IACH,MAAMC,EAAa,CAAED,MAAO,CAAEE,UAAWF,EAAME,UAAWC,aAAcH,EAAMG,eAE9E,OADA1D,KAAK2C,SAASa,GACPN,QAAQC,YAElBvC,MAAM+C,IACCA,aAAiBC,EACjB5D,KAAK6D,YAAYF,GAEjB3D,KAAK6D,YAAY,IAAID,EAAmB,QAASD,QAoBjEX,EAAAhD,KAAO4C,YAAY7B,GACRI,EAAC2C,EAAc/C,KApE1BiC,EADStD,EACKI,OAAO"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"../internal/RedirectButton/RedirectButton.js";import{TxVariants as s}from"../tx-variants.js";import a from"./components/AchComponent.js";import r from"./defaultProps.js";import n from"../../core/Errors/SRPanelProvider.js";function p(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class i extends e{formatData(){return!!this.props.storedPaymentMethodId?{paymentMethod:{type:i.type,storedPaymentMethodId:this.props.storedPaymentMethodId}}:{paymentMethod:{type:i.type,ownerName:this.state.data.ownerName,accountHolderType:this.state.data.selectedAccountType?.split(".")[0],bankAccountType:this.state.data.selectedAccountType?.split(".")[1],bankLocationId:this.state.data.routingNumber,bankAccountNumber:this.state.data.accountNumber},...this.state.storePaymentMethod&&{storePaymentMethod:this.state.storePaymentMethod}}}get isValid(){return!!this.props.storedPaymentMethodId||!!this.state.isValid}get displayName(){return this.props.storedPaymentMethodId&&this.props.bankAccountNumber?`•••• ${this.props.bankAccountNumber.slice(-4)}`:this.props.name}get additionalInfo(){return this.props.storedPaymentMethodId?this.props.i18n.get("ach.savedBankAccount"):""}componentToRender(){return this.props.storedPaymentMethodId?t(o,{showPayButton:this.props.showPayButton,name:this.displayName,amount:this.props.amount,payButton:this.payButton,onSubmit:this.submit,ref:t=>{this.componentRef=t}}):t(n,{srPanel:this.props.modules.srPanel},t(a,{onChange:this.setState,payButton:this.payButton,showPayButton:this.props.showPayButton,hasHolderName:this.props.hasHolderName,placeholders:this.props.placeholders,data:this.props.data,setComponentRef:this.setComponentRef,enableStoreDetails:this.props.enableStoreDetails}))}}p(i,"type",s.ach),p(i,"defaultProps",r);export{i as AchElement,i as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"../internal/RedirectButton/RedirectButton.js";import{TxVariants as s}from"../tx-variants.js";import a from"./components/AchComponent.js";import n from"./defaultProps.js";function r(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class p extends e{formatData(){return!!this.props.storedPaymentMethodId?{paymentMethod:{type:p.type,storedPaymentMethodId:this.props.storedPaymentMethodId}}:{paymentMethod:{type:p.type,ownerName:this.state.data.ownerName,accountHolderType:this.state.data.selectedAccountType?.split(".")[0],bankAccountType:this.state.data.selectedAccountType?.split(".")[1],bankLocationId:this.state.data.routingNumber,bankAccountNumber:this.state.data.accountNumber},...this.state.storePaymentMethod&&{storePaymentMethod:this.state.storePaymentMethod}}}get isValid(){return!!this.props.storedPaymentMethodId||!!this.state.isValid}get displayName(){return this.props.storedPaymentMethodId&&this.props.bankAccountNumber?`•••• ${this.props.bankAccountNumber.slice(-4)}`:this.props.name}get additionalInfo(){return this.props.storedPaymentMethodId?this.props.i18n.get("ach.savedBankAccount"):""}componentToRender(){return this.props.storedPaymentMethodId?t(o,{showPayButton:this.props.showPayButton,name:this.displayName,amount:this.props.amount,payButton:this.payButton,onSubmit:this.submit,ref:t=>{this.componentRef=t}}):t(a,{onChange:this.setState,payButton:this.payButton,showPayButton:this.props.showPayButton,hasHolderName:this.props.hasHolderName,placeholders:this.props.placeholders,data:this.props.data,setComponentRef:this.setComponentRef,enableStoreDetails:this.props.enableStoreDetails})}}r(p,"type",s.ach),r(p,"defaultProps",n);export{p as AchElement,p as default};
2
2
  //# sourceMappingURL=Ach.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Ach.js","sources":["../../../../src/components/Ach/Ach.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport RedirectButton from '../internal/RedirectButton';\nimport { TxVariants } from '../tx-variants';\nimport AchComponent from './components/AchComponent';\nimport defaultProps from './defaultProps';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\n\nimport type { AchConfiguration } from './types';\n\nexport class AchElement extends UIElement<AchConfiguration> {\n public static type = TxVariants.ach;\n\n protected static defaultProps = defaultProps;\n\n public override formatData() {\n const recurringPayment = !!this.props.storedPaymentMethodId;\n\n if (recurringPayment) {\n return {\n paymentMethod: {\n type: AchElement.type,\n storedPaymentMethodId: this.props.storedPaymentMethodId\n }\n };\n }\n\n return {\n paymentMethod: {\n type: AchElement.type,\n ownerName: this.state.data.ownerName,\n accountHolderType: this.state.data.selectedAccountType?.split('.')[0],\n bankAccountType: this.state.data.selectedAccountType?.split('.')[1],\n bankLocationId: this.state.data.routingNumber,\n bankAccountNumber: this.state.data.accountNumber\n },\n ...(this.state.storePaymentMethod && { storePaymentMethod: this.state.storePaymentMethod })\n };\n }\n\n public override get isValid(): boolean {\n if (this.props.storedPaymentMethodId) {\n return true;\n }\n\n return !!this.state.isValid;\n }\n\n public override get displayName(): string {\n if (this.props.storedPaymentMethodId && this.props.bankAccountNumber) {\n return `•••• ${this.props.bankAccountNumber.slice(-4)}`;\n }\n return this.props.name;\n }\n\n public override get additionalInfo(): string {\n return this.props.storedPaymentMethodId ? this.props.i18n.get('ach.savedBankAccount') : '';\n }\n\n protected override componentToRender(): h.JSX.Element {\n return this.props.storedPaymentMethodId ? (\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.displayName}\n amount={this.props.amount}\n payButton={this.payButton}\n onSubmit={this.submit}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n ) : (\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <AchComponent\n onChange={this.setState}\n payButton={this.payButton}\n showPayButton={this.props.showPayButton}\n hasHolderName={this.props.hasHolderName}\n placeholders={this.props.placeholders}\n data={this.props.data}\n setComponentRef={this.setComponentRef}\n enableStoreDetails={this.props.enableStoreDetails}\n />\n </SRPanelProvider>\n );\n }\n}\n\nexport default AchElement;\n"],"names":["AchElement","UIElement","formatData","this","props","storedPaymentMethodId","paymentMethod","type","ownerName","state","data","accountHolderType","selectedAccountType","split","bankAccountType","bankLocationId","routingNumber","bankAccountNumber","accountNumber","storePaymentMethod","isValid","displayName","slice","name","additionalInfo","i18n","get","componentToRender","h","RedirectButton","showPayButton","amount","payButton","onSubmit","submit","ref","componentRef","SRPanelProvider","srPanel","modules","AchComponent","onChange","setState","hasHolderName","placeholders","setComponentRef","enableStoreDetails","_define_property","TxVariants","ach","defaultProps"],"mappings":"weAUO,MAAMA,UAAmBC,EAKZC,UAAAA,GAGZ,QAF2BC,KAAKC,MAAMC,sBAG3B,CACHC,cAAe,CACXC,KAAMP,EAAWO,KACjBF,sBAAuBF,KAAKC,MAAMC,wBAKvC,CACHC,cAAe,CACXC,KAAMP,EAAWO,KACjBC,UAAWL,KAAKM,MAAMC,KAAKF,UAC3BG,kBAAmBR,KAAKM,MAAMC,KAAKE,qBAAqBC,MAAM,KAAK,GACnEC,gBAAiBX,KAAKM,MAAMC,KAAKE,qBAAqBC,MAAM,KAAK,GACjEE,eAAgBZ,KAAKM,MAAMC,KAAKM,cAChCC,kBAAmBd,KAAKM,MAAMC,KAAKQ,kBAEnCf,KAAKM,MAAMU,oBAAsB,CAAEA,mBAAoBhB,KAAKM,MAAMU,oBAE9E,CAEA,WAAoBC,GAChB,QAAIjB,KAAKC,MAAMC,yBAINF,KAAKM,MAAMW,OACxB,CAEA,eAAoBC,GAChB,OAAIlB,KAAKC,MAAMC,uBAAyBF,KAAKC,MAAMa,kBACxC,QAAQd,KAAKC,MAAMa,kBAAkBK,OAAM,KAE/CnB,KAAKC,MAAMmB,IACtB,CAEA,kBAAoBC,GAChB,OAAOrB,KAAKC,MAAMC,sBAAwBF,KAAKC,MAAMqB,KAAKC,IAAI,wBAA0B,EAC5F,CAEmBC,iBAAAA,GACf,OAAOxB,KAAKC,MAAMC,sBACduB,EAACC,EAAAA,CACGC,cAAe3B,KAAKC,MAAM0B,cAC1BP,KAAMpB,KAAKkB,YACXU,OAAQ5B,KAAKC,MAAM2B,OACnBC,UAAW7B,KAAK6B,UAChBC,SAAU9B,KAAK+B,OACfC,IAAKA,IACDhC,KAAKiC,aAAeD,KAI5BP,EAACS,EAAAA,CAAgBC,QAASnC,KAAKC,MAAMmC,QAAQD,SACzCV,EAACY,EAAAA,CACGC,SAAUtC,KAAKuC,SACfV,UAAW7B,KAAK6B,UAChBF,cAAe3B,KAAKC,MAAM0B,cAC1Ba,cAAexC,KAAKC,MAAMuC,cAC1BC,aAAczC,KAAKC,MAAMwC,aACzBlC,KAAMP,KAAKC,MAAMM,KACjBmC,gBAAiB1C,KAAK0C,gBACtBC,mBAAoB3C,KAAKC,MAAM0C,qBAI/C,EA1EAC,EADS/C,EACKO,OAAOyC,EAAWC,KAEhCF,EAHS/C,EAGQkD,eAAeA"}
1
+ {"version":3,"file":"Ach.js","sources":["../../../../src/components/Ach/Ach.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport RedirectButton from '../internal/RedirectButton';\nimport { TxVariants } from '../tx-variants';\nimport AchComponent from './components/AchComponent';\nimport defaultProps from './defaultProps';\n\nimport type { AchConfiguration } from './types';\n\nexport class AchElement extends UIElement<AchConfiguration> {\n public static type = TxVariants.ach;\n\n protected static defaultProps = defaultProps;\n\n public override formatData() {\n const recurringPayment = !!this.props.storedPaymentMethodId;\n\n if (recurringPayment) {\n return {\n paymentMethod: {\n type: AchElement.type,\n storedPaymentMethodId: this.props.storedPaymentMethodId\n }\n };\n }\n\n return {\n paymentMethod: {\n type: AchElement.type,\n ownerName: this.state.data.ownerName,\n accountHolderType: this.state.data.selectedAccountType?.split('.')[0],\n bankAccountType: this.state.data.selectedAccountType?.split('.')[1],\n bankLocationId: this.state.data.routingNumber,\n bankAccountNumber: this.state.data.accountNumber\n },\n ...(this.state.storePaymentMethod && { storePaymentMethod: this.state.storePaymentMethod })\n };\n }\n\n public override get isValid(): boolean {\n if (this.props.storedPaymentMethodId) {\n return true;\n }\n\n return !!this.state.isValid;\n }\n\n public override get displayName(): string {\n if (this.props.storedPaymentMethodId && this.props.bankAccountNumber) {\n return `•••• ${this.props.bankAccountNumber.slice(-4)}`;\n }\n return this.props.name;\n }\n\n public override get additionalInfo(): string {\n return this.props.storedPaymentMethodId ? this.props.i18n.get('ach.savedBankAccount') : '';\n }\n\n protected override componentToRender(): h.JSX.Element {\n return this.props.storedPaymentMethodId ? (\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.displayName}\n amount={this.props.amount}\n payButton={this.payButton}\n onSubmit={this.submit}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n ) : (\n <AchComponent\n onChange={this.setState}\n payButton={this.payButton}\n showPayButton={this.props.showPayButton}\n hasHolderName={this.props.hasHolderName}\n placeholders={this.props.placeholders}\n data={this.props.data}\n setComponentRef={this.setComponentRef}\n enableStoreDetails={this.props.enableStoreDetails}\n />\n );\n }\n}\n\nexport default AchElement;\n"],"names":["AchElement","UIElement","formatData","this","props","storedPaymentMethodId","paymentMethod","type","ownerName","state","data","accountHolderType","selectedAccountType","split","bankAccountType","bankLocationId","routingNumber","bankAccountNumber","accountNumber","storePaymentMethod","isValid","displayName","slice","name","additionalInfo","i18n","get","componentToRender","h","RedirectButton","showPayButton","amount","payButton","onSubmit","submit","ref","componentRef","AchComponent","onChange","setState","hasHolderName","placeholders","setComponentRef","enableStoreDetails","_define_property","TxVariants","ach","defaultProps"],"mappings":"obASO,MAAMA,UAAmBC,EAKZC,UAAAA,GAGZ,QAF2BC,KAAKC,MAAMC,sBAG3B,CACHC,cAAe,CACXC,KAAMP,EAAWO,KACjBF,sBAAuBF,KAA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C,eAAeA"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./components/BlikInput.js";import{Await as s}from"../internal/Await/Await.js";import r from"./config.js";import n from"../internal/RedirectButton/RedirectButton.js";import i from"../../core/Errors/SRPanelProvider.js";import{TxVariants as a}from"../tx-variants.js";class p extends e{formatData(){const t=!!this.props.storedPaymentMethodId;return{paymentMethod:{type:p.type,...!t&&{blikCode:this.state?.data?.blikCode},...t&&{storedPaymentMethodId:this.props.storedPaymentMethodId}}}}get isValid(){return!!this.props.storedPaymentMethodId||!!this.state.isValid}get displayName(){return this.props.storedPaymentMethodId&&this.props.label?this.props.label:this.props.name}get additionalInfo(){return this.props.storedPaymentMethodId&&this.props.label?this.props.name:null}componentToRender(){return this.props.paymentData?t(i,{srPanel:this.props.modules.srPanel},t(s,{clientKey:this.props.clientKey,paymentData:this.props.paymentData,onError:this.handleError,onComplete:this.onComplete,brandLogo:this.icon,type:r.type,messageText:this.props.i18n.get(r.messageTextId),awaitText:this.props.i18n.get(r.awaitTextId),showCountdownTimer:r.showCountdownTimer,delay:r.STATUS_INTERVAL,countdownTime:r.COUNTDOWN_MINUTES,throttleTime:r.THROTTLE_TIME,throttleInterval:r.THROTTLE_INTERVAL,onActionHandled:this.onActionHandled})):this.props.storedPaymentMethodId?t(n,{showPayButton:this.props.showPayButton,name:this.displayName,amount:this.props.amount,payButton:this.payButton,onSubmit:this.submit,ref:t=>{this.componentRef=t}}):t(o,{ref:t=>{this.componentRef=t},...this.props,onChange:this.setState,onSubmit:this.submit,payButton:this.payButton})}}var m,d,h;m=p,d="type",h=a.blik,d in m?Object.defineProperty(m,d,{value:h,enumerable:!0,configurable:!0,writable:!0}):m[d]=h;export{p as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./components/BlikInput.js";import{Await as s}from"../internal/Await/Await.js";import n from"./config.js";import i from"../internal/RedirectButton/RedirectButton.js";import{TxVariants as r}from"../tx-variants.js";class a extends e{formatData(){const t=!!this.props.storedPaymentMethodId;return{paymentMethod:{type:a.type,...!t&&{blikCode:this.state?.data?.blikCode},...t&&{storedPaymentMethodId:this.props.storedPaymentMethodId}}}}get isValid(){return!!this.props.storedPaymentMethodId||!!this.state.isValid}get displayName(){return this.props.storedPaymentMethodId&&this.props.label?this.props.label:this.props.name}get additionalInfo(){return this.props.storedPaymentMethodId&&this.props.label?this.props.name:null}componentToRender(){return this.props.paymentData?t(s,{clientKey:this.props.clientKey,paymentData:this.props.paymentData,onError:this.handleError,onComplete:this.onComplete,brandLogo:this.icon,type:n.type,messageText:this.props.i18n.get(n.messageTextId),awaitText:this.props.i18n.get(n.awaitTextId),showCountdownTimer:n.showCountdownTimer,delay:n.STATUS_INTERVAL,countdownTime:n.COUNTDOWN_MINUTES,throttleTime:n.THROTTLE_TIME,throttleInterval:n.THROTTLE_INTERVAL,onActionHandled:this.onActionHandled}):this.props.storedPaymentMethodId?t(i,{showPayButton:this.props.showPayButton,name:this.displayName,amount:this.props.amount,payButton:this.payButton,onSubmit:this.submit,ref:t=>{this.componentRef=t}}):t(o,{ref:t=>{this.componentRef=t},...this.props,onChange:this.setState,onSubmit:this.submit,payButton:this.payButton})}}var p,m,d;p=a,m="type",d=r.blik,m in p?Object.defineProperty(p,m,{value:d,enumerable:!0,configurable:!0,writable:!0}):p[m]=d;export{a as default};
2
2
  //# sourceMappingURL=Blik.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Blik.js","sources":["../../../../src/components/Blik/Blik.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport BlikInput from '../../components/Blik/components/BlikInput';\nimport { Await } from '../internal/Await';\nimport config from './config';\nimport RedirectButton from '../../components/internal/RedirectButton';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport { AwaitConfiguration } from '../internal/Await/types';\n\ninterface BlikElementData {\n paymentMethod: {\n type: string;\n blikCode: string;\n };\n}\n\nclass BlikElement extends UIElement<AwaitConfiguration> {\n public static type = TxVariants.blik;\n\n formatData(): BlikElementData {\n const recurringPayment = !!this.props.storedPaymentMethodId;\n\n return {\n paymentMethod: {\n type: BlikElement.type,\n ...(!recurringPayment && { blikCode: this.state?.data?.blikCode }),\n ...(recurringPayment && { storedPaymentMethodId: this.props.storedPaymentMethodId })\n }\n };\n }\n\n get isValid(): boolean {\n if (this.props.storedPaymentMethodId) {\n return true;\n }\n\n return !!this.state.isValid;\n }\n\n get displayName() {\n if (this.props.storedPaymentMethodId && this.props.label) {\n return this.props.label;\n }\n return this.props.name;\n }\n\n get additionalInfo() {\n if (this.props.storedPaymentMethodId && this.props.label) {\n return this.props.name;\n }\n return null;\n }\n\n /**\n * NOTE: for future reference:\n * this.props.onComplete (which is called from this.onComplete) equates to the merchant defined onAdditionalDetails callback\n * (the initial /payments response defines an \"await\" action, actionTypes.ts translates this to \"onComplete: props.onAdditionalDetails\")\n */\n protected override componentToRender(): h.JSX.Element {\n if (this.props.paymentData) {\n return (\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <Await\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onError={this.handleError}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n type={config.type}\n messageText={this.props.i18n.get(config.messageTextId)}\n awaitText={this.props.i18n.get(config.awaitTextId)}\n showCountdownTimer={config.showCountdownTimer}\n delay={config.STATUS_INTERVAL}\n countdownTime={config.COUNTDOWN_MINUTES}\n throttleTime={config.THROTTLE_TIME}\n throttleInterval={config.THROTTLE_INTERVAL}\n onActionHandled={this.onActionHandled}\n />\n </SRPanelProvider>\n );\n }\n\n return this.props.storedPaymentMethodId ? (\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.displayName}\n amount={this.props.amount}\n payButton={this.payButton}\n onSubmit={this.submit}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n ) : (\n <BlikInput\n // @ts-ignore Ref is used by preact component\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n onChange={this.setState}\n onSubmit={this.submit}\n payButton={this.payButton}\n />\n );\n }\n}\n\nexport default BlikElement;\n"],"names":["BlikElement","UIElement","formatData","recurringPayment","this","props","storedPaymentMethodId","paymentMethod","type","blikCode","state","data","isValid","displayName","label","name","additionalInfo","componentToRender","paymentData","h","SRPanelProvider","srPanel","modules","Await","clientKey","onError","handleError","onComplete","brandLogo","icon","config","messageText","i18n","get","messageTextId","awaitText","awaitTextId","showCountdownTimer","delay","STATUS_INTERVAL","countdownTime","COUNTDOWN_MINUTES","throttleTime","THROTTLE_TIME","throttleInterval","THROTTLE_INTERVAL","onActionHandled","RedirectButton","showPayButton","amount","payButton","onSubmit","submit","ref","componentRef","BlikInput","onChange","setState","TxVariants","blik"],"mappings":"0ZAiBA,MAAMA,UAAoBC,EAGtBC,UAAAA,GACI,MAAMC,IAAqBC,KAAKC,MAAMC,sBAEtC,MAAO,CACHC,cAAe,CACXC,KAAMR,EAAYQ,SACbL,GAAoB,CAAEM,SAAUL,KAAKM,OAAOC,MAAMF,aACnDN,GAAoB,CAAEG,sBAAuBF,KAAKC,MAAMC,wBAGxE,CAEA,WAAIM,GACA,QAAIR,KAAKC,MAAMC,yBAINF,KAAKM,MAAME,OACxB,CAEA,eAAIC,GACA,OAAIT,KAAKC,MAAMC,uBAAyBF,KAAKC,MAAMS,MACxCV,KAAKC,MAAMS,MAEfV,KAAKC,MAAMU,IACtB,CAEA,kBAAIC,GACA,OAAIZ,KAAKC,MAAMC,uBAAyBF,KAAKC,MAAMS,MACxCV,KAAKC,MAAMU,KAEf,IACX,CAOA,iBAAAE,GACI,OAAIb,KAAKC,MAAMa,YAEPC,EAACC,EAAAA,CAAgBC,QAASjB,KAAKC,MAAMiB,QAAQD,SACzCF,EAACI,EAAAA,CACGC,UAAWpB,KAAKC,MAAMmB,UACtBN,YAAad,KAAKC,MAAMa,YACxBO,QAASrB,KAAKsB,YACdC,WAAYvB,KAAKuB,WACjBC,UAAWxB,KAAKyB,KAChBrB,KAAMsB,EAAOtB,KACbuB,YAAa3B,KAAKC,MAAM2B,KAAKC,IAAIH,EAAOI,eACxCC,UAAW/B,KAAKC,MAAM2B,KAAKC,IAAIH,EAAOM,aACtCC,mBAAoBP,EAAOO,mBAC3BC,MAAOR,EAAOS,gBACdC,cAAeV,EAAOW,kBACtBC,aAAcZ,EAAOa,cACrBC,iBAAkBd,EAAOe,kBACzBC,gBAAiB1C,KAAK0C,mBAM/B1C,KAAKC,MAAMC,sBACda,EAAC4B,EAAAA,CACGC,cAAe5C,KAAKC,MAAM2C,cAC1BjC,KAAMX,KAAKS,YACXoC,OAAQ7C,KAAKC,MAAM4C,OACnBC,UAAW9C,KAAK8C,UAChBC,SAAU/C,KAAKgD,OACfC,IAAKA,IACDjD,KAAKkD,aAAeD,KAI5BlC,EAACoC,EAAAA,CAEGF,IAAKA,IACDjD,KAAKkD,aAAeD,MAEpBjD,KAAKC,MACTmD,SAAUpD,KAAKqD,SACfN,SAAU/C,KAAKgD,OACfF,UAAW9C,KAAK8C,WAG5B,cAzFElD,IACYQ,SAAOkD,EAAWC"}
1
+ {"version":3,"file":"Blik.js","sources":["../../../../src/components/Blik/Blik.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport BlikInput from '../../components/Blik/components/BlikInput';\nimport { Await } from '../internal/Await';\nimport config from './config';\nimport RedirectButton from '../../components/internal/RedirectButton';\nimport { TxVariants } from '../tx-variants';\nimport { AwaitConfiguration } from '../internal/Await/types';\n\ninterface BlikElementData {\n paymentMethod: {\n type: string;\n blikCode: string;\n };\n}\n\nclass BlikElement extends UIElement<AwaitConfiguration> {\n public static type = TxVariants.blik;\n\n formatData(): BlikElementData {\n const recurringPayment = !!this.props.storedPaymentMethodId;\n\n return {\n paymentMethod: {\n type: BlikElement.type,\n ...(!recurringPayment && { blikCode: this.state?.data?.blikCode }),\n ...(recurringPayment && { storedPaymentMethodId: this.props.storedPaymentMethodId })\n }\n };\n }\n\n get isValid(): boolean {\n if (this.props.storedPaymentMethodId) {\n return true;\n }\n\n return !!this.state.isValid;\n }\n\n get displayName() {\n if (this.props.storedPaymentMethodId && this.props.label) {\n return this.props.label;\n }\n return this.props.name;\n }\n\n get additionalInfo() {\n if (this.props.storedPaymentMethodId && this.props.label) {\n return this.props.name;\n }\n return null;\n }\n\n /**\n * NOTE: for future reference:\n * this.props.onComplete (which is called from this.onComplete) equates to the merchant defined onAdditionalDetails callback\n * (the initial /payments response defines an \"await\" action, actionTypes.ts translates this to \"onComplete: props.onAdditionalDetails\")\n */\n protected override componentToRender(): h.JSX.Element {\n if (this.props.paymentData) {\n return (\n <Await\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onError={this.handleError}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n type={config.type}\n messageText={this.props.i18n.get(config.messageTextId)}\n awaitText={this.props.i18n.get(config.awaitTextId)}\n showCountdownTimer={config.showCountdownTimer}\n delay={config.STATUS_INTERVAL}\n countdownTime={config.COUNTDOWN_MINUTES}\n throttleTime={config.THROTTLE_TIME}\n throttleInterval={config.THROTTLE_INTERVAL}\n onActionHandled={this.onActionHandled}\n />\n );\n }\n\n return this.props.storedPaymentMethodId ? (\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.displayName}\n amount={this.props.amount}\n payButton={this.payButton}\n onSubmit={this.submit}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n ) : (\n <BlikInput\n // @ts-ignore Ref is used by preact component\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n onChange={this.setState}\n onSubmit={this.submit}\n payButton={this.payButton}\n />\n );\n }\n}\n\nexport default BlikElement;\n"],"names":["BlikElement","UIElement","formatData","recurringPayment","this","props","storedPaymentMethodId","paymentMethod","type","blikCode","state","data","isValid","displayName","label","name","additionalInfo","componentToRender","paymentData","h","Await","clientKey","onError","handleError","onComplete","brandLogo","icon","config","messageText","i18n","get","messageTextId","awaitText","awaitTextId","showCountdownTimer","delay","STATUS_INTERVAL","countdownTime","COUNTDOWN_MINUTES","throttleTime","THROTTLE_TIME","throttleInterval","THROTTLE_INTERVAL","onActionHandled","RedirectButton","showPayButton","amount","payButton","onSubmit","submit","ref","componentRef","BlikInput","onChange","setState","TxVariants","blik"],"mappings":"sWAgBA,MAAMA,UAAoBC,EAGtBC,UAAAA,GACI,MAAMC,IAAqBC,KAAKC,MAAMC,sBAEtC,MAAO,CACHC,cAAe,CACXC,KAAMR,EAAYQ,SACbL,GAAoB,CAAEM,SAAUL,KAAKM,OAAOC,MAAMF,aACnDN,GAAoB,CAAEG,sBAAuBF,KAAKC,MAAMC,wBAGxE,CAEA,WAAIM,GACA,QAAIR,KAAKC,MAAMC,yBAINF,KAAKM,MAAME,OACxB,CAEA,eAAIC,GACA,OAAIT,KAAKC,MAAMC,uBAAyBF,KAAKC,MAAMS,MACxCV,KAAKC,MAAMS,MAEfV,KAAKC,MAAMU,IACtB,CAEA,kBAAIC,GACA,OAAIZ,KAAKC,MAAMC,uBAAyBF,KAAKC,MAAMS,MACxCV,KAAKC,MAAMU,KAEf,IACX,CAOA,iBAAAE,GACI,OAAIb,KAAKC,MAAMa,YAEPC,EAACC,EAAAA,CACGC,UAAWjB,KAAKC,MAAMgB,UACtBH,YAAad,KAAKC,MAAMa,YACxBI,QAASlB,KAAKmB,YACdC,WAAYpB,KAAKoB,WACjBC,UAAWrB,KAAKsB,KAChBlB,KAAMmB,EAAOnB,KACboB,YAAaxB,KAAKC,MAAMwB,KAAKC,IAAIH,EAAOI,eACxCC,UAAW5B,KAAKC,MAAMwB,KAAKC,IAAIH,EAAOM,aACtCC,mBAAoBP,EAAOO,mBAC3BC,MAAOR,EAAOS,gBACdC,cAAeV,EAAOW,kBACtBC,aAAcZ,EAAOa,cACrBC,iBAAkBd,EAAOe,kBACzBC,gBAAiBvC,KAAKuC,kBAK3BvC,KAAKC,MAAMC,sBACda,EAACyB,EAAAA,CACGC,cAAezC,KAAKC,MAAMwC,cAC1B9B,KAAMX,KAAKS,YACXiC,OAAQ1C,KAAKC,MAAMyC,OACnBC,UAAW3C,KAAK2C,UAChBC,SAAU5C,KAAK6C,OACfC,IAAKA,IACD9C,KAAK+C,aAAeD,KAI5B/B,EAACiC,EAAAA,CAEGF,IAAKA,IACD9C,KAAK+C,aAAeD,MAEpB9C,KAAKC,MACTgD,SAAUjD,KAAKkD,SACfN,SAAU5C,KAAK6C,OACfF,UAAW3C,KAAK2C,WAG5B,cAvFE/C,IACYQ,SAAO+C,EAAWC"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import e from"./components/CardInput/CardInput.js";import o from"../../utils/browserInfo.js";import s from"../internal/SecuredFields/binLookup/triggerBinLookUp.js";import{fieldTypeToSnakeCase as n}from"../internal/SecuredFields/utils.js";import{reject as i}from"../../utils/commonUtils.js";import{hasValidInstallmentsObject as r}from"./components/CardInput/utils.js";import a from"../internal/ClickToPay/services/create-clicktopay-service.js";import p from"./components/ClickToPayWrapper.js";import c from"../../core/Errors/SRPanelProvider.js";import{TxVariants as l}from"../tx-variants.js";import{UIElement as u}from"../internal/UIElement/UIElement.js";import d from"../internal/PayButton/PayButton.js";import{ALL_SECURED_FIELDS as h}from"../internal/SecuredFields/lib/constants.js";import m,{IMPLEMENTATION_ERROR as y}from"../../core/Errors/AdyenCheckoutError.js";import f from"./components/CardInput/defaultProps.js";import{AnalyticsInfoEvent as b,InfoEventType as g}from"../../core/Analytics/events/AnalyticsInfoEvent.js";function P(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class C extends u{setStatus(t,e){return this.componentRef?.setStatus&&this.componentRef.setStatus(t,e),this.clickToPayRef?.setStatus&&this.clickToPayRef.setStatus(t,e),this}formatProps(t){const e=t.session?.configuration?.enableStoreDetails??t.enableStoreDetails,o=!(0===t.amount?.value)&&e,s=t.storedPaymentMethodId||t.id,n=s&&t?.supportedShopperInteractions?.includes("Ecommerce");if(s&&!n)throw new m(y,"You are trying to create a storedCard from a stored PM that does not support Ecommerce interactions");return{...t,holderNameRequired:!!t.hasHolderName&&t.holderNameRequired,hasCVC:!(t.brand&&"bcmc"===t.brand||t.hideCVC),billingAddressRequired:!t.storedPaymentMethodId&&t.billingAddressRequired,billingAddressMode:t.onAddressLookup?f.billingAddressMode:t.billingAddressMode,brand:t.brand??l.card,countryCode:t.countryCode?t.countryCode.toLowerCase():null,configuration:{...t.configuration,socialSecurityNumberMode:t.configuration?.socialSecurityNumberMode??"auto"},brandsConfiguration:t.brandsConfiguration||t.configuration?.brandsConfiguration||{},icon:t.icon||t.configuration?.icon,installmentOptions:t.session?.configuration?.installmentOptions||t.installmentOptions,enableStoreDetails:e,showStoreDetailsCheckbox:o,clickToPayConfiguration:{...t.clickToPayConfiguration,disableOtpAutoFocus:t.clickToPayConfiguration?.disableOtpAutoFocus||!1,shopperEmail:t.clickToPayConfiguration?.shopperEmail||this.core.options?.session?.shopperEmail,telephoneNumber:t.clickToPayConfiguration?.telephoneNumber||this.core.options?.session?.telephoneNumber,locale:t.clickToPayConfiguration?.locale||t.i18n?.locale?.replace("-","_")},...s&&{storedPaymentMethodId:s}}}formatData(){const t=this.state.selectedBrandValue;return{paymentMethod:{type:C.type,...this.state.data,...this.props.storedPaymentMethodId&&{storedPaymentMethodId:this.props.storedPaymentMethodId,holderName:this.props.holderName??""},...t&&{brand:t},...this.props.fundingSource&&{fundingSource:this.props.fundingSource},...this.state.fastlaneData&&{fastlaneData:btoa(JSON.stringify(this.state.fastlaneData))}},...this.state.billingAddress&&{billingAddress:this.state.billingAddress},...this.state.socialSecurityNumber&&{socialSecurityNumber:this.state.socialSecurityNumber},...this.storePaymentMethodPayload,...r(this.state.installments)&&{installments:this.state.installments},browserInfo:this.browserInfo,origin:!!window&&window.location.origin}}beforeRender(t){if(t?.originalAction)return;const e=new b({type:g.rendered,component:this.type,configData:{...t,showPayButton:this.props.showPayButton},...t?.oneClick&&{isStoredPaymentMethod:!0,brand:t.brand}});this.analytics.sendAnalytics(e)}updateStyles(t){return this.componentRef?.updateStyles&&this.componentRef.updateStyles(t),this}setFocusOn(t){return this.componentRef?.setFocusOn&&this.componentRef.setFocusOn(t),this}processBinLookupResponse(t,e=!1){return this.componentRef?.processBinLookupResponse&&this.componentRef.processBinLookupResponse(t,e),this}handleUnsupportedCard(t){return this.componentRef?.handleUnsupportedCard&&this.componentRef.handleUnsupportedCard(t),this}onBinLookup(t){if(!t.isReset){const e=i("supportedBrandsRaw").from(t);this.props.onBinLookup?.(e)}}get storePaymentMethodPayload(){if(this.props.storedPaymentMethodId?.length>0)return{};if(0===this.props.amount?.value)return this.props.enableStoreDetails?{storePaymentMethod:!0}:{};return this.props.showStoreDetailsCheckbox&&void 0!==this.state.storePaymentMethod?{storePaymentMethod:Boolean(this.state.storePaymentMethod)}:{}}get isValid(){return!!this.state.isValid}get icon(){return this.props.icon??this.resources.getImage()(this.props.brand)}get brands(){const{brands:t,brandsConfiguration:e}=this.props;return t?t.map(t=>({icon:e[t]?.icon??this.props.modules.resources.getImage()(t),name:t})):[]}get displayName(){return this.props.storedPaymentMethodId?`•••• ${this.props.lastFour}`:this.props.name||C.type}get accessibleName(){return(this.props.name||C.type)+(this.props.storedPaymentMethodId?" "+this.props.i18n.get("creditCard.storedCard.description.ariaLabel").replace("%@",this.props.lastFour):"")}get browserInfo(){return o()}renderCardInput(o=!0){return t(e,{setComponentRef:this.setComponentRef,...this.props,...this.state,onSubmitAnalytics:this.submitAnalytics,onChange:this.setState,onSubmit:this.submit,handleKeyPress:this.handleKeyPress,payButton:this.payButton,onBrand:this.onBrand,onBinValue:this.onBinValue,brand:this.props.brand,brandsIcons:this.brands,isPayButtonPrimaryVariant:o,resources:this.resources,onFocus:this.onFocus,onBlur:this.onBlur,onConfigSuccess:this.onConfigSuccess})}componentToRender(){return t(c,{srPanel:this.props.modules.srPanel},t(p,{amount:this.props.amount,configuration:this.props.clickToPayConfiguration,clickToPayService:this.clickToPayService,isStandaloneComponent:!1,setClickToPayRef:this.setClickToPayRef,onSetStatus:this.setElementStatus,onSubmit:this.handleClickToPaySubmit,onError:this.handleError},t=>this.renderCardInput(t)))}constructor(e,o){super(e,o),P(this,"clickToPayService",void 0),P(this,"clickToPayRef",null),P(this,"setClickToPayRef",t=>{this.clickToPayRef=t}),P(this,"onBrand",t=>{this.props.onBrand?.(t)}),P(this,"handleClickToPaySubmit",t=>{this.setState({data:{...t},valid:{},errors:{},isValid:!0}),this.submit()}),P(this,"onConfigSuccess",t=>{const e=new b({component:this.type,type:g.configured});this.submitAnalytics(e),this.props.onConfigSuccess?.(t)}),P(this,"onFocus",t=>{const e=new b({component:this.type,type:g.focus,target:n(t.fieldType)});this.submitAnalytics(e),h.includes(t.fieldType)?this.props.onFocus?.(t.event):this.props.onFocus?.(t)}),P(this,"onBlur",t=>{const e=new b({component:this.type,type:g.unfocus,target:n(t.fieldType)});this.submitAnalytics(e),h.includes(t.fieldType)?this.props.onBlur?.(t.event):this.props.onBlur?.(t)}),P(this,"onBinValue",s(this)),P(this,"payButton",e=>{const o=0===this.props.amount?.value,s=this.props.storedPaymentMethodId?.length>0;return t(d,{...e,amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,label:o&&!s?this.props.i18n.get("payButton.saveDetails"):"",onClick:this.submit})}),o&&!o._disableClickToPay&&(this.clickToPayService=a(this.props.configuration,this.props.clickToPayConfiguration,this.props.environment,this.analytics),this.clickToPayService?.initialize())}}P(C,"type",l.scheme),P(C,"defaultProps",{showFormInstruction:!0,_disableClickToPay:!1,doBinLookup:!0,...i(["type","setComponentRef"]).from(f)});export{C as CardElement,C as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import e from"./components/CardInput/CardInput.js";import o from"../../utils/browserInfo.js";import s from"../internal/SecuredFields/binLookup/triggerBinLookUp.js";import{fieldTypeToSnakeCase as n}from"../internal/SecuredFields/utils.js";import{reject as i}from"../../utils/commonUtils.js";import{hasValidInstallmentsObject as r}from"./components/CardInput/utils.js";import a from"../internal/ClickToPay/services/create-clicktopay-service.js";import p from"./components/ClickToPayWrapper.js";import{TxVariants as c}from"../tx-variants.js";import{UIElement as l}from"../internal/UIElement/UIElement.js";import u from"../internal/PayButton/PayButton.js";import{ALL_SECURED_FIELDS as d}from"../internal/SecuredFields/lib/constants.js";import h,{IMPLEMENTATION_ERROR as m}from"../../core/Errors/AdyenCheckoutError.js";import y from"./components/CardInput/defaultProps.js";import{AnalyticsInfoEvent as f,InfoEventType as b}from"../../core/Analytics/events/AnalyticsInfoEvent.js";function g(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class P extends l{setStatus(t,e){return this.componentRef?.setStatus&&this.componentRef.setStatus(t,e),this.clickToPayRef?.setStatus&&this.clickToPayRef.setStatus(t,e),this}formatProps(t){const e=t.session?.configuration?.enableStoreDetails??t.enableStoreDetails,o=!(0===t.amount?.value)&&e,s=t.storedPaymentMethodId||t.id,n=s&&t?.supportedShopperInteractions?.includes("Ecommerce");if(s&&!n)throw new h(m,"You are trying to create a storedCard from a stored PM that does not support Ecommerce interactions");return{...t,holderNameRequired:!!t.hasHolderName&&t.holderNameRequired,hasCVC:!(t.brand&&"bcmc"===t.brand||t.hideCVC),billingAddressRequired:!t.storedPaymentMethodId&&t.billingAddressRequired,billingAddressMode:t.onAddressLookup?y.billingAddressMode:t.billingAddressMode,brand:t.brand??c.card,countryCode:t.countryCode?t.countryCode.toLowerCase():null,configuration:{...t.configuration,socialSecurityNumberMode:t.configuration?.socialSecurityNumberMode??"auto"},brandsConfiguration:t.brandsConfiguration||t.configuration?.brandsConfiguration||{},icon:t.icon||t.configuration?.icon,installmentOptions:t.session?.configuration?.installmentOptions||t.installmentOptions,enableStoreDetails:e,showStoreDetailsCheckbox:o,clickToPayConfiguration:{...t.clickToPayConfiguration,disableOtpAutoFocus:t.clickToPayConfiguration?.disableOtpAutoFocus||!1,shopperEmail:t.clickToPayConfiguration?.shopperEmail||this.core.options?.session?.shopperEmail,telephoneNumber:t.clickToPayConfiguration?.telephoneNumber||this.core.options?.session?.telephoneNumber,locale:t.clickToPayConfiguration?.locale||t.i18n?.locale?.replace("-","_")},...s&&{storedPaymentMethodId:s}}}formatData(){const t=this.state.selectedBrandValue;return{paymentMethod:{type:P.type,...this.state.data,...this.props.storedPaymentMethodId&&{storedPaymentMethodId:this.props.storedPaymentMethodId,holderName:this.props.holderName??""},...t&&{brand:t},...this.props.fundingSource&&{fundingSource:this.props.fundingSource},...this.state.fastlaneData&&{fastlaneData:btoa(JSON.stringify(this.state.fastlaneData))}},...this.state.billingAddress&&{billingAddress:this.state.billingAddress},...this.state.socialSecurityNumber&&{socialSecurityNumber:this.state.socialSecurityNumber},...this.storePaymentMethodPayload,...r(this.state.installments)&&{installments:this.state.installments},browserInfo:this.browserInfo,origin:!!window&&window.location.origin}}beforeRender(t){if(t?.originalAction)return;const e=new f({type:b.rendered,component:this.type,configData:{...t,showPayButton:this.props.showPayButton},...t?.oneClick&&{isStoredPaymentMethod:!0,brand:t.brand}});this.analytics.sendAnalytics(e)}updateStyles(t){return this.componentRef?.updateStyles&&this.componentRef.updateStyles(t),this}setFocusOn(t){return this.componentRef?.setFocusOn&&this.componentRef.setFocusOn(t),this}processBinLookupResponse(t,e=!1){return this.componentRef?.processBinLookupResponse&&this.componentRef.processBinLookupResponse(t,e),this}handleUnsupportedCard(t){return this.componentRef?.handleUnsupportedCard&&this.componentRef.handleUnsupportedCard(t),this}onBinLookup(t){if(!t.isReset){const e=i("supportedBrandsRaw").from(t);this.props.onBinLookup?.(e)}}get storePaymentMethodPayload(){if(this.props.storedPaymentMethodId?.length>0)return{};if(0===this.props.amount?.value)return this.props.enableStoreDetails?{storePaymentMethod:!0}:{};return this.props.showStoreDetailsCheckbox&&void 0!==this.state.storePaymentMethod?{storePaymentMethod:Boolean(this.state.storePaymentMethod)}:{}}get isValid(){return!!this.state.isValid}get icon(){return this.props.icon??this.resources.getImage()(this.props.brand)}get brands(){const{brands:t,brandsConfiguration:e}=this.props;return t?t.map(t=>({icon:e[t]?.icon??this.props.modules.resources.getImage()(t),name:t})):[]}get displayName(){return this.props.storedPaymentMethodId?`•••• ${this.props.lastFour}`:this.props.name||P.type}get accessibleName(){return(this.props.name||P.type)+(this.props.storedPaymentMethodId?" "+this.props.i18n.get("creditCard.storedCard.description.ariaLabel").replace("%@",this.props.lastFour):"")}get browserInfo(){return o()}renderCardInput(o=!0){return t(e,{setComponentRef:this.setComponentRef,...this.props,...this.state,onSubmitAnalytics:this.submitAnalytics,onChange:this.setState,onSubmit:this.submit,handleKeyPress:this.handleKeyPress,payButton:this.payButton,onBrand:this.onBrand,onBinValue:this.onBinValue,brand:this.props.brand,brandsIcons:this.brands,isPayButtonPrimaryVariant:o,resources:this.resources,onFocus:this.onFocus,onBlur:this.onBlur,onConfigSuccess:this.onConfigSuccess})}componentToRender(){return t(p,{amount:this.props.amount,configuration:this.props.clickToPayConfiguration,clickToPayService:this.clickToPayService,isStandaloneComponent:!1,setClickToPayRef:this.setClickToPayRef,onSetStatus:this.setElementStatus,onSubmit:this.handleClickToPaySubmit,onError:this.handleError},t=>this.renderCardInput(t))}constructor(e,o){super(e,o),g(this,"clickToPayService",void 0),g(this,"clickToPayRef",null),g(this,"setClickToPayRef",t=>{this.clickToPayRef=t}),g(this,"onBrand",t=>{this.props.onBrand?.(t)}),g(this,"handleClickToPaySubmit",t=>{this.setState({data:{...t},valid:{},errors:{},isValid:!0}),this.submit()}),g(this,"onConfigSuccess",t=>{const e=new f({component:this.type,type:b.configured});this.submitAnalytics(e),this.props.onConfigSuccess?.(t)}),g(this,"onFocus",t=>{const e=new f({component:this.type,type:b.focus,target:n(t.fieldType)});this.submitAnalytics(e),d.includes(t.fieldType)?this.props.onFocus?.(t.event):this.props.onFocus?.(t)}),g(this,"onBlur",t=>{const e=new f({component:this.type,type:b.unfocus,target:n(t.fieldType)});this.submitAnalytics(e),d.includes(t.fieldType)?this.props.onBlur?.(t.event):this.props.onBlur?.(t)}),g(this,"onBinValue",s(this)),g(this,"payButton",e=>{const o=0===this.props.amount?.value,s=this.props.storedPaymentMethodId?.length>0;return t(u,{...e,amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,label:o&&!s?this.props.i18n.get("payButton.saveDetails"):"",onClick:this.submit})}),o&&!o._disableClickToPay&&(this.clickToPayService=a(this.props.configuration,this.props.clickToPayConfiguration,this.props.environment,this.analytics),this.clickToPayService?.initialize())}}g(P,"type",c.scheme),g(P,"defaultProps",{showFormInstruction:!0,_disableClickToPay:!1,doBinLookup:!0,...i(["type","setComponentRef"]).from(y)});export{P as CardElement,P as default};
2
2
  //# sourceMappingURL=Card.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Card.js","sources":["../../../../src/components/Card/Card.tsx"],"sourcesContent":["import { h } from 'preact';\nimport CardInput from './components/CardInput';\nimport collectBrowserInfo from '../../utils/browserInfo';\nimport { BinLookupResponse, CardElementData, CardConfiguration } from './types';\nimport triggerBinLookUp from '../internal/SecuredFields/binLookup/triggerBinLookUp';\nimport { CardBinLookupData, CardConfigSuccessData, CardFocusData } from '../internal/SecuredFields/lib/types';\nimport { fieldTypeToSnakeCase } from '../internal/SecuredFields/utils';\nimport { reject } from '../../utils/commonUtils';\nimport { hasValidInstallmentsObject } from './components/CardInput/utils';\nimport createClickToPayService from '../internal/ClickToPay/services/create-clicktopay-service';\nimport { ClickToPayCheckoutPayload, IClickToPayService } from '../internal/ClickToPay/services/types';\nimport ClickToPayWrapper from './components/ClickToPayWrapper';\nimport { ComponentFocusObject } from '../../types/global-types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport type { PayButtonFunctionProps, UIElementStatus } from '../internal/UIElement/types';\nimport UIElement from '../internal/UIElement';\nimport PayButton from '../internal/PayButton';\nimport type { ICore } from '../../core/types';\nimport { ALL_SECURED_FIELDS } from '../internal/SecuredFields/lib/constants';\nimport AdyenCheckoutError, { IMPLEMENTATION_ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport CardInputDefaultProps from './components/CardInput/defaultProps';\nimport { AnalyticsInfoEvent, InfoEventType } from '../../core/Analytics/events/AnalyticsInfoEvent';\n\nexport class CardElement extends UIElement<CardConfiguration> {\n public static type = TxVariants.scheme;\n\n private readonly clickToPayService: IClickToPayService | null;\n\n /**\n * Reference to the 'ClickToPayComponent'\n */\n private clickToPayRef = null;\n\n constructor(checkout: ICore, props?: CardConfiguration) {\n super(checkout, props);\n\n if (props && !props._disableClickToPay) {\n this.clickToPayService = createClickToPayService(\n this.props.configuration,\n this.props.clickToPayConfiguration,\n this.props.environment,\n this.analytics\n );\n\n void this.clickToPayService?.initialize();\n }\n }\n\n protected static defaultProps = {\n showFormInstruction: true,\n _disableClickToPay: false,\n doBinLookup: true,\n // Merge most of CardInput's defaultProps\n ...reject(['type', 'setComponentRef']).from(CardInputDefaultProps)\n };\n\n public setStatus(status: UIElementStatus, props?): this {\n if (this.componentRef?.setStatus) {\n this.componentRef.setStatus(status, props);\n }\n if (this.clickToPayRef?.setStatus) {\n this.clickToPayRef.setStatus(status, props);\n }\n return this;\n }\n\n private setClickToPayRef = ref => {\n this.clickToPayRef = ref;\n };\n\n formatProps(props: CardConfiguration): CardConfiguration {\n // The value from a session should be used, before falling back to the merchant configuration\n const enableStoreDetails = props.session?.configuration?.enableStoreDetails ?? props.enableStoreDetails;\n\n const isZeroAuth = props.amount?.value === 0;\n const showStoreDetailsCheckbox = isZeroAuth ? false : enableStoreDetails;\n\n const storedCardID = props.storedPaymentMethodId || props.id; // check if we've been passed a (checkout) processed storedCard or one that merchant has pulled from the PMs response\n const isEcommerceStoredCard = storedCardID && props?.supportedShopperInteractions?.includes('Ecommerce'); // If we have a storedCard does it support Ecommerce (it might not if the merchant has pulled it from the PMs response)\n\n // If we have a storedPM but it doesn't support Ecommerce - we can't make a storedCard component from it\n if (storedCardID && !isEcommerceStoredCard) {\n // TODO - Decide if an error is too severe? Would a console.warning suffice?\n throw new AdyenCheckoutError(\n IMPLEMENTATION_ERROR,\n 'You are trying to create a storedCard from a stored PM that does not support Ecommerce interactions'\n );\n }\n\n return {\n ...props,\n // Mismatch between hasHolderName & holderNameRequired which can mean card can never be valid\n holderNameRequired: !props.hasHolderName ? false : props.holderNameRequired,\n // False for *stored* BCMC cards & if merchant explicitly wants to hide the CVC field\n hasCVC: !((props.brand && props.brand === 'bcmc') || props.hideCVC),\n // billingAddressRequired only available for non-stored cards\n billingAddressRequired: props.storedPaymentMethodId ? false : props.billingAddressRequired,\n // edge case where merchant has defined both an onAddressLookup callback AND set billingAddressMode: 'partial' - which leads to some strange behaviour in the address UI\n billingAddressMode: props.onAddressLookup ? CardInputDefaultProps.billingAddressMode : props.billingAddressMode,\n /** props.brand will be specified in the case of a StoredCard or a Bancontact component, for a regular Card we default it to 'card' */\n brand: props.brand ?? TxVariants.card,\n countryCode: props.countryCode ? props.countryCode.toLowerCase() : null,\n // Required for transition period (until configuration object becomes the norm)\n // - if merchant has defined value directly in props, use this instead\n configuration: {\n ...props.configuration,\n socialSecurityNumberMode: props.configuration?.socialSecurityNumberMode ?? 'auto'\n },\n brandsConfiguration: props.brandsConfiguration || props.configuration?.brandsConfiguration || {},\n icon: props.icon || props.configuration?.icon,\n // installmentOptions of a session should be used before falling back to the merchant configuration\n installmentOptions: props.session?.configuration?.installmentOptions || props.installmentOptions,\n enableStoreDetails,\n showStoreDetailsCheckbox,\n /**\n * Click to Pay configuration\n * - If email is set explicitly in the configuration, then it can override the one used in the session creation\n */\n clickToPayConfiguration: {\n ...props.clickToPayConfiguration,\n disableOtpAutoFocus: props.clickToPayConfiguration?.disableOtpAutoFocus || false,\n shopperEmail: props.clickToPayConfiguration?.shopperEmail || this.core.options?.session?.shopperEmail,\n telephoneNumber: props.clickToPayConfiguration?.telephoneNumber || this.core.options?.session?.telephoneNumber,\n locale: props.clickToPayConfiguration?.locale || props.i18n?.locale?.replace('-', '_')\n },\n ...(storedCardID && { storedPaymentMethodId: storedCardID })\n };\n }\n\n /**\n * Formats the component data output\n */\n formatData(): CardElementData {\n /**\n * this.state.selectedBrandValue will be set when:\n * - /binLookup detects a single brand,\n * - when /binLookup detects a dual-branded card and the shopper makes a brand selection\n * - or, in the case of a storedCard\n */\n const cardBrand = this.state.selectedBrandValue;\n\n return {\n paymentMethod: {\n type: CardElement.type,\n ...this.state.data,\n ...(this.props.storedPaymentMethodId && {\n storedPaymentMethodId: this.props.storedPaymentMethodId,\n holderName: this.props.holderName ?? ''\n }),\n ...(cardBrand && { brand: cardBrand }),\n ...(this.props.fundingSource && { fundingSource: this.props.fundingSource }),\n ...(this.state.fastlaneData && { fastlaneData: btoa(JSON.stringify(this.state.fastlaneData)) })\n },\n ...(this.state.billingAddress && { billingAddress: this.state.billingAddress }),\n ...(this.state.socialSecurityNumber && { socialSecurityNumber: this.state.socialSecurityNumber }),\n ...this.storePaymentMethodPayload,\n ...(hasValidInstallmentsObject(this.state.installments) && { installments: this.state.installments }),\n browserInfo: this.browserInfo,\n origin: !!window && window.location.origin\n };\n }\n\n protected override beforeRender(configSetByMerchant?: CardConfiguration): void {\n // We don't send 'rendered' events when rendering actions\n if (configSetByMerchant?.originalAction) {\n return;\n }\n\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.rendered,\n component: this.type,\n configData: { ...configSetByMerchant, showPayButton: this.props.showPayButton },\n ...(configSetByMerchant?.oneClick && {\n isStoredPaymentMethod: true,\n brand: configSetByMerchant.brand\n })\n });\n\n this.analytics.sendAnalytics(event);\n }\n\n updateStyles(stylesObj) {\n if (this.componentRef?.updateStyles) this.componentRef.updateStyles(stylesObj);\n return this;\n }\n\n setFocusOn(fieldName) {\n if (this.componentRef?.setFocusOn) this.componentRef.setFocusOn(fieldName);\n return this;\n }\n\n public onBrand = event => {\n this.props.onBrand?.(event);\n };\n\n processBinLookupResponse(binLookupResponse: BinLookupResponse, isReset = false) {\n if (this.componentRef?.processBinLookupResponse) this.componentRef.processBinLookupResponse(binLookupResponse, isReset);\n return this;\n }\n\n handleUnsupportedCard(errObj) {\n if (this.componentRef?.handleUnsupportedCard) this.componentRef.handleUnsupportedCard(errObj);\n return this;\n }\n\n private handleClickToPaySubmit = (payload: ClickToPayCheckoutPayload) => {\n this.setState({ data: { ...payload }, valid: {}, errors: {}, isValid: true });\n this.submit();\n };\n\n onBinLookup(obj: CardBinLookupData) {\n // Handler for regular card comp doesn't need this 'raw' data or to know about 'resets'\n if (!obj.isReset) {\n const nuObj = reject('supportedBrandsRaw').from(obj);\n this.props.onBinLookup?.(nuObj);\n }\n }\n\n private onConfigSuccess = (obj: CardConfigSuccessData) => {\n const event = new AnalyticsInfoEvent({ component: this.type, type: InfoEventType.configured });\n this.submitAnalytics(event);\n\n this.props.onConfigSuccess?.(obj);\n };\n\n private onFocus = (obj: ComponentFocusObject) => {\n const event = new AnalyticsInfoEvent({ component: this.type, type: InfoEventType.focus, target: fieldTypeToSnakeCase(obj.fieldType) });\n this.submitAnalytics(event);\n\n // Call merchant defined callback\n if (ALL_SECURED_FIELDS.includes(obj.fieldType)) {\n this.props.onFocus?.(obj.event as CardFocusData);\n } else {\n this.props.onFocus?.(obj);\n }\n };\n\n private onBlur = (obj: ComponentFocusObject) => {\n const event = new AnalyticsInfoEvent({ component: this.type, type: InfoEventType.unfocus, target: fieldTypeToSnakeCase(obj.fieldType) });\n this.submitAnalytics(event);\n\n // Call merchant defined callback\n if (ALL_SECURED_FIELDS.includes(obj.fieldType)) {\n this.props.onBlur?.(obj.event as CardFocusData);\n } else {\n this.props.onBlur?.(obj);\n }\n };\n\n public onBinValue = triggerBinLookUp(this);\n\n get storePaymentMethodPayload() {\n const isStoredCard = this.props.storedPaymentMethodId?.length > 0;\n if (isStoredCard) {\n return {};\n }\n\n /**\n * For regular card, zero auth payments, we store the payment method, *if* the configuration says we should:\n * - For sessions, this means if the session has been created with storePaymentMethodMode: 'askForConsent'\n * - For the advanced flow, this means if the merchant has still set enableStoreDetails: true\n *\n * What we are doing is.. if for a normal payment we would show the \"Save for my next payment\" checkbox,\n * for a zero-auth payment we effectively click the checkbox on behalf of the shopper.\n */\n const isZeroAuth = this.props.amount?.value === 0;\n if (isZeroAuth) {\n return this.props.enableStoreDetails ? { storePaymentMethod: true } : {};\n }\n\n // For regular card, non-zero auth payments, we store the payment method based on the checkbox value.\n const includeStorePaymentMethod = this.props.showStoreDetailsCheckbox && typeof this.state.storePaymentMethod !== 'undefined';\n return includeStorePaymentMethod ? { storePaymentMethod: Boolean(this.state.storePaymentMethod) } : {};\n }\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get icon() {\n return this.props.icon ?? this.resources.getImage()(this.props.brand);\n }\n\n get brands(): { icon: any; name: string }[] {\n const { brands, brandsConfiguration } = this.props;\n if (brands) {\n return brands.map(brand => {\n const brandIcon = brandsConfiguration[brand]?.icon ?? this.props.modules.resources.getImage()(brand);\n return { icon: brandIcon, name: brand };\n });\n }\n\n return [];\n }\n\n get displayName(): string {\n if (this.props.storedPaymentMethodId) {\n return `•••• ${this.props.lastFour}`;\n }\n\n return this.props.name || CardElement.type;\n }\n\n get accessibleName(): string {\n // Use display name, unless it's a stored payment method, there inform user\n return (\n (this.props.name || CardElement.type) +\n (this.props.storedPaymentMethodId\n ? ' ' + this.props.i18n.get('creditCard.storedCard.description.ariaLabel').replace('%@', this.props.lastFour)\n : '')\n );\n }\n\n get browserInfo() {\n return collectBrowserInfo();\n }\n\n protected override payButton = (props: PayButtonFunctionProps) => {\n const isZeroAuth = this.props.amount?.value === 0;\n const isStoredCard = this.props.storedPaymentMethodId?.length > 0;\n return (\n <PayButton\n {...props}\n amount={this.props.amount}\n secondaryAmount={this.props.secondaryAmount}\n label={isZeroAuth && !isStoredCard ? this.props.i18n.get('payButton.saveDetails') : ''}\n onClick={this.submit}\n />\n );\n };\n\n private renderCardInput(isCardPrimaryInput = true): h.JSX.Element {\n return (\n <CardInput\n setComponentRef={this.setComponentRef}\n {...this.props}\n {...this.state}\n onSubmitAnalytics={this.submitAnalytics}\n onChange={this.setState}\n onSubmit={this.submit}\n handleKeyPress={this.handleKeyPress}\n payButton={this.payButton}\n onBrand={this.onBrand}\n onBinValue={this.onBinValue}\n brand={this.props.brand}\n brandsIcons={this.brands}\n isPayButtonPrimaryVariant={isCardPrimaryInput}\n resources={this.resources}\n onFocus={this.onFocus}\n onBlur={this.onBlur}\n onConfigSuccess={this.onConfigSuccess}\n />\n );\n }\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <ClickToPayWrapper\n amount={this.props.amount}\n configuration={this.props.clickToPayConfiguration}\n clickToPayService={this.clickToPayService}\n isStandaloneComponent={false}\n setClickToPayRef={this.setClickToPayRef}\n onSetStatus={this.setElementStatus}\n onSubmit={this.handleClickToPaySubmit}\n onError={this.handleError}\n >\n {isCardPrimaryInput => this.renderCardInput(isCardPrimaryInput)}\n </ClickToPayWrapper>\n </SRPanelProvider>\n );\n }\n}\n\nexport default CardElement;\n"],"names":["CardElement","UIElement","setStatus","status","props","this","componentRef","clickToPayRef","formatProps","enableStoreDetails","session","configuration","showStoreDetailsCheckbox","amount","value","storedCardID","storedPaymentMethodId","id","isEcommerceStoredCard","supportedShopperInteractions","includes","AdyenCheckoutError","IMPLEMENTATION_ERROR","holderNameRequired","hasHolderName","hasCVC","brand","hideCVC","billingAddressRequired","billingAddressMode","onAddressLookup","CardInputDefaultProps","TxVariants","card","countryCode","toLowerCase","socialSecurityNumberMode","brandsConfiguration","icon","installmentOptions","clickToPayConfiguration","disableOtpAutoFocus","shopperEmail","core","options","telephoneNumber","locale","i18n","replace","formatData","cardBrand","state","selectedBrandValue","paymentMethod","type","data","holderName","fundingSource","fastlaneData","btoa","JSON","stringify","billingAddress","socialSecurityNumber","storePaymentMethodPayload","hasValidInstallmentsObject","installments","browserInfo","origin","window","location","beforeRender","configSetByMerchant","originalAction","event","AnalyticsInfoEvent","InfoEventType","rendered","component","configData","showPayButton","oneClick","isStoredPaymentMethod","analytics","sendAnalytics","updateStyles","stylesObj","setFocusOn","fieldName","processBinLookupResponse","binLookupResponse","isReset","handleUnsupportedCard","errObj","onBinLookup","obj","nuObj","reject","from","length","storePaymentMethod","Boolean","isValid","resources","getImage","brands","map","modules","name","displayName","lastFour","accessibleName","get","collectBrowserInfo","renderCardInput","isCardPrimaryInput","h","CardInput","setComponentRef","onSubmitAnalytics","submitAnalytics","onChange","setState","onSubmit","submit","handleKeyPress","payButton","onBrand","onBinValue","brandsIcons","isPayButtonPrimaryVariant","onFocus","onBlur","onConfigSuccess","componentToRender","SRPanelProvider","srPanel","ClickToPayWrapper","clickToPayService","isStandaloneComponent","setClickToPayRef","onSetStatus","setElementStatus","handleClickToPaySubmit","onError","handleError","constructor","checkout","super","_define_property","ref","payload","valid","errors","configured","focus","target","fieldTypeToSnakeCase","fieldType","ALL_SECURED_FIELDS","unfocus","triggerBinLookUp","isZeroAuth","isStoredCard","PayButton","secondaryAmount","label","onClick","_disableClickToPay","createClickToPayService","environment","initialize","scheme","defaultProps","showFormInstruction","doBinLookup"],"mappings":"+rCAwBO,MAAMA,UAAoBC,EAiCtBC,SAAAA,CAAUC,EAAyBC,GAOtC,OANIC,KAAKC,cAAcJ,WACnBG,KAAKC,aAAaJ,UAAUC,EAAQC,GAEpCC,KAAKE,eAAeL,WACpBG,KAAKE,cAAcL,UAAUC,EAAQC,GAElCC,IACX,CAMAG,WAAAA,CAAYJ,GAER,MAAMK,EAAqBL,EAAMM,SAASC,eAAeF,oBAAsBL,EAAMK,mBAG/EG,IADqC,IAAxBR,EAAMS,QAAQC,QACqBL,EAEhDM,EAAeX,EAAMY,uBAAyBZ,EAAMa,GACpDC,EAAwBH,GAAgBX,GAAOe,8BAA8BC,SAAS,aAG5F,GAAIL,IAAiBG,EAEjB,MAAM,IAAIG,EACNC,EACA,uGAIR,MAAO,IACAlB,EAEHmB,qBAAqBnB,EAAMoB,eAAwBpB,EAAMmB,mBAEzDE,SA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CAAC,OAAQ,oBAAoBC,KAAKnE"}
1
+ {"version":3,"file":"Card.js","sources":["../../../../src/components/Card/Card.tsx"],"sourcesContent":["import { h } from 'preact';\nimport CardInput from './components/CardInput';\nimport collectBrowserInfo from '../../utils/browserInfo';\nimport { BinLookupResponse, CardElementData, CardConfiguration } from './types';\nimport triggerBinLookUp from '../internal/SecuredFields/binLookup/triggerBinLookUp';\nimport { CardBinLookupData, CardConfigSuccessData, CardFocusData } from '../internal/SecuredFields/lib/types';\nimport { fieldTypeToSnakeCase } from '../internal/SecuredFields/utils';\nimport { reject } from '../../utils/commonUtils';\nimport { hasValidInstallmentsObject } from './components/CardInput/utils';\nimport createClickToPayService from '../internal/ClickToPay/services/create-clicktopay-service';\nimport { ClickToPayCheckoutPayload, IClickToPayService } from '../internal/ClickToPay/services/types';\nimport ClickToPayWrapper from './components/ClickToPayWrapper';\nimport { ComponentFocusObject } from '../../types/global-types';\nimport { TxVariants } from '../tx-variants';\nimport type { PayButtonFunctionProps, UIElementStatus } from '../internal/UIElement/types';\nimport UIElement from '../internal/UIElement';\nimport PayButton from '../internal/PayButton';\nimport type { ICore } from '../../core/types';\nimport { ALL_SECURED_FIELDS } from '../internal/SecuredFields/lib/constants';\nimport AdyenCheckoutError, { IMPLEMENTATION_ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport CardInputDefaultProps from './components/CardInput/defaultProps';\nimport { AnalyticsInfoEvent, InfoEventType } from '../../core/Analytics/events/AnalyticsInfoEvent';\n\nexport class CardElement extends UIElement<CardConfiguration> {\n public static type = TxVariants.scheme;\n\n private readonly clickToPayService: IClickToPayService | null;\n\n /**\n * Reference to the 'ClickToPayComponent'\n */\n private clickToPayRef = null;\n\n constructor(checkout: ICore, props?: CardConfiguration) {\n super(checkout, props);\n\n if (props && !props._disableClickToPay) {\n this.clickToPayService = createClickToPayService(\n this.props.configuration,\n this.props.clickToPayConfiguration,\n this.props.environment,\n this.analytics\n );\n\n void this.clickToPayService?.initialize();\n }\n }\n\n protected static defaultProps = {\n showFormInstruction: true,\n _disableClickToPay: false,\n doBinLookup: true,\n // Merge most of CardInput's defaultProps\n ...reject(['type', 'setComponentRef']).from(CardInputDefaultProps)\n };\n\n public setStatus(status: UIElementStatus, props?): this {\n if (this.componentRef?.setStatus) {\n this.componentRef.setStatus(status, props);\n }\n if (this.clickToPayRef?.setStatus) {\n this.clickToPayRef.setStatus(status, props);\n }\n return this;\n }\n\n private setClickToPayRef = ref => {\n this.clickToPayRef = ref;\n };\n\n formatProps(props: CardConfiguration): CardConfiguration {\n // The value from a session should be used, before falling back to the merchant configuration\n const enableStoreDetails = props.session?.configuration?.enableStoreDetails ?? props.enableStoreDetails;\n\n const isZeroAuth = props.amount?.value === 0;\n const showStoreDetailsCheckbox = isZeroAuth ? false : enableStoreDetails;\n\n const storedCardID = props.storedPaymentMethodId || props.id; // check if we've been passed a (checkout) processed storedCard or one that merchant has pulled from the PMs response\n const isEcommerceStoredCard = storedCardID && props?.supportedShopperInteractions?.includes('Ecommerce'); // If we have a storedCard does it support Ecommerce (it might not if the merchant has pulled it from the PMs response)\n\n // If we have a storedPM but it doesn't support Ecommerce - we can't make a storedCard component from it\n if (storedCardID && !isEcommerceStoredCard) {\n // TODO - Decide if an error is too severe? Would a console.warning suffice?\n throw new AdyenCheckoutError(\n IMPLEMENTATION_ERROR,\n 'You are trying to create a storedCard from a stored PM that does not support Ecommerce interactions'\n );\n }\n\n return {\n ...props,\n // Mismatch between hasHolderName & holderNameRequired which can mean card can never be valid\n holderNameRequired: !props.hasHolderName ? false : props.holderNameRequired,\n // False for *stored* BCMC cards & if merchant explicitly wants to hide the CVC field\n hasCVC: !((props.brand && props.brand === 'bcmc') || props.hideCVC),\n // billingAddressRequired only available for non-stored cards\n billingAddressRequired: props.storedPaymentMethodId ? false : props.billingAddressRequired,\n // edge case where merchant has defined both an onAddressLookup callback AND set billingAddressMode: 'partial' - which leads to some strange behaviour in the address UI\n billingAddressMode: props.onAddressLookup ? CardInputDefaultProps.billingAddressMode : props.billingAddressMode,\n /** props.brand will be specified in the case of a StoredCard or a Bancontact component, for a regular Card we default it to 'card' */\n brand: props.brand ?? TxVariants.card,\n countryCode: props.countryCode ? props.countryCode.toLowerCase() : null,\n // Required for transition period (until configuration object becomes the norm)\n // - if merchant has defined value directly in props, use this instead\n configuration: {\n ...props.configuration,\n socialSecurityNumberMode: props.configuration?.socialSecurityNumberMode ?? 'auto'\n },\n brandsConfiguration: props.brandsConfiguration || props.configuration?.brandsConfiguration || {},\n icon: props.icon || props.configuration?.icon,\n // installmentOptions of a session should be used before falling back to the merchant configuration\n installmentOptions: props.session?.configuration?.installmentOptions || props.installmentOptions,\n enableStoreDetails,\n showStoreDetailsCheckbox,\n /**\n * Click to Pay configuration\n * - If email is set explicitly in the configuration, then it can override the one used in the session creation\n */\n clickToPayConfiguration: {\n ...props.clickToPayConfiguration,\n disableOtpAutoFocus: props.clickToPayConfiguration?.disableOtpAutoFocus || false,\n shopperEmail: props.clickToPayConfiguration?.shopperEmail || this.core.options?.session?.shopperEmail,\n telephoneNumber: props.clickToPayConfiguration?.telephoneNumber || this.core.options?.session?.telephoneNumber,\n locale: props.clickToPayConfiguration?.locale || props.i18n?.locale?.replace('-', '_')\n },\n ...(storedCardID && { storedPaymentMethodId: storedCardID })\n };\n }\n\n /**\n * Formats the component data output\n */\n formatData(): CardElementData {\n /**\n * this.state.selectedBrandValue will be set when:\n * - /binLookup detects a single brand,\n * - when /binLookup detects a dual-branded card and the shopper makes a brand selection\n * - or, in the case of a storedCard\n */\n const cardBrand = this.state.selectedBrandValue;\n\n return {\n paymentMethod: {\n type: CardElement.type,\n ...this.state.data,\n ...(this.props.storedPaymentMethodId && {\n storedPaymentMethodId: this.props.storedPaymentMethodId,\n holderName: this.props.holderName ?? ''\n }),\n ...(cardBrand && { brand: cardBrand }),\n ...(this.props.fundingSource && { fundingSource: this.props.fundingSource }),\n ...(this.state.fastlaneData && { fastlaneData: btoa(JSON.stringify(this.state.fastlaneData)) })\n },\n ...(this.state.billingAddress && { billingAddress: this.state.billingAddress }),\n ...(this.state.socialSecurityNumber && { socialSecurityNumber: this.state.socialSecurityNumber }),\n ...this.storePaymentMethodPayload,\n ...(hasValidInstallmentsObject(this.state.installments) && { installments: this.state.installments }),\n browserInfo: this.browserInfo,\n origin: !!window && window.location.origin\n };\n }\n\n protected override beforeRender(configSetByMerchant?: CardConfiguration): void {\n // We don't send 'rendered' events when rendering actions\n if (configSetByMerchant?.originalAction) {\n return;\n }\n\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.rendered,\n component: this.type,\n configData: { ...configSetByMerchant, showPayButton: this.props.showPayButton },\n ...(configSetByMerchant?.oneClick && {\n isStoredPaymentMethod: true,\n brand: configSetByMerchant.brand\n })\n });\n\n this.analytics.sendAnalytics(event);\n }\n\n updateStyles(stylesObj) {\n if (this.componentRef?.updateStyles) this.componentRef.updateStyles(stylesObj);\n return this;\n }\n\n setFocusOn(fieldName) {\n if (this.componentRef?.setFocusOn) this.componentRef.setFocusOn(fieldName);\n return this;\n }\n\n public onBrand = event => {\n this.props.onBrand?.(event);\n };\n\n processBinLookupResponse(binLookupResponse: BinLookupResponse, isReset = false) {\n if (this.componentRef?.processBinLookupResponse) this.componentRef.processBinLookupResponse(binLookupResponse, isReset);\n return this;\n }\n\n handleUnsupportedCard(errObj) {\n if (this.componentRef?.handleUnsupportedCard) this.componentRef.handleUnsupportedCard(errObj);\n return this;\n }\n\n private handleClickToPaySubmit = (payload: ClickToPayCheckoutPayload) => {\n this.setState({ data: { ...payload }, valid: {}, errors: {}, isValid: true });\n this.submit();\n };\n\n onBinLookup(obj: CardBinLookupData) {\n // Handler for regular card comp doesn't need this 'raw' data or to know about 'resets'\n if (!obj.isReset) {\n const nuObj = reject('supportedBrandsRaw').from(obj);\n this.props.onBinLookup?.(nuObj);\n }\n }\n\n private onConfigSuccess = (obj: CardConfigSuccessData) => {\n const event = new AnalyticsInfoEvent({ component: this.type, type: InfoEventType.configured });\n this.submitAnalytics(event);\n\n this.props.onConfigSuccess?.(obj);\n };\n\n private onFocus = (obj: ComponentFocusObject) => {\n const event = new AnalyticsInfoEvent({ component: this.type, type: InfoEventType.focus, target: fieldTypeToSnakeCase(obj.fieldType) });\n this.submitAnalytics(event);\n\n // Call merchant defined callback\n if (ALL_SECURED_FIELDS.includes(obj.fieldType)) {\n this.props.onFocus?.(obj.event as CardFocusData);\n } else {\n this.props.onFocus?.(obj);\n }\n };\n\n private onBlur = (obj: ComponentFocusObject) => {\n const event = new AnalyticsInfoEvent({ component: this.type, type: InfoEventType.unfocus, target: fieldTypeToSnakeCase(obj.fieldType) });\n this.submitAnalytics(event);\n\n // Call merchant defined callback\n if (ALL_SECURED_FIELDS.includes(obj.fieldType)) {\n this.props.onBlur?.(obj.event as CardFocusData);\n } else {\n this.props.onBlur?.(obj);\n }\n };\n\n public onBinValue = triggerBinLookUp(this);\n\n get storePaymentMethodPayload() {\n const isStoredCard = this.props.storedPaymentMethodId?.length > 0;\n if (isStoredCard) {\n return {};\n }\n\n /**\n * For regular card, zero auth payments, we store the payment method, *if* the configuration says we should:\n * - For sessions, this means if the session has been created with storePaymentMethodMode: 'askForConsent'\n * - For the advanced flow, this means if the merchant has still set enableStoreDetails: true\n *\n * What we are doing is.. if for a normal payment we would show the \"Save for my next payment\" checkbox,\n * for a zero-auth payment we effectively click the checkbox on behalf of the shopper.\n */\n const isZeroAuth = this.props.amount?.value === 0;\n if (isZeroAuth) {\n return this.props.enableStoreDetails ? { storePaymentMethod: true } : {};\n }\n\n // For regular card, non-zero auth payments, we store the payment method based on the checkbox value.\n const includeStorePaymentMethod = this.props.showStoreDetailsCheckbox && typeof this.state.storePaymentMethod !== 'undefined';\n return includeStorePaymentMethod ? { storePaymentMethod: Boolean(this.state.storePaymentMethod) } : {};\n }\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get icon() {\n return this.props.icon ?? this.resources.getImage()(this.props.brand);\n }\n\n get brands(): { icon: any; name: string }[] {\n const { brands, brandsConfiguration } = this.props;\n if (brands) {\n return brands.map(brand => {\n const brandIcon = brandsConfiguration[brand]?.icon ?? this.props.modules.resources.getImage()(brand);\n return { icon: brandIcon, name: brand };\n });\n }\n\n return [];\n }\n\n get displayName(): string {\n if (this.props.storedPaymentMethodId) {\n return `•••• ${this.props.lastFour}`;\n }\n\n return this.props.name || CardElement.type;\n }\n\n get accessibleName(): string {\n // Use display name, unless it's a stored payment method, there inform user\n return (\n (this.props.name || CardElement.type) +\n (this.props.storedPaymentMethodId\n ? ' ' + this.props.i18n.get('creditCard.storedCard.description.ariaLabel').replace('%@', this.props.lastFour)\n : '')\n );\n }\n\n get browserInfo() {\n return collectBrowserInfo();\n }\n\n protected override payButton = (props: PayButtonFunctionProps) => {\n const isZeroAuth = this.props.amount?.value === 0;\n const isStoredCard = this.props.storedPaymentMethodId?.length > 0;\n return (\n <PayButton\n {...props}\n amount={this.props.amount}\n secondaryAmount={this.props.secondaryAmount}\n label={isZeroAuth && !isStoredCard ? this.props.i18n.get('payButton.saveDetails') : ''}\n onClick={this.submit}\n />\n );\n };\n\n private renderCardInput(isCardPrimaryInput = true): h.JSX.Element {\n return (\n <CardInput\n setComponentRef={this.setComponentRef}\n {...this.props}\n {...this.state}\n onSubmitAnalytics={this.submitAnalytics}\n onChange={this.setState}\n onSubmit={this.submit}\n handleKeyPress={this.handleKeyPress}\n payButton={this.payButton}\n onBrand={this.onBrand}\n onBinValue={this.onBinValue}\n brand={this.props.brand}\n brandsIcons={this.brands}\n isPayButtonPrimaryVariant={isCardPrimaryInput}\n resources={this.resources}\n onFocus={this.onFocus}\n onBlur={this.onBlur}\n onConfigSuccess={this.onConfigSuccess}\n />\n );\n }\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <ClickToPayWrapper\n amount={this.props.amount}\n configuration={this.props.clickToPayConfiguration}\n clickToPayService={this.clickToPayService}\n isStandaloneComponent={false}\n setClickToPayRef={this.setClickToPayRef}\n onSetStatus={this.setElementStatus}\n onSubmit={this.handleClickToPaySubmit}\n onError={this.handleError}\n >\n {isCardPrimaryInput => this.renderCardInput(isCardPrimaryInput)}\n </ClickToPayWrapper>\n );\n }\n}\n\nexport default CardElement;\n"],"names":["CardElement","UIElement","setStatus","status","props","this","componentRef","clickToPayRef","formatProps","enableStoreDetails","session","configuration","showStoreDetailsCheckbox","amount","value","storedCardID","storedPaymentMethodId","id","isEcommerceStoredCard","supportedShopperInteractions","includes","AdyenCheckoutError","IMPLEMENTATION_ERROR","holderNameRequired","hasHolderName","hasCVC","brand","hideCVC","billingAddressRequired","billingAddressMode","onAddressLookup","CardInputDefaultProps","TxVariants","card","countryCode","toLowerCase","socialSecurityNumberMode","brandsConfiguration","icon","installmentOptions","clickToPayConfiguration","disableOtpAutoFocus","shopperEmail","core","options","telephoneNumber","locale","i18n","replace","formatData","cardBrand","state","selectedBrandValue","paymentMethod","type","data","holderName","fundingSource","fastlaneData","btoa","JSON","stringify","billingAddress","socialSecurityNumber","storePaymentMethodPayload","hasValidInstallmentsObject","installments","browserInfo","origin","window","location","beforeRender","configSetByMerchant","originalAction","event","AnalyticsInfoEvent","InfoEventType","rendered","component","configData","showPayButton","oneClick","isStoredPaymentMethod","analytics","sendAnalytics","updateStyles","stylesObj","setFocusOn","fieldName","processBinLookupResponse","binLookupResponse","isReset","handleUnsupportedCard","errObj","onBinLookup","obj","nuObj","reject","from","length","storePaymentMethod","Boolean","isValid","resources","getImage","brands","map","modules","name","displayName","lastFour","accessibleName","get","collectBrowserInfo","renderCardInput","isCardPrimaryInput","h","CardInput","setComponentRef","onSubmitAnalytics","submitAnalytics","onChange","setState","onSubmit","submit","handleKeyPress","payButton","onBrand","onBinValue","brandsIcons","isPayButtonPrimaryVariant","onFocus","onBlur","onConfigSuccess","componentToRender","ClickToPayWrapper","clickToPayService","isStandaloneComponent","setClickToPayRef","onSetStatus","setElementStatus","handleClickToPaySubmit","onError","handleError","constructor","checkout","super","_define_property","ref","payload","valid","errors","configured","focus","target","fieldTypeToSnakeCase","fieldType","ALL_SECURED_FIELDS","unfocus","triggerBinLookUp","isZeroAuth","isStoredCard","PayButton","secondaryAmount","label","onClick","_disableClickToPay","createClickToPayService","environment","initialize","scheme","defaultProps","showFormInstruction","doBinLookup"],"mappings":"2oCAuBO,MAAMA,UAAoBC,EAiCtBC,SAAAA,CAAUC,EAAyBC,GAOtC,OANIC,KAAKC,cAAcJ,WACnBG,KAAKC,aAAaJ,UAAUC,EAAQC,GAEpCC,KAAKE,eAAeL,WACpBG,KAAKE,cAAcL,UAAUC,EAAQC,GAElCC,IACX,CAMAG,WAAAA,CAAYJ,GAER,MAAMK,EAAqBL,EAAMM,SAASC,eAAeF,oBAAsBL,EAAMK,mBAG/EG,IADqC,IAAxBR,EAAMS,QAAQC,QACqBL,EAEhDM,EAAeX,EAAMY,uBAAyBZ,EAAMa,GACpDC,EAAwBH,GAAgBX,GAAOe,8BAA8BC,SAAS,aAG5F,GAAIL,IAAiBG,EAEjB,MAAM,IAAIG,EACNC,EACA,uGAIR,MAAO,IACAlB,EAEHmB,qBAAqBnB,EAAMoB,eAAwBpB,EAAMmB,mBAEzDE,SAAUrB,EAAOsB,OAAyB,SAAhBtB,EAAMsB,OAAqBtB,EAAMuB,SAE3DC,wBAAwBxB,EAAMY,uBAAgCZ,EAAMwB,uBAEpEC,mBAAoBzB,EAAM0B,gBAAkBC,EAAsBF,mBAAqBzB,EAAMyB,mBAE7FH,MAAOtB,EAAMsB,OAASM,EAAWC,KACjCC,YAAa9B,EAAM8B,YAAc9B,EAAM8B,YAAYC,cAAgB,KAGnExB,cAAe,IACRP,EAAMO,cACTyB,yBAA0BhC,EAAMO,eAAeyB,0BAA4B,QAE/EC,oBAAqBjC,EAAMiC,qBAAuBjC,EAAMO,eAAe0B,qBAAuB,CAAA,EAC9FC,KAAMlC,EAAMkC,MAAQlC,EAAMO,eAAe2B,KAEzCC,mBAAoBnC,EAAMM,SAASC,eAAe4B,oBAAsBnC,EAAMmC,mBAC9E9B,qBACAG,2BAKA4B,wBAAyB,IAClBpC,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IAA7B3J,KAAKD,MAAMS,QAAQC,MAChCmJ,EAAe5J,KAAKD,MAAMY,uBAAuBmF,OAAS,EAChE,OACIiB,EAAC8C,EAAAA,IACO9J,EACJS,OAAQR,KAAKD,MAAMS,OACnBsJ,gBAAiB9J,KAAKD,MAAM+J,gBAC5BC,MAAOJ,IAAeC,EAAe5J,KAAKD,MAAM2C,KAAKiE,IAAI,yBAA2B,GACpFqD,QAAShK,KAAKuH,WAlSlBxH,IAAUA,EAAMkK,qBAChBjK,KAAKmI,kBAAoB+B,EACrBlK,KAAKD,MAAMO,cACXN,KAAKD,MAAMoC,wBACXnC,KAAKD,MAAMoK,YACXnK,KAAK8E,WAGJ9E,KAAKmI,mBAAmBiC,aAErC,EAtBAtB,EADSnJ,EACKsD,OAAOtB,EAAW0I,QAwBhCvB,EAzBSnJ,EAyBQ2K,eAAe,CAC5BC,qBAAqB,EACrBN,oBAAoB,EACpBO,aAAa,KAEV5E,EAAO,CAAC,OAAQ,oBAAoBC,KAAKnE"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import n from"./defaultProps.js";import{DropinComponent as o}from"./components/DropinComponent.js";import i from"./elements/createElements.js";import s from"./elements/createStoredElements.js";import r from"./elements/createInstantPaymentElements.js";import{hasOwnProperty as a}from"../../utils/hasOwnProperty.js";import h from"../../core/Errors/SRPanelProvider.js";import d from"./elements/splitPaymentMethods.js";import{TxVariants as m}from"../tx-variants.js";function p(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}const c=["paywithgoogle","googlepay","applepay"];class l extends e{reportIntegrationFlavor(){this.analytics.sendFlavor("dropin")}storeElementRefOnCore(){this.core.storeElementReference(this)}formatProps(t){return{...super.formatProps(t),instantPaymentTypes:Array.from(new Set(t.instantPaymentTypes)).filter(t=>c.includes(t))}}get isValid(){return!!this.dropinRef&&!!this.dropinRef.state.activePaymentMethod&&!!this.dropinRef.state.activePaymentMethod.isValid}showValidation(){return this.dropinRef.state.activePaymentMethod&&this.dropinRef.state.activePaymentMethod.showValidation(),this}setStatus(t,e={}){return this.dropinRef?.setStatus(t,e),this}get activePaymentMethod(){return this.dropinRef?.state||this.dropinRef?.state.activePaymentMethod?this.dropinRef.state.activePaymentMethod:null}get data(){return this.activePaymentMethod?this.dropinRef.state.activePaymentMethod.data:null}displayFinalAnimation(t){this.props.disableFinalAnimation||this.dropinRef?.setStatus(t)}submit(){if(!this.activePaymentMethod)throw new Error("No active payment method.");this.activePaymentMethod.isValid||this.activePaymentMethod.showValidation(),this.activePaymentMethod.isInstantPayment&&this.closeActivePaymentMethod(),this.activePaymentMethod.submit()}handleAction(t,e={}){if(!t||!t.type){if(a(t,"action")&&a(t,"resultCode"))throw new Error('handleAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('handleAction::Invalid Action - the passed action object does not have a "type" property')}if("redirect"!==t.type&&this.activePaymentMethod?.updateWithAction)return this.activePaymentMethod.updateWithAction(t);this.elementRef instanceof l&&(e={...this.elementRef.activePaymentMethod?.props,...e});const n=this.core.createFromAction(t,{...e,elementRef:this.elementRef,isDropin:!0});return n?(this.setStatus(n.props.statusType,{component:n}),this.componentFromAction=n,this):null}closeActivePaymentMethod(){this.dropinRef.closeActivePaymentMethod()}handleKeyPress(t){if("Enter"===t.key||"Enter"===t.code){if("radio"===document?.activeElement?.getAttribute("role"))return;super.handleKeyPress(t)}}onEnterKeyPressed(t,e){const n=this.activePaymentMethod??e;this.activePaymentMethod?.onEnterKeyPressed(t,n)}componentToRender(){return t(h,{srPanel:this.props.modules.srPanel},t(o,{...this.props,core:this.core,elementRef:this.elementRef,onCreateElements:this.handleCreate,ref:t=>{this.dropinRef=t}}))}constructor(t,e){super(t,e),p(this,"dropinRef",null),p(this,"paymentMethodsConfiguration",void 0),p(this,"componentFromAction",void 0),p(this,"handleCreate",()=>{const{paymentMethodsConfiguration:t,showStoredPaymentMethods:e,showPaymentMethods:n,instantPaymentTypes:o}=this.props,{paymentMethods:a,storedPaymentMethods:h,instantPaymentMethods:m,fastlanePaymentMethod:p}=d(this.core.paymentMethodsResponse,o),c={elementRef:this.elementRef,isDropin:!0},l=n?i(a,t,c,this.core):[],y=r(m,t,c,this.core);return[e?s(this.props.filterStoredPaymentMethods?.(h)??h,t,c,this.core):[],l,y,p?i([p],t,c,this.core):[]]}),p(this,"handleOrder",({order:t})=>{this.updateParent({order:t})}),this.submit=this.submit.bind(this),this.handleAction=this.handleAction.bind(this),this.props.paymentMethodComponents.forEach(t=>this.core.register(t)),this.paymentMethodsConfiguration=this.props.paymentMethodsConfiguration||{}}}p(l,"type",m.dropin),p(l,"defaultProps",n);export{l as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import n from"./defaultProps.js";import{DropinComponent as o}from"./components/DropinComponent.js";import i from"./elements/createElements.js";import s from"./elements/createStoredElements.js";import r from"./elements/createInstantPaymentElements.js";import{hasOwnProperty as a}from"../../utils/hasOwnProperty.js";import h from"./elements/splitPaymentMethods.js";import{TxVariants as d}from"../tx-variants.js";function m(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}const p=["paywithgoogle","googlepay","applepay"];class c extends e{reportIntegrationFlavor(){this.analytics.sendFlavor("dropin")}storeElementRefOnCore(){this.core.storeElementReference(this)}formatProps(t){return{...super.formatProps(t),instantPaymentTypes:Array.from(new Set(t.instantPaymentTypes)).filter(t=>p.includes(t))}}get isValid(){return!!this.dropinRef&&!!this.dropinRef.state.activePaymentMethod&&!!this.dropinRef.state.activePaymentMethod.isValid}showValidation(){return this.dropinRef.state.activePaymentMethod&&this.dropinRef.state.activePaymentMethod.showValidation(),this}setStatus(t,e={}){return this.dropinRef?.setStatus(t,e),this}get activePaymentMethod(){return this.dropinRef?.state||this.dropinRef?.state.activePaymentMethod?this.dropinRef.state.activePaymentMethod:null}get data(){return this.activePaymentMethod?this.dropinRef.state.activePaymentMethod.data:null}displayFinalAnimation(t){this.props.disableFinalAnimation||this.dropinRef?.setStatus(t)}submit(){if(!this.activePaymentMethod)throw new Error("No active payment method.");this.activePaymentMethod.isValid||this.activePaymentMethod.showValidation(),this.activePaymentMethod.isInstantPayment&&this.closeActivePaymentMethod(),this.activePaymentMethod.submit()}handleAction(t,e={}){if(!t||!t.type){if(a(t,"action")&&a(t,"resultCode"))throw new Error('handleAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('handleAction::Invalid Action - the passed action object does not have a "type" property')}if("redirect"!==t.type&&this.activePaymentMethod?.updateWithAction)return this.activePaymentMethod.updateWithAction(t);this.elementRef instanceof c&&(e={...this.elementRef.activePaymentMethod?.props,...e});const n=this.core.createFromAction(t,{...e,elementRef:this.elementRef,isDropin:!0});return n?(this.setStatus(n.props.statusType,{component:n}),this.componentFromAction=n,this):null}closeActivePaymentMethod(){this.dropinRef.closeActivePaymentMethod()}handleKeyPress(t){if("Enter"===t.key||"Enter"===t.code){if("radio"===document?.activeElement?.getAttribute("role"))return;super.handleKeyPress(t)}}onEnterKeyPressed(t,e){const n=this.activePaymentMethod??e;this.activePaymentMethod?.onEnterKeyPressed(t,n)}componentToRender(){return t(o,{...this.props,core:this.core,elementRef:this.elementRef,onCreateElements:this.handleCreate,ref:t=>{this.dropinRef=t}})}constructor(t,e){super(t,e),m(this,"dropinRef",null),m(this,"paymentMethodsConfiguration",void 0),m(this,"componentFromAction",void 0),m(this,"handleCreate",()=>{const{paymentMethodsConfiguration:t,showStoredPaymentMethods:e,showPaymentMethods:n,instantPaymentTypes:o}=this.props,{paymentMethods:a,storedPaymentMethods:d,instantPaymentMethods:m,fastlanePaymentMethod:p}=h(this.core.paymentMethodsResponse,o),c={elementRef:this.elementRef,isDropin:!0},l=n?i(a,t,c,this.core):[],y=r(m,t,c,this.core);return[e?s(this.props.filterStoredPaymentMethods?.(d)??d,t,c,this.core):[],l,y,p?i([p],t,c,this.core):[]]}),m(this,"handleOrder",({order:t})=>{this.updateParent({order:t})}),this.submit=this.submit.bind(this),this.handleAction=this.handleAction.bind(this),this.props.paymentMethodComponents.forEach(t=>this.core.register(t)),this.paymentMethodsConfiguration=this.props.paymentMethodsConfiguration||{}}}m(c,"type",d.dropin),m(c,"defaultProps",n);export{c as default};
2
2
  //# sourceMappingURL=Dropin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dropin.js","sources":["../../../../src/components/Dropin/Dropin.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport defaultProps from './defaultProps';\nimport DropinComponent from '../../components/Dropin/components/DropinComponent';\nimport { createElements, createStoredElements } from './elements';\nimport createInstantPaymentElements from './elements/createInstantPaymentElements';\nimport { hasOwnProperty } from '../../utils/hasOwnProperty';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport splitPaymentMethods from './elements/splitPaymentMethods';\nimport { TxVariants } from '../tx-variants';\n\nimport type { DropinConfiguration, InstantPaymentTypes, PaymentMethodsConfiguration } from './types';\nimport type { PaymentAction, PaymentResponseData } from '../../types/global-types';\nimport type { ICore } from '../../core/types';\nimport type { IDropin } from './types';\n\nconst SUPPORTED_INSTANT_PAYMENTS = ['paywithgoogle', 'googlepay', 'applepay'];\n\nclass DropinElement extends UIElement<DropinConfiguration> implements IDropin {\n public static type = TxVariants.dropin;\n\n protected static defaultProps = defaultProps;\n\n public dropinRef = null;\n\n private paymentMethodsConfiguration: PaymentMethodsConfiguration;\n /**\n * Reference to the component created from `handleAction` (Ex.: ThreeDS2Challenge)\n */\n public componentFromAction?: UIElement;\n\n constructor(checkout: ICore, props?: DropinConfiguration) {\n super(checkout, props);\n this.submit = this.submit.bind(this);\n this.handleAction = this.handleAction.bind(this);\n\n this.props.paymentMethodComponents.forEach(PaymentMethod => this.core.register(PaymentMethod));\n this.paymentMethodsConfiguration = this.props.paymentMethodsConfiguration || {};\n }\n\n protected override reportIntegrationFlavor(): void {\n void this.analytics.sendFlavor('dropin');\n }\n\n protected override storeElementRefOnCore() {\n this.core.storeElementReference(this);\n }\n\n formatProps(props) {\n return {\n ...super.formatProps(props),\n instantPaymentTypes: Array.from<InstantPaymentTypes>(new Set(props.instantPaymentTypes)).filter(value =>\n SUPPORTED_INSTANT_PAYMENTS.includes(value)\n )\n };\n }\n\n get isValid() {\n return !!this.dropinRef && !!this.dropinRef.state.activePaymentMethod && !!this.dropinRef.state.activePaymentMethod.isValid;\n }\n\n showValidation() {\n if (this.dropinRef.state.activePaymentMethod) {\n this.dropinRef.state.activePaymentMethod.showValidation();\n }\n\n return this;\n }\n\n public setStatus(status, props = {}): this {\n this.dropinRef?.setStatus(status, props);\n return this;\n }\n\n get activePaymentMethod() {\n if (!this.dropinRef?.state && !this.dropinRef?.state.activePaymentMethod) {\n return null;\n }\n\n return this.dropinRef.state.activePaymentMethod;\n }\n\n get data() {\n if (!this.activePaymentMethod) {\n return null;\n }\n\n return this.dropinRef.state.activePaymentMethod.data;\n }\n\n public displayFinalAnimation(type: 'success' | 'error') {\n if (this.props.disableFinalAnimation) return;\n\n this.dropinRef?.setStatus(type);\n }\n\n /**\n * Calls the onSubmit event with the state of the activePaymentMethod\n */\n public override submit(): void {\n if (!this.activePaymentMethod) {\n throw new Error('No active payment method.');\n }\n\n if (!this.activePaymentMethod.isValid) {\n this.activePaymentMethod.showValidation();\n }\n\n if (this.activePaymentMethod.isInstantPayment) {\n this.closeActivePaymentMethod();\n }\n\n this.activePaymentMethod.submit();\n }\n\n /**\n * Creates the Drop-in elements\n */\n private handleCreate = () => {\n const { paymentMethodsConfiguration, showStoredPaymentMethods, showPaymentMethods, instantPaymentTypes } = this.props;\n\n const { paymentMethods, storedPaymentMethods, instantPaymentMethods, fastlanePaymentMethod } = splitPaymentMethods(\n this.core.paymentMethodsResponse,\n instantPaymentTypes\n );\n\n const dropinProps = {\n elementRef: this.elementRef,\n isDropin: true\n };\n\n const elements = showPaymentMethods ? createElements(paymentMethods, paymentMethodsConfiguration, dropinProps, this.core) : [];\n const instantPaymentElements = createInstantPaymentElements(instantPaymentMethods, paymentMethodsConfiguration, dropinProps, this.core);\n const storedElements = showStoredPaymentMethods\n ? createStoredElements(\n this.props.filterStoredPaymentMethods?.(storedPaymentMethods) ?? storedPaymentMethods,\n paymentMethodsConfiguration,\n dropinProps,\n this.core\n )\n : [];\n const fastlanePaymentElement = fastlanePaymentMethod\n ? createElements([fastlanePaymentMethod], paymentMethodsConfiguration, dropinProps, this.core)\n : [];\n\n return [storedElements, elements, instantPaymentElements, fastlanePaymentElement];\n };\n\n public handleAction(action: PaymentAction, props = {}): this | null {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'handleAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('handleAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n if (action.type !== 'redirect' && this.activePaymentMethod?.updateWithAction) {\n return this.activePaymentMethod.updateWithAction(action);\n }\n\n if (this.elementRef instanceof DropinElement) {\n props = {\n ...this.elementRef.activePaymentMethod?.props,\n ...props\n };\n }\n\n const paymentAction: UIElement = this.core.createFromAction(action, {\n ...props,\n elementRef: this.elementRef, // maintain elementRef for 3DS2 flow\n isDropin: true\n });\n\n if (paymentAction) {\n this.setStatus(paymentAction.props.statusType, { component: paymentAction });\n this.componentFromAction = paymentAction;\n return this;\n }\n\n return null;\n }\n\n /**\n * handleOrder is implemented so we don't trigger a callback like in the components\n * @param response - PaymentResponse\n */\n protected handleOrder = ({ order }: PaymentResponseData): void => {\n void this.updateParent({ order });\n };\n\n closeActivePaymentMethod() {\n this.dropinRef.closeActivePaymentMethod();\n }\n\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement> | KeyboardEvent) {\n if (e.key === 'Enter' || e.code === 'Enter') {\n // If the active element has role=\"radio\", we're on a header in the PMList, in which case we don't want to validate the form, or, prevent the default behaviour\n const isPMHeader = document?.activeElement?.getAttribute('role') === 'radio';\n if (isPMHeader) {\n return;\n }\n super.handleKeyPress(e);\n }\n }\n\n protected onEnterKeyPressed(activeElement: Element, component: UIElement) {\n // We want to have a ref to the activePM, if we can; not a ref to the Dropin\n const pmComponent = this.activePaymentMethod ?? component;\n this.activePaymentMethod?.onEnterKeyPressed(activeElement, pmComponent);\n }\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <DropinComponent\n {...this.props}\n core={this.core}\n elementRef={this.elementRef}\n onCreateElements={this.handleCreate}\n ref={dropinRef => {\n this.dropinRef = dropinRef;\n }}\n />\n </SRPanelProvider>\n );\n }\n}\n\nexport default DropinElement;\n"],"names":["SUPPORTED_INSTANT_PAYMENTS","DropinElement","UIElement","reportIntegrationFlavor","this","analytics","sendFlavor","storeElementRefOnCore","core","storeElementReference","formatProps","props","super","instantPaymentTypes","Array","from","Set","filter","value","includes","isValid","dropinRef","state","activePaymentMethod","showValidation","setStatus","status","data","displayFinalAnimation","type","disableFinalAnimation","submit","Error","isInstantPayment","closeActivePaymentMethod","handleAction","action","hasOwnProperty","updateWithAction","elementRef","paymentAction","createFromAction","isDropin","statusType","component","componentFromAction","handleKeyPress","e","key","code","document","activeElement","getAttribute","onEnterKeyPressed","pmComponent","componentToRender","h","SRPanelProvider","srPanel","modules","DropinComponent","onCreateElements","handleCreate","ref","constructor","checkout","_define_property","paymentMethodsConfiguration","showStoredPaymentMethods","showPaymentMethods","paymentMethods","storedPaymentMethods","instantPaymentMethods","fastlanePaymentMethod","splitPaymentMethods","paymentMethodsResponse","dropinProps","elements","createElements","instantPaymentElements","createInstantPaymentElements","createStoredElements","filterStoredPaymentMethods","handleOrder","order","updateParent","bind","paymentMethodComponents","forEach","PaymentMethod","register","TxVariants","dropin","defaultProps"],"mappings":"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AAQJ,eAAe,KACnB,MAAMK,4BAAEA,EAA2BC,yBAAEA,EAAwBC,mBAAEA,EAAkBxD,oBAAEA,GAAwBT,KAAKO,OAE1G2D,eAAEA,EAAcC,qBAAEA,EAAoBC,sBAAEA,EAAqBC,sBAAEA,GAA0BC,EAC3FtE,KAAKI,KAAKmE,uBACV9D,GAGE+D,EAAc,CAChBrC,WAAYnC,KAAKmC,WACjBG,UAAU,GAGRmC,EAAWR,EAAqBS,EAAeR,EAAgBH,EAA6BS,EAAaxE,KAAKI,MAAQ,GACtHuE,EAAyBC,EAA6BR,EAAuBL,EAA6BS,EAAaxE,KAAKI,MAalI,MAAO,CAZgB4D,EACjBa,EACI7E,KAAKO,MAAMuE,6BAA6BX,IAAyBA,EACjEJ,EACAS,EACAxE,KAAKI,MAET,GAKkBqE,EAAUE,EAJHN,EACzBK,EAAe,CAACL,GAAwBN,EAA6BS,EAAaxE,KAAKI,MACvF,MA8CV0D,EAAA9D,KAAU+E,cAAc,EAAGC,YAClBhF,KAAKiF,aAAa,CAAED,YA7JzBhF,KAAK2B,OAAS3B,KAAK2B,OAAOuD,KAAKlF,MAC/BA,KAAK+B,aAAe/B,KAAK+B,aAAamD,KAAKlF,MAE3CA,KAAKO,MAAM4E,wBAAwBC,QAAQC,GAAiBrF,KAAKI,KAAKkF,SAASD,IAC/ErF,KAAK+D,4BAA8B/D,KAAKO,MAAMwD,6BAA+B,CAAA,CACjF,EAnBAD,EADEjE,EACY4B,OAAO8D,EAAWC,QAEhC1B,EAHEjE,EAGe4F,eAAeA"}
1
+ {"version":3,"file":"Dropin.js","sources":["../../../../src/components/Dropin/Dropin.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport defaultProps from './defaultProps';\nimport DropinComponent from '../../components/Dropin/components/DropinComponent';\nimport { createElements, createStoredElements } from './elements';\nimport createInstantPaymentElements from './elements/createInstantPaymentElements';\nimport { hasOwnProperty } from '../../utils/hasOwnProperty';\nimport splitPaymentMethods from './elements/splitPaymentMethods';\nimport { TxVariants } from '../tx-variants';\n\nimport type { DropinConfiguration, InstantPaymentTypes, PaymentMethodsConfiguration } from './types';\nimport type { PaymentAction, PaymentResponseData } from '../../types/global-types';\nimport type { ICore } from '../../core/types';\nimport type { IDropin } from './types';\n\nconst SUPPORTED_INSTANT_PAYMENTS = ['paywithgoogle', 'googlepay', 'applepay'];\n\nclass DropinElement extends UIElement<DropinConfiguration> implements IDropin {\n public static type = TxVariants.dropin;\n\n protected static defaultProps = defaultProps;\n\n public dropinRef = null;\n\n private paymentMethodsConfiguration: PaymentMethodsConfiguration;\n /**\n * Reference to the component created from `handleAction` (Ex.: ThreeDS2Challenge)\n */\n public componentFromAction?: UIElement;\n\n constructor(checkout: ICore, props?: DropinConfiguration) {\n super(checkout, props);\n this.submit = this.submit.bind(this);\n this.handleAction = this.handleAction.bind(this);\n\n this.props.paymentMethodComponents.forEach(PaymentMethod => this.core.register(PaymentMethod));\n this.paymentMethodsConfiguration = this.props.paymentMethodsConfiguration || {};\n }\n\n protected override reportIntegrationFlavor(): void {\n void this.analytics.sendFlavor('dropin');\n }\n\n protected override storeElementRefOnCore() {\n this.core.storeElementReference(this);\n }\n\n formatProps(props) {\n return {\n ...super.formatProps(props),\n instantPaymentTypes: Array.from<InstantPaymentTypes>(new Set(props.instantPaymentTypes)).filter(value =>\n SUPPORTED_INSTANT_PAYMENTS.includes(value)\n )\n };\n }\n\n get isValid() {\n return !!this.dropinRef && !!this.dropinRef.state.activePaymentMethod && !!this.dropinRef.state.activePaymentMethod.isValid;\n }\n\n showValidation() {\n if (this.dropinRef.state.activePaymentMethod) {\n this.dropinRef.state.activePaymentMethod.showValidation();\n }\n\n return this;\n }\n\n public setStatus(status, props = {}): this {\n this.dropinRef?.setStatus(status, props);\n return this;\n }\n\n get activePaymentMethod() {\n if (!this.dropinRef?.state && !this.dropinRef?.state.activePaymentMethod) {\n return null;\n }\n\n return this.dropinRef.state.activePaymentMethod;\n }\n\n get data() {\n if (!this.activePaymentMethod) {\n return null;\n }\n\n return this.dropinRef.state.activePaymentMethod.data;\n }\n\n public displayFinalAnimation(type: 'success' | 'error') {\n if (this.props.disableFinalAnimation) return;\n\n this.dropinRef?.setStatus(type);\n }\n\n /**\n * Calls the onSubmit event with the state of the activePaymentMethod\n */\n public override submit(): void {\n if (!this.activePaymentMethod) {\n throw new Error('No active payment method.');\n }\n\n if (!this.activePaymentMethod.isValid) {\n this.activePaymentMethod.showValidation();\n }\n\n if (this.activePaymentMethod.isInstantPayment) {\n this.closeActivePaymentMethod();\n }\n\n this.activePaymentMethod.submit();\n }\n\n /**\n * Creates the Drop-in elements\n */\n private handleCreate = () => {\n const { paymentMethodsConfiguration, showStoredPaymentMethods, showPaymentMethods, instantPaymentTypes } = this.props;\n\n const { paymentMethods, storedPaymentMethods, instantPaymentMethods, fastlanePaymentMethod } = splitPaymentMethods(\n this.core.paymentMethodsResponse,\n instantPaymentTypes\n );\n\n const dropinProps = {\n elementRef: this.elementRef,\n isDropin: true\n };\n\n const elements = showPaymentMethods ? createElements(paymentMethods, paymentMethodsConfiguration, dropinProps, this.core) : [];\n const instantPaymentElements = createInstantPaymentElements(instantPaymentMethods, paymentMethodsConfiguration, dropinProps, this.core);\n const storedElements = showStoredPaymentMethods\n ? createStoredElements(\n this.props.filterStoredPaymentMethods?.(storedPaymentMethods) ?? storedPaymentMethods,\n paymentMethodsConfiguration,\n dropinProps,\n this.core\n )\n : [];\n const fastlanePaymentElement = fastlanePaymentMethod\n ? createElements([fastlanePaymentMethod], paymentMethodsConfiguration, dropinProps, this.core)\n : [];\n\n return [storedElements, elements, instantPaymentElements, fastlanePaymentElement];\n };\n\n public handleAction(action: PaymentAction, props = {}): this | null {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'handleAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('handleAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n if (action.type !== 'redirect' && this.activePaymentMethod?.updateWithAction) {\n return this.activePaymentMethod.updateWithAction(action);\n }\n\n if (this.elementRef instanceof DropinElement) {\n props = {\n ...this.elementRef.activePaymentMethod?.props,\n ...props\n };\n }\n\n const paymentAction: UIElement = this.core.createFromAction(action, {\n ...props,\n elementRef: this.elementRef, // maintain elementRef for 3DS2 flow\n isDropin: true\n });\n\n if (paymentAction) {\n this.setStatus(paymentAction.props.statusType, { component: paymentAction });\n this.componentFromAction = paymentAction;\n return this;\n }\n\n return null;\n }\n\n /**\n * handleOrder is implemented so we don't trigger a callback like in the components\n * @param response - PaymentResponse\n */\n protected handleOrder = ({ order }: PaymentResponseData): void => {\n void this.updateParent({ order });\n };\n\n closeActivePaymentMethod() {\n this.dropinRef.closeActivePaymentMethod();\n }\n\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement> | KeyboardEvent) {\n if (e.key === 'Enter' || e.code === 'Enter') {\n // If the active element has role=\"radio\", we're on a header in the PMList, in which case we don't want to validate the form, or, prevent the default behaviour\n const isPMHeader = document?.activeElement?.getAttribute('role') === 'radio';\n if (isPMHeader) {\n return;\n }\n super.handleKeyPress(e);\n }\n }\n\n protected onEnterKeyPressed(activeElement: Element, component: UIElement) {\n // We want to have a ref to the activePM, if we can; not a ref to the Dropin\n const pmComponent = this.activePaymentMethod ?? component;\n this.activePaymentMethod?.onEnterKeyPressed(activeElement, pmComponent);\n }\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <DropinComponent\n {...this.props}\n core={this.core}\n elementRef={this.elementRef}\n onCreateElements={this.handleCreate}\n ref={dropinRef => {\n this.dropinRef = dropinRef;\n }}\n />\n );\n }\n}\n\nexport default DropinElement;\n"],"names":["SUPPORTED_INSTANT_PAYMENTS","DropinElement","UIElement","reportIntegrationFlavor","this","analytics","sendFlavor","storeElementRefOnCore","core","storeElementReference","formatProps","props","super","instantPaymentTypes","Array","from","Set","filter","value","includes","isValid","dropinRef","state","activePaymentMethod","showValidation","setStatus","status","data","displayFinalAnimation","type","disableFinalAnimation","submit","Error","isInstantPayment","closeActivePaymentMethod","handleAction","action","hasOwnProperty","updateWithAction","elementRef","paymentAction","createFromAction","isDropin","statusType","component","componentFromAction","handleKeyPress","e","key","code","document","activeElement","getAttribute","onEnterKeyPressed","pmComponent","componentToRender","h","DropinComponent","onCreateElements","handleCreate","ref","constructor","checkout","_define_property","paymentMethodsConfiguration","showStoredPaymentMethods","showPaymentMethods","paymentMethods","storedPaymentMethods","instantPaymentMethods","fastlanePaymentMethod","splitPaymentMethods","paymentMethodsResponse","dropinProps","elements","createElements","instantPaymentElements","createInstantPaymentElements","createStoredElements","filterStoredPaymentMethods","handleOrder","order","updateParent","bind","paymentMethodComponents","forEach","PaymentMethod","register","TxVariants","dropin","defaultProps"],"mappings":"spBAeA,MAAMA,EAA6B,CAAC,gBAAiB,YAAa,YAElE,MAAMC,UAAsBC,EAsBLC,uBAAAA,GACVC,KAAKC,UAAUC,WAAW,SACnC,CAEmBC,qBAAAA,GACfH,KAAKI,KAAKC,sBAAsBL,KACpC,CAEAM,WAAAA,CAAYC,GACR,MAAO,IACAC,MAAMF,YAAYC,GACrBE,oBAAqBC,MAAMC,KAA0B,IAAIC,IAAIL,EAAME,sBAAsBI,OAAOC,GAC5FlB,EAA2BmB,SAASD,IAGhD,CAEA,WAAIE,GACA,QAAShB,KAAKiB,aAAejB,KAAKiB,UAAUC,MAAMC,uBAAyBnB,KAAKiB,UAAUC,MAAMC,oBAAoBH,OACxH,CAEAI,cAAAA,GAKI,OAJIpB,KAAKiB,UAAUC,MAAMC,qBACrBnB,KAAKiB,UAAUC,MAAMC,oBAAoBC,iBAGtCpB,IACX,CAEOqB,SAAAA,CAAUC,EAAQf,EAAQ,IAE7B,OADAP,KAAKiB,WAAWI,UAAUC,EAAQf,GAC3BP,IACX,CAEA,uBAAImB,GACA,OAAKnB,KAAKiB,WAAWC,OAAUl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3CA,KAAKO,MAAMyE,wBAAwBC,QAAQC,GAAiBlF,KAAKI,KAAK+E,SAASD,IAC/ElF,KAAK4D,4BAA8B5D,KAAKO,MAAMqD,6BAA+B,CAAA,CACjF,EAnBAD,EADE9D,EACY4B,OAAO2D,EAAWC,QAEhC1B,EAHE9D,EAGeyF,eAAeA"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import r from"./components/GiftcardComponent.js";import s from"../internal/PayButton/PayButton.js";import n from"../../core/Errors/AdyenCheckoutError.js";import{TxVariants as o}from"../tx-variants.js";import a from"../../core/Errors/SRPanelProvider.js";function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class h extends t{formatProps(e){return{...e?.configuration,...e}}formatData(){return{paymentMethod:{type:this.constructor.type,brand:this.props.brand,encryptedCardNumber:this.state.data?.encryptedCardNumber,encryptedSecurityCode:this.state.data?.encryptedSecurityCode}}}get isValid(){return!!this.state.isValid}get icon(){return this.props.brandsConfiguration[this.props.brand]?.icon||this.props.icon||this.resources.getImage()(this.props.brand)}get displayName(){return this.props.brandsConfiguration[this.props.brand]?.name||this.props.name}setBalanceCheckError(e){this.componentRef?.setBalanceCheckErrors?.(e)}balanceCheck(){return this.onBalanceCheck()}submit(){this.balanceCheck()}makeSubmitCall(){super.submit()}componentToRender(){return e(a,{srPanel:this.props.modules.srPanel},e(r,{ref:e=>{this.componentRef=e},...this.props,handleKeyPress:this.handleKeyPress,showPayButton:this.props.showPayButton,onChange:this.setState,makeBalanceCheck:()=>this.onBalanceCheck(),makePayment:()=>this.makeSubmitCall(),payButton:this.payButton}))}constructor(...t){super(...t),i(this,"componentRef",void 0),i(this,"handleBalanceCheck",e=>this.props.onBalanceCheck?new Promise((t,r)=>{this.props.onBalanceCheck(t,r,e)}):this.props.session?this.props.session.checkBalance(e):void 0),i(this,"onOrderRequest",e=>this.props.onOrderRequest?new Promise((t,r)=>{this.props.onOrderRequest(t,r,e)}):this.props.session?this.props.session.createOrder():void 0),i(this,"onBalanceCheck",()=>{if(!this.isValid)return void this.showValidation();if(!(this.props.session||this.props.onBalanceCheck))return super.submit();this.setStatus("loading"),this.handleBalanceCheck(this.formatData()).then(({balance:e,transactionLimit:t={}})=>{if(this.setBalanceCheckError(null),!e)throw new Error("card-error");if(e?.currency!==this.props.amount?.currency)throw new Error("currency-error");if(e?.value<=0)throw new Error("no-balance");return this.props.amount.value>e.value||this.props.amount.value>t.value?this.props.order?this.makeSubmitCall():this.onOrderRequest(this.data).then(e=>(this.setState({order:{orderData:e.orderData,pspReference:e.pspReference}}),this.makeSubmitCall())):this.handleOnRequiringConfirmation(e,t)}).catch(e=>{this.setBalanceCheckError(e?.message),e instanceof n?this.handleError(e):this.handleError(new n("ERROR",e))})}),i(this,"handleOnRequiringConfirmation",(e,t)=>{if(this.componentRef.setBalance({balance:e,transactionLimit:t}),this.setStatus("ready"),!this.props.showPayButton){if(!this.props.onRequiringConfirmation)throw new n("IMPLEMENTATION_ERROR","onRequiringConfirmation must be provided");return new Promise((e,t)=>{this.props.onRequiringConfirmation(e,t)}).then(()=>this.makeSubmitCall()).catch(()=>{})}}),i(this,"payButton",t=>e(s,t))}}i(h,"type",o.giftcard),i(h,"defaultProps",{brandsConfiguration:{}});export{h as GiftcardElement,h as default};
1
+ import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import r from"./components/GiftcardComponent.js";import s from"../internal/PayButton/PayButton.js";import n from"../../core/Errors/AdyenCheckoutError.js";import{TxVariants as a}from"../tx-variants.js";function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class i extends t{formatProps(e){return{...e?.configuration,...e}}formatData(){return{paymentMethod:{type:this.constructor.type,brand:this.props.brand,encryptedCardNumber:this.state.data?.encryptedCardNumber,encryptedSecurityCode:this.state.data?.encryptedSecurityCode}}}get isValid(){return!!this.state.isValid}get icon(){return this.props.brandsConfiguration[this.props.brand]?.icon||this.props.icon||this.resources.getImage()(this.props.brand)}get displayName(){return this.props.brandsConfiguration[this.props.brand]?.name||this.props.name}setBalanceCheckError(e){this.componentRef?.setBalanceCheckErrors?.(e)}balanceCheck(){return this.onBalanceCheck()}submit(){this.balanceCheck()}makeSubmitCall(){super.submit()}componentToRender(){return e(r,{ref:e=>{this.componentRef=e},...this.props,handleKeyPress:this.handleKeyPress,showPayButton:this.props.showPayButton,onChange:this.setState,makeBalanceCheck:()=>this.onBalanceCheck(),makePayment:()=>this.makeSubmitCall(),payButton:this.payButton})}constructor(...t){super(...t),o(this,"componentRef",void 0),o(this,"handleBalanceCheck",e=>this.props.onBalanceCheck?new Promise((t,r)=>{this.props.onBalanceCheck(t,r,e)}):this.props.session?this.props.session.checkBalance(e):void 0),o(this,"onOrderRequest",e=>this.props.onOrderRequest?new Promise((t,r)=>{this.props.onOrderRequest(t,r,e)}):this.props.session?this.props.session.createOrder():void 0),o(this,"onBalanceCheck",()=>{if(!this.isValid)return void this.showValidation();if(!(this.props.session||this.props.onBalanceCheck))return super.submit();this.setStatus("loading"),this.handleBalanceCheck(this.formatData()).then(({balance:e,transactionLimit:t={}})=>{if(this.setBalanceCheckError(null),!e)throw new Error("card-error");if(e?.currency!==this.props.amount?.currency)throw new Error("currency-error");if(e?.value<=0)throw new Error("no-balance");return this.props.amount.value>e.value||this.props.amount.value>t.value?this.props.order?this.makeSubmitCall():this.onOrderRequest(this.data).then(e=>(this.setState({order:{orderData:e.orderData,pspReference:e.pspReference}}),this.makeSubmitCall())):this.handleOnRequiringConfirmation(e,t)}).catch(e=>{this.setBalanceCheckError(e?.message),e instanceof n?this.handleError(e):this.handleError(new n("ERROR",e))})}),o(this,"handleOnRequiringConfirmation",(e,t)=>{if(this.componentRef.setBalance({balance:e,transactionLimit:t}),this.setStatus("ready"),!this.props.showPayButton){if(!this.props.onRequiringConfirmation)throw new n("IMPLEMENTATION_ERROR","onRequiringConfirmation must be provided");return new Promise((e,t)=>{this.props.onRequiringConfirmation(e,t)}).then(()=>this.makeSubmitCall()).catch(()=>{})}}),o(this,"payButton",t=>e(s,t))}}o(i,"type",a.giftcard),o(i,"defaultProps",{brandsConfiguration:{}});export{i as GiftcardElement,i as default};
2
2
  //# sourceMappingURL=Giftcard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Giftcard.js","sources":["../../../../src/components/Giftcard/Giftcard.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport GiftcardComponent from './components/GiftcardComponent';\nimport PayButton from '../internal/PayButton';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { PaymentAmount } from '../../types/global-types';\nimport { GiftCardElementData, GiftCardConfiguration, balanceCheckResponseType, GiftCardBalanceCheckErrorType } from './types';\nimport { TxVariants } from '../tx-variants';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\n\nexport class GiftcardElement extends UIElement<GiftCardConfiguration> {\n public static type = TxVariants.giftcard;\n\n protected componentRef: GiftcardComponent | undefined;\n\n protected static defaultProps = {\n brandsConfiguration: {}\n };\n\n formatProps(props) {\n return {\n ...props?.configuration,\n ...props\n };\n }\n\n formatData(): GiftCardElementData {\n return {\n paymentMethod: {\n type: this.constructor['type'],\n brand: this.props.brand,\n encryptedCardNumber: this.state.data?.encryptedCardNumber,\n encryptedSecurityCode: this.state.data?.encryptedSecurityCode\n }\n };\n }\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get icon() {\n return this.props.brandsConfiguration[this.props.brand]?.icon || this.props.icon || this.resources.getImage()(this.props.brand);\n }\n\n get displayName() {\n return this.props.brandsConfiguration[this.props.brand]?.name || this.props.name;\n }\n\n private setBalanceCheckError(errorMessage: GiftCardBalanceCheckErrorType | null): void {\n this.componentRef?.setBalanceCheckErrors?.(errorMessage);\n }\n\n private handleBalanceCheck = (data: GiftCardElementData): Promise<balanceCheckResponseType> => {\n if (this.props.onBalanceCheck) {\n return new Promise((resolve, reject) => {\n void this.props.onBalanceCheck(resolve, reject, data);\n });\n }\n\n if (this.props.session) {\n return this.props.session.checkBalance(data);\n }\n };\n\n private onOrderRequest = data => {\n if (this.props.onOrderRequest)\n return new Promise((resolve, reject) => {\n void this.props.onOrderRequest(resolve, reject, data);\n });\n if (this.props.session) {\n return this.props.session.createOrder();\n }\n };\n\n public balanceCheck() {\n return this.onBalanceCheck();\n }\n\n private onBalanceCheck = (): void => {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n // skip balance check if no onBalanceCheck event has been defined\n const hasBalanceCheck = this.props.session || this.props.onBalanceCheck;\n if (!hasBalanceCheck) return super.submit();\n\n this.setStatus('loading');\n\n this.handleBalanceCheck(this.formatData())\n .then(({ balance, transactionLimit = {} as PaymentAmount }) => {\n // Clear any previous balance check errors on success\n this.setBalanceCheckError(null);\n\n // We still need to throw these errors, otherwise it would be a breaking changing\n if (!balance) throw new Error('card-error'); // card doesn't exist\n if (balance?.currency !== this.props.amount?.currency) throw new Error('currency-error');\n if (balance?.value <= 0) throw new Error('no-balance');\n\n if (this.props.amount.value > balance.value || this.props.amount.value > transactionLimit.value) {\n if (this.props.order) {\n return this.makeSubmitCall();\n }\n\n return this.onOrderRequest(this.data).then((order: { orderData: string; pspReference: string }) => {\n this.setState({ order: { orderData: order.orderData, pspReference: order.pspReference } });\n return this.makeSubmitCall();\n });\n } else {\n return this.handleOnRequiringConfirmation(balance, transactionLimit);\n }\n })\n .catch(error => {\n // Simply pass the raw error message to setBalanceCheckError\n this.setBalanceCheckError(error?.message);\n\n // Still call handleError for other side effects (analytics, onError callback)\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', error));\n }\n });\n };\n\n /**\n * Check if it should call onRequiringConfirmation\n */\n private handleOnRequiringConfirmation = (balance, transactionLimit): Promise<any> => {\n this.componentRef.setBalance({ balance, transactionLimit });\n this.setStatus('ready');\n\n // 1. if we show pay button we don't need to ask for confirmation\n if (this.props.showPayButton) {\n return;\n }\n // 2. there's no callback, we throw error\n if (!this.props.onRequiringConfirmation) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'onRequiringConfirmation must be provided');\n }\n // 3. success case if in case of custom pay button\n return (\n new Promise<void>((resolve, reject) => {\n void this.props.onRequiringConfirmation(resolve, reject);\n })\n //when this resolve passed to onRequiringConfirmation gets resolved make payments call\n .then(() => this.makeSubmitCall())\n //when it gets rejected handle cancellation\n .catch(() => {})\n );\n };\n\n public submit() {\n // for simplicity of the merchant we always only expose .submit()\n // however to make the actual payment call we call makeSubmitCall\n this.balanceCheck();\n }\n\n // this makes the payment, as .submit is used by the merchant to trigger the payButton action\n private makeSubmitCall() {\n super.submit();\n }\n\n // Giftcards override the regular payButton flow\n public payButton = props => {\n return <PayButton {...props} />;\n };\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <GiftcardComponent\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n handleKeyPress={this.handleKeyPress}\n showPayButton={this.props.showPayButton}\n onChange={this.setState}\n makeBalanceCheck={() => this.onBalanceCheck()}\n makePayment={() => this.makeSubmitCall()}\n payButton={this.payButton}\n />\n </SRPanelProvider>\n );\n }\n}\n\nexport default GiftcardElement;\n"],"names":["GiftcardElement","UIElement","formatProps","props","configuration","formatData","paymentMethod","type","this","constructor","brand","encryptedCardNumber","state","data","encryptedSecurityCode","isValid","icon","brandsConfiguration","resources","getImage","displayName","name","setBalanceCheckError","errorMessage","componentRef","setBalanceCheckErrors","balanceCheck","onBalanceCheck","submit","makeSubmitCall","super","componentToRender","h","SRPanelProvider","srPanel","modules","GiftcardComponent","ref","handleKeyPress","showPayButton","onChange","setState","makeBalanceCheck","makePayment","payButton","args","_define_property","handleBalanceCheck","Promise","resolve","reject","session","checkBalance","onOrderRequest","createOrder","showValidation","setStatus","then","balance","transactionLimit","Error","currency","amount","value","order","orderData","pspReference","handleOnRequiringConfirmation","catch","error","message","AdyenCheckoutError","handleError","setBalance","onRequiringConfirmation","PayButton","TxVariants","giftcard","defaultProps"],"mappings":"yfAUO,MAAMA,UAAwBC,EASjCC,WAAAA,CAAYC,GACR,MAAO,IACAA,GAAOC,iBACPD,EAEX,CAEAE,UAAAA,GACI,MAAO,CACHC,cAAe,CACXC,KAAMC,KAAKC,YAAY,KACvBC,MAAOF,KAAKL,MAAMO,MAClBC,oBAAqBH,KAAKI,MAAMC,MAAMF,oBACtCG,sBAAuBN,KAAKI,MAAMC,MAAMC,uBAGpD,CAEA,WAAIC,GACA,QAASP,KAAKI,MAAMG,OACxB,CAEA,QAAIC,GACA,OAAOR,KAAKL,MAAMc,oBAAoBT,KAAKL,MAAMO,QAAQM,MAAQR,KAAKL,MAAMa,MAAQR,KAAKU,UAAUC,UAAfX,CAA0BA,KAAKL,MAAMO,MAC7H,CAEA,eAAIU,GACA,OAAOZ,KAAKL,MAAMc,oBAAoBT,KAAKL,MAAMO,QAAQW,MAAQb,KAAKL,MAAMkB,IAChF,CAEQC,oBAAAA,CAAqBC,GACzBf,KAAKgB,cAAcC,wBAAwBF,EAC/C,CAwBOG,YAAAA,GACH,OAAOlB,KAAKmB,gBAChB,CA6EOC,MAAAA,GAGHpB,KAAKkB,cACT,CAGQG,cAAAA,GACJC,MAAMF,QACV,CAOmBG,iBAAAA,GACf,OACIC,EAACC,EAAAA,CAAgBC,QAAS1B,KAAKL,MAAMgC,QAAQD,SACzCF,EAACI,EAAAA,CACGC,IAAKA,IACD7B,KAAKgB,aAAea,MAEpB7B,KAAKL,MACTmC,eAAgB9B,KAAK8B,eACrBC,cAAe/B,KAAKL,MAAMoC,cAC1BC,SAAUhC,KAAKiC,SACfC,iBAAkB,IAAMlC,KAAKmB,iBAC7BgB,YAAa,IAAMnC,KAAKqB,iBACxBe,UAAWpC,KAAKoC,YAIhC,mBAjLGd,SAAAe,GAGHC,OAAUtB,o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aAAiBE,EACjB/D,KAAKgE,YAAYH,GAEjB7D,KAAKgE,YAAY,IAAID,EAAmB,QAASF,QAQjEvB,EAAAtC,KAAQ2D,gCAAgC,CAACT,EAASC,KAK9C,GAJAnD,KAAKgB,aAAaiD,WAAW,CAAEf,UAASC,qBACxCnD,KAAKgD,UAAU,UAGXhD,KAAKL,MAAMoC,cAAf,CAIA,IAAK/B,KAAKL,MAAMuE,wBACZ,MAAM,IAAIH,EAAmB,uBAAwB,4CAGzD,OACI,IAAIvB,QAAc,CAACC,EAASC,KACnB1C,KAAKL,MAAMuE,wBAAwBzB,EAASC,KAGhDO,KAAK,IAAMjD,KAAKqB,kBAEhBuC,MAAM,OAbf,IA6BJtB,EAAAtC,KAAOoC,YAAYzC,GACR6B,EAAC2C,EAAcxE,KA5J1B2C,EADS9C,EACKO,OAAOqE,EAAWC,UAIhC/B,EALS9C,EAKQ8E,eAAe,CAC5B7D,oBAAqB,CAAA"}
1
+ {"version":3,"file":"Giftcard.js","sources":["../../../../src/components/Giftcard/Giftcard.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport GiftcardComponent from './components/GiftcardComponent';\nimport PayButton from '../internal/PayButton';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { PaymentAmount } from '../../types/global-types';\nimport { GiftCardElementData, GiftCardConfiguration, balanceCheckResponseType, GiftCardBalanceCheckErrorType } from './types';\nimport { TxVariants } from '../tx-variants';\n\nexport class GiftcardElement extends UIElement<GiftCardConfiguration> {\n public static type = TxVariants.giftcard;\n\n protected componentRef: GiftcardComponent | undefined;\n\n protected static defaultProps = {\n brandsConfiguration: {}\n };\n\n formatProps(props) {\n return {\n ...props?.configuration,\n ...props\n };\n }\n\n formatData(): GiftCardElementData {\n return {\n paymentMethod: {\n type: this.constructor['type'],\n brand: this.props.brand,\n encryptedCardNumber: this.state.data?.encryptedCardNumber,\n encryptedSecurityCode: this.state.data?.encryptedSecurityCode\n }\n };\n }\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get icon() {\n return this.props.brandsConfiguration[this.props.brand]?.icon || this.props.icon || this.resources.getImage()(this.props.brand);\n }\n\n get displayName() {\n return this.props.brandsConfiguration[this.props.brand]?.name || this.props.name;\n }\n\n private setBalanceCheckError(errorMessage: GiftCardBalanceCheckErrorType | null): void {\n this.componentRef?.setBalanceCheckErrors?.(errorMessage);\n }\n\n private handleBalanceCheck = (data: GiftCardElementData): Promise<balanceCheckResponseType> => {\n if (this.props.onBalanceCheck) {\n return new Promise((resolve, reject) => {\n void this.props.onBalanceCheck(resolve, reject, data);\n });\n }\n\n if (this.props.session) {\n return this.props.session.checkBalance(data);\n }\n };\n\n private onOrderRequest = data => {\n if (this.props.onOrderRequest)\n return new Promise((resolve, reject) => {\n void this.props.onOrderRequest(resolve, reject, data);\n });\n if (this.props.session) {\n return this.props.session.createOrder();\n }\n };\n\n public balanceCheck() {\n return this.onBalanceCheck();\n }\n\n private onBalanceCheck = (): void => {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n // skip balance check if no onBalanceCheck event has been defined\n const hasBalanceCheck = this.props.session || this.props.onBalanceCheck;\n if (!hasBalanceCheck) return super.submit();\n\n this.setStatus('loading');\n\n this.handleBalanceCheck(this.formatData())\n .then(({ balance, transactionLimit = {} as PaymentAmount }) => {\n // Clear any previous balance check errors on success\n this.setBalanceCheckError(null);\n\n // We still need to throw these errors, otherwise it would be a breaking changing\n if (!balance) throw new Error('card-error'); // card doesn't exist\n if (balance?.currency !== this.props.amount?.currency) throw new Error('currency-error');\n if (balance?.value <= 0) throw new Error('no-balance');\n\n if (this.props.amount.value > balance.value || this.props.amount.value > transactionLimit.value) {\n if (this.props.order) {\n return this.makeSubmitCall();\n }\n\n return this.onOrderRequest(this.data).then((order: { orderData: string; pspReference: string }) => {\n this.setState({ order: { orderData: order.orderData, pspReference: order.pspReference } });\n return this.makeSubmitCall();\n });\n } else {\n return this.handleOnRequiringConfirmation(balance, transactionLimit);\n }\n })\n .catch(error => {\n // Simply pass the raw error message to setBalanceCheckError\n this.setBalanceCheckError(error?.message);\n\n // Still call handleError for other side effects (analytics, onError callback)\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', error));\n }\n });\n };\n\n /**\n * Check if it should call onRequiringConfirmation\n */\n private handleOnRequiringConfirmation = (balance, transactionLimit): Promise<any> => {\n this.componentRef.setBalance({ balance, transactionLimit });\n this.setStatus('ready');\n\n // 1. if we show pay button we don't need to ask for confirmation\n if (this.props.showPayButton) {\n return;\n }\n // 2. there's no callback, we throw error\n if (!this.props.onRequiringConfirmation) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'onRequiringConfirmation must be provided');\n }\n // 3. success case if in case of custom pay button\n return (\n new Promise<void>((resolve, reject) => {\n void this.props.onRequiringConfirmation(resolve, reject);\n })\n //when this resolve passed to onRequiringConfirmation gets resolved make payments call\n .then(() => this.makeSubmitCall())\n //when it gets rejected handle cancellation\n .catch(() => {})\n );\n };\n\n public submit() {\n // for simplicity of the merchant we always only expose .submit()\n // however to make the actual payment call we call makeSubmitCall\n this.balanceCheck();\n }\n\n // this makes the payment, as .submit is used by the merchant to trigger the payButton action\n private makeSubmitCall() {\n super.submit();\n }\n\n // Giftcards override the regular payButton flow\n public payButton = props => {\n return <PayButton {...props} />;\n };\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <GiftcardComponent\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n handleKeyPress={this.handleKeyPress}\n showPayButton={this.props.showPayButton}\n onChange={this.setState}\n makeBalanceCheck={() => this.onBalanceCheck()}\n makePayment={() => this.makeSubmitCall()}\n payButton={this.payButton}\n />\n );\n }\n}\n\nexport default GiftcardElement;\n"],"names":["GiftcardElement","UIElement","formatProps","props","configuration","formatData","paymentMethod","type","this","constructor","brand","encryptedCardNumber","state","data","encryptedSecurityCode","isValid","icon","brandsConfiguration","resources","getImage","displayName","name","setBalanceCheckError","errorMessage","componentRef","setBalanceCheckErrors","balanceCheck","onBalanceCheck","submit","makeSubmitCall","super","componentToRender","h","GiftcardComponent","ref","handleKeyPress","showPayButton","onChange","setState","makeBalanceCheck","makePayment","payButton","args","_define_property","handleBalanceCheck","Promise","resolve","reject","session","checkBalance","onOrderRequest","createOrder","showValidation","setStatus","then","balance","transactionLimit","Error","currency","amount","value","order","orderData","pspReference","handleOnRequiringConfirmation","catch","error","message","AdyenCheckoutError","handleError","setBalance","onRequiringConfirmation","PayButton","TxVariants","giftcard","defaultProps"],"mappings":"qcASO,MAAMA,UAAwBC,EASjCC,WAAAA,CAAYC,GACR,MAAO,IACAA,GAAOC,iBACPD,EAEX,CAEAE,UAAAA,GACI,MAAO,CACHC,cAAe,CACXC,KAAMC,KAAKC,YAAY,KACvBC,MAAOF,KAAKL,MAAMO,MAClBC,oBAAqBH,KAAKI,MAAMC,MAAMF,oBACtCG,sBAAuBN,KAAKI,MAAMC,MAAMC,uBAGpD,CAEA,WAAIC,GACA,QAASP,KAAKI,MAAMG,OACxB,CAEA,QAAIC,GACA,OAAOR,KAAKL,MAAMc,oBAAoBT,KAAKL,MAAMO,QAAQM,MAAQR,KAAKL,MAAMa,MAAQR,KAAKU,UAAUC,UAAfX,CAA0BA,KAAKL,MAAMO,MAC7H,CAEA,eAAIU,GACA,OAAOZ,KAAKL,MAAMc,oBAAoBT,KAAKL,MAAMO,QAAQW,MAAQb,KAAKL,MAAMkB,IAChF,CAEQC,oBAAAA,CAAqBC,GACzBf,KAAKgB,cAAcC,wBAAwBF,EAC/C,CAwBOG,YAAAA,GACH,OAAOlB,KAAKmB,gBAChB,CA6EOC,MAAAA,GAGHpB,KAAKkB,cACT,CAGQG,cAAAA,GACJC,MAAMF,QACV,CAOmBG,iBAAAA,GACf,OACIC,EAACC,EAAAA,CACGC,IAAKA,IACD1B,KAAKgB,aAAeU,MAEpB1B,KAAKL,MACTgC,eAAgB3B,KAAK2B,eACrBC,cAAe5B,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AAS,CAAEuB,MAAO,CAAEC,UAAWD,EAAMC,UAAWC,aAAcF,EAAME,gBAClEvD,KAAKqB,mBAGTrB,KAAKwD,8BAA8BT,EAASC,KAG1DS,MAAMC,IAEH1D,KAAKc,qBAAqB4C,GAAOC,SAG7BD,aAAiBE,EACjB5D,KAAK6D,YAAYH,GAEjB1D,KAAK6D,YAAY,IAAID,EAAmB,QAASF,QAQjEvB,EAAAnC,KAAQwD,gCAAgC,CAACT,EAASC,KAK9C,GAJAhD,KAAKgB,aAAa8C,WAAW,CAAEf,UAASC,qBACxChD,KAAK6C,UAAU,UAGX7C,KAAKL,MAAMiC,cAAf,CAIA,IAAK5B,KAAKL,MAAMoE,wBACZ,MAAM,IAAIH,EAAmB,uBAAwB,4CAGzD,OACI,IAAIvB,QAAc,CAACC,EAASC,KACnBvC,KAAKL,MAAMoE,wBAAwBzB,EAASC,KAGhDO,KAAK,IAAM9C,KAAKqB,kBAEhBoC,MAAM,OAbf,IA6BJtB,EAAAnC,KAAOiC,YAAYtC,GACR6B,EAACwC,EAAcrE,KA5J1BwC,EADS3C,EACKO,OAAOkE,EAAWC,UAIhC/B,EALS3C,EAKQ2E,eAAe,CAC5B1D,oBAAqB,CAAA"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import o from"./components/MBWayInput/MBWayInput.js";import r from"./components/MBWayAwait/config.js";import{Await as n}from"../internal/Await/Await.js";import a from"../../core/Errors/SRPanelProvider.js";import{TxVariants as s}from"../tx-variants.js";class p extends t{formatProps(e){const{data:t={},placeholders:o={}}=e;return{...e,data:{phoneNumber:t.telephoneNumber||t.phoneNumber,phonePrefix:t.phonePrefix||"+351"},placeholders:{phoneNumber:o.telephoneNumber||o.phoneNumber}}}formatData(){return{paymentMethod:{type:p.type,...this.state.data?.phoneNumber&&{telephoneNumber:this.state.data.phonePrefix+this.state.data.phoneNumber}}}}get isValid(){return!!this.state.isValid}get displayName(){return this.props.name}componentToRender(){return this.props.paymentData?e(a,{srPanel:this.props.modules.srPanel},e(n,{clientKey:this.props.clientKey,paymentData:this.props.paymentData,onError:this.props.onError,onComplete:this.onComplete,brandLogo:this.icon,type:r.type,messageText:this.props.i18n.get(r.messageTextId),awaitText:this.props.i18n.get(r.awaitTextId),showCountdownTimer:r.showCountdownTimer,delay:r.STATUS_INTERVAL,countdownTime:r.COUNTDOWN_MINUTES,throttleTime:r.THROTTLE_TIME,throttleInterval:r.THROTTLE_INTERVAL,onActionHandled:this.onActionHandled})):e(o,{ref:e=>{this.componentRef=e},...this.props,setComponentRef:this.setComponentRef,onChange:this.setState,onSubmit:this.submit,payButton:this.payButton})}}var i,m,h;i=p,m="type",h=s.mbway,m in i?Object.defineProperty(i,m,{value:h,enumerable:!0,configurable:!0,writable:!0}):i[m]=h;export{p as MBWayElement,p as default};
1
+ import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import o from"./components/MBWayInput/MBWayInput.js";import n from"./components/MBWayAwait/config.js";import{Await as r}from"../internal/Await/Await.js";import{TxVariants as a}from"../tx-variants.js";class s extends t{formatProps(e){const{data:t={},placeholders:o={}}=e;return{...e,data:{phoneNumber:t.telephoneNumber||t.phoneNumber,phonePrefix:t.phonePrefix||"+351"},placeholders:{phoneNumber:o.telephoneNumber||o.phoneNumber}}}formatData(){return{paymentMethod:{type:s.type,...this.state.data?.phoneNumber&&{telephoneNumber:this.state.data.phonePrefix+this.state.data.phoneNumber}}}}get isValid(){return!!this.state.isValid}get displayName(){return this.props.name}componentToRender(){return this.props.paymentData?e(r,{clientKey:this.props.clientKey,paymentData:this.props.paymentData,onError:this.props.onError,onComplete:this.onComplete,brandLogo:this.icon,type:n.type,messageText:this.props.i18n.get(n.messageTextId),awaitText:this.props.i18n.get(n.awaitTextId),showCountdownTimer:n.showCountdownTimer,delay:n.STATUS_INTERVAL,countdownTime:n.COUNTDOWN_MINUTES,throttleTime:n.THROTTLE_TIME,throttleInterval:n.THROTTLE_INTERVAL,onActionHandled:this.onActionHandled}):e(o,{ref:e=>{this.componentRef=e},...this.props,setComponentRef:this.setComponentRef,onChange:this.setState,onSubmit:this.submit,payButton:this.payButton})}}var p,i,m;p=s,i="type",m=a.mbway,i in p?Object.defineProperty(p,i,{value:m,enumerable:!0,configurable:!0,writable:!0}):p[i]=m;export{s as MBWayElement,s as default};
2
2
  //# sourceMappingURL=MBWay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MBWay.js","sources":["../../../../src/components/MBWay/MBWay.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport MBWayInput from './components/MBWayInput';\nimport config from './components/MBWayAwait/config';\nimport { Await } from '../../components/internal/Await';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport { AwaitConfiguration } from '../internal/Await/types';\n\nexport class MBWayElement extends UIElement<AwaitConfiguration> {\n public static type = TxVariants.mbway;\n\n formatProps(props) {\n const { data = {}, placeholders = {} } = props;\n\n return {\n ...props,\n data: {\n phoneNumber: data.telephoneNumber || data.phoneNumber,\n phonePrefix: data.phonePrefix || '+351' // if not specified default to Portuguese country code\n },\n placeholders: {\n phoneNumber: placeholders.telephoneNumber || placeholders.phoneNumber\n }\n };\n }\n\n /**\n * Formats the component data output\n */\n formatData(): object {\n return {\n paymentMethod: {\n type: MBWayElement.type,\n ...(this.state.data?.phoneNumber && { telephoneNumber: this.state.data.phonePrefix + this.state.data.phoneNumber })\n }\n };\n }\n\n get isValid(): boolean {\n return !!this.state.isValid;\n }\n\n get displayName(): string {\n return this.props.name;\n }\n\n protected override componentToRender(): h.JSX.Element {\n if (this.props.paymentData) {\n return (\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <Await\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onError={this.props.onError}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n type={config.type}\n messageText={this.props.i18n.get(config.messageTextId)}\n awaitText={this.props.i18n.get(config.awaitTextId)}\n showCountdownTimer={config.showCountdownTimer}\n delay={config.STATUS_INTERVAL}\n countdownTime={config.COUNTDOWN_MINUTES}\n throttleTime={config.THROTTLE_TIME}\n throttleInterval={config.THROTTLE_INTERVAL}\n onActionHandled={this.onActionHandled}\n />\n </SRPanelProvider>\n );\n }\n\n return (\n <MBWayInput\n /* @ts-ignore ref handled internally by Component */\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n setComponentRef={this.setComponentRef}\n onChange={this.setState}\n onSubmit={this.submit}\n payButton={this.payButton}\n />\n );\n }\n}\n\nexport default MBWayElement;\n"],"names":["MBWayElement","UIElement","formatProps","props","data","placeholders","phoneNumber","telephoneNumber","phonePrefix","formatData","paymentMethod","type","this","state","isValid","displayName","name","componentToRender","paymentData","h","SRPanelProvider","srPanel","modules","Await","clientKey","onError","onComplete","brandLogo","icon","config","messageText","i18n","get","messageTextId","awaitText","awaitTextId","showCountdownTimer","delay","STATUS_INTERVAL","countdownTime","COUNTDOWN_MINUTES","throttleTime","THROTTLE_TIME","throttleInterval","THROTTLE_INTERVAL","onActionHandled","MBWayInput","ref","componentRef","setComponentRef","onChange","setState","onSubmit","submit","payButton","TxVariants","mbway"],"mappings":"gYASO,MAAMA,UAAqBC,EAG9BC,WAAAA,CAAYC,GACR,MAAMC,KAAEA,EAAO,CAAA,EAAEC,aAAEA,EAAe,CAAA,GAAOF,EAEzC,MAAO,IACAA,EACHC,KAAM,CACFE,YAAaF,EAAKG,iBAAmBH,EAAKE,YAC1CE,YAAaJ,EAAKI,aAAe,QAErCH,aAAc,CACVC,YAAaD,EAAaE,iBAAmBF,EAAaC,aAGtE,CAKAG,UAAAA,GACI,MAAO,CACHC,cAAe,CACXC,KAAMX,EAAaW,QACfC,KAAKC,MAAMT,MAAME,aAAe,CAAEC,gBAAiBK,KAAKC,MAAMT,KAAKI,YAAcI,KAAKC,MAAMT,KAAKE,cAGjH,CAEA,WAAIQ,GACA,QAASF,KAAKC,MAAMC,OACxB,CAEA,eAAIC,GACA,OAAOH,KAAKT,MAAMa,IACtB,CAEmBC,iBAAAA,GACf,OAAIL,KAAKT,MAAMe,YAEPC,EAACC,EAAAA,CAAgBC,QAAST,KAAKT,MAAMmB,QAAQD,SACzCF,EAACI,EAAAA,CACGC,UAAWZ,KAAKT,MAAMqB,UACtBN,YAAaN,KAAKT,MAAMe,YACxBO,QAASb,KAAKT,MAAMsB,QACpBC,WAAYd,KAAKc,WACjBC,UAAWf,KAAKgB,KAChBjB,KAAMkB,EAAOlB,KACbmB,YAAalB,KAAKT,MAAM4B,KAAKC,IAAIH,EAAOI,eACxCC,UAAWtB,KAAKT,MAAM4B,KAAKC,IAAIH,EAAOM,aACtCC,mBAAoBP,EAAOO,mBAC3BC,MAAOR,EAAOS,gBACdC,cAAeV,EAAOW,kBACtBC,aAAcZ,EAAOa,cACrBC,iBAAkBd,EAAOe,kBACzBC,gBAAiBjC,KAAKiC,mBAOlC1B,EAAC2B,EAAAA,CAEGC,IAAKA,IACDnC,KAAKoC,aAAeD,MAEpBnC,KAAKT,MACT8C,gBAAiBrC,KAAKqC,gBACtBC,SAAUtC,KAAKuC,SACfC,SAAUxC,KAAKyC,OACfC,UAAW1C,KAAK0C,WAG5B,cA3EStD,IACKW,SAAO4C,EAAWC"}
1
+ {"version":3,"file":"MBWay.js","sources":["../../../../src/components/MBWay/MBWay.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport MBWayInput from './components/MBWayInput';\nimport config from './components/MBWayAwait/config';\nimport { Await } from '../../components/internal/Await';\nimport { TxVariants } from '../tx-variants';\nimport { AwaitConfiguration } from '../internal/Await/types';\n\nexport class MBWayElement extends UIElement<AwaitConfiguration> {\n public static type = TxVariants.mbway;\n\n formatProps(props) {\n const { data = {}, placeholders = {} } = props;\n\n return {\n ...props,\n data: {\n phoneNumber: data.telephoneNumber || data.phoneNumber,\n phonePrefix: data.phonePrefix || '+351' // if not specified default to Portuguese country code\n },\n placeholders: {\n phoneNumber: placeholders.telephoneNumber || placeholders.phoneNumber\n }\n };\n }\n\n /**\n * Formats the component data output\n */\n formatData(): object {\n return {\n paymentMethod: {\n type: MBWayElement.type,\n ...(this.state.data?.phoneNumber && { telephoneNumber: this.state.data.phonePrefix + this.state.data.phoneNumber })\n }\n };\n }\n\n get isValid(): boolean {\n return !!this.state.isValid;\n }\n\n get displayName(): string {\n return this.props.name;\n }\n\n protected override componentToRender(): h.JSX.Element {\n if (this.props.paymentData) {\n return (\n <Await\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onError={this.props.onError}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n type={config.type}\n messageText={this.props.i18n.get(config.messageTextId)}\n awaitText={this.props.i18n.get(config.awaitTextId)}\n showCountdownTimer={config.showCountdownTimer}\n delay={config.STATUS_INTERVAL}\n countdownTime={config.COUNTDOWN_MINUTES}\n throttleTime={config.THROTTLE_TIME}\n throttleInterval={config.THROTTLE_INTERVAL}\n onActionHandled={this.onActionHandled}\n />\n );\n }\n\n return (\n <MBWayInput\n /* @ts-ignore ref handled internally by Component */\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n setComponentRef={this.setComponentRef}\n onChange={this.setState}\n onSubmit={this.submit}\n payButton={this.payButton}\n />\n );\n }\n}\n\nexport default MBWayElement;\n"],"names":["MBWayElement","UIElement","formatProps","props","data","placeholders","phoneNumber","telephoneNumber","phonePrefix","formatData","paymentMethod","type","this","state","isValid","displayName","name","componentToRender","paymentData","h","Await","clientKey","onError","onComplete","brandLogo","icon","config","messageText","i18n","get","messageTextId","awaitText","awaitTextId","showCountdownTimer","delay","STATUS_INTERVAL","countdownTime","COUNTDOWN_MINUTES","throttleTime","THROTTLE_TIME","throttleInterval","THROTTLE_INTERVAL","onActionHandled","MBWayInput","ref","componentRef","setComponentRef","onChange","setState","onSubmit","submit","payButton","TxVariants","mbway"],"mappings":"4UAQO,MAAMA,UA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