UNPKG

apple-pay

Version:

Wrapper for working with Apple Pay payments

2 lines (1 loc) 2.28 kB
var r=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var _=o=>r(o,"__esModule",{value:!0});var P=(o,e)=>{for(var t in e)r(o,t,{get:e[t],enumerable:!0})},I=(o,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of A(e))!T.call(o,p)&&(t||p!=="default")&&r(o,p,{get:()=>e[p],enumerable:!(s=a(e,p))||s.enumerable});return o};var l=(o=>(e,t)=>o&&o.get(e)||(t=I(_({}),e,1),o&&o.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var u={};P(u,{STATUS_FAILURE:()=>N,STATUS_INVALID_BILLING_POSTAL_ADDRESS:()=>c,STATUS_INVALID_SHIPPING_CONTACT:()=>y,STATUS_INVALID_SHIPPING_POSTAL_ADDRESS:()=>m,STATUS_PIN_INCORRECT:()=>U,STATUS_PIN_LOCKOUT:()=>R,STATUS_PIN_REQUIRED:()=>h,STATUS_SUCCESS:()=>L,default:()=>n});var S={amex:1,cartesBancaires:4,chinaUnionPay:1,discover:1,eftpos:4,electron:4,elo:5,girocard:11,interac:1,jcb:2,mada:5,maestro:4,masterCard:1,mir:11,privateLabel:1,visa:1,vPay:4};var n=class{options;session;constructor(e){this.options=e}static get isPaymentAvailable(){return ApplePaySession&&ApplePaySession.canMakePayments()}startSession(){let e=this.getAppalePayVersion(),t=this.getApplePayRequest(e);this.session=new ApplePaySession(e,t),this.session.onvalidatemerchant=this.options.onValidateMerchant,this.session.onpaymentauthorized=this.options.onPaymentAuthorized;try{this.session.begin()}catch{}}completeMerchantValidation(e){var t;(t=this.session)==null||t.completeMerchantValidation(e)}abort(){var e;(e=this.session)==null||e.abort()}completePayment(e){var t;(t=this.session)==null||t.completePayment(e)}getAppalePayVersion(){var e;return(e=Array(12).fill("").map((t,s)=>++s).reverse().find(ApplePaySession.supportsVersion))!=null?e:1}filterSupportedNetworksByVersion(e,t){return e.filter(s=>S[s]<=t)}getApplePayRequest(e){return this.options.paymentRequest.supportedNetworks=this.filterSupportedNetworksByVersion(this.options.paymentRequest.supportedNetworks,e),this.options.paymentRequest}},N=0,c=2,y=4,m=3,U=6,R=7,h=5,L=0;module.exports=l(u);0&&(module.exports={STATUS_FAILURE,STATUS_INVALID_BILLING_POSTAL_ADDRESS,STATUS_INVALID_SHIPPING_CONTACT,STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,STATUS_PIN_INCORRECT,STATUS_PIN_LOCKOUT,STATUS_PIN_REQUIRED,STATUS_SUCCESS});