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) 2.83 kB
import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./components/AchInput/AchInput.js";import{CoreProvider as r}from"../../core/Context/CoreProvider.js";import s from"../internal/RedirectButton/RedirectButton.js";import{TxVariants as n}from"../tx-variants.js";function i(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function a(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){i(t,e,o[e])}))}return t}function p(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}class h extends e{formatProps(t){var e;return p(a({},t),{holderNameRequired:null!==(e=t.hasHolderName)&&void 0!==e?e:t.holderNameRequired})}formatData(){var t;const e=!!this.props.storedPaymentMethodId,o=a(p(a({type:h.type},this.state.data),{ownerName:null===(t=this.state.data)||void 0===t?void 0:t.holderName}),e&&{storedPaymentMethodId:this.props.storedPaymentMethodId});return delete o.holderName,a({paymentMethod:o},this.state.storePaymentMethod&&{storePaymentMethod:this.state.storePaymentMethod})}updateStyles(t){return this.componentRef&&this.componentRef.updateStyles&&this.componentRef.updateStyles(t),this}setFocusOn(t){return this.componentRef&&this.componentRef.setFocusOn&&this.componentRef.setFocusOn(t),this}get isValid(){return!!this.props.storedPaymentMethodId||!!this.state.isValid}get displayName(){return this.props.storedPaymentMethodId&&this.props.bankAccountNumber?`•••• ${this.props.bankAccountNumber.slice(-4)}`:this.props.name}get additionalInfo(){return this.props.storedPaymentMethodId?this.props.i18n.get("ach.savedBankAccount"):""}render(){return t(r,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},this.props.storedPaymentMethodId?t(s,{showPayButton:this.props.showPayButton,name:this.displayName,amount:this.props.amount,payButton:this.payButton,onSubmit:this.submit,ref:t=>{this.componentRef=t}}):t(o,p(a({setComponentRef:this.setComponentRef,handleKeyPress:this.handleKeyPress},this.props),{onChange:this.setState,onSubmit:this.submit,payButton:this.payButton,resources:this.resources})))}}i(h,"type",n.ach);export{h as AchElement,h as default}; //# sourceMappingURL=Ach.js.map