UNPKG

@adyen/adyen-web

Version:

[![npm](https://img.shields.io/npm/v/@adyen/adyen-web.svg)](https://www.npmjs.com/package/@adyen/adyen-web)

3 lines (2 loc) 3.48 kB
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 r}from"../internal/Await/Await.js";import{TxVariants as n}from"../tx-variants.js";import{PayToIdentifierEnum as s}from"./components/IdentifierSelector.js";import a 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 c}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}function d(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable}))),r.forEach(function(e){h(t,e,o[e])})}return t}function l(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e.push.apply(e,o)}return e}(Object(e)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(e,o))}),t}const u=6e4,y=1e4,f=!1,b=t=>{if("bsb-option"===t.selectedInput)return`${t.bsb}-${t.bankAccountNumber}`;if("payid-option"===t.selectedInput)switch(t.selectedIdentifier){case s.email:return t.email;case s.abn:return t.abn;case s.orgid:return t.orgid;case s.phone:return`${t.phonePrefix}-${t.phoneNumber}`}};class P extends o{formatProps(t){return l(d({},t),{data:l(d({},t.data),{phonePrefix:"+61"})})}formatData(){return this.props.storedPaymentMethodId?{paymentMethod:{type:P.type,storedPaymentMethodId:this.props.storedPaymentMethodId}}:{paymentMethod:{type:P.type,shopperAccountIdentifier:b(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,l(d({},this.props),{classNameModifiers:["standalone"],label:c(this.props.i18n,this.props.amount),onClick:this.submit}))):this.props.paymentData?t(r,{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:f,throttleTime:u,throttleInterval:y,onActionHandled:this.onActionHandled,endSlot:()=>!!this.props.mandate&&t(i,{mandate:this.props.mandate,payee:this.props.payee,currencyCode:this.props.amount.currency})}):t(a,{data:this.props.data,placeholders:this.props.placeholders,setComponentRef:this.setComponentRef,onChange:this.setState,payButton:this.payButton,showPayButton:this.props.showPayButton})}}h(P,"type",n.payto),h(P,"defaultProps",{placeholders:{}});export{P as PayToElement,P as default}; //# sourceMappingURL=PayTo.js.map