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.96 kB
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 r from"../internal/Await/Await.js";import s 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 c}from"../internal/PayButton/utils.js";function d(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function l(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){d(t,e,o[e])}))}return t}function u(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 y=6e4,f=1e4,b=!1,P=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 g extends e{formatProps(t){return u(l({},t),{data:u(l({},t.data),{phonePrefix:"+61"})})}formatData(){return this.props.storedPaymentMethodId?{paymentMethod:{type:g.type,storedPaymentMethodId:this.props.storedPaymentMethodId}}:{paymentMethod:{type:g.type,shopperAccountIdentifier:P(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,u(l({},this.props),{classNameModifiers:["standalone"],amount:this.props.amount,label:c(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(s,{srPanel:this.props.modules.srPanel},t(r,{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:b,throttleTime:y,throttleInterval:f,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}))}}d(g,"type",n.payto),d(g,"defaultProps",{placeholders:{}});export{g as PayToElement,g as default}; //# sourceMappingURL=PayTo.js.map