@atlas-kitchen/adyen-web
Version:
3 lines (2 loc) • 3.24 kB
JavaScript
import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import{CoreProvider as o}from"../../core/Context/CoreProvider.js";import s from"../internal/Await/Await.js";import r from"../../core/Errors/SRPanelProvider.js";import{TxVariants as n}from"../tx-variants.js";import{PayToIdentifierEnum as a}from"./components/IdentifierSelector.js";import i from"./components/PayToComponent.js";import{PayToInstructions as p}from"./components/PayToInstructions.js";import m from"./components/MandateSummary.js";import h from"../internal/PayButton/PayButton.js";import{payAmountLabel as d}from"../internal/PayButton/utils.js";function l(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}const u=6e4,c=1e4,y=!1,f=t=>{if("bsb-option"===t.selectedInput)return`${t.bsb}-${t.bankAccountNumber}`;if("payid-option"===t.selectedInput)switch(t.selectedIdentifier){case a.email:return t.email;case a.abn:return t.abn;case a.orgid:return t.orgid;case a.phone:return`${t.phonePrefix}-${t.phoneNumber}`}};class P extends e{formatProps(t){return{...t,data:{...t.data,phonePrefix:"+61"}}}formatData(){return this.props.storedPaymentMethodId?{paymentMethod:{type:P.type,storedPaymentMethodId:this.props.storedPaymentMethodId}}:{paymentMethod:{type:P.type,shopperAccountIdentifier:f(this.state.data)},shopperName:{firstName:this.state.data.firstName,lastName:this.state.data.lastName}}}get isValid(){return!!this.props.storedPaymentMethodId||!!this.state.isValid}get displayName(){return this.props.storedPaymentMethodId&&this.props.label?this.props.label:this.props.name}get additionalInfo(){return this.props.storedPaymentMethodId?this.props.name:""}render(){return this.props.storedPaymentMethodId?t(o,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},this.props.showPayButton&&t(h,{...this.props,classNameModifiers:["standalone"],amount:this.props.amount,label:d(this.props.i18n,this.props.amount),onClick:this.submit})):this.props.paymentData?t(o,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(r,{srPanel:this.props.modules.srPanel},t(s,{ref:t=>{this.componentRef=t},amount:this.props.amount,showAmount:!0,instructions:p,clientKey:this.props.clientKey,paymentData:this.props.paymentData,onError:this.props.onError,onComplete:this.onComplete,brandLogo:this.icon,type:this.constructor.type,messageText:this.props.i18n.get("payto.confirmPayment"),awaitText:this.props.i18n.get("payto.await.waitForConfirmation"),showCountdownTimer:y,throttleTime:u,throttleInterval:c,onActionHandled:this.onActionHandled,endSlot:()=>!!this.props.mandate&&t(m,{mandate:this.props.mandate,payee:this.props.payee,currencyCode:this.props.amount.currency})}))):t(o,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(i,{data:this.props.data,placeholders:this.props.placeholders,setComponentRef:this.setComponentRef,onChange:this.setState,payButton:this.payButton,showPayButton:this.props.showPayButton}))}}l(P,"type",n.payto),l(P,"defaultProps",{placeholders:{}});export{P as PayToElement,P as default};
//# sourceMappingURL=PayTo.js.map