@adyen/adyen-web 6.20.0 → 6.22.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.
- package/README.md +1 -1
- package/dist/cjs/adyen.css +9 -10
- package/dist/cjs/adyen.css.map +1 -1
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +33 -9
- package/dist/es/adyen.css +9 -10
- package/dist/es/adyen.css.map +1 -1
- package/dist/es/components/Ach/Ach.js +1 -1
- package/dist/es/components/Ach/Ach.js.map +1 -1
- package/dist/es/components/Ach/components/AchComponent.js +1 -1
- package/dist/es/components/Ach/components/AchComponent.js.map +1 -1
- package/dist/es/components/Card/Card.js +1 -1
- package/dist/es/components/Card/Card.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es/components/PayByBankPix/PayByBankPix.js +1 -1
- package/dist/es/components/PayByBankPix/PayByBankPix.js.map +1 -1
- package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
- package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
- package/dist/es/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js +1 -1
- package/dist/es/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js.map +1 -1
- package/dist/es/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js +1 -1
- package/dist/es/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js.map +1 -1
- package/dist/es/components/PayByBankPix/components/StoredPayment/StoredPayment.js +1 -1
- package/dist/es/components/PayByBankPix/components/StoredPayment/StoredPayment.js.map +1 -1
- package/dist/es/components/PayTo/components/BSBInput.js +1 -1
- package/dist/es/components/PayTo/components/BSBInput.js.map +1 -1
- package/dist/es/components/PayTo/components/PayIDInput.js +1 -1
- package/dist/es/components/PayTo/components/PayIDInput.js.map +1 -1
- package/dist/es/components/PayTo/components/PayToComponent.js +1 -1
- package/dist/es/components/PayTo/components/PayToComponent.js.map +1 -1
- package/dist/es/components/UPI/UPI.js +1 -1
- package/dist/es/components/UPI/UPI.js.map +1 -1
- package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
- package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
- package/dist/es/components/UPI/components/UPIMandate/UPIMandate.js +2 -0
- package/dist/es/components/UPI/components/UPIMandate/UPIMandate.js.map +1 -0
- package/dist/es/components/internal/Address/components/AddressSearch.js.map +1 -1
- package/dist/es/components/internal/Await/Await.js +1 -1
- package/dist/es/components/internal/Await/Await.js.map +1 -1
- package/dist/es/components/internal/FormFields/Fieldset/Fieldset.js +1 -1
- package/dist/es/components/internal/FormFields/Fieldset/Fieldset.js.map +1 -1
- package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
- package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
- package/dist/es/components/internal/PayButton/PayButton.js +1 -1
- package/dist/es/components/internal/PayButton/PayButton.js.map +1 -1
- package/dist/es/components/internal/PayButton/components/SecondaryButtonLabel.js.map +1 -1
- package/dist/es/components/internal/QRLoader/QRLoader.js +1 -1
- package/dist/es/components/internal/QRLoader/QRLoader.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js +1 -1
- package/dist/es/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/binLookup/extensions.js +1 -1
- package/dist/es/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
- package/dist/es/core/Analytics/Analytics.js +1 -1
- package/dist/es/core/Analytics/Analytics.js.map +1 -1
- package/dist/es/core/Analytics/utils.js +1 -1
- package/dist/es/core/Analytics/utils.js.map +1 -1
- package/dist/es/core/Services/analytics/collect-id.js +1 -1
- package/dist/es/core/Services/analytics/collect-id.js.map +1 -1
- package/dist/es/core/core.js +1 -1
- package/dist/es/core/core.js.map +1 -1
- package/dist/es/index.d.ts +33 -9
- package/dist/es/utils/setFocus.js +1 -1
- package/dist/es/utils/setFocus.js.map +1 -1
- package/dist/es-legacy/adyen.css +9 -10
- package/dist/es-legacy/adyen.css.map +1 -1
- package/dist/es-legacy/components/Ach/Ach.js +1 -1
- package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
- package/dist/es-legacy/components/Ach/components/AchComponent.js +1 -1
- package/dist/es-legacy/components/Ach/components/AchComponent.js.map +1 -1
- package/dist/es-legacy/components/Card/Card.js +1 -1
- package/dist/es-legacy/components/Card/Card.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
- package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
- package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
- package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
- package/dist/es-legacy/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js +1 -1
- package/dist/es-legacy/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js.map +1 -1
- package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js +1 -1
- package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js.map +1 -1
- package/dist/es-legacy/components/PayByBankPix/components/StoredPayment/StoredPayment.js +1 -1
- package/dist/es-legacy/components/PayByBankPix/components/StoredPayment/StoredPayment.js.map +1 -1
- package/dist/es-legacy/components/PayTo/components/BSBInput.js +1 -1
- package/dist/es-legacy/components/PayTo/components/BSBInput.js.map +1 -1
- package/dist/es-legacy/components/PayTo/components/PayIDInput.js +1 -1
- package/dist/es-legacy/components/PayTo/components/PayIDInput.js.map +1 -1
- package/dist/es-legacy/components/PayTo/components/PayToComponent.js +1 -1
- package/dist/es-legacy/components/PayTo/components/PayToComponent.js.map +1 -1
- package/dist/es-legacy/components/UPI/UPI.js +1 -1
- package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
- package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
- package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
- package/dist/es-legacy/components/UPI/components/UPIMandate/UPIMandate.js +2 -0
- package/dist/es-legacy/components/UPI/components/UPIMandate/UPIMandate.js.map +1 -0
- package/dist/es-legacy/components/internal/Address/components/AddressSearch.js.map +1 -1
- package/dist/es-legacy/components/internal/Await/Await.js +1 -1
- package/dist/es-legacy/components/internal/Await/Await.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/Fieldset/Fieldset.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Fieldset/Fieldset.js.map +1 -1
- package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
- package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
- package/dist/es-legacy/components/internal/PayButton/PayButton.js +1 -1
- package/dist/es-legacy/components/internal/PayButton/PayButton.js.map +1 -1
- package/dist/es-legacy/components/internal/PayButton/components/SecondaryButtonLabel.js.map +1 -1
- package/dist/es-legacy/components/internal/QRLoader/QRLoader.js +1 -1
- package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
- package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
- package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
- package/dist/es-legacy/core/Analytics/utils.js +1 -1
- package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
- package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
- package/dist/es-legacy/core/Services/analytics/collect-id.js.map +1 -1
- package/dist/es-legacy/core/core.js +1 -1
- package/dist/es-legacy/core/core.js.map +1 -1
- package/dist/es-legacy/utils/setFocus.js +1 -1
- package/dist/es-legacy/utils/setFocus.js.map +1 -1
- package/package.json +157 -159
- package/styles/adyen.css +9 -10
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{AddressModeOptions as e}from"./types.js";import{CREDIT_CARD_NAME_TOP as o,CREDIT_CARD_NAME_BOTTOM as n,KCP_CARD_NAME_TOP as i,KCP_CARD_NAME_BOTTOM as r,SSN_CARD_NAME_TOP as t,SSN_CARD_NAME_BOTTOM as l,CREDIT_CARD as s,KCP_CARD as a,SSN_CARD as d}from"./layouts.js";import{PARTIAL_ADDRESS_SCHEMA as u}from"../../../internal/Address/constants.js";import{DEFAULT_CARD_GROUP_TYPES as c,BRAND_READABLE_NAME_MAP as m}from"../../../internal/SecuredFields/lib/constants.js";import p from"../../../../core/Context/useImage.js";import{SF_ErrorCodes as g}from"../../../../core/Errors/constants.js";import{DEFAULT_CHALLENGE_WINDOW_SIZE as h}from"../../../ThreeDS2/constants.js";import y from"./defaultProps.js";import{isConfigurationValid as b}from"../Fastlane/utils/validate-configuration.js";import{notFalsy as O}from"../../../../utils/commonUtils.js";function f(e,o,n){return o in e?Object.defineProperty(e,o,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[o]=n,e}function C(e){for(var o=1;o<arguments.length;o++){var n=null!=arguments[o]?arguments[o]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(o){f(e,o,n[o])})}return e}function S(e,o){return o=null!=o?o:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):function(e){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);o.push.apply(o,n)}return o}(Object(o)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}),e}const v=(e,o)=>o({type:"card"===e?"nocard":e||"nocard",extension:"svg"})(e),A=e=>"revolving"===(null==e?void 0:e.plan)||(null==e?void 0:e.value)>1,R=({props:e,showKCP:u,showBrazilianSSN:c,countrySpecificSchemas:m=null,billingAddressRequiredFields:p=null})=>{let g=s;const h=e.hasHolderName&&e.holderNameRequired;if(h&&(g=e.positionHolderNameOnTop?o:n),u&&(g=a,h&&(g=e.positionHolderNameOnTop?i:r)),c&&(g=d,h&&(g=e.positionHolderNameOnTop?t:l)),m){const i=m.flat(2).filter(e=>"number"!=typeof e);let r=i;p&&(r=i.filter(e=>p.includes(e))),g=s.concat(r),h&&(g=e.positionHolderNameOnTop?o.concat(r):n.concat(r))}return g},w=(e,o,n)=>{switch(e){case"socialSecurityNumber":return o.get(`boleto.${e}`);case"street":case"houseNumberOrName":case"postalCode":case"stateOrProvince":case"city":case"country":return(null==n?void 0:n[e])?o.get(null==n?void 0:n[e]):o.get(e);default:return null}},F=e=>({amount:e.amount,billingAddressRequired:e.billingAddressRequired,billingAddressRequiredFields:e.billingAddressRequiredFields,billingAddressAllowedCountries:e.billingAddressAllowedCountries,brandsConfiguration:e.brandsConfiguration,showStoreDetailsCheckbox:e.showStoreDetailsCheckbox,hasCVC:e.hasCVC,hasHolderName:e.hasHolderName,holderNameRequired:e.holderNameRequired,installmentOptions:e.installmentOptions,placeholders:e.placeholders,positionHolderNameOnTop:e.positionHolderNameOnTop,showBrandIcon:e.showBrandIcon,showContextualElement:e.showContextualElement,lastFour:e.lastFour,expiryMonth:e.expiryMonth,expiryYear:e.expiryYear,disclaimerMessage:e.disclaimerMessage}),E=e=>({autoFocus:e.autoFocus,brands:e.brands,brandsConfiguration:e.brandsConfiguration,clientKey:e.clientKey,countryCode:e.countryCode,forceCompat:e.forceCompat,i18n:e.i18n,implementationType:e.implementationType,keypadFix:e.keypadFix,legacyInputMode:e.legacyInputMode,loadingContext:e.loadingContext,maskSecurityCode:e.maskSecurityCode,exposeExpiryDate:e.exposeExpiryDate,minimumExpiryDate:e.minimumExpiryDate,onAdditionalSFConfig:e.onAdditionalSFConfig,onAdditionalSFRemoved:e.onAdditionalSFRemoved,onAllValid:e.onAllValid,onAutoComplete:e.onAutoComplete,onBinValue:e.onBinValue,onConfigSuccess:e.onConfigSuccess,handleKeyPress:e.handleKeyPress,onError:e.onError,onFieldValid:e.onFieldValid,onLoad:e.onLoad,placeholders:e.placeholders,resources:e.resources,showContextualElement:e.showContextualElement,showWarnings:e.showWarnings,trimTrailingSeparator:e.trimTrailingSeparator}),x=o=>o==e.partial?u:null;function N(e){return![g.ERROR_MSG_UNSUPPORTED_CARD_ENTERED,g.ERROR_MSG_CARD_TOO_OLD,g.ERROR_MSG_CARD_TOO_FAR_IN_FUTURE,g.ERROR_MSG_CARD_EXPIRES_TOO_SOON].includes(e)}function P(e){var o;return null!==(o=m[e])&&void 0!==o?o:e}const D=e=>{var o,n,i,r,t,l,s,a;const{autoFocus:d,billingAddressAllowedCountries:u,billingAddressMode:m,billingAddressRequired:p,billingAddressRequiredFields:g,brands:f=c,brandsConfiguration:v,challengeWindowSize:A=h,configuration:R,countryCode:w,data:F,disclaimerMessage:E,disableIOSArrowKeys:x,doBinLookup:N,enableStoreDetails:P,exposeExpiryDate:D,fastlaneConfiguration:j,forceCompat:B,hasHolderName:k,hideCVC:T,holderNameRequired:M,installmentOptions:V,keypadFix:_,legacyInputMode:I,maskSecurityCode:q,minimumExpiryDate:H,name:L,placeholders:K,positionHolderNameOnTop:U,showBrandIcon:G,showInstallmentAmounts:W,showPayButton:z=!1,styles:J,onAllValid:Y,onBinLookup:X,onBinValue:$,onBlur:Q,onBrand:Z,onConfigSuccess:ee,onEnterKeyPressed:oe,onFieldValid:ne,onFocus:ie,onLoad:re}=e,te=JSON.stringify(y.data),le=null===(n=e.modules)||void 0===n||null===(o=n.srPanel)||void 0===o?void 0:o.enabled,se=null===(r=e.modules)||void 0===r||null===(i=r.srPanel)||void 0===i?void 0:i.moveFocus,ae=null===(l=e.modules)||void 0===l||null===(t=l.risk)||void 0===t?void 0:t.enabled,de=b(j),ue=e.onAddressLookup?"lookup":m;let ce="none";!0===(null==R?void 0:R.koreanAuthenticationRequired)&&(ce="kr"===(null==w?void 0:w.toLowerCase())?"atStart":"auto");return C(S(C({autoFocus:d},(null==u?void 0:u.length)>0&&{billingAddressAllowedCountries:u.toString().substring(0,128)}),{billingAddressMode:ue,billingAddressRequired:p,billingAddressRequiredFields:null==g||null===(s=g.toString())||void 0===s?void 0:s.substring(0,128),brands:null==f||null===(a=f.toString())||void 0===a?void 0:a.substring(0,128),challengeWindowSize:A,disableIOSArrowKeys:x,doBinLookup:N,enableStoreDetails:P,exposeExpiryDate:D,forceCompat:B,hasBrandsConfiguration:O(v),hasData:F&&JSON.stringify(e.data)!==te,hasDisclaimerMessage:!!E,hasHolderName:k,hasInstallmentOptions:O(V),hasPlaceholders:O(K),hasStylesConfigured:O(J),hideCVC:T,holderNameRequired:M,keypadFix:_,legacyInputMode:I,maskSecurityCode:q,minimumExpiryDate:!!H,name:L,positionHolderNameOnTop:U,riskEnabled:ae,showBrandIcon:G,showInstallmentAmounts:!!W,showKCPType:ce,showPayButton:z,socialSecurityNumberMode:null==R?void 0:R.socialSecurityNumberMode,srPanelEnabled:le,srPanelMoveFocus:se,hasOnAllValid:Y!==y.onAllValid,hasOnBinValue:$!==y.onBinValue,hasOnBlur:Q!==y.onBlur,hasOnBrand:Z!==y.onBrand,hasOnConfigSuccess:ee!==y.onConfigSuccess,hasOnFieldValid:ne!==y.onFieldValid,hasOnFocus:ie!==y.onFocus,hasOnLoad:re!==y.onLoad,hasOnBinLookup:!!X,hasOnEnterKeyPressed:!!oe}),de&&{hasFastlaneConfigured:!0,isFastlaneConsentDefaultOn:j.defaultToggleState})},j=(e,o)=>e.map(e=>{var n;const i=e.id,r=p(),t="card"===i?"nocard":i;var l;const s=null!==(l=null===(n=o[i])||void 0===n?void 0:n.icon)&&void 0!==l?l:v(t,r);return{id:e.id,name:e.brandObject.localeBrand||e.brandObject.brand,imageURL:s,altName:P(i)}});export{F as extractPropsForCardFields,E as extractPropsForSFP,D as getCardConfigData,v as getCardImageUrl,P as getFullBrandName,R as getLayout,x as handlePartialAddressMode,A as hasValidInstallmentsObject,N as lookupBlurBasedErrors,j as mapDualBrandButtons,w as mapFieldKey};
|
|
1
|
+
import{AddressModeOptions as e}from"./types.js";import{CREDIT_CARD_NAME_TOP as o,CREDIT_CARD_NAME_BOTTOM as n,KCP_CARD_NAME_TOP as i,KCP_CARD_NAME_BOTTOM as r,SSN_CARD_NAME_TOP as t,SSN_CARD_NAME_BOTTOM as l,CREDIT_CARD as s,KCP_CARD as a,SSN_CARD as d}from"./layouts.js";import{PARTIAL_ADDRESS_SCHEMA as u}from"../../../internal/Address/constants.js";import{DEFAULT_CARD_GROUP_TYPES as c,BRAND_READABLE_NAME_MAP as m}from"../../../internal/SecuredFields/lib/constants.js";import p from"../../../../core/Context/useImage.js";import{SF_ErrorCodes as g}from"../../../../core/Errors/constants.js";import{DEFAULT_CHALLENGE_WINDOW_SIZE as h}from"../../../ThreeDS2/constants.js";import y from"./defaultProps.js";import{isConfigurationValid as b}from"../Fastlane/utils/validate-configuration.js";import{notFalsy as O}from"../../../../utils/commonUtils.js";function f(e,o,n){return o in e?Object.defineProperty(e,o,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[o]=n,e}function C(e){for(var o=1;o<arguments.length;o++){var n=null!=arguments[o]?arguments[o]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(o){f(e,o,n[o])})}return e}function S(e,o){return o=null!=o?o:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):function(e){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);o.push.apply(o,n)}return o}(Object(o)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}),e}const v=(e,o)=>o({type:"card"===e?"nocard":e||"nocard",extension:"svg"})(e),A=e=>"revolving"===(null==e?void 0:e.plan)||(null==e?void 0:e.value)>1,R=({props:e,showKCP:u,showBrazilianSSN:c,countrySpecificSchemas:m=null,billingAddressRequiredFields:p=null})=>{let g=s;const h=e.hasHolderName&&e.holderNameRequired;if(h&&(g=e.positionHolderNameOnTop?o:n),u&&(g=a,h&&(g=e.positionHolderNameOnTop?i:r)),c&&(g=d,h&&(g=e.positionHolderNameOnTop?t:l)),m){const i=m.flat(2).filter(e=>"number"!=typeof e);let r=i;p&&(r=i.filter(e=>p.includes(e))),g=s.concat(r),h&&(g=e.positionHolderNameOnTop?o.concat(r):n.concat(r))}return g},w=(e,o,n)=>{switch(e){case"socialSecurityNumber":return o.get(`boleto.${e}`);case"street":case"houseNumberOrName":case"postalCode":case"stateOrProvince":case"city":case"country":return(null==n?void 0:n[e])?o.get(null==n?void 0:n[e]):o.get(e);default:return null}},F=e=>({amount:e.amount,billingAddressRequired:e.billingAddressRequired,billingAddressRequiredFields:e.billingAddressRequiredFields,billingAddressAllowedCountries:e.billingAddressAllowedCountries,brandsConfiguration:e.brandsConfiguration,showStoreDetailsCheckbox:e.showStoreDetailsCheckbox,hasCVC:e.hasCVC,hasHolderName:e.hasHolderName,holderNameRequired:e.holderNameRequired,installmentOptions:e.installmentOptions,placeholders:e.placeholders,positionHolderNameOnTop:e.positionHolderNameOnTop,showBrandIcon:e.showBrandIcon,showContextualElement:e.showContextualElement,lastFour:e.lastFour,expiryMonth:e.expiryMonth,expiryYear:e.expiryYear,disclaimerMessage:e.disclaimerMessage}),E=e=>({autoFocus:e.autoFocus,brands:e.brands,brandsConfiguration:e.brandsConfiguration,clientKey:e.clientKey,countryCode:e.countryCode,forceCompat:e.forceCompat,i18n:e.i18n,implementationType:e.implementationType,keypadFix:e.keypadFix,legacyInputMode:e.legacyInputMode,loadingContext:e.loadingContext,maskSecurityCode:e.maskSecurityCode,exposeExpiryDate:e.exposeExpiryDate,minimumExpiryDate:e.minimumExpiryDate,onAdditionalSFConfig:e.onAdditionalSFConfig,onAdditionalSFRemoved:e.onAdditionalSFRemoved,onAllValid:e.onAllValid,onAutoComplete:e.onAutoComplete,onBinValue:e.onBinValue,onConfigSuccess:e.onConfigSuccess,handleKeyPress:e.handleKeyPress,onError:e.onError,onFieldValid:e.onFieldValid,onLoad:e.onLoad,placeholders:e.placeholders,resources:e.resources,showContextualElement:e.showContextualElement,showWarnings:e.showWarnings,trimTrailingSeparator:e.trimTrailingSeparator}),x=o=>o==e.partial?u:null;function N(e){return![g.ERROR_MSG_UNSUPPORTED_CARD_ENTERED,g.ERROR_MSG_CARD_TOO_OLD,g.ERROR_MSG_CARD_TOO_FAR_IN_FUTURE,g.ERROR_MSG_CARD_EXPIRES_TOO_SOON].includes(e)}function P(e){var o;return null!==(o=m[e])&&void 0!==o?o:e}const D=e=>{var o,n,i,r,t,l,s,a;const{autoFocus:d,billingAddressAllowedCountries:u,billingAddressMode:m,billingAddressRequired:p,billingAddressRequiredFields:g,brands:f=c,brandsConfiguration:v,challengeWindowSize:A=h,configuration:R,countryCode:w,data:F,disclaimerMessage:E,disableIOSArrowKeys:x,doBinLookup:N,enableStoreDetails:P,exposeExpiryDate:D,fastlaneConfiguration:j,forceCompat:B,hasHolderName:k,hideCVC:T,holderNameRequired:M,installmentOptions:V,keypadFix:_,legacyInputMode:I,maskSecurityCode:q,minimumExpiryDate:H,name:L,placeholders:K,positionHolderNameOnTop:U,showBrandIcon:G,showInstallmentAmounts:W,showPayButton:z=!1,styles:J,onAllValid:Y,onBinLookup:X,onBinValue:$,onBlur:Q,onBrand:Z,onConfigSuccess:ee,onEnterKeyPressed:oe,onFieldValid:ne,onFocus:ie,onLoad:re}=e,te=JSON.stringify(y.data),le=null===(n=e.modules)||void 0===n||null===(o=n.srPanel)||void 0===o?void 0:o.enabled,se=null===(r=e.modules)||void 0===r||null===(i=r.srPanel)||void 0===i?void 0:i.moveFocus,ae=null===(l=e.modules)||void 0===l||null===(t=l.risk)||void 0===t?void 0:t.enabled,de=b(j),ue=e.onAddressLookup?"lookup":m;let ce="none";!0===(null==R?void 0:R.koreanAuthenticationRequired)&&(ce="kr"===(null==w?void 0:w.toLowerCase())?"atStart":"auto");return C(S(C({autoFocus:d},(null==u?void 0:u.length)>0&&{billingAddressAllowedCountries:u.toString().substring(0,128)}),{billingAddressMode:ue,billingAddressRequired:p,billingAddressRequiredFields:null==g||null===(s=g.toString())||void 0===s?void 0:s.substring(0,128),brands:null==f||null===(a=f.toString())||void 0===a?void 0:a.substring(0,128),challengeWindowSize:A,disableIOSArrowKeys:x,doBinLookup:N,enableStoreDetails:P,exposeExpiryDate:D,forceCompat:B,hasBrandsConfiguration:O(v),hasData:F&&JSON.stringify(e.data)!==te,hasDisclaimerMessage:!!E,hasHolderName:k,hasInstallmentOptions:O(V),hasPlaceholders:O(K),hasStylesConfigured:O(J),hideCVC:T,holderNameRequired:M,keypadFix:_,legacyInputMode:I,maskSecurityCode:q,minimumExpiryDate:!!H,name:L,positionHolderNameOnTop:U,riskEnabled:ae,showBrandIcon:G,showInstallmentAmounts:!!W,showKCPType:ce,showPayButton:z,socialSecurityNumberMode:null==R?void 0:R.socialSecurityNumberMode,srPanelEnabled:le,srPanelMoveFocus:se,hasOnAllValid:Y!==y.onAllValid,hasOnBinValue:$!==y.onBinValue,hasOnBlur:Q!==y.onBlur,hasOnBrand:Z!==y.onBrand,hasOnConfigSuccess:ee!==y.onConfigSuccess,hasOnFieldValid:ne!==y.onFieldValid,hasOnFocus:ie!==y.onFocus,hasOnLoad:re!==y.onLoad,hasOnBinLookup:!!X,hasOnEnterKeyPressed:!!oe}),de&&{hasFastlaneConfigured:!0,isFastlaneConsentDefaultOn:j.defaultToggleState})},j=(e,o)=>e.map(e=>{var n;const i=e.id,r=p(),t="card"===i?"nocard":i;var l;const s=null!==(l=null===(n=o[i])||void 0===n?void 0:n.icon)&&void 0!==l?l:v(t,r);return{id:e.id,name:e.brandObject.localeBrand||e.brandObject.brand,imageURL:s,altName:P(i)}}),B=(e,o,n)=>!!o.filter(o=>e.includes(o[n])).length;export{F as extractPropsForCardFields,E as extractPropsForSFP,D as getCardConfigData,v as getCardImageUrl,P as getFullBrandName,R as getLayout,x as handlePartialAddressMode,A as hasValidInstallmentsObject,N as lookupBlurBasedErrors,j as mapDualBrandButtons,w as mapFieldKey,B as mustHandleDualBrandingAccordingToEURegulations};
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../../../src/components/Card/components/CardInput/utils.ts"],"sourcesContent":["import Language from '../../../../language/Language';\nimport { AddressModeOptions, CardInputProps, LayoutObj } from './types';\nimport {\n CREDIT_CARD,\n CREDIT_CARD_NAME_BOTTOM,\n CREDIT_CARD_NAME_TOP,\n KCP_CARD,\n KCP_CARD_NAME_BOTTOM,\n KCP_CARD_NAME_TOP,\n SSN_CARD,\n SSN_CARD_NAME_BOTTOM,\n SSN_CARD_NAME_TOP\n} from './layouts';\nimport { AddressSpecifications, StringObject } from '../../../internal/Address/types';\nimport { PARTIAL_ADDRESS_SCHEMA } from '../../../internal/Address/constants';\nimport { InstallmentsObj } from './components/Installments/Installments';\nimport { SFPProps } from '../../../internal/SecuredFields/SFP/types';\nimport { BRAND_READABLE_NAME_MAP, DEFAULT_CARD_GROUP_TYPES } from '../../../internal/SecuredFields/lib/constants';\nimport useImage, { UseImageHookType } from '../../../../core/Context/useImage';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\nimport { CardBrandsConfiguration, CardConfiguration, DualBrandSelectElement } from '../../types';\nimport { CardConfigData } from '../../../../core/Analytics/types';\nimport { DEFAULT_CHALLENGE_WINDOW_SIZE } from '../../../ThreeDS2/constants';\nimport CardInputDefaultProps from './defaultProps';\nimport { isConfigurationValid as isFastlaneComponentConfigValid } from '../Fastlane/utils/validate-configuration';\nimport { notFalsy } from '../../../../utils/commonUtils';\n\nexport const getCardImageUrl = (brand: string, getImage: UseImageHookType): string => {\n const imageOptions = {\n type: brand === 'card' ? 'nocard' : brand || 'nocard',\n extension: 'svg'\n };\n\n return getImage(imageOptions)(brand);\n};\n\n/**\n * Verifies that installment object is valid to send to the Backend.\n * Valid means that it has 'revolving' plan set, or the number of installments is bigger than one\n */\nexport const hasValidInstallmentsObject = (installments?: InstallmentsObj) => {\n return installments?.plan === 'revolving' || installments?.value > 1;\n};\n\nexport const getLayout = ({\n props,\n showKCP,\n showBrazilianSSN,\n countrySpecificSchemas = null,\n billingAddressRequiredFields = null\n}: LayoutObj): string[] => {\n let layout = CREDIT_CARD;\n const hasRequiredHolderName = props.hasHolderName && props.holderNameRequired;\n\n if (hasRequiredHolderName) {\n layout = props.positionHolderNameOnTop ? CREDIT_CARD_NAME_TOP : CREDIT_CARD_NAME_BOTTOM;\n }\n\n if (showKCP) {\n layout = KCP_CARD;\n if (hasRequiredHolderName) {\n layout = props.positionHolderNameOnTop ? KCP_CARD_NAME_TOP : KCP_CARD_NAME_BOTTOM;\n }\n }\n\n if (showBrazilianSSN) {\n layout = SSN_CARD;\n if (hasRequiredHolderName) {\n layout = props.positionHolderNameOnTop ? SSN_CARD_NAME_TOP : SSN_CARD_NAME_BOTTOM;\n }\n }\n\n // w. Billing address\n if (countrySpecificSchemas) {\n // Flatten array and remove any numbers that describe how fields should be aligned\n const countrySpecificSchemasFlat: string[] = countrySpecificSchemas['flat'](2).filter(item => typeof item !== 'number') as string[];\n\n let countryBasedAddressLayout = countrySpecificSchemasFlat;\n\n if (billingAddressRequiredFields) {\n // Get intersection of the 2 arrays\n countryBasedAddressLayout = countrySpecificSchemasFlat.filter(x => billingAddressRequiredFields.includes(x));\n }\n\n layout = CREDIT_CARD.concat(countryBasedAddressLayout);\n if (hasRequiredHolderName) {\n layout = props.positionHolderNameOnTop\n ? CREDIT_CARD_NAME_TOP.concat(countryBasedAddressLayout)\n : CREDIT_CARD_NAME_BOTTOM.concat(countryBasedAddressLayout);\n }\n // TODO we are not yet creating a layout for AVS + SSN field (w. or w/o holderName) - is AVS + SSN a real world scenario?\n }\n return layout;\n};\n\n/**\n * Lookup service to map local (CardInput) field refs to a key, possibly region specific, by which to retrieve the translation\n */\nexport const mapFieldKey = (key: string, i18n: Language, countrySpecificLabels: StringObject): string => {\n // console.log('### utils::mapFieldKey:: key', key);\n switch (key) {\n case 'socialSecurityNumber':\n return i18n.get(`boleto.${key}`);\n // Address related - if we have a country specific key for the field - use that to get the translation\n case 'street':\n case 'houseNumberOrName':\n case 'postalCode':\n case 'stateOrProvince':\n case 'city':\n case 'country':\n return countrySpecificLabels?.[key] ? i18n.get(countrySpecificLabels?.[key]) : i18n.get(key);\n // We know that the translated error messages do contain a reference to the field they refer to, so we won't need to map them (currently applies mostly to SecuredFields related errors)\n default:\n return null;\n }\n};\n\nexport const extractPropsForCardFields = (props: CardInputProps) => {\n return {\n // Extract props for CardFieldsWrapper & StoredCardFieldsWrapper(just needs amount, hasCVC, installmentOptions)\n amount: props.amount,\n billingAddressRequired: props.billingAddressRequired,\n billingAddressRequiredFields: props.billingAddressRequiredFields,\n billingAddressAllowedCountries: props.billingAddressAllowedCountries,\n brandsConfiguration: props.brandsConfiguration,\n showStoreDetailsCheckbox: props.showStoreDetailsCheckbox,\n hasCVC: props.hasCVC,\n hasHolderName: props.hasHolderName,\n holderNameRequired: props.holderNameRequired,\n installmentOptions: props.installmentOptions,\n placeholders: props.placeholders,\n positionHolderNameOnTop: props.positionHolderNameOnTop,\n // Extract props for CardFields > CardNumber\n showBrandIcon: props.showBrandIcon,\n showContextualElement: props.showContextualElement,\n // Extract props for StoredCardFields\n lastFour: props.lastFour,\n expiryMonth: props.expiryMonth,\n expiryYear: props.expiryYear,\n disclaimerMessage: props.disclaimerMessage\n };\n};\n\nexport const extractPropsForSFP = (props: CardInputProps) => {\n return {\n autoFocus: props.autoFocus,\n brands: props.brands,\n brandsConfiguration: props.brandsConfiguration,\n clientKey: props.clientKey,\n countryCode: props.countryCode,\n forceCompat: props.forceCompat,\n i18n: props.i18n,\n implementationType: props.implementationType,\n keypadFix: props.keypadFix,\n legacyInputMode: props.legacyInputMode,\n loadingContext: props.loadingContext,\n maskSecurityCode: props.maskSecurityCode,\n exposeExpiryDate: props.exposeExpiryDate,\n minimumExpiryDate: props.minimumExpiryDate,\n onAdditionalSFConfig: props.onAdditionalSFConfig,\n onAdditionalSFRemoved: props.onAdditionalSFRemoved,\n onAllValid: props.onAllValid,\n onAutoComplete: props.onAutoComplete,\n onBinValue: props.onBinValue,\n onConfigSuccess: props.onConfigSuccess,\n handleKeyPress: props.handleKeyPress,\n onError: props.onError,\n onFieldValid: props.onFieldValid,\n onLoad: props.onLoad,\n placeholders: props.placeholders,\n resources: props.resources,\n showContextualElement: props.showContextualElement,\n showWarnings: props.showWarnings,\n trimTrailingSeparator: props.trimTrailingSeparator\n } as SFPProps; // Can't set as return type on fn or it will complain about missing, mandatory, props\n};\n\nexport const handlePartialAddressMode = (addressMode: AddressModeOptions): AddressSpecifications | null => {\n return addressMode == AddressModeOptions.partial ? PARTIAL_ADDRESS_SCHEMA : null;\n};\n\n// Almost all errors are blur based, but some SF ones are not i.e. when an unsupported card is entered or the expiry date is out of range\nexport function lookupBlurBasedErrors(errorCode) {\n // If it's NOT one of these, then it's a blur based error\n return ![\n SF_ErrorCodes.ERROR_MSG_UNSUPPORTED_CARD_ENTERED,\n SF_ErrorCodes.ERROR_MSG_CARD_TOO_OLD,\n SF_ErrorCodes.ERROR_MSG_CARD_TOO_FAR_IN_FUTURE,\n SF_ErrorCodes.ERROR_MSG_CARD_EXPIRES_TOO_SOON\n ].includes(errorCode);\n}\n\nexport function getFullBrandName(brand) {\n return BRAND_READABLE_NAME_MAP[brand] ?? brand;\n}\n\nexport const getCardConfigData = (cardProps: CardConfiguration): CardConfigData => {\n const MAX_LENGTH = 128;\n\n // Extract props from cardProps - mostly setting a default value, if prop not found\n const {\n autoFocus,\n billingAddressAllowedCountries,\n billingAddressMode,\n billingAddressRequired,\n billingAddressRequiredFields,\n brands = DEFAULT_CARD_GROUP_TYPES,\n brandsConfiguration,\n challengeWindowSize = DEFAULT_CHALLENGE_WINDOW_SIZE,\n configuration,\n countryCode,\n data,\n disclaimerMessage,\n disableIOSArrowKeys,\n doBinLookup,\n enableStoreDetails,\n exposeExpiryDate,\n fastlaneConfiguration,\n forceCompat,\n hasHolderName,\n hideCVC,\n holderNameRequired,\n installmentOptions,\n keypadFix,\n legacyInputMode,\n maskSecurityCode,\n minimumExpiryDate,\n name, // = 'none',\n placeholders,\n positionHolderNameOnTop,\n showBrandIcon,\n showInstallmentAmounts,\n showPayButton = false, // hard coded default\n styles,\n onAllValid,\n onBinLookup,\n onBinValue,\n onBlur,\n onBrand,\n onConfigSuccess,\n onEnterKeyPressed,\n onFieldValid,\n onFocus,\n onLoad\n } = cardProps;\n\n const dataString = JSON.stringify(CardInputDefaultProps.data);\n\n const srPanelEnabled = cardProps.modules?.srPanel?.enabled;\n const srPanelMoveFocus = cardProps.modules?.srPanel?.moveFocus;\n\n const riskEnabled = cardProps.modules?.risk?.enabled;\n\n const isFastlaneConfigValid = isFastlaneComponentConfigValid(fastlaneConfiguration);\n\n const billingAddressModeValue = cardProps.onAddressLookup ? 'lookup' : billingAddressMode;\n\n let showKCPType: 'none' | 'auto' | 'atStart' = 'none';\n if (configuration?.koreanAuthenticationRequired === true) {\n showKCPType = countryCode?.toLowerCase() === 'kr' ? 'atStart' : 'auto';\n }\n\n const configData: CardConfigData = {\n autoFocus,\n ...(billingAddressAllowedCountries?.length > 0 && {\n billingAddressAllowedCountries: billingAddressAllowedCountries.toString().substring(0, MAX_LENGTH)\n }),\n billingAddressMode: billingAddressModeValue,\n billingAddressRequired,\n billingAddressRequiredFields: billingAddressRequiredFields?.toString()?.substring(0, MAX_LENGTH),\n // Probably just for development - in real life we wouldn't expect the number of supported brands to push the endpoint limit on 128 chars\n brands: brands?.toString()?.substring(0, MAX_LENGTH),\n challengeWindowSize,\n disableIOSArrowKeys,\n doBinLookup,\n enableStoreDetails,\n exposeExpiryDate,\n forceCompat,\n hasBrandsConfiguration: notFalsy(brandsConfiguration),\n hasData: data && JSON.stringify(cardProps.data) !== dataString,\n hasDisclaimerMessage: !!disclaimerMessage,\n hasHolderName,\n hasInstallmentOptions: notFalsy(installmentOptions),\n hasPlaceholders: notFalsy(placeholders), // has merchant defined placeholders\n hasStylesConfigured: notFalsy(styles),\n hideCVC,\n holderNameRequired,\n keypadFix,\n legacyInputMode,\n maskSecurityCode,\n minimumExpiryDate: !!minimumExpiryDate, // Potentially, in the future, we can send the actual string value\n name,\n positionHolderNameOnTop,\n riskEnabled,\n showBrandIcon,\n showInstallmentAmounts: !!showInstallmentAmounts,\n showKCPType,\n showPayButton,\n socialSecurityNumberMode: configuration?.socialSecurityNumberMode,\n srPanelEnabled,\n srPanelMoveFocus,\n /** callbacks */\n // We need to detect if the merchant themselves has defined these, not if we've set them as a default\n hasOnAllValid: onAllValid !== CardInputDefaultProps.onAllValid,\n hasOnBinValue: onBinValue !== CardInputDefaultProps.onBinValue,\n hasOnBlur: onBlur !== CardInputDefaultProps.onBlur,\n hasOnBrand: onBrand !== CardInputDefaultProps.onBrand,\n hasOnConfigSuccess: onConfigSuccess !== CardInputDefaultProps.onConfigSuccess,\n hasOnFieldValid: onFieldValid !== CardInputDefaultProps.onFieldValid,\n hasOnFocus: onFocus !== CardInputDefaultProps.onFocus,\n hasOnLoad: onLoad !== CardInputDefaultProps.onLoad,\n // Card level props\n hasOnBinLookup: !!onBinLookup,\n hasOnEnterKeyPressed: !!onEnterKeyPressed,\n /**\n * Fastlane\n */\n ...(isFastlaneConfigValid && {\n hasFastlaneConfigured: true,\n isFastlaneConsentDefaultOn: fastlaneConfiguration.defaultToggleState\n })\n };\n\n return configData;\n};\n\nexport const mapDualBrandButtons = (dualBrandSelectElements: DualBrandSelectElement[], brandsConfiguration: CardBrandsConfiguration): any => {\n return dualBrandSelectElements.map(item => {\n const brand = item.id;\n const getImage = useImage();\n const imageName = brand === 'card' ? 'nocard' : brand;\n const imageURL = brandsConfiguration[brand]?.icon ?? getCardImageUrl(imageName, getImage);\n\n // TODO - check below if we have to still generate altName through the mapping function or whether it just\n // corresponds to item.brandObject.localeBrand\n return {\n id: item.id,\n name: item.brandObject.localeBrand || item.brandObject.brand,\n imageURL,\n altName: getFullBrandName(brand)\n };\n });\n};\n"],"names":["getCardImageUrl","brand","getImage","type","extension","hasValidInstallmentsObject","installments","plan","value","getLayout","props","showKCP","showBrazilianSSN","countrySpecificSchemas","billingAddressRequiredFields","layout","CREDIT_CARD","hasRequiredHolderName","hasHolderName","holderNameRequired","positionHolderNameOnTop","CREDIT_CARD_NAME_TOP","CREDIT_CARD_NAME_BOTTOM","KCP_CARD","KCP_CARD_NAME_TOP","KCP_CARD_NAME_BOTTOM","SSN_CARD","SSN_CARD_NAME_TOP","SSN_CARD_NAME_BOTTOM","countrySpecificSchemasFlat","filter","item","countryBasedAddressLayout","x","includes","concat","mapFieldKey","key","i18n","countrySpecificLabels","get","extractPropsForCardFields","amount","billingAddressRequired","billingAddressAllowedCountries","brandsConfiguration","showStoreDetailsCheckbox","hasCVC","installmentOptions","placeholders","showBrandIcon","showContextualElement","lastFour","expiryMonth","expiryYear","disclaimerMessage","extractPropsForSFP","autoFocus","brands","clientKey","countryCode","forceCompat","implementationType","keypadFix","legacyInputMode","loadingContext","maskSecurityCode","exposeExpiryDate","minimumExpiryDate","onAdditionalSFConfig","onAdditionalSFRemoved","onAllValid","onAutoComplete","onBinValue","onConfigSuccess","handleKeyPress","onError","onFieldValid","onLoad","resources","showWarnings","trimTrailingSeparator","handlePartialAddressMode","addressMode","AddressModeOptions","partial","PARTIAL_ADDRESS_SCHEMA","lookupBlurBasedErrors","errorCode","SF_ErrorCodes","ERROR_MSG_UNSUPPORTED_CARD_ENTERED","ERROR_MSG_CARD_TOO_OLD","ERROR_MSG_CARD_TOO_FAR_IN_FUTURE","ERROR_MSG_CARD_EXPIRES_TOO_SOON","getFullBrandName","BRAND_READABLE_NAME_MAP","getCardConfigData","cardProps","billingAddressMode","DEFAULT_CARD_GROUP_TYPES","challengeWindowSize","DEFAULT_CHALLENGE_WINDOW_SIZE","configuration","data","disableIOSArrowKeys","doBinLookup","enableStoreDetails","fastlaneConfiguration","hideCVC","name","showInstallmentAmounts","showPayButton","styles","onBinLookup","onBlur","onBrand","onEnterKeyPressed","onFocus","dataString","JSON","stringify","CardInputDefaultProps","srPanelEnabled","modules","srPanel","enabled","srPanelMoveFocus","moveFocus","riskEnabled","risk","isFastlaneConfigValid","isFastlaneComponentConfigValid","billingAddressModeValue","onAddressLookup","showKCPType","koreanAuthenticationRequired","toLowerCase","_object_spread","_object_spread_props","length","toString","substring","hasBrandsConfiguration","notFalsy","hasData","hasDisclaimerMessage","hasInstallmentOptions","hasPlaceholders","hasStylesConfigured","socialSecurityNumberMode","hasOnAllValid","hasOnBinValue","hasOnBlur","hasOnBrand","hasOnConfigSuccess","hasOnFieldValid","hasOnFocus","hasOnLoad","hasOnBinLookup","hasOnEnterKeyPressed","hasFastlaneConfigured","isFastlaneConsentDefaultOn","defaultToggleState","mapDualBrandButtons","dualBrandSelectElements","map","id","useImage","imageName","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lD,WACpDgF,cAAe9E,IAAegD,EAAsBhD,WACpD+E,UAAWtC,IAAWO,EAAsBP,OAC5CuC,WAAYtC,IAAYM,EAAsBN,QAC9CuC,mBAAoBhF,KAAoB+C,EAAsB/C,gBAC9DiF,gBAAiB9E,KAAiB4C,EAAsB5C,aACxD+E,WAAYvC,KAAYI,EAAsBJ,QAC9CwC,UAAW/E,KAAW2C,EAAsB3C,OAE5CgF,iBAAkB7C,EAClB8C,uBAAwB3C,KAIpBc,IAAyB,CACzB8B,uBAAuB,EACvBC,2BAA4BtD,EAAsBuD,sBAOjDC,EAAsB,CAACC,EAAmDvH,IAC5EuH,EAAwBC,IAAItI,IAIdc,IAAAA,EAHjB,MAAM5C,EAAQ8B,EAAKuI,GACbpK,EAAWqK,IACXC,EAAsB,SAAVvK,EAAmB,SAAWA,EAC/B4C,IAAAA,EAAjB,MAAM4H,EAA2C,QAAhC5H,EAA0B,QAA1BA,EAAAA,EAAoB5C,UAApB4C,IAAAA,OAAAA,EAAAA,EAA4B6H,YAA5B7H,IAAAA,EAAAA,EAAoC7C,EAAgBwK,EAAWtK,GAIhF,MAAO,CACHoK,GAAIvI,EAAKuI,GACTzD,KAAM9E,EAAK4I,YAAYC,aAAe7I,EAAK4I,YAAY1K,MACvDwK,WACAI,QAAS/E,EAAiB7F"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../../../src/components/Card/components/CardInput/utils.ts"],"sourcesContent":["import Language from '../../../../language/Language';\nimport { AddressModeOptions, CardInputProps, LayoutObj } from './types';\nimport {\n CREDIT_CARD,\n CREDIT_CARD_NAME_BOTTOM,\n CREDIT_CARD_NAME_TOP,\n KCP_CARD,\n KCP_CARD_NAME_BOTTOM,\n KCP_CARD_NAME_TOP,\n SSN_CARD,\n SSN_CARD_NAME_BOTTOM,\n SSN_CARD_NAME_TOP\n} from './layouts';\nimport { AddressSpecifications, StringObject } from '../../../internal/Address/types';\nimport { PARTIAL_ADDRESS_SCHEMA } from '../../../internal/Address/constants';\nimport { InstallmentsObj } from './components/Installments/Installments';\nimport { SFPProps } from '../../../internal/SecuredFields/SFP/types';\nimport { BRAND_READABLE_NAME_MAP, DEFAULT_CARD_GROUP_TYPES } from '../../../internal/SecuredFields/lib/constants';\nimport useImage, { UseImageHookType } from '../../../../core/Context/useImage';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\nimport { BrandObject, CardBrandsConfiguration, CardConfiguration, DualBrandSelectElement } from '../../types';\nimport { CardConfigData } from '../../../../core/Analytics/types';\nimport { DEFAULT_CHALLENGE_WINDOW_SIZE } from '../../../ThreeDS2/constants';\nimport CardInputDefaultProps from './defaultProps';\nimport { isConfigurationValid as isFastlaneComponentConfigValid } from '../Fastlane/utils/validate-configuration';\nimport { notFalsy } from '../../../../utils/commonUtils';\n\nexport const getCardImageUrl = (brand: string, getImage: UseImageHookType): string => {\n const imageOptions = {\n type: brand === 'card' ? 'nocard' : brand || 'nocard',\n extension: 'svg'\n };\n\n return getImage(imageOptions)(brand);\n};\n\n/**\n * Verifies that installment object is valid to send to the Backend.\n * Valid means that it has 'revolving' plan set, or the number of installments is bigger than one\n */\nexport const hasValidInstallmentsObject = (installments?: InstallmentsObj) => {\n return installments?.plan === 'revolving' || installments?.value > 1;\n};\n\nexport const getLayout = ({\n props,\n showKCP,\n showBrazilianSSN,\n countrySpecificSchemas = null,\n billingAddressRequiredFields = null\n}: LayoutObj): string[] => {\n let layout = CREDIT_CARD;\n const hasRequiredHolderName = props.hasHolderName && props.holderNameRequired;\n\n if (hasRequiredHolderName) {\n layout = props.positionHolderNameOnTop ? CREDIT_CARD_NAME_TOP : CREDIT_CARD_NAME_BOTTOM;\n }\n\n if (showKCP) {\n layout = KCP_CARD;\n if (hasRequiredHolderName) {\n layout = props.positionHolderNameOnTop ? KCP_CARD_NAME_TOP : KCP_CARD_NAME_BOTTOM;\n }\n }\n\n if (showBrazilianSSN) {\n layout = SSN_CARD;\n if (hasRequiredHolderName) {\n layout = props.positionHolderNameOnTop ? SSN_CARD_NAME_TOP : SSN_CARD_NAME_BOTTOM;\n }\n }\n\n // w. Billing address\n if (countrySpecificSchemas) {\n // Flatten array and remove any numbers that describe how fields should be aligned\n const countrySpecificSchemasFlat: string[] = countrySpecificSchemas['flat'](2).filter(item => typeof item !== 'number') as string[];\n\n let countryBasedAddressLayout = countrySpecificSchemasFlat;\n\n if (billingAddressRequiredFields) {\n // Get intersection of the 2 arrays\n countryBasedAddressLayout = countrySpecificSchemasFlat.filter(x => billingAddressRequiredFields.includes(x));\n }\n\n layout = CREDIT_CARD.concat(countryBasedAddressLayout);\n if (hasRequiredHolderName) {\n layout = props.positionHolderNameOnTop\n ? CREDIT_CARD_NAME_TOP.concat(countryBasedAddressLayout)\n : CREDIT_CARD_NAME_BOTTOM.concat(countryBasedAddressLayout);\n }\n // TODO we are not yet creating a layout for AVS + SSN field (w. or w/o holderName) - is AVS + SSN a real world scenario?\n }\n return layout;\n};\n\n/**\n * Lookup service to map local (CardInput) field refs to a key, possibly region specific, by which to retrieve the translation\n */\nexport const mapFieldKey = (key: string, i18n: Language, countrySpecificLabels: StringObject): string => {\n // console.log('### utils::mapFieldKey:: key', key);\n switch (key) {\n case 'socialSecurityNumber':\n return i18n.get(`boleto.${key}`);\n // Address related - if we have a country specific key for the field - use that to get the translation\n case 'street':\n case 'houseNumberOrName':\n case 'postalCode':\n case 'stateOrProvince':\n case 'city':\n case 'country':\n return countrySpecificLabels?.[key] ? i18n.get(countrySpecificLabels?.[key]) : i18n.get(key);\n // We know that the translated error messages do contain a reference to the field they refer to, so we won't need to map them (currently applies mostly to SecuredFields related errors)\n default:\n return null;\n }\n};\n\nexport const extractPropsForCardFields = (props: CardInputProps) => {\n return {\n // Extract props for CardFieldsWrapper & StoredCardFieldsWrapper(just needs amount, hasCVC, installmentOptions)\n amount: props.amount,\n billingAddressRequired: props.billingAddressRequired,\n billingAddressRequiredFields: props.billingAddressRequiredFields,\n billingAddressAllowedCountries: props.billingAddressAllowedCountries,\n brandsConfiguration: props.brandsConfiguration,\n showStoreDetailsCheckbox: props.showStoreDetailsCheckbox,\n hasCVC: props.hasCVC,\n hasHolderName: props.hasHolderName,\n holderNameRequired: props.holderNameRequired,\n installmentOptions: props.installmentOptions,\n placeholders: props.placeholders,\n positionHolderNameOnTop: props.positionHolderNameOnTop,\n // Extract props for CardFields > CardNumber\n showBrandIcon: props.showBrandIcon,\n showContextualElement: props.showContextualElement,\n // Extract props for StoredCardFields\n lastFour: props.lastFour,\n expiryMonth: props.expiryMonth,\n expiryYear: props.expiryYear,\n disclaimerMessage: props.disclaimerMessage\n };\n};\n\nexport const extractPropsForSFP = (props: CardInputProps) => {\n return {\n autoFocus: props.autoFocus,\n brands: props.brands,\n brandsConfiguration: props.brandsConfiguration,\n clientKey: props.clientKey,\n countryCode: props.countryCode,\n forceCompat: props.forceCompat,\n i18n: props.i18n,\n implementationType: props.implementationType,\n keypadFix: props.keypadFix,\n legacyInputMode: props.legacyInputMode,\n loadingContext: props.loadingContext,\n maskSecurityCode: props.maskSecurityCode,\n exposeExpiryDate: props.exposeExpiryDate,\n minimumExpiryDate: props.minimumExpiryDate,\n onAdditionalSFConfig: props.onAdditionalSFConfig,\n onAdditionalSFRemoved: props.onAdditionalSFRemoved,\n onAllValid: props.onAllValid,\n onAutoComplete: props.onAutoComplete,\n onBinValue: props.onBinValue,\n onConfigSuccess: props.onConfigSuccess,\n handleKeyPress: props.handleKeyPress,\n onError: props.onError,\n onFieldValid: props.onFieldValid,\n onLoad: props.onLoad,\n placeholders: props.placeholders,\n resources: props.resources,\n showContextualElement: props.showContextualElement,\n showWarnings: props.showWarnings,\n trimTrailingSeparator: props.trimTrailingSeparator\n } as SFPProps; // Can't set as return type on fn or it will complain about missing, mandatory, props\n};\n\nexport const handlePartialAddressMode = (addressMode: AddressModeOptions): AddressSpecifications | null => {\n return addressMode == AddressModeOptions.partial ? PARTIAL_ADDRESS_SCHEMA : null;\n};\n\n// Almost all errors are blur based, but some SF ones are not i.e. when an unsupported card is entered or the expiry date is out of range\nexport function lookupBlurBasedErrors(errorCode) {\n // If it's NOT one of these, then it's a blur based error\n return ![\n SF_ErrorCodes.ERROR_MSG_UNSUPPORTED_CARD_ENTERED,\n SF_ErrorCodes.ERROR_MSG_CARD_TOO_OLD,\n SF_ErrorCodes.ERROR_MSG_CARD_TOO_FAR_IN_FUTURE,\n SF_ErrorCodes.ERROR_MSG_CARD_EXPIRES_TOO_SOON\n ].includes(errorCode);\n}\n\nexport function getFullBrandName(brand) {\n return BRAND_READABLE_NAME_MAP[brand] ?? brand;\n}\n\nexport const getCardConfigData = (cardProps: CardConfiguration): CardConfigData => {\n const MAX_LENGTH = 128;\n\n // Extract props from cardProps - mostly setting a default value, if prop not found\n const {\n autoFocus,\n billingAddressAllowedCountries,\n billingAddressMode,\n billingAddressRequired,\n billingAddressRequiredFields,\n brands = DEFAULT_CARD_GROUP_TYPES,\n brandsConfiguration,\n challengeWindowSize = DEFAULT_CHALLENGE_WINDOW_SIZE,\n configuration,\n countryCode,\n data,\n disclaimerMessage,\n disableIOSArrowKeys,\n doBinLookup,\n enableStoreDetails,\n exposeExpiryDate,\n fastlaneConfiguration,\n forceCompat,\n hasHolderName,\n hideCVC,\n holderNameRequired,\n installmentOptions,\n keypadFix,\n legacyInputMode,\n maskSecurityCode,\n minimumExpiryDate,\n name, // = 'none',\n placeholders,\n positionHolderNameOnTop,\n showBrandIcon,\n showInstallmentAmounts,\n showPayButton = false, // hard coded default\n styles,\n onAllValid,\n onBinLookup,\n onBinValue,\n onBlur,\n onBrand,\n onConfigSuccess,\n onEnterKeyPressed,\n onFieldValid,\n onFocus,\n onLoad\n } = cardProps;\n\n const dataString = JSON.stringify(CardInputDefaultProps.data);\n\n const srPanelEnabled = cardProps.modules?.srPanel?.enabled;\n const srPanelMoveFocus = cardProps.modules?.srPanel?.moveFocus;\n\n const riskEnabled = cardProps.modules?.risk?.enabled;\n\n const isFastlaneConfigValid = isFastlaneComponentConfigValid(fastlaneConfiguration);\n\n const billingAddressModeValue = cardProps.onAddressLookup ? 'lookup' : billingAddressMode;\n\n let showKCPType: 'none' | 'auto' | 'atStart' = 'none';\n if (configuration?.koreanAuthenticationRequired === true) {\n showKCPType = countryCode?.toLowerCase() === 'kr' ? 'atStart' : 'auto';\n }\n\n const configData: CardConfigData = {\n autoFocus,\n ...(billingAddressAllowedCountries?.length > 0 && {\n billingAddressAllowedCountries: billingAddressAllowedCountries.toString().substring(0, MAX_LENGTH)\n }),\n billingAddressMode: billingAddressModeValue,\n billingAddressRequired,\n billingAddressRequiredFields: billingAddressRequiredFields?.toString()?.substring(0, MAX_LENGTH),\n // Probably just for development - in real life we wouldn't expect the number of supported brands to push the endpoint limit on 128 chars\n brands: brands?.toString()?.substring(0, MAX_LENGTH),\n challengeWindowSize,\n disableIOSArrowKeys,\n doBinLookup,\n enableStoreDetails,\n exposeExpiryDate,\n forceCompat,\n hasBrandsConfiguration: notFalsy(brandsConfiguration),\n hasData: data && JSON.stringify(cardProps.data) !== dataString,\n hasDisclaimerMessage: !!disclaimerMessage,\n hasHolderName,\n hasInstallmentOptions: notFalsy(installmentOptions),\n hasPlaceholders: notFalsy(placeholders), // has merchant defined placeholders\n hasStylesConfigured: notFalsy(styles),\n hideCVC,\n holderNameRequired,\n keypadFix,\n legacyInputMode,\n maskSecurityCode,\n minimumExpiryDate: !!minimumExpiryDate, // Potentially, in the future, we can send the actual string value\n name,\n positionHolderNameOnTop,\n riskEnabled,\n showBrandIcon,\n showInstallmentAmounts: !!showInstallmentAmounts,\n showKCPType,\n showPayButton,\n socialSecurityNumberMode: configuration?.socialSecurityNumberMode,\n srPanelEnabled,\n srPanelMoveFocus,\n /** callbacks */\n // We need to detect if the merchant themselves has defined these, not if we've set them as a default\n hasOnAllValid: onAllValid !== CardInputDefaultProps.onAllValid,\n hasOnBinValue: onBinValue !== CardInputDefaultProps.onBinValue,\n hasOnBlur: onBlur !== CardInputDefaultProps.onBlur,\n hasOnBrand: onBrand !== CardInputDefaultProps.onBrand,\n hasOnConfigSuccess: onConfigSuccess !== CardInputDefaultProps.onConfigSuccess,\n hasOnFieldValid: onFieldValid !== CardInputDefaultProps.onFieldValid,\n hasOnFocus: onFocus !== CardInputDefaultProps.onFocus,\n hasOnLoad: onLoad !== CardInputDefaultProps.onLoad,\n // Card level props\n hasOnBinLookup: !!onBinLookup,\n hasOnEnterKeyPressed: !!onEnterKeyPressed,\n /**\n * Fastlane\n */\n ...(isFastlaneConfigValid && {\n hasFastlaneConfigured: true,\n isFastlaneConsentDefaultOn: fastlaneConfiguration.defaultToggleState\n })\n };\n\n return configData;\n};\n\nexport const mapDualBrandButtons = (dualBrandSelectElements: DualBrandSelectElement[], brandsConfiguration: CardBrandsConfiguration): any => {\n return dualBrandSelectElements.map(item => {\n const brand = item.id;\n const getImage = useImage();\n const imageName = brand === 'card' ? 'nocard' : brand;\n const imageURL = brandsConfiguration[brand]?.icon ?? getCardImageUrl(imageName, getImage);\n\n // TODO - check below if we have to still generate altName through the mapping function or whether it just\n // corresponds to item.brandObject.localeBrand\n return {\n id: item.id,\n name: item.brandObject.localeBrand || item.brandObject.brand,\n imageURL,\n altName: getFullBrandName(brand)\n };\n });\n};\n\n/**\n * Only if the brands in EU_BrandArray are present in the binLookup response should we handle dual branding based on EU regulations\n *\n * If the result from Array.filter contains anything - then we are in a EU dual branding regulation scenario, i.e.\n * - Show the new dualBranding UI Buttons\n * - Preselect a card brand\n */\nexport const mustHandleDualBrandingAccordingToEURegulations = (\n EU_BrandArray: string[],\n returnedDualBrandingObjects: DualBrandSelectElement[] | BrandObject[],\n key: string\n) => !!returnedDualBrandingObjects.filter(item => EU_BrandArray.includes(item[key])).length;\n"],"names":["getCardImageUrl","brand","getImage","type","extension","hasValidInstallmentsObject","installments","plan","value","getLayout","props","showKCP","showBrazilianSSN","countrySpecificSchemas","billingAddressRequiredFields","layout","CREDIT_CARD","hasRequiredHolderName","hasHolderName","holderNameRequired","positionHolderNameOnTop","CREDIT_CARD_NAME_TOP","CREDIT_CARD_NAME_BOTTOM","KCP_CARD","KCP_CARD_NAME_TOP","KCP_CARD_NAME_BOTTOM","SSN_CARD","SSN_CARD_NAME_TOP","SSN_CARD_NAME_BOTTOM","countrySpecificSchemasFlat","filter","item","countryBasedAddressLayout","x","includes","concat","mapFieldKey","key","i18n","countrySpecificLabels","get","extractPropsForCardFields","amount","billingAddressRequired","billingAddressAllowedCountries","brandsConfiguration","showStoreDetailsCheckbox","hasCVC","installmentOptions","placeholders","showBrandIcon","showContextualElement","lastFour","expiryMonth","expiryYear","disclaimerMessage","extractPropsForSFP","autoFocus","brands","clientKey","countryCode","forceCompat","implementationType","keypadFix","legacyInputMode","loadingContext","maskSecurityCode","exposeExpiryDate","minimumExpiryDate","onAdditionalSFConfig","onAdditionalSFRemoved","onAllValid","onAutoComplete","onBinValue","onConfigSuccess","handleKeyPress","onError","onFieldValid","onLoad","resources","showWarnings","trimTrailingSeparator","handlePartialAddressMode","addressMode","AddressModeOptions","partial","PARTIAL_ADDRESS_SCHEMA","lookupBlurBasedErrors","errorCode","SF_ErrorCodes","ERROR_MSG_UNSUPPORTED_CARD_ENTERED","ERROR_MSG_CARD_TOO_OLD","ERROR_MSG_CARD_TOO_FAR_IN_FUTURE","ERROR_MSG_CARD_EXPIRES_TOO_SOON","getFullBrandName","BRAND_READABLE_NAME_MAP","getCardConfigData","cardProps","billingAddressMode","DEFAULT_CARD_GROUP_TYPES","challengeWindowSize","DEFAULT_CHALLENGE_WINDOW_SIZE","configuration","data","disableIOSArrowKeys","doBinLookup","enableStoreDetails","fastlaneConfiguration","hideCVC","name","showInstallmentAmounts","showPayButton","styles","onBinLookup","onBlur","onBrand","onEnterKeyPressed","onFocus","dataString","JSON","stringify","CardInputDefaultProps","srPanelEnabled","modules","srPanel","enabled","srPanelMoveFocus","moveFocus","riskEnabled","risk","isFastlaneConfigValid","isFastlaneComponentConfigValid","billingAddressModeValue","onAddressLookup","showKCPType","koreanAuthenticationRequired","toLowerCase","_object_spread","_object_spread_props","length","toString","substring","hasBrandsConfiguration","notFalsy","hasData","hasDisclaimerMessage","hasInstallmentOptions","hasPlaceholders","hasStylesConfigured","socialSecurityNumberMode","hasOnAllValid","hasOnBinValue","hasOnBlur","hasOnBrand","hasOnConfigSuccess","hasOnFieldValid","hasOnFocus","hasOnLoad","hasOnBinLookup","hasOnEnterKeyPressed","hasFastlaneConfigured","isFastlaneConsentDefaultOn","defaultToggleState","mapDualBrandButtons","dualBrandSelectElements","map","id","useImage","imageName","imageURL","icon","brandObject","localeBrand","altName","mustHandleDualBrandingAccordingToEURegulations","EU_BrandArray","returnedDualBrandingObjects"],"mappings":"0nDA2BO,MAAMA,EAAkB,CAACC,EAAeC,IAMpCA,EALc,CACjBC,KAAgB,SAAVF,EAAmB,SAAWA,GAAS,SAC7CG,UAAW,OAGRF,CAAuBD,GAOrBI,EAA8BC,GACT,eAAvBA,aAAAA,EAAAA,EAAcC,QAAwBD,aAAAA,EAAAA,EAAcE,OAAQ,EAG1DC,EAAY,EACrBC,QACAC,UACAC,mBACAC,yBAAyB,KACzBC,+BAA+B,SAE/B,IAAIC,EAASC,EACb,MAAMC,EAAwBP,EAAMQ,eAAiBR,EAAMS,mBAqB3D,GAnBIF,IACAF,EAASL,EAAMU,wBAA0BC,EAAuBC,GAGhEX,IACAI,EAASQ,EACLN,IACAF,EAASL,EAAMU,wBAA0BI,EAAoBC,IAIjEb,IACAG,EAASW,EACLT,IACAF,EAASL,EAAMU,wBAA0BO,EAAoBC,IAKjEf,EAAwB,CAExB,MAAMgB,EAAuChB,EAAuB,KAAQ,GAAGiB,OAAOC,GAAwB,iBAATA,GAErG,IAAIC,EAA4BH,EAE5Bf,IAEAkB,EAA4BH,EAA2BC,OAAOG,GAAKnB,EAA6BoB,SAASD,KAG7GlB,EAASC,EAAYmB,OAAOH,GACxBf,IACAF,EAASL,EAAMU,wBACTC,EAAqBc,OAAOH,GAC5BV,EAAwBa,OAAOH,GAG7C,CACA,OAAOjB,GAMEqB,EAAc,CAACC,EAAaC,EAAgB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I,SAASH,EAAKM,KAAOsG"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../external/preact/dist/preact.js";import{CoreProvider as t}from"../../core/Context/CoreProvider.js";import{TxVariants as r}from"../tx-variants.js";import{UIElement as n}from"../internal/UIElement/UIElement.js";import
|
|
1
|
+
import{createElement as e}from"../../external/preact/dist/preact.js";import{CoreProvider as t}from"../../core/Context/CoreProvider.js";import{TxVariants as r}from"../tx-variants.js";import{UIElement as n}from"../internal/UIElement/UIElement.js";import o from"../../core/Errors/SRPanelProvider.js";import i from"../internal/RedirectButton/RedirectButton.js";import s,{ERROR as a}from"../../core/Errors/AdyenCheckoutError.js";import{PasskeyService as p}from"./services/PasskeyService.js";import{authorizeEnrollment as d}from"./services/authorizeEnrollment.js";import{authorizePayment as l}from"./services/authorizePayment.js";import h from"./components/StoredPayment/StoredPayment.js";import c from"./components/Enrollment/Enrollment.js";function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){y(e,t,r[t])})}return e}function u(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function v(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}class f extends n{get isValid(){var e;return!(this.props._isAdyenHosted&&!this.props.storedPaymentMethodId)||!!(null===(e=this.state)||void 0===e?void 0:e.isValid)}get additionalInfo(){var e,t;return this.props.storedPaymentMethodId?this.props.i18n.get("paybybankpix.storedPayment.additionalLabel",{values:{receiver:null===(t=this.props)||void 0===t||null===(e=t.payByBankPixDetails)||void 0===e?void 0:e.receiver}}):""}get icon(){var e,t;return this.props.storedPaymentMethodId?this.resources.getImage({parentFolder:`${f.type}/`})(null===(t=this.props)||void 0===t||null===(e=t.payByBankPixDetails)||void 0===e?void 0:e.ispb):super.icon}async isAvailable(){const e=await this.passkeyService.getWebAuthnUnsupportedReason();if(e)return Promise.reject(new s(a,e));if(!this.props._isAdyenHosted)return Promise.resolve();try{if(await this.passkeyService.initialize(),this.props.storedPaymentMethodId){return await this.passkeyService.canUseStoredCredential()?Promise.resolve():Promise.reject(new s("ERROR","The stored payment method is not available on this device"))}return Promise.resolve()}catch(e){return Promise.reject(e instanceof Error?null==e?void 0:e.message:"Unknown error")}}handleAction(e,t={}){const r=this.core.createFromAction(e,u(m({},this.elementRef.props,t),{onAdditionalDetails:this.handleAdditionalDetails}));return r?(this.unmount(),r.isAvailable().then(()=>{r.mount(this._node)}),r):null}formatData(){if(!this.props._isAdyenHosted)return{paymentMethod:{type:r.paybybank_pix}};const e=null==this.props.storedPaymentMethodId;return m({paymentMethod:m({type:r.paybybank_pix},this.state.data)},e?{storePaymentMethod:!0}:{})}render(){var r,n,s;return this.props._isAdyenHosted?e(t,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},e(o,{srPanel:this.props.modules.srPanel},null!=this.props.storedPaymentMethodId?e(h,{txVariant:f.type,type:this.props.type,clientKey:this.props.clientKey,amount:this.props.amount,enrollmentId:null===(r=this.props.paymentMethodData)||void 0===r?void 0:r.enrollmentId,initiationId:null===(n=this.props.paymentMethodData)||void 0===n?void 0:n.initiationId,setComponentRef:this.setComponentRef,onPay:this.payWithStoredPayment,onAuthorize:this.authorizePayment}):e(c,{onError:this.handleError,txVariant:f.type,type:this.props.type,clientKey:this.props.clientKey,enrollmentId:null===(s=this.props.paymentMethodData)||void 0===s?void 0:s.enrollmentId,countdownTime:this.props.countdownTime,onEnroll:this.authorizeEnrollment,issuers:this.props.issuers,payButton:this.payButton,onChange:this.onIssuerSelected,onSubmitAnalytics:this.submitAnalytics,setComponentRef:this.setComponentRef}))):e(t,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},e(o,{srPanel:this.props.modules.srPanel},e(i,{showPayButton:this.props.showPayButton,name:this.displayName,label:this.props.i18n.get("paybybankpix.redirectBtn.label"),amount:this.props.amount,payButton:this.payButton,onSubmit:this.submit,ref:e=>{this.componentRef=e}})))}constructor(e,t){var r,n;super(e,t),y(this,"passkeyService",void 0),y(this,"onIssuerSelected",async e=>{try{const{data:t={}}=e;if(!t.issuer)return;const r=await this.passkeyService.captureRiskSignalsEnrollment(),{deviceId:n}=r,o=v(r,["deviceId"]);this.setState(u(m({},e),{data:u(m({},t),{riskSignals:o,deviceId:n})}))}catch(e){const t=e instanceof Error?e.message:"Unknown error in the onIssuerSelected";this.handleError(e instanceof s?e:new s(a,t))}}),y(this,"authorizeEnrollment",async e=>{try{var t;const r=await this.passkeyService.createCredentialForEnrollment(e),n={enrollmentId:null===(t=this.props.paymentMethodData)||void 0===t?void 0:t.enrollmentId,fidoAssertion:r},{redirectResult:o}=await d({enrollment:n,clientKey:this.props.clientKey,loadingContext:this.props.loadingContext});this.handleAdditionalDetails({data:{details:{redirectResult:o}}})}catch(e){const t=e instanceof Error?e.message:"Unknown error in the authorizeEnrollment";this.handleError(e instanceof s?e:new s(a,t))}}),y(this,"payWithStoredPayment",async()=>{try{const e=await this.passkeyService.captureRiskSignalsAuthentication(),{deviceId:t}=e,r=v(e,["deviceId"]);this.state=m({},this.state,{data:{storedPaymentMethodId:this.props.storedPaymentMethodId,riskSignals:r,deviceId:t}}),super.submit()}catch(e){const t=e instanceof Error?e.message:"Unknown error in the payWithStoredPayment";this.handleError(e instanceof s?e:new s(a,t))}}),y(this,"authorizePayment",async e=>{try{var t,r;const n=await this.passkeyService.authenticateWithCredential(e),o={enrollmentId:null===(t=this.props.paymentMethodData)||void 0===t?void 0:t.enrollmentId,initiationId:null===(r=this.props.paymentMethodData)||void 0===r?void 0:r.initiationId,fidoAssertion:n},{redirectResult:i}=await l({payment:o,clientKey:this.props.clientKey,loadingContext:this.props.loadingContext});this.handleAdditionalDetails({data:{details:{redirectResult:i}}})}catch(e){const t=e instanceof Error?e.message:"Unknown error in the authorizePayment";this.handleError(e instanceof s?e:new s(a,t))}});const o=this.props.storedPaymentMethodId?null===(n=this.props)||void 0===n||null===(r=n.payByBankPixDetails)||void 0===r?void 0:r.deviceId:this.props.deviceId;this.passkeyService=new p({environment:this.props.environment,deviceId:o}),this.props._isAdyenHosted&&this.passkeyService.initialize()}}y(f,"type",r.paybybank_pix),y(f,"TIMEOUT_MINUTES",1),y(f,"defaultProps",{showPayButton:!0,_isAdyenHosted:(()=>{try{return new URL(window.location.href).hostname.endsWith(".adyen.com")}catch(e){return!1}})(),countdownTime:f.TIMEOUT_MINUTES});export{f as default};
|
|
2
2
|
//# sourceMappingURL=PayByBankPix.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayByBankPix.js","sources":["../../../../src/components/PayByBankPix/PayByBankPix.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport { PayByBankPixData, PayByBankPixConfiguration } from './types';\nimport { TxVariants } from '../tx-variants';\nimport UIElement from '../internal/UIElement';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport RedirectButton from '../internal/RedirectButton';\nimport AdyenCheckoutError, { ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { PasskeyService } from './services/PasskeyService';\nimport { authorizeEnrollment } from './services/authorizeEnrollment';\nimport { authorizePayment } from './services/authorizePayment';\nimport StoredPayment from './components/StoredPayment';\nimport Enrollment from './components/Enrollment';\nimport { PaymentAction } from '../../types/global-types';\nimport type { ICore } from '../../core/types';\n\nconst isAdyenHosted = () => {\n try {\n const currentUrl = new URL(window.location.href);\n return currentUrl.hostname.endsWith('.adyen.com');\n } catch (e) {\n // SSR, or it fails to parse the full url\n return false;\n }\n};\nclass PayByBankPixElement extends UIElement<PayByBankPixConfiguration> {\n public static readonly type = TxVariants.paybybank_pix;\n private static readonly TIMEOUT_MINUTES = 1;\n private readonly passkeyService: PasskeyService;\n\n public static readonly defaultProps: PayByBankPixConfiguration = {\n showPayButton: true,\n _isAdyenHosted: isAdyenHosted(),\n countdownTime: PayByBankPixElement.TIMEOUT_MINUTES\n };\n\n constructor(checkout: ICore, props?: PayByBankPixConfiguration) {\n super(checkout, props);\n const deviceId = this.props.storedPaymentMethodId ? this.props?.payByBankPixDetails?.deviceId : this.props.deviceId;\n this.passkeyService = new PasskeyService({ environment: this.props.environment, deviceId });\n if (this.props._isAdyenHosted) {\n void this.passkeyService.initialize();\n }\n }\n\n get isValid(): boolean {\n // Always true for non-hosted page or stored payment\n if (!this.props._isAdyenHosted || this.props.storedPaymentMethodId) {\n return true;\n }\n return !!this.state?.isValid;\n }\n\n /**\n * Display in the drop-in\n */\n get additionalInfo() {\n return this.props.storedPaymentMethodId\n ? this.props.i18n.get('paybybankpix.storedPayment.additionalLabel', { values: { receiver: this.props?.payByBankPixDetails?.receiver } })\n : '';\n }\n\n /**\n * Display in the drop-in\n */\n public override get icon() {\n return this.props.storedPaymentMethodId\n ? this.resources.getImage({ parentFolder: `${PayByBankPixElement.type}/` })(this.props?.payByBankPixDetails?.ispb)\n : super.icon;\n }\n\n /**\n * Method used to let the merchant know if the shopper's device supports WebAuthn APIs: https://featuredetect.passkeys.dev/\n */\n public override async isAvailable(): Promise<void> {\n const unsupportedReason = await this.passkeyService.getWebAuthnUnsupportedReason();\n if (unsupportedReason) {\n return Promise.reject(new AdyenCheckoutError(ERROR, unsupportedReason));\n }\n if (!this.props._isAdyenHosted) {\n return Promise.resolve();\n }\n\n // Load passkey sdk on the hosted page\n try {\n await this.passkeyService.initialize();\n\n if (this.props.storedPaymentMethodId) {\n // If the provided deviceId from the server does not match the localstorage deviceId, do not render the stored payment component.\n const shouldShowStoredPaymentMethod = await this.passkeyService.canUseStoredCredential();\n return shouldShowStoredPaymentMethod\n ? Promise.resolve()\n : Promise.reject(new AdyenCheckoutError('ERROR', 'The stored payment method is not available on this device'));\n }\n\n return Promise.resolve();\n } catch (error) {\n return Promise.reject(error instanceof Error ? error?.message : 'Unknown error');\n }\n }\n\n /**\n * Make sure the await action UIElement is available before mounting\n */\n public override handleAction(action: PaymentAction, props: {} = {}): UIElement | null {\n const paymentAction = this.core.createFromAction(action, {\n ...this.elementRef.props,\n ...props,\n onAdditionalDetails: this.handleAdditionalDetails\n });\n if (paymentAction) {\n this.unmount();\n void paymentAction.isAvailable().then(() => {\n paymentAction.mount(this._node);\n });\n return paymentAction;\n }\n\n return null;\n }\n\n formatData(): PayByBankPixData {\n if (!this.props._isAdyenHosted) {\n return {\n paymentMethod: { type: TxVariants.paybybank_pix }\n };\n }\n\n const isEnrollment = this.props.storedPaymentMethodId == null;\n return {\n paymentMethod: { type: TxVariants.paybybank_pix, ...this.state.data },\n // Always store the payment method for the enrollment flow.\n ...(isEnrollment ? { storePaymentMethod: true } : {})\n };\n }\n\n /**\n * There are 3 endpoints (stages) we need to call for the enrollment flow.\n * The first one is the regular payments call on issuer selection - we indicate to store the payment token for the selected issuer.\n * The second one is to poll the enrollment eligibility - we poll the server to get the enrollment challenge in the `getEnrollmentStatus` function.\n * The third one is in the `authorizeEnrollment` function - we create passkeys and authorize the enrollment with shopper's passkey.\n */\n private readonly onIssuerSelected = async payload => {\n try {\n const { data = {} } = payload;\n if (!data.issuer) {\n return;\n }\n\n const { deviceId, ...riskSignals } = await this.passkeyService.captureRiskSignalsEnrollment();\n this.setState({ ...payload, data: { ...data, riskSignals, deviceId } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the onIssuerSelected';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n private readonly authorizeEnrollment = async (registrationOptions: string): Promise<void> => {\n try {\n const fidoAssertion = await this.passkeyService.createCredentialForEnrollment(registrationOptions); // Create passkey and trigger biometrics\n const enrollment = { enrollmentId: this.props.paymentMethodData?.enrollmentId, fidoAssertion };\n const { redirectResult } = await authorizeEnrollment({\n enrollment,\n clientKey: this.props.clientKey,\n loadingContext: this.props.loadingContext\n });\n // Make paymentDetails call to finalize the enrollment.\n this.handleAdditionalDetails({ data: { details: { redirectResult } } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the authorizeEnrollment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n /**\n * There are 3 endpoints (stages) we need to call for the payment flow.\n * The first one `payWithStoredPayment` is the regular payments call - we attempt to pay with the stored payment token.\n * The second one is to poll the authorization options - we poll the server to get the challenge in the `getAuthorizationStatus` function.\n * The third one is in the `authorizePayment` function - we authorize the payment with shopper's passkey.\n */\n private readonly payWithStoredPayment = async () => {\n try {\n const { deviceId, ...riskSignals } = await this.passkeyService.captureRiskSignalsAuthentication();\n this.state = { ...this.state, ...{ data: { storedPaymentMethodId: this.props.storedPaymentMethodId, riskSignals, deviceId } } };\n super.submit();\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the payWithStoredPayment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n private readonly authorizePayment = async (authenticationOptions: string): Promise<void> => {\n try {\n const fidoAssertion = await this.passkeyService.authenticateWithCredential(authenticationOptions);\n const payment = {\n enrollmentId: this.props.paymentMethodData?.enrollmentId,\n initiationId: this.props.paymentMethodData?.initiationId,\n fidoAssertion\n };\n const { redirectResult } = await authorizePayment({\n payment,\n clientKey: this.props.clientKey,\n loadingContext: this.props.loadingContext\n });\n this.handleAdditionalDetails({ data: { details: { redirectResult } } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the authorizePayment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n render() {\n // Always render the redirect button on the merchant's page\n if (!this.props._isAdyenHosted) {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.displayName}\n label={this.props.i18n.get('paybybankpix.redirectBtn.label')}\n amount={this.props.amount}\n payButton={this.payButton}\n onSubmit={this.submit}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n {this.props.storedPaymentMethodId != null ? (\n <StoredPayment\n txVariant={PayByBankPixElement.type}\n type={this.props.type}\n clientKey={this.props.clientKey}\n amount={this.props.amount}\n issuer={this.props?.payByBankPixDetails?.ispb}\n receiver={this.props?.payByBankPixDetails?.receiver}\n enrollmentId={this.props.paymentMethodData?.enrollmentId}\n initiationId={this.props.paymentMethodData?.initiationId}\n setComponentRef={this.setComponentRef}\n onPay={this.payWithStoredPayment}\n onAuthorize={this.authorizePayment}\n />\n ) : (\n <Enrollment\n onError={this.handleError}\n txVariant={PayByBankPixElement.type}\n // Await\n type={this.props.type}\n clientKey={this.props.clientKey}\n enrollmentId={this.props.paymentMethodData?.enrollmentId}\n countdownTime={this.props.countdownTime}\n onEnroll={this.authorizeEnrollment}\n // Issuer List\n issuers={this.props.issuers}\n payButton={this.payButton}\n onChange={this.onIssuerSelected}\n onSubmitAnalytics={this.submitAnalytics}\n setComponentRef={this.setComponentRef}\n />\n )}\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n//\nexport default PayByBankPixElement;\n"],"names":["PayByBankPixElement","UIElement","isValid","_this_state","this","props","_isAdyenHosted","storedPaymentMethodId","state","additionalInfo","_this_props_payByBankPixDetails","_this_props","i18n","get","values","receiver","payByBankPixDetails","icon","resources","getImage","parentFolder","type","ispb","super","isAvailable","unsupportedReason","passkeyService","getWebAuthnUnsupportedReason","Promise","reject","AdyenCheckoutError","ERROR","resolve","initialize","canUseStoredCredential","error","Error","message","handleAction","action","paymentAction","core","createFromAction","_object_spread_props","_object_spread","elementRef","onAdditionalDetails","handleAdditionalDetails","unmount","then","mount","_node","formatData","paymentMethod","TxVariants","paybybank_pix","isEnrollment","data","storePaymentMethod","render","_this_props_payByBankPixDetails1","_this_props1","_this_props_paymentMethodData","_this_props_paymentMethodData1","_this_props_paymentMethodData2","h","CoreProvider","loadingContext","SRPanelProvider","srPanel","modules","StoredPayment","txVariant","clientKey","amount","issuer","enrollmentId","paymentMethodData","initiationId","setComponentRef","onPay","payWithStoredPayment","onAuthorize","authorizePayment","Enrollment","onError","handleError","countdownTime","onEnroll","authorizeEnrollment","issuers","payButton","onChange","onIssuerSelected","onSubmitAnalytics","submitAnalytics","RedirectButton","showPayButton","name","displayName","label","onSubmit","submit","ref","componentRef","constructor","checkout","_define_property","async","payload","_ref","captureRiskSignalsEnrollment","deviceId","riskSignals","setState","errorMsg","registrationOptions","fidoAssertion","createCredentialForEnrollment","enrollment","redirectResult","details","captureRiskSignalsAuthentication","authenticationOptions","authenticateWithCredential","payment","PasskeyService","environment","TIMEOUT_MINUTES","defaultProps","URL","window","location","href","hostname","endsWith","e","isAdyenHosted"],"mappings":"63DAyBA,MAAMA,UAA4BC,EAoB9B,WAAIC,GAKS,IAAAC,EAHT,QAAKC,KAAKC,MAAMC,iBAAkBF,KAA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ankPix/PayByBankPix.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport { PayByBankPixData, PayByBankPixConfiguration } from './types';\nimport { TxVariants } from '../tx-variants';\nimport UIElement from '../internal/UIElement';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport RedirectButton from '../internal/RedirectButton';\nimport AdyenCheckoutError, { ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { PasskeyService } from './services/PasskeyService';\nimport { authorizeEnrollment } from './services/authorizeEnrollment';\nimport { authorizePayment } from './services/authorizePayment';\nimport StoredPayment from './components/StoredPayment';\nimport Enrollment from './components/Enrollment';\nimport { PaymentAction } from '../../types/global-types';\nimport type { ICore } from '../../core/types';\n\nconst isAdyenHosted = () => {\n try {\n const currentUrl = new URL(window.location.href);\n return currentUrl.hostname.endsWith('.adyen.com');\n } catch (e) {\n // SSR, or it fails to parse the full url\n return false;\n }\n};\nclass PayByBankPixElement extends UIElement<PayByBankPixConfiguration> {\n public static readonly type = TxVariants.paybybank_pix;\n private static readonly TIMEOUT_MINUTES = 1;\n private readonly passkeyService: PasskeyService;\n\n public static readonly defaultProps: PayByBankPixConfiguration = {\n showPayButton: true,\n _isAdyenHosted: isAdyenHosted(),\n countdownTime: PayByBankPixElement.TIMEOUT_MINUTES\n };\n\n constructor(checkout: ICore, props?: PayByBankPixConfiguration) {\n super(checkout, props);\n const deviceId = this.props.storedPaymentMethodId ? this.props?.payByBankPixDetails?.deviceId : this.props.deviceId;\n this.passkeyService = new PasskeyService({ environment: this.props.environment, deviceId });\n if (this.props._isAdyenHosted) {\n void this.passkeyService.initialize();\n }\n }\n\n get isValid(): boolean {\n // Always true for non-hosted page or stored payment\n if (!this.props._isAdyenHosted || this.props.storedPaymentMethodId) {\n return true;\n }\n return !!this.state?.isValid;\n }\n\n /**\n * Display in the drop-in\n */\n get additionalInfo() {\n return this.props.storedPaymentMethodId\n ? this.props.i18n.get('paybybankpix.storedPayment.additionalLabel', { values: { receiver: this.props?.payByBankPixDetails?.receiver } })\n : '';\n }\n\n /**\n * Display in the drop-in\n */\n public override get icon() {\n return this.props.storedPaymentMethodId\n ? this.resources.getImage({ parentFolder: `${PayByBankPixElement.type}/` })(this.props?.payByBankPixDetails?.ispb)\n : super.icon;\n }\n\n /**\n * Method used to let the merchant know if the shopper's device supports WebAuthn APIs: https://featuredetect.passkeys.dev/\n */\n public override async isAvailable(): Promise<void> {\n const unsupportedReason = await this.passkeyService.getWebAuthnUnsupportedReason();\n if (unsupportedReason) {\n return Promise.reject(new AdyenCheckoutError(ERROR, unsupportedReason));\n }\n if (!this.props._isAdyenHosted) {\n return Promise.resolve();\n }\n\n // Load passkey sdk on the hosted page\n try {\n await this.passkeyService.initialize();\n\n if (this.props.storedPaymentMethodId) {\n // If the provided deviceId from the server does not match the localstorage deviceId, do not render the stored payment component.\n const shouldShowStoredPaymentMethod = await this.passkeyService.canUseStoredCredential();\n return shouldShowStoredPaymentMethod\n ? Promise.resolve()\n : Promise.reject(new AdyenCheckoutError('ERROR', 'The stored payment method is not available on this device'));\n }\n\n return Promise.resolve();\n } catch (error) {\n return Promise.reject(error instanceof Error ? error?.message : 'Unknown error');\n }\n }\n\n /**\n * Make sure the await action UIElement is available before mounting\n */\n public override handleAction(action: PaymentAction, props: {} = {}): UIElement | null {\n const paymentAction = this.core.createFromAction(action, {\n ...this.elementRef.props,\n ...props,\n onAdditionalDetails: this.handleAdditionalDetails\n });\n if (paymentAction) {\n this.unmount();\n void paymentAction.isAvailable().then(() => {\n paymentAction.mount(this._node);\n });\n return paymentAction;\n }\n\n return null;\n }\n\n formatData(): PayByBankPixData {\n if (!this.props._isAdyenHosted) {\n return {\n paymentMethod: { type: TxVariants.paybybank_pix }\n };\n }\n\n const isEnrollment = this.props.storedPaymentMethodId == null;\n return {\n paymentMethod: { type: TxVariants.paybybank_pix, ...this.state.data },\n // Always store the payment method for the enrollment flow.\n ...(isEnrollment ? { storePaymentMethod: true } : {})\n };\n }\n\n /**\n * There are 3 endpoints (stages) we need to call for the enrollment flow.\n * The first one is the regular payments call on issuer selection - we indicate to store the payment token for the selected issuer.\n * The second one is to poll the enrollment eligibility - we poll the server to get the enrollment challenge in the `getEnrollmentStatus` function.\n * The third one is in the `authorizeEnrollment` function - we create passkeys and authorize the enrollment with shopper's passkey.\n */\n private readonly onIssuerSelected = async payload => {\n try {\n const { data = {} } = payload;\n if (!data.issuer) {\n return;\n }\n\n const { deviceId, ...riskSignals } = await this.passkeyService.captureRiskSignalsEnrollment();\n this.setState({ ...payload, data: { ...data, riskSignals, deviceId } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the onIssuerSelected';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n private readonly authorizeEnrollment = async (registrationOptions: string): Promise<void> => {\n try {\n const fidoAssertion = await this.passkeyService.createCredentialForEnrollment(registrationOptions); // Create passkey and trigger biometrics\n const enrollment = { enrollmentId: this.props.paymentMethodData?.enrollmentId, fidoAssertion };\n const { redirectResult } = await authorizeEnrollment({\n enrollment,\n clientKey: this.props.clientKey,\n loadingContext: this.props.loadingContext\n });\n // Make paymentDetails call to finalize the enrollment.\n this.handleAdditionalDetails({ data: { details: { redirectResult } } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the authorizeEnrollment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n /**\n * There are 3 endpoints (stages) we need to call for the payment flow.\n * The first one `payWithStoredPayment` is the regular payments call - we attempt to pay with the stored payment token.\n * The second one is to poll the authorization options - we poll the server to get the challenge in the `getAuthorizationStatus` function.\n * The third one is in the `authorizePayment` function - we authorize the payment with shopper's passkey.\n */\n private readonly payWithStoredPayment = async () => {\n try {\n const { deviceId, ...riskSignals } = await this.passkeyService.captureRiskSignalsAuthentication();\n this.state = { ...this.state, ...{ data: { storedPaymentMethodId: this.props.storedPaymentMethodId, riskSignals, deviceId } } };\n super.submit();\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the payWithStoredPayment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n private readonly authorizePayment = async (authenticationOptions: string): Promise<void> => {\n try {\n const fidoAssertion = await this.passkeyService.authenticateWithCredential(authenticationOptions);\n const payment = {\n enrollmentId: this.props.paymentMethodData?.enrollmentId,\n initiationId: this.props.paymentMethodData?.initiationId,\n fidoAssertion\n };\n const { redirectResult } = await authorizePayment({\n payment,\n clientKey: this.props.clientKey,\n loadingContext: this.props.loadingContext\n });\n this.handleAdditionalDetails({ data: { details: { redirectResult } } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the authorizePayment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n render() {\n // Always render the redirect button on the merchant's page\n if (!this.props._isAdyenHosted) {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.displayName}\n label={this.props.i18n.get('paybybankpix.redirectBtn.label')}\n amount={this.props.amount}\n payButton={this.payButton}\n onSubmit={this.submit}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n {this.props.storedPaymentMethodId != null ? (\n <StoredPayment\n txVariant={PayByBankPixElement.type}\n type={this.props.type}\n clientKey={this.props.clientKey}\n amount={this.props.amount}\n enrollmentId={this.props.paymentMethodData?.enrollmentId}\n initiationId={this.props.paymentMethodData?.initiationId}\n setComponentRef={this.setComponentRef}\n onPay={this.payWithStoredPayment}\n onAuthorize={this.authorizePayment}\n />\n ) : (\n <Enrollment\n onError={this.handleError}\n txVariant={PayByBankPixElement.type}\n // Await\n type={this.props.type}\n clientKey={this.props.clientKey}\n enrollmentId={this.props.paymentMethodData?.enrollmentId}\n countdownTime={this.props.countdownTime}\n onEnroll={this.authorizeEnrollment}\n // Issuer List\n issuers={this.props.issuers}\n payButton={this.payButton}\n onChange={this.onIssuerSelected}\n onSubmitAnalytics={this.submitAnalytics}\n setComponentRef={this.setComponentRef}\n />\n )}\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n//\nexport default PayByBankPixElement;\n"],"names":["PayByBankPixElement","UIElement","isValid","_this_state","this","props","_isAdyenHosted","storedPaymentMethodId","state","additionalInfo","_this_props_payByBankPixDetails","_this_props","i18n","get","values","receiver","payByBankPixDetails","icon","resources","getImage","parentFolder","type","ispb","super","isAvailable","unsupportedReason","passkeyService","getWebAuthnUnsupportedReason","Promise","reject","AdyenCheckoutError","ERROR","resolve","initialize","canUseStoredCredential","error","Error","message","handleAction","action","paymentAction","core","createFromAction","_object_spread_props","_object_spread","elementRef","onAdditionalDetails","handleAdditionalDetails","unmount","then","mount","_node","formatData","paymentMethod","TxVariants","paybybank_pix","isEnrollment","data","storePaymentMethod","render","_this_props_paymentMethodData","_this_props_paymentMethodData1","_this_props_paymentMethodData2","h","CoreProvider","loadingContext","SRPanelProvider","srPanel","modules","StoredPayment","txVariant","clientKey","amount","enrollmentId","paymentMethodData","initiationId","setComponentRef","onPay","payWithStoredPayment","onAuthorize","authorizePayment","Enrollment","onError","handleError","countdownTime","onEnroll","authorizeEnrollment","issuers","payButton","onChange","onIssuerSelected","onSubmitAnalytics","submitAnalytics","RedirectButton","showPayButton","name","displayName","label","onSubmit","submit","ref","componentRef","constructor","checkout","_define_property","async","payload","issuer","_ref","captureRiskSignalsEnrollment","deviceId","riskSignals","setState","errorMsg","registrationOptions","fidoAssertion","createCredentialForEnrollment","enrollment","redirectResult","details","captureRiskSignalsAuthentication","authenticationOptions","authenticateWithCredential","payment","PasskeyService","environment","TIMEOUT_MINUTES","defaultProps","URL","window","location","href","hostname","endsWith","e","isAdyenHosted"],"mappings":"63DAyBA,MAAMA,UAA4BC,EAoB9B,WAAIC,GAKS,IAAAC,EAHT,QAAKC,KAAKC,MAAMC,iBAAkBF,KAAKC,MAAME,2BAG1B,QAAVJ,EAAAC,KAAKI,aAAL,IAAAL,OAAA,EAAAA,EAAYD,QACzB,CAKA,kBAAIO,OAE8FC,EAAAC,EAD9F,OAAOP,KAAKC,MAAME,sBACZH,KAAKC,MAAMO,KAAKC,IAAI,6CAA8C,CAAEC,OAAQ,CAAEC,SAAoB,QAAVJ,EAAAP,KAAKC,aAAL,IAAAM,GAA+B,QAA/BD,EAAAC,EAAYK,2BAAZ,IAAAN,OAAA,EAAAA,EAAiCK,YACzH,EACV,CAKA,QAAoBE,OAEgEP,EAAAC,EADhF,OAAOP,KAAKC,MAAME,sBACZH,KAAKc,UAAUC,SAAS,CAAEC,aAAc,GAAGpB,EAAoBqB,SAA/DjB,SAA0EO,EAAAP,KAAKC,aAAL,IAAAM,WAAAD,EAAAC,EAAYK,2BAAZ,IAAAN,OAAA,EAAAA,EAAiCY,MAC3GC,MAAMN,IAChB,CAKA,iBAAsBO,GAClB,MAAMC,QAA0BrB,KAAKsB,eAAeC,+BACpD,GAAIF,EACA,OAAOG,QAAQC,OAAO,IAAIC,EAAmBC,EAAON,IAExD,IAAKrB,KAAKC,MAAMC,eACZ,OAAOsB,QAAQI,UAInB,IAGI,SAFM5B,KAAKsB,eAAeO,aAEtB7B,KAAKC,MAAME,sBAAuB,CAGlC,aAD4CH,KAAKsB,eAAeQ,yBAE1DN,QAAQI,UACRJ,QAAQC,OAAO,IAAIC,EAAmB,QAAS,6DACzD,CAEA,OAAOF,QAAQI,SACnB,CAAE,MAAOG,GACL,OAAOP,QAAQC,OAAOM,aAAiBC,MAAQD,aAAAA,EAAAA,EAAOE,QAAU,gBACpE,CACJ,CAKA,YAAAC,CA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eAAegG,2BAA2BD,GACrEE,EAAU,CACZlD,aAA0C,QAA5Bb,EAAAxD,KAAKC,MAAMqE,yBAAX,IAAAd,OAAA,EAAAA,EAA8Ba,aAC5CE,aAA0C,QAA5Bd,EAAAzD,KAAKC,MAAMqE,yBAAX,IAAAb,OAAA,EAAAA,EAA8Bc,aAC5CwC,kBAEEG,eAAEA,SAAyBtC,EAAiB,CAC9C2C,UACApD,UAAWnE,KAAKC,MAAMkE,UACtBN,eAAgB7D,KAAKC,MAAM4D,iBAE/B7D,KAAK2C,wBAAwB,CAAEU,KAAM,CAAE8D,QAAS,CAAED,oBACtD,CAAE,MAAOnF,GACL,MAAM8E,EAAW9E,aAAiBC,MAAQD,EAAME,QAAU,wCAC1DjC,KAAK+E,YAAYhD,aAAiBL,EAAqBK,EAAQ,IAAIL,EAAmBC,EAAOkF,GACjG,IA1KA,MAAMH,EAAW1G,KAAKC,MAAME,sBAAkC,QAAVI,EAAAP,KAAKC,iBAALM,GAA+B,QAA/BD,EAAAC,EAAYK,2BAAZ,IAAAN,SAAAA,EAAiCoG,SAAW1G,KAAKC,MAAMyG,SAC3G1G,KAAKsB,eAAiB,IAAIkG,EAAe,CAAEC,YAAazH,KAAKC,MAAMwH,YAAaf,aAC5E1G,KAAKC,MAAMC,gBACNF,KAAKsB,eAAeO,YAEjC,EAjBAuE,EADExG,EACqBqB,OAAOiC,EAAWC,eACzCiD,EAFExG,EAEsB8H,kBAAkB,GAG1CtB,EALExG,EAKqB+H,eAA0C,CAC7DjC,eAAe,EACfxF,eAhBc,MAClB,IAEI,OADmB,IAAI0H,IAAIC,OAAOC,SAASC,MACzBC,SAASC,SAAS,aACxC,CAAE,MAAOC,GAEL,OAAO,CACX,GASoBC,GAChBnD,cAAepF,EAAoB8H"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as t}from"../../../../external/preact/dist/preact.js";import{useRef as e,useState as n,useEffect as a}from"../../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";import i from"../../../internal/IssuerList/IssuerList.js";import{useIssuerWithLogo as r}from"./useIssuerWithLogo.js";import s from"./getEnrollmentStatus.js";import l from"./components/IssuerListIntroduction.js";import m from"./components/PayByBankPixAwait.js";import p from"../../../../core/Context/useImage.js";import{LabelOnlyDisclaimerMessage as c}from"../../../internal/DisclaimerMessage/DisclaimerMessage.js";function u(u){const{i18n:y,loadingContext:d}=o(),g=p(),w=e(null),[x
|
|
1
|
+
import{createElement as t}from"../../../../external/preact/dist/preact.js";import{useRef as e,useState as n,useEffect as a}from"../../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";import i from"../../../internal/IssuerList/IssuerList.js";import{useIssuerWithLogo as r}from"./useIssuerWithLogo.js";import s from"./getEnrollmentStatus.js";import l from"./components/IssuerListIntroduction.js";import m from"./components/PayByBankPixAwait.js";import p from"../../../../core/Context/useImage.js";import{LabelOnlyDisclaimerMessage as c}from"../../../internal/DisclaimerMessage/DisclaimerMessage.js";function u(u){const{i18n:y,loadingContext:d}=o(),g=p(),w=e(null),[b,x]=n(null),f=[{name:"open-finance",alt:y.get("paybybankpix.await.logoAlt.openFinance"),src:`${g({parentFolder:`${u.txVariant}/`})("open-finance")}`},{name:"arrow-down",alt:y.get("paybybankpix.await.logoAlt.arrowDown"),src:`${g({imageFolder:"components/"})("arrow_down")}`},{name:"bank",alt:y.get("paybybankpix.await.logoAlt.bank"),src:`${g({imageFolder:"components/"})("bank")}`}],k=e({showValidation:()=>{var t;null==w||null===(t=w.current)||void 0===t||t.showValidation()},setStatus:t=>{var e;null==w||null===(e=w.current)||void 0===e||e.setStatus(t)}});return a(()=>{u.setComponentRef(k.current)},[u.setComponentRef]),a(()=>{b&&u.onEnroll(b)},[b]),t("div",{className:"adyen-checkout-pix-enrollment"},(t=>"await"===t.type)(u)?t(m,{logos:f,type:u.txVariant,countdownTime:u.countdownTime,clientKey:u.clientKey,onError:u.onError,awaitText:y.get("paybybankpix.await.waitForConfirmation"),instructions:y.get("paybybankpix.await.timeToPay",{values:{numberOfMin:u.countdownTime}}),pollStatus:async()=>{if(b)return;const{enrollmentId:t,clientKey:e}=u,n=await s({enrollmentId:t,clientKey:e,loadingContext:d});return n.registrationOptions&&x(n.registrationOptions),n},endSlot:()=>t("span",null,y.get("paybybankpix.await.withOpenFinance"))}):t("div",{className:"adyen-checkout-pix-enrollment-issuer-list"},t(l,{txVariant:u.txVariant}),t(i,{items:r({issuers:u.issuers,txVariant:u.txVariant}),selectFieldLabel:y.get("paybybankpix.issuerList.selectField.label"),onSubmitAnalytics:u.onSubmitAnalytics,onChange:u.onChange,payButton:u.payButton,showPayButton:!0,ref:w}),t("span",{className:"adyen-checkout-disclaimer__label"},t(c,{message:y.get("paybybankpix.issuerList.disclaimer"),urls:["https://www.adyen.com/pt_BR/legal/termo-de-consentimento-br"]}))))}export{u as default};
|
|
2
2
|
//# sourceMappingURL=Enrollment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Enrollment.js","sources":["../../../../../../src/components/PayByBankPix/components/Enrollment/Enrollment.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useRef, useState, useEffect } from 'preact/hooks';\nimport { AwaitProps, EnrollmentProps } from './types';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport IssuerList from '../../../internal/IssuerList';\nimport { useIssuerWithLogo } from './useIssuerWithLogo';\nimport getEnrollmentStatus from './getEnrollmentStatus';\nimport IssuerListIntroduction from './components/IssuerListIntroduction';\nimport PayByBankPixAwait from './components/PayByBankPixAwait';\nimport useImage from '../../../../core/Context/useImage';\nimport './Enrollment.scss';\nimport { LabelOnlyDisclaimerMessage } from '../../../internal/DisclaimerMessage/DisclaimerMessage';\nimport { ComponentMethodsRef, UIElementStatus } from '../../../internal/UIElement/types';\n\
|
|
1
|
+
{"version":3,"file":"Enrollment.js","sources":["../../../../../../src/components/PayByBankPix/components/Enrollment/Enrollment.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useRef, useState, useEffect } from 'preact/hooks';\nimport { AwaitProps, EnrollmentProps } from './types';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport IssuerList from '../../../internal/IssuerList';\nimport { useIssuerWithLogo } from './useIssuerWithLogo';\nimport getEnrollmentStatus from './getEnrollmentStatus';\nimport IssuerListIntroduction from './components/IssuerListIntroduction';\nimport PayByBankPixAwait from './components/PayByBankPixAwait';\nimport useImage from '../../../../core/Context/useImage';\nimport './Enrollment.scss';\nimport { LabelOnlyDisclaimerMessage } from '../../../internal/DisclaimerMessage/DisclaimerMessage';\nimport { ComponentMethodsRef, UIElementStatus } from '../../../internal/UIElement/types';\n\nconst TERMS_CONDITIONS_URL = 'https://www.adyen.com/pt_BR/legal/termo-de-consentimento-br';\n\nfunction Enrollment(props: EnrollmentProps) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const issuerListRef = useRef<ComponentMethodsRef>(null);\n const [registrationOptions, setRegistrationOptions] = useState<string>(null);\n const logos = [\n {\n name: 'open-finance',\n alt: i18n.get('paybybankpix.await.logoAlt.openFinance'),\n src: `${getImage({ parentFolder: `${props.txVariant}/` })('open-finance')}`\n },\n {\n name: 'arrow-down',\n alt: i18n.get('paybybankpix.await.logoAlt.arrowDown'),\n src: `${getImage({ imageFolder: 'components/' })('arrow_down')}`\n },\n { name: 'bank', alt: i18n.get('paybybankpix.await.logoAlt.bank'), src: `${getImage({ imageFolder: 'components/' })('bank')}` }\n ];\n const self = useRef({\n showValidation: () => {\n issuerListRef?.current?.showValidation();\n },\n setStatus: (newStatus: UIElementStatus) => {\n issuerListRef?.current?.setStatus(newStatus);\n }\n });\n\n const pollStatus = async () => {\n if (registrationOptions) return;\n\n const { enrollmentId, clientKey } = props as AwaitProps;\n const response = await getEnrollmentStatus({ enrollmentId, clientKey, loadingContext });\n if (response.registrationOptions) {\n setRegistrationOptions(response.registrationOptions);\n }\n return response;\n };\n // Assist typescript to narrow down the type.\n const isAwait = (props: EnrollmentProps): props is AwaitProps => props.type === 'await';\n const awaitEndSlot = () => <span>{i18n.get('paybybankpix.await.withOpenFinance')}</span>;\n\n useEffect(() => {\n props.setComponentRef(self.current);\n }, [props.setComponentRef]);\n\n useEffect(() => {\n if (registrationOptions) {\n props.onEnroll(registrationOptions);\n }\n }, [registrationOptions]);\n\n return (\n <div className={'adyen-checkout-pix-enrollment'}>\n {isAwait(props) ? (\n <PayByBankPixAwait\n logos={logos}\n type={props.txVariant}\n countdownTime={props.countdownTime}\n clientKey={props.clientKey}\n onError={props.onError}\n awaitText={i18n.get('paybybankpix.await.waitForConfirmation')}\n instructions={i18n.get('paybybankpix.await.timeToPay', {\n values: { numberOfMin: props.countdownTime }\n })}\n pollStatus={pollStatus}\n endSlot={awaitEndSlot}\n ></PayByBankPixAwait>\n ) : (\n <div className=\"adyen-checkout-pix-enrollment-issuer-list\">\n <IssuerListIntroduction txVariant={props.txVariant} />\n <IssuerList\n items={useIssuerWithLogo({ issuers: props.issuers, txVariant: props.txVariant })}\n selectFieldLabel={i18n.get('paybybankpix.issuerList.selectField.label')}\n onSubmitAnalytics={props.onSubmitAnalytics}\n onChange={props.onChange}\n payButton={props.payButton}\n showPayButton={true}\n ref={issuerListRef}\n ></IssuerList>\n <span className=\"adyen-checkout-disclaimer__label\">\n <LabelOnlyDisclaimerMessage message={i18n.get('paybybankpix.issuerList.disclaimer')} urls={[TERMS_CONDITIONS_URL]} />\n </span>\n </div>\n )}\n </div>\n );\n}\n\nexport default Enrollment;\n"],"names":["Enrollment","props","i18n","loadingContext","useCoreContext","getImage","useImage","issuerListRef","useRef","registrationOptions","setRegistrationOptions","useState","logos","name","alt","get","src","parentFolder","txVariant","imageFolder","self","showValidation","current","setStatus","newStatus","useEffect","setComponentRef","onEnroll","h","div","className","type","isAwait","PayByBankPixAwait","countdownTime","clientKey","onError","awaitText","instructions","values","numberOfMin","pollStatus","async","enrollmentId","response","getEnrollmentStatus","endSlot","span","IssuerListIntroduction","IssuerList","items","useIssuerWithLogo","issuers","selectFieldLabel","onSubmitAnalytics","onChange","payButton","showPayButton","ref","LabelOnlyDisclaimerMessage","message","urls"],"mappings":"ypBAgBA,SAASA,EAAWC,GAChB,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,IAC3BC,EAAWC,IACXC,EAAgBC,EAA4B,OAC3CC,EAAqBC,GAA0BC,EAAiB,MACjEC,EAAQ,CACV,CACIC,KAAM,eACNC,IAAKZ,EAAKa,IAAI,0CACdC,IAAK,GAAGX,EAAS,CAAEY,aAAc,GAAGhB,EAAMiB,cAAlCb,CAAkD,mBAE9D,CACIQ,KAAM,aACNC,IAAKZ,EAAKa,IAAI,wCACdC,IAAK,GAAGX,EAAS,CAAEc,YAAa,eAAxBd,CAAyC,iBAErD,CAAEQ,KAAM,OAAQC,IAAKZ,EAAKa,IAAI,mCAAoCC,IAAK,GAAGX,EAAS,CAAEc,YAAa,eAAxBd,CAAyC,YAEjHe,EAAOZ,EAAO,CAChBa,eAAgB,KACZd,IAAAA,EAAAA,SAAsB,QAAtBA,EAAAA,EAAee,eAAff,IAAAA,GAAAA,EAAwBc,kBAE5BE,UAAYC,IACRjB,IAAAA,EAAAA,iBAAAA,EAAAA,EAAee,eAAff,IAAAA,GAAAA,EAAwBgB,UAAUC,MA4B1C,OAVAC,EAAU,KACNxB,EAAMyB,gBAAgBN,EAAKE,UAC5B,CAACrB,EAAMyB,kBAEVD,EAAU,KACFhB,GACAR,EAAM0B,SAASlB,IAEpB,CAACA,IAGAmB,EAACC,MAAAA,CAAIC,UAAW,iCAdJ,CAAC7B,GAA+D,UAAfA,EAAM8B,KAe9DC,CAAQ/B,GACL2B,EAACK,EAAAA,CACGrB,MAAOA,EACPmB,KAAM9B,EAAMiB,UACZgB,cAAejC,EAAMiC,cACrBC,UAAWlC,EAAMkC,UACjBC,QAASnC,EAAMmC,QACfC,UAAWnC,EAAKa,IAAI,0CACpBuB,aAAcpC,EAAKa,IAAI,+BAAgC,CACnDwB,OAAQ,CAAEC,YAAavC,EAAMiC,iBAEjCO,WArCGC,UACf,GAAIjC,EAAqB,OAEzB,MAAMkC,aAAEA,EAAYR,UAAEA,GAAclC,EAC9B2C,QAAiBC,EAAoB,CAAEF,eAAcR,YAAWhC,mBAItE,OAHIyC,EAASnC,qBACTC,EAAuBkC,EAASnC,qBAE7BmC,GA8BKE,QA1BK,IAAMlB,EAACmB,OAAAA,KAAM7C,EAAKa,IAAI,yCA6B/Ba,EAACC,MAAAA,CAAIC,UAAU,6CACXF,EAACoB,EAAAA,CAAuB9B,UAAWjB,EAAMiB,YACzCU,EAACqB,EAAAA,CACGC,MAAOC,EAAkB,CAAEC,QAASnD,EAAMmD,QAASlC,UAAWjB,EAAMiB,YACpEmC,iBAAkBnD,EAAKa,IAAI,6CAC3BuC,kBAAmBrD,EAAMqD,kBACzBC,SAAUtD,EAAMsD,SAChBC,UAAWvD,EAAMuD,UACjBC,eAAe,EACfC,IAAKnD,IAETqB,EAACmB,OAAAA,CAAKjB,UAAU,oCACZF,EAAC+B,EAAAA,CAA2BC,QAAS1D,EAAKa,IAAI,sCAAuC8C,KAAM,CAlFtF,mEAwF7B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as t}from"../../../../../external/preact/dist/preact.js";import{useCoreContext as e}from"../../../../../core/Context/CoreProvider.js";import
|
|
1
|
+
import{createElement as t}from"../../../../../external/preact/dist/preact.js";import{useCoreContext as e}from"../../../../../core/Context/CoreProvider.js";import o from"../../../../../core/Context/useImage.js";const n="open-finance",i="paybybankpix.await.logoAlt.openFinance";function a({txVariant:a}){const{i18n:r}=e(),s=o();return t("div",{className:"adyen-checkout-issuer-list-introduction"},t("div",{className:"adyen-checkout-issuer-list-introduction-logo-container"},t("img",{src:s({parentFolder:`${a}/`})(n),alt:r.get(i),className:"adyen-checkout-issuer-list-introduction-logo-container__logo"}),t("p",{className:"adyen-checkout-issuer-list-introduction-logo-container__title"},r.get("paybybankpix.issuerList.introduction.logo.content"))))}export{a as default};
|
|
2
2
|
//# sourceMappingURL=IssuerListIntroduction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IssuerListIntroduction.js","sources":["../../../../../../../src/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './IssuerListIntroduction.scss';\nimport useImage from '../../../../../core/Context/useImage';\n\nconst LOGO = {\n name: 'open-finance',\n altI18nKey: 'paybybankpix.await.logoAlt.openFinance'\n};\n\nfunction IssuerListIntroduction({ txVariant }) {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n <div className={'adyen-checkout-issuer-list-introduction'}>\n <div className=\"adyen-checkout-issuer-list-introduction-logo-container\">\n <img\n src={getImage({ parentFolder: `${txVariant}/` })(LOGO.name)}\n alt={i18n.get(LOGO.altI18nKey)}\n className=\"adyen-checkout-issuer-list-introduction-logo-container__logo\"\n />\n <p className=\"adyen-checkout-issuer-list-introduction-logo-container__title\">\n {i18n.get('paybybankpix.issuerList.introduction.logo.content')}\n </p>\n </div>\n
|
|
1
|
+
{"version":3,"file":"IssuerListIntroduction.js","sources":["../../../../../../../src/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './IssuerListIntroduction.scss';\nimport useImage from '../../../../../core/Context/useImage';\n\nconst LOGO = {\n name: 'open-finance',\n altI18nKey: 'paybybankpix.await.logoAlt.openFinance'\n};\n\nfunction IssuerListIntroduction({ txVariant }) {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n <div className={'adyen-checkout-issuer-list-introduction'}>\n <div className=\"adyen-checkout-issuer-list-introduction-logo-container\">\n <img\n src={getImage({ parentFolder: `${txVariant}/` })(LOGO.name)}\n alt={i18n.get(LOGO.altI18nKey)}\n className=\"adyen-checkout-issuer-list-introduction-logo-container__logo\"\n />\n <p className=\"adyen-checkout-issuer-list-introduction-logo-container__title\">\n {i18n.get('paybybankpix.issuerList.introduction.logo.content')}\n </p>\n </div>\n </div>\n );\n}\n\nexport default IssuerListIntroduction;\n"],"names":["LOGO","IssuerListIntroduction","txVariant","i18n","useCoreContext","getImage","useImage","h","div","className","img","src","parentFolder","alt","get","p"],"mappings":"kNAKA,MAAMA,EACI,eADJA,EAEU,yCAGhB,SAASC,GAAuBC,UAAEA,IAC9B,MAAMC,KAAEA,GAASC,IACXC,EAAWC,IAEjB,OACIC,EAACC,MAAAA,CAAIC,UAAW,2CACZF,EAACC,MAAAA,CAAIC,UAAU,0DACXF,EAACG,MAAAA,CACGC,IAAKN,EAAS,CAAEO,aAAc,GAAGV,MAA5BG,CAA4CL,GACjDa,IAAKV,EAAKW,IAAId,GACdS,UAAU,iEAEdF,EAACQ,IAAAA,CAAEN,UAAU,iEACRN,EAAKW,IAAI,uDAK9B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as e,useEffect as t}from"../../../../external/preact/hooks/dist/hooks.js";import r from"../../../../utils/get-issuer-image.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";import n from"../../../../core/Context/useImage.js";function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}const s=({issuers:s,txVariant:u})=>{const{loadingContext:p}=o(),a=n(),[f,l]=e(s);return t(()=>{if((null==s?void 0:s.length)>0){const e=r({loadingContext:p},u,a);l(s.map(t=>i(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){c(e,t,r[t])})}return e}({},t),{icon:e(t.id)})))}},[s,u]),f};export{s as useIssuerWithLogo};
|
|
1
|
+
import{useState as e,useEffect as t}from"../../../../external/preact/hooks/dist/hooks.js";import r from"../../../../utils/get-issuer-image.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";import n from"../../../../core/Context/useImage.js";function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}const s=({issuers:s=[],txVariant:u})=>{const{loadingContext:p}=o(),a=n(),[f,l]=e(s);return t(()=>{if((null==s?void 0:s.length)>0){const e=r({loadingContext:p},u,a);l(s.map(t=>i(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){c(e,t,r[t])})}return e}({},t),{icon:e(t.id)})))}},[s,u]),f};export{s as useIssuerWithLogo};
|
|
2
2
|
//# sourceMappingURL=useIssuerWithLogo.js.map
|
package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIssuerWithLogo.js","sources":["../../../../../../src/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.ts"],"sourcesContent":["import { useEffect, useState } from 'preact/hooks';\nimport { IssuerItem } from '../../../internal/IssuerList/types';\nimport getIssuerImageUrl from '../../../../utils/get-issuer-image';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport useImage from '../../../../core/Context/useImage';\n\ninterface UseIssuerWithLogoProps {\n txVariant: string;\n issuers: IssuerItem[];\n}\nexport const useIssuerWithLogo = ({ issuers, txVariant }: UseIssuerWithLogoProps): IssuerItem[] => {\n const { loadingContext } = useCoreContext();\n const getImage = useImage();\n const [issuersWithLogo, setIssuersWithLogo] = useState<IssuerItem[]>(issuers);\n\n useEffect(() => {\n if (issuers?.length > 0) {\n const getIssuerIcon = getIssuerImageUrl({ loadingContext }, txVariant, getImage);\n setIssuersWithLogo(\n issuers.map(item => ({\n ...item,\n icon: getIssuerIcon(item.id)\n }))\n );\n }\n }, [issuers, txVariant]);\n\n return issuersWithLogo;\n};\n"],"names":["useIssuerWithLogo","issuers","txVariant","loadingContext","useCoreContext","getImage","useImage","issuersWithLogo","setIssuersWithLogo","useState","useEffect","length","getIssuerIcon","getIssuerImageUrl","map","item","_object_spread_props","_object_spread","icon","id"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIssuerWithLogo.js","sources":["../../../../../../src/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.ts"],"sourcesContent":["import { useEffect, useState } from 'preact/hooks';\nimport { IssuerItem } from '../../../internal/IssuerList/types';\nimport getIssuerImageUrl from '../../../../utils/get-issuer-image';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport useImage from '../../../../core/Context/useImage';\n\ninterface UseIssuerWithLogoProps {\n txVariant: string;\n issuers: IssuerItem[];\n}\nexport const useIssuerWithLogo = ({ issuers = [], txVariant }: UseIssuerWithLogoProps): IssuerItem[] => {\n const { loadingContext } = useCoreContext();\n const getImage = useImage();\n const [issuersWithLogo, setIssuersWithLogo] = useState<IssuerItem[]>(issuers);\n\n useEffect(() => {\n if (issuers?.length > 0) {\n const getIssuerIcon = getIssuerImageUrl({ loadingContext }, txVariant, getImage);\n setIssuersWithLogo(\n issuers.map(item => ({\n ...item,\n icon: getIssuerIcon(item.id)\n }))\n );\n }\n }, [issuers, txVariant]);\n\n return issuersWithLogo;\n};\n"],"names":["useIssuerWithLogo","issuers","txVariant","loadingContext","useCoreContext","getImage","useImage","issuersWithLogo","setIssuersWithLogo","useState","useEffect","length","getIssuerIcon","getIssuerImageUrl","map","item","_object_spread_props","_object_spread","icon","id"],"mappings":"kvBAUO,MAAMA,EAAoB,EAAGC,UAAU,GAAIC,gBAC9C,MAAMC,eAAEA,GAAmBC,IACrBC,EAAWC,KACVC,EAAiBC,GAAsBC,EAAuBR,GAcrE,OAZAS,EAAU,KACN,IAAIT,aAAAA,EAAAA,EAASU,QAAS,EAAG,CACrB,MAAMC,EAAgBC,EAAkB,CAAEV,kBAAkBD,EAAWG,GACvEG,EACIP,EAAQa,IAAIC,GAASC,oUAAAC,CAAA,GACdF,GAAAA,CACHG,KAAMN,EAAcG,EAAKI,OAGrC,GACD,CAAClB,EAASC,IAENK"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as
|
|
1
|
+
import{createElement as t}from"../../../../external/preact/dist/preact.js";import{useState as e,useRef as n,useCallback as o,useEffect as a}from"../../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as i}from"../../../../core/Context/CoreProvider.js";import r from"../../../../core/Context/useImage.js";import s from"../../../internal/PayButton/PayButton.js";import l from"./getAuthorizationStatus.js";import p from"../Enrollment/components/PayByBankPixAwait.js";function c({onPay:c,type:m,countdownTime:u,amount:f,txVariant:y,setComponentRef:d,enrollmentId:x,initiationId:b,clientKey:g,onAuthorize:k,onError:w}){const{i18n:C,loadingContext:h}=i(),j=r(),[P,B]=e("ready"),[E,I]=e(null),z=[{name:"open-finance",alt:C.get("paybybankpix.await.logoAlt.openFinance"),src:`${j({parentFolder:`${y}/`})("open-finance")}`}],A=n({setStatus:B}),S=o(async()=>{if(E)return;const t=await l({enrollmentId:x,initiationId:b,clientKey:g,loadingContext:h});return t.authorizationOptions&&I(t.authorizationOptions),t},[E,x,b,g,h]);return a(()=>{d(A.current)},[d]),a(()=>{E&&k(E)},[E]),"await"===m?t(p,{logos:z,type:y,countdownTime:u,clientKey:g,onError:w,awaitText:C.get("paybybankpix.await.fetchDetails"),pollStatus:S}):t(s,{classNameModifiers:["standalone"],label:C.get("paybybankpix.redirectBtn.label"),status:P,amount:f,onClick:c})}export{c as default};
|
|
2
2
|
//# sourceMappingURL=StoredPayment.js.map
|
package/dist/es-legacy/components/PayByBankPix/components/StoredPayment/StoredPayment.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StoredPayment.js","sources":["../../../../../../src/components/PayByBankPix/components/StoredPayment/StoredPayment.tsx"],"sourcesContent":["import { h
|
|
1
|
+
{"version":3,"file":"StoredPayment.js","sources":["../../../../../../src/components/PayByBankPix/components/StoredPayment/StoredPayment.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useEffect, useRef, useCallback } from 'preact/hooks';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { PaymentProps } from './types';\nimport useImage from '../../../../core/Context/useImage';\nimport PayButton from '../../../internal/PayButton';\nimport './StoredPayment.scss';\nimport getAuthorizationStatus from './getAuthorizationStatus';\nimport PayByBankPixAwait from '../Enrollment/components/PayByBankPixAwait';\n\nfunction StoredPayment({\n onPay,\n type,\n countdownTime,\n amount,\n txVariant,\n setComponentRef,\n enrollmentId,\n initiationId,\n clientKey,\n onAuthorize,\n onError\n}: PaymentProps) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const [status, setStatus] = useState('ready');\n const [authorizationOptions, setAuthorizationOptions] = useState<string>(null);\n const buttonModifiers = ['standalone'];\n const logos = [\n {\n name: 'open-finance',\n alt: i18n.get('paybybankpix.await.logoAlt.openFinance'),\n src: `${getImage({ parentFolder: `${txVariant}/` })('open-finance')}`\n }\n ];\n\n const self = useRef({\n setStatus\n });\n\n const pollStatus = useCallback(async () => {\n if (authorizationOptions) return;\n\n const response = await getAuthorizationStatus({ enrollmentId, initiationId, clientKey, loadingContext });\n if (response.authorizationOptions) {\n setAuthorizationOptions(response.authorizationOptions);\n }\n\n return response;\n }, [authorizationOptions, enrollmentId, initiationId, clientKey, loadingContext]);\n\n useEffect(() => {\n setComponentRef(self.current);\n }, [setComponentRef]);\n\n useEffect(() => {\n if (authorizationOptions) {\n onAuthorize(authorizationOptions);\n }\n }, [authorizationOptions]);\n\n return type === 'await' ? (\n <PayByBankPixAwait\n logos={logos}\n type={txVariant}\n countdownTime={countdownTime}\n clientKey={clientKey}\n onError={onError}\n awaitText={i18n.get('paybybankpix.await.fetchDetails')}\n pollStatus={pollStatus}\n ></PayByBankPixAwait>\n ) : (\n <PayButton\n classNameModifiers={buttonModifiers}\n label={i18n.get('paybybankpix.redirectBtn.label')}\n status={status}\n amount={amount}\n onClick={onPay}\n />\n );\n}\n\nexport default StoredPayment;\n"],"names":["StoredPayment","onPay","type","countdownTime","amount","txVariant","setComponentRef","enrollmentId","initiationId","clientKey","onAuthorize","onError","i18n","loadingContext","useCoreContext","getImage","useImage","status","setStatus","useState","authorizationOptions","setAuthorizationOptions","logos","name","alt","get","src","parentFolder","self","useRef","pollStatus","useCallback","async","response","getAuthorizationStatus","useEffect","current","h","PayByBankPixAwait","awaitText","PayButton","classNameModifiers","label","onClick"],"mappings":"geAUA,SAASA,GAAcC,MACnBA,EAAKC,KACLA,EAAIC,cACJA,EAAaC,OACbA,EAAMC,UACNA,EAASC,gBACTA,EAAeC,aACfA,EAAYC,aACZA,EAAYC,UACZA,EAASC,YACTA,EAAWC,QACXA,IAEA,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,IAC3BC,EAAWC,KACVC,EAAQC,GAAaC,EAAS,UAC9BC,EAAsBC,GAA2BF,EAAiB,MAEnEG,EAAQ,CACV,CACIC,KAAM,eACNC,IAAKZ,EAAKa,IAAI,0CACdC,IAAK,GAAGX,EAAS,CAAEY,aAAc,GAAGtB,MAA5BU,CAA4C,oBAItDa,EAAOC,EAAO,CAChBX,cAGEY,EAAaC,EAAYC,UAC3B,GAAIZ,EAAsB,OAE1B,MAAMa,QAAiBC,EAAuB,CAAE3B,eAAcC,eAAcC,YAAWI,mBAKvF,OAJIoB,EAASb,sBACTC,EAAwBY,EAASb,sBAG9Ba,GACR,CAACb,EAAsBb,EAAcC,EAAcC,EAAWI,IAYjE,OAVAsB,EAAU,KACN7B,EAAgBsB,EAAKQ,UACtB,CAAC9B,IAEJ6B,EAAU,KACFf,GACAV,EAAYU,IAEjB,CAACA,IAEY,UAATlB,EACHmC,EAACC,EAAAA,CACGhB,MAAOA,EACPpB,KAAMG,EACNF,cAAeA,EACfM,UAAWA,EACXE,QAASA,EACT4B,UAAW3B,EAAKa,IAAI,mCACpBK,WAAYA,IAGhBO,EAACG,EAAAA,CACGC,mBA9CgB,CAAC,cA+CjBC,MAAO9B,EAAKa,IAAI,kCAChBR,OAAQA,EACRb,OAAQA,EACRuC,QAAS1C,GAGrB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../external/preact/dist/preact.js";import r from"../../internal/FormFields/Fieldset/Fieldset.js";import{useEffect as a,useRef as t}from"../../../external/preact/hooks/dist/hooks.js";import o from"../../../utils/useForm/useForm.js";import{getErrorMessage as s}from"../../../utils/getErrorMessage.js";import n from"../../internal/FormFields/Field/Field.js";import{useCoreContext as
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import r from"../../internal/FormFields/Fieldset/Fieldset.js";import{useEffect as a,useRef as t}from"../../../external/preact/hooks/dist/hooks.js";import o from"../../../utils/useForm/useForm.js";import{getErrorMessage as s}from"../../../utils/getErrorMessage.js";import n from"../../internal/FormFields/Field/Field.js";import{useCoreContext as i}from"../../../core/Context/CoreProvider.js";import l from"../../internal/FormFields/InputText.js";import{bsbValidationRules as b}from"./validate.js";import{phoneFormatters as u}from"../../internal/PhoneInput/validate.js";import m from"./PayToNameFields.js";const c=["bankAccountNumber","bsb","firstName","lastName"];function d({setComponentRef:d,defaultData:p,placeholders:f,onChange:N,setStatus:h,id:k}){const{i18n:F}=i(),g=o({schema:c,defaultData:p,rules:b,formatters:u}),{handleChangeFor:j,triggerValidation:A,data:v,errors:B,valid:C,isValid:M}=g;a(()=>{N({data:v,valid:C,errors:B,isValid:M})},[v,C,B,M]);const x=t({setStatus:h,showValidation:A});return a(()=>{d(x.current)},[d]),e(r,{id:k,classNameModifiers:["payto__bsb_input"],label:"BSB",description:"payto.bsb.description"},e(n,{label:F.get("payto.bsb.label.bankAccountNumber"),classNameModifiers:["col-60","bankAccountNumber"],errorMessage:s(F,B.bankAccountNumber,F.get("payto.bsb.label.bankAccountNumber")),name:"bankAccountNumber",i18n:F},e(l,{name:"bankAccountNumber",value:v.bankAccountNumber,onInput:j("bankAccountNumber","input"),onBlur:j("bankAccountNumber","blur"),placeholder:null==f?void 0:f.bankAccountNumber,required:!0})),e(n,{label:F.get("Bank State Branch"),classNameModifiers:["col-40","bsb"],errorMessage:s(F,B.bsb,F.get("Bank State Branch")),name:"bsb",i18n:F},e(l,{name:"bsb",value:v.bsb,onInput:j("bsb","input"),onBlur:j("bsb","blur"),placeholder:null==f?void 0:f.bsb,required:!0})),e(m,{i18n:F,data:v,handleChangeFor:j,errors:B,placeholders:f}))}export{d as default};
|
|
2
2
|
//# sourceMappingURL=BSBInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BSBInput.js","sources":["../../../../../src/components/PayTo/components/BSBInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Fieldset from '../../internal/FormFields/Fieldset';\nimport { useEffect, useRef } from 'preact/hooks';\nimport useForm from '../../../utils/useForm';\nimport { getErrorMessage } from '../../../utils/getErrorMessage';\nimport Field from '../../internal/FormFields/Field';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport InputText from '../../internal/FormFields/InputText';\nimport { bsbValidationRules } from './validate';\nimport './PayIDInput.scss';\nimport { phoneFormatters } from '../../internal/PhoneInput/validate';\nimport { ComponentMethodsRef, UIElementStatus } from '../../internal/UIElement/types';\nimport PayToNameFields from './PayToNameFields';\nimport { PayToPlaceholdersType } from '../types';\n\nexport interface BSBFormData {\n bsb: string;\n bankAccountNumber: string;\n firstName: string;\n lastName: string;\n}\n\nexport interface BSBInputProps {\n status: UIElementStatus;\n setStatus: (status: UIElementStatus) => void;\n defaultData: BSBFormData;\n placeholders: PayToPlaceholdersType;\n onChange: (e) => void;\n setComponentRef: (ref: ComponentMethodsRef) => void;\n}\n\nconst BASE_SCHEMA = ['bankAccountNumber', 'bsb', 'firstName', 'lastName'];\n\nexport default function BSBInput({ setComponentRef, defaultData, placeholders, onChange, setStatus }: BSBInputProps) {\n const { i18n } = useCoreContext();\n\n const form = useForm<BSBFormData>({\n schema: BASE_SCHEMA,\n defaultData: defaultData,\n rules: bsbValidationRules,\n formatters: phoneFormatters\n });\n const { handleChangeFor, triggerValidation, data, errors, valid, isValid } = form;\n\n // standard onChange propagate to parent state\n useEffect(() => {\n onChange({ data, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n const payToRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus,\n showValidation: triggerValidation\n });\n\n useEffect(() => {\n setComponentRef(payToRef.current);\n }, [setComponentRef]);\n\n return (\n <Fieldset classNameModifiers={['payto__bsb_input']} label={'BSB'} description={'payto.bsb.description'}>\n <Field\n label={i18n.get('payto.bsb.label.bankAccountNumber')}\n classNameModifiers={['col-60', 'bankAccountNumber']}\n errorMessage={getErrorMessage(i18n, errors.bankAccountNumber, i18n.get('payto.bsb.label.bankAccountNumber'))}\n name={'bankAccountNumber'}\n i18n={i18n}\n >\n <InputText\n name={'bankAccountNumber'}\n value={data.bankAccountNumber}\n onInput={handleChangeFor('bankAccountNumber', 'input')}\n onBlur={handleChangeFor('bankAccountNumber', 'blur')}\n placeholder={placeholders?.bankAccountNumber}\n required={true}\n />\n </Field>\n\n <Field\n label={i18n.get('Bank State Branch')}\n classNameModifiers={['col-40', 'bsb']}\n errorMessage={getErrorMessage(i18n, errors.bsb, i18n.get('Bank State Branch'))}\n name={'bsb'}\n i18n={i18n}\n >\n <InputText\n name={'bsb'}\n value={data.bsb}\n onInput={handleChangeFor('bsb', 'input')}\n onBlur={handleChangeFor('bsb', 'blur')}\n placeholder={placeholders?.bsb}\n required={true}\n />\n </Field>\n\n <PayToNameFields i18n={i18n} data={data} handleChangeFor={handleChangeFor} errors={errors} placeholders={placeholders} />\n </Fieldset>\n );\n}\n"],"names":["BASE_SCHEMA","BSBInput","setComponentRef","defaultData","placeholders","onChange","setStatus","i18n","useCoreContext","form","useForm","schema","rules","bsbValidationRules","formatters","phoneFormatters","handleChangeFor","triggerValidation","data","errors","valid","isValid","useEffect","payToRef","useRef","showValidation","current","h","Fieldset","classNameModifiers","label","description","Field","get","errorMessage","getErrorMessage","bankAccountNumber","name","InputText","value","onInput","onBlur","placeholder","required","bsb","PayToNameFields"],"mappings":"
|
|
1
|
+
{"version":3,"file":"BSBInput.js","sources":["../../../../../src/components/PayTo/components/BSBInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Fieldset from '../../internal/FormFields/Fieldset';\nimport { useEffect, useRef } from 'preact/hooks';\nimport useForm from '../../../utils/useForm';\nimport { getErrorMessage } from '../../../utils/getErrorMessage';\nimport Field from '../../internal/FormFields/Field';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport InputText from '../../internal/FormFields/InputText';\nimport { bsbValidationRules } from './validate';\nimport './PayIDInput.scss';\nimport { phoneFormatters } from '../../internal/PhoneInput/validate';\nimport { ComponentMethodsRef, UIElementStatus } from '../../internal/UIElement/types';\nimport PayToNameFields from './PayToNameFields';\nimport { PayToPlaceholdersType } from '../types';\n\nexport interface BSBFormData {\n bsb: string;\n bankAccountNumber: string;\n firstName: string;\n lastName: string;\n}\n\nexport interface BSBInputProps {\n status: UIElementStatus;\n setStatus: (status: UIElementStatus) => void;\n defaultData: BSBFormData;\n placeholders: PayToPlaceholdersType;\n onChange: (e) => void;\n setComponentRef: (ref: ComponentMethodsRef) => void;\n id?: string;\n}\n\nconst BASE_SCHEMA = ['bankAccountNumber', 'bsb', 'firstName', 'lastName'];\n\nexport default function BSBInput({ setComponentRef, defaultData, placeholders, onChange, setStatus, id }: BSBInputProps) {\n const { i18n } = useCoreContext();\n\n const form = useForm<BSBFormData>({\n schema: BASE_SCHEMA,\n defaultData: defaultData,\n rules: bsbValidationRules,\n formatters: phoneFormatters\n });\n const { handleChangeFor, triggerValidation, data, errors, valid, isValid } = form;\n\n // standard onChange propagate to parent state\n useEffect(() => {\n onChange({ data, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n const payToRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus,\n showValidation: triggerValidation\n });\n\n useEffect(() => {\n setComponentRef(payToRef.current);\n }, [setComponentRef]);\n\n return (\n <Fieldset id={id} classNameModifiers={['payto__bsb_input']} label={'BSB'} description={'payto.bsb.description'}>\n <Field\n label={i18n.get('payto.bsb.label.bankAccountNumber')}\n classNameModifiers={['col-60', 'bankAccountNumber']}\n errorMessage={getErrorMessage(i18n, errors.bankAccountNumber, i18n.get('payto.bsb.label.bankAccountNumber'))}\n name={'bankAccountNumber'}\n i18n={i18n}\n >\n <InputText\n name={'bankAccountNumber'}\n value={data.bankAccountNumber}\n onInput={handleChangeFor('bankAccountNumber', 'input')}\n onBlur={handleChangeFor('bankAccountNumber', 'blur')}\n placeholder={placeholders?.bankAccountNumber}\n required={true}\n />\n </Field>\n\n <Field\n label={i18n.get('Bank State Branch')}\n classNameModifiers={['col-40', 'bsb']}\n errorMessage={getErrorMessage(i18n, errors.bsb, i18n.get('Bank State Branch'))}\n name={'bsb'}\n i18n={i18n}\n >\n <InputText\n name={'bsb'}\n value={data.bsb}\n onInput={handleChangeFor('bsb', 'input')}\n onBlur={handleChangeFor('bsb', 'blur')}\n placeholder={placeholders?.bsb}\n required={true}\n />\n </Field>\n\n <PayToNameFields i18n={i18n} data={data} handleChangeFor={handleChangeFor} errors={errors} placeholders={placeholders} />\n </Fieldset>\n );\n}\n"],"names":["BASE_SCHEMA","BSBInput","setComponentRef","defaultData","placeholders","onChange","setStatus","id","i18n","useCoreContext","form","useForm","schema","rules","bsbValidationRules","formatters","phoneFormatters","handleChangeFor","triggerValidation","data","errors","valid","isValid","useEffect","payToRef","useRef","showValidation","current","h","Fieldset","classNameModifiers","label","description","Field","get","errorMessage","getErrorMessage","bankAccountNumber","name","InputText","value","onInput","onBlur","placeholder","required","bsb","PayToNameFields"],"mappings":"oqBAgCA,MAAMA,EAAc,CAAC,oBAAqB,MAAO,YAAa,YAE/C,SAASC,GAASC,gBAAEA,EAAeC,YAAEA,EAAWC,aAAEA,EAAYC,SAAEA,EAAQC,UAAEA,EAASC,GAAEA,IAChG,MAAMC,KAAEA,GAASC,IAEXC,EAAOC,EAAqB,CAC9BC,OAAQZ,EACRG,YAAaA,EACbU,MAAOC,EACPC,WAAYC,KAEVC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,OAAEA,EAAMC,MAAEA,EAAKC,QAAEA,GAAYZ,EAG7Ea,EAAU,KACNlB,EAAS,CAAEc,OAAME,QAAOD,SAAQE,aACjC,CAACH,EAAME,EAAOD,EAAQE,IAEzB,MAAME,EAAWC,EAA4B,CACzCnB,UAAWA,EACXoB,eAAgBR,IAOpB,OAJAK,EAAU,KACNrB,EAAgBsB,EAASG,UAC1B,CAACzB,IAGA0B,EAACC,EAAAA,CAAStB,GAAIA,EAAIuB,mBAAoB,CAAC,oBAAqBC,MAAO,MAAOC,YAAa,yBACnFJ,EAACK,EAAAA,CACGF,MAAOvB,EAAK0B,IAAI,qCAChBJ,mBAAoB,CAAC,SAAU,qBAC/BK,aAAcC,EAAgB5B,EAAMY,EAAOiB,kBAAmB7B,EAAK0B,IAAI,sCACvEI,KAAM,oBACN9B,KAAMA,GAENoB,EAACW,EAAAA,CACGD,KAAM,oBACNE,MAAOrB,EAAKkB,kBACZI,QAASxB,EAAgB,oBAAqB,SAC9CyB,OAAQzB,EAAgB,oBAAqB,QAC7C0B,YAAavC,aAAAA,EAAAA,EAAciC,kBAC3BO,UAAU,KAIlBhB,EAACK,EAAAA,CACGF,MAAOvB,EAAK0B,IAAI,qBAChBJ,mBAAoB,CAAC,SAAU,OAC/BK,aAAcC,EAAgB5B,EAAMY,EAAOyB,IAAKrC,EAAK0B,IAAI,sBACzDI,KAAM,MACN9B,KAAMA,GAENoB,EAACW,EAAAA,CACGD,KAAM,MACNE,MAAOrB,EAAK0B,IACZJ,QAASxB,EAAgB,MAAO,SAChCyB,OAAQzB,EAAgB,MAAO,QAC/B0B,YAAavC,aAAAA,EAAAA,EAAcyC,IAC3BD,UAAU,KAIlBhB,EAACkB,EAAAA,CAAgBtC,KAAMA,EAAMW,KAAMA,EAAMF,gBAAiBA,EAAiBG,OAAQA,EAAQhB,aAAcA,IAGrH"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../external/preact/dist/preact.js";import r from"../../internal/FormFields/Fieldset/Fieldset.js";import i,{PayToIdentifierEnum as t}from"./IdentifierSelector.js";import{useEffect as o,useRef as a}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../utils/useForm/useForm.js";import l from"./PayToPhone.js";import s from"../../internal/FormFields/InputEmail.js";import{getErrorMessage as d}from"../../../utils/getErrorMessage.js";import m from"../../internal/FormFields/Field/Field.js";import{useCoreContext as p}from"../../../core/Context/CoreProvider.js";import c from"../../internal/FormFields/InputText.js";import{payIdValidationRules as f}from"./validate.js";import{phoneFormatters as u}from"../../internal/PhoneInput/validate.js";import g from"./PayToNameFields.js";function b(e,r,i){return r in e?Object.defineProperty(e,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[r]=i,e}function h(e){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{},t=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),t.forEach(function(r){b(e,r,i[r])})}return e}const I=["selectedIdentifier","firstName","lastName"],j={[t.email]:["email"],[t.phone]:["phoneNumber","phonePrefix"],[t.abn]:["abn"],[t.orgid]:["orgid"]};function y({setComponentRef:b,defaultData:y,placeholders:F,onChange:v,setStatus:N}){const{i18n:
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import r from"../../internal/FormFields/Fieldset/Fieldset.js";import i,{PayToIdentifierEnum as t}from"./IdentifierSelector.js";import{useEffect as o,useRef as a}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../utils/useForm/useForm.js";import l from"./PayToPhone.js";import s from"../../internal/FormFields/InputEmail.js";import{getErrorMessage as d}from"../../../utils/getErrorMessage.js";import m from"../../internal/FormFields/Field/Field.js";import{useCoreContext as p}from"../../../core/Context/CoreProvider.js";import c from"../../internal/FormFields/InputText.js";import{payIdValidationRules as f}from"./validate.js";import{phoneFormatters as u}from"../../internal/PhoneInput/validate.js";import g from"./PayToNameFields.js";function b(e,r,i){return r in e?Object.defineProperty(e,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[r]=i,e}function h(e){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{},t=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),t.forEach(function(r){b(e,r,i[r])})}return e}const I=["selectedIdentifier","firstName","lastName"],j={[t.email]:["email"],[t.phone]:["phoneNumber","phonePrefix"],[t.abn]:["abn"],[t.orgid]:["orgid"]};function y({setComponentRef:b,defaultData:y,placeholders:F,onChange:v,setStatus:N,id:P}){const{i18n:M}=p(),O=n({schema:I,defaultData:h({selectedIdentifier:t.phone},y),rules:f,formatters:u}),{handleChangeFor:C,triggerValidation:E,data:S,errors:x,valid:B,isValid:w,setSchema:D}=O;o(()=>{D([...j[S.selectedIdentifier],...I])},[S.selectedIdentifier]),o(()=>{v({data:S,valid:B,errors:x,isValid:w})},[S,B,x,w]);const V=a({setStatus:N,showValidation:E});return o(()=>{b(V.current)},[b]),e(r,{id:P,classNameModifiers:["payto__payid_input"],label:"PayID",description:"payto.payid.description"},e(i,{classNameModifiers:["col-40"],onSelectedIdentifier:C("selectedIdentifier"),selectedIdentifier:S.selectedIdentifier}),S.selectedIdentifier===t.phone&&e(l,{onChange:C("phone","blur"),data:S,form:O}),S.selectedIdentifier===t.email&&e(m,{label:M.get("shopperEmail"),classNameModifiers:["col-60","email"],errorMessage:d(M,x.email,M.get("shopperEmail")),dir:"ltr",name:"email",i18n:M},e(s,{name:"email",value:S.email,onInput:C("email","input"),onBlur:C("email","blur"),placeholder:null==F?void 0:F.email,required:!0})),S.selectedIdentifier===t.abn&&e(m,{label:M.get("ABN"),classNameModifiers:["col-60","abn"],errorMessage:d(M,x.abn,M.get("ABN")),name:"ABN",i18n:M},e(c,{name:"abn",value:S.abn,onInput:C("abn","input"),onBlur:C("abn","blur"),placeholder:null==F?void 0:F.abn,required:!0})),S.selectedIdentifier===t.orgid&&e(m,{label:M.get("payto.payid.label.orgid"),classNameModifiers:["col-60","orgid"],errorMessage:d(M,x.orgid,M.get("payto.payid.label.orgid")),name:"orgid",i18n:M},e(c,{name:"orgid",value:S.orgid,onInput:C("orgid","input"),onBlur:C("orgid","blur"),placeholder:null==F?void 0:F.orgid,required:!0})),e(g,{i18n:M,data:S,handleChangeFor:C,errors:x,placeholders:F}))}export{y as default};
|
|
2
2
|
//# sourceMappingURL=PayIDInput.js.map
|