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.27 kB
function e(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}class n{begin(){return this.session.begin()}onvalidatemerchant(e,n){return new Promise((t,o)=>{n(t,o,e.validationURL)}).then(e=>{this.session.completeMerchantValidation(e)}).catch(e=>{console.error(e),this.session.abort(),this.options.onError(e)})}onpaymentauthorized(e,n){return new Promise((t,o)=>n(t,o,e)).then(e=>{this.session.completePayment(e)}).catch(e=>{this.session.completePayment(e)})}onpaymentmethodselected(e,n){return new Promise((t,o)=>n(t,o,e)).then(e=>{this.session.completePaymentMethodSelection(e)}).catch(e=>{this.session.completePaymentMethodSelection(e)})}onshippingcontactselected(e,n){return new Promise((t,o)=>n(t,o,e)).then(e=>{this.session.completeShippingContactSelection(e)}).catch(e=>{this.session.completeShippingContactSelection(e)})}onshippingmethodselected(e,n){return new Promise((t,o)=>n(t,o,e)).then(e=>{this.session.completeShippingMethodSelection(e)}).catch(e=>{this.session.completeShippingMethodSelection(e)})}oncouponcodechanged(e,n){return new Promise((t,o)=>n(t,o,e)).then(e=>{this.session.completeCouponCodeChange(e)}).catch(e=>{this.session.completeCouponCodeChange(e)})}oncancel(e,n){n(e)}constructor(n,t){e(this,"session",void 0),e(this,"options",void 0),this.options=t,this.session=new ApplePaySession(t.version,n),this.session.onvalidatemerchant=e=>{this.onvalidatemerchant(e,t.onValidateMerchant)},this.session.onpaymentauthorized=e=>{this.onpaymentauthorized(e,t.onPaymentAuthorized)},this.session.oncancel=e=>{this.oncancel(e,t.onCancel)},"function"==typeof t.onPaymentMethodSelected&&(this.session.onpaymentmethodselected=e=>{this.onpaymentmethodselected(e,t.onPaymentMethodSelected)}),"function"==typeof t.onShippingContactSelected&&(this.session.onshippingcontactselected=e=>{this.onshippingcontactselected(e,t.onShippingContactSelected)}),"function"==typeof t.onShippingMethodSelected&&(this.session.onshippingmethodselected=e=>{this.onshippingmethodselected(e,t.onShippingMethodSelected)}),"function"==typeof t.onCouponCodeChanged&&(this.session.oncouponcodechanged=e=>{this.oncouponcodechanged(e,t.onCouponCodeChanged)})}}export{n as default}; //# sourceMappingURL=ApplePayService.js.map