@adyen/adyen-web
Version:
[](https://www.npmjs.com/package/@adyen/adyen-web)
3 lines (2 loc) • 2.77 kB
JavaScript
import{createElement as t,Fragment as e}from"../../external/preact/dist/preact.js";import{UIElement as o}from"../internal/UIElement/UIElement.js";import{Await as s}from"../internal/Await/Await.js";import{TxVariants as r}from"../tx-variants.js";import{PayToIdentifierEnum as a}from"./components/IdentifierSelector.js";import n from"./components/PayToComponent.js";import{PayToInstructions as p}from"./components/PayToInstructions.js";import i from"./components/MandateSummary.js";import m from"../internal/PayButton/PayButton.js";import{payAmountLabel as d}from"../internal/PayButton/utils.js";function h(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}const l=6e4,c=1e4,u=!1,y=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 f extends o{formatProps(t){return{...t,data:{...t.data,phonePrefix:"+61"}}}formatData(){return this.props.storedPaymentMethodId?{paymentMethod:{type:f.type,storedPaymentMethodId:this.props.storedPaymentMethodId}}:{paymentMethod:{type:f.type,shopperAccountIdentifier:y(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:""}componentToRender(){return this.props.storedPaymentMethodId?t(e,null,this.props.showPayButton&&t(m,{...this.props,classNameModifiers:["standalone"],label:d(this.props.i18n,this.props.amount),onClick:this.submit})):this.props.paymentData?t(s,{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:u,throttleTime:l,throttleInterval:c,onActionHandled:this.onActionHandled,endSlot:()=>!!this.props.mandate&&t(i,{mandate:this.props.mandate,payee:this.props.payee,currencyCode:this.props.amount.currency})}):t(n,{data:this.props.data,placeholders:this.props.placeholders,setComponentRef:this.setComponentRef,onChange:this.setState,payButton:this.payButton,showPayButton:this.props.showPayButton})}}h(f,"type",r.payto),h(f,"defaultProps",{placeholders:{}});export{f as PayToElement,f as default};
//# sourceMappingURL=PayTo.js.map