@adyen/adyen-web
Version:
[](https://www.npmjs.com/package/@adyen/adyen-web)
3 lines (2 loc) • 2.73 kB
JavaScript
import s from"../Services/sessions/make-payment.js";import t from"../Services/sessions/submit-details.js";import e from"../Services/sessions/fetch-donation-campaigns.js";import i from"../Services/sessions/make-donation.js";import o from"../Services/sessions/setup-session.js";import n from"../Services/sessions/check-balance.js";import a from"../../utils/Storage.js";import r from"../Services/sessions/create-order.js";import{sanitizeSession as h}from"./utils.js";import d from"../Services/sessions/cancel-order.js";import c from"../../utils/browserInfo.js";function u(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}class D{get shopperLocale(){return this.session.shopperLocale}get id(){return this.session.id}get data(){return this.session.sessionData}set sessionsDonationInitiated(s){this._sessionsDonationInitiated=s}get sessionsDonationInitiated(){return this._sessionsDonationInitiated}updateSessionData(s){this.session.sessionData=s,this.storeSession()}setupSession(s){const t={...s,browserInfo:c()};return o(this,t).then(s=>(s.configuration&&(this.configuration={...s.configuration}),s.sessionData&&this.updateSessionData(s.sessionData),s))}submitPayment(t){return s(t,this).then(s=>(s.sessionData&&this.updateSessionData(s.sessionData),s))}submitDetails(s){return t(s,this).then(s=>(s.sessionData&&this.updateSessionData(s.sessionData),s))}fetchDonationCampaigns(){return e(this).then(s=>(s.sessionData&&this.updateSessionData(s.sessionData),s))}makeDonation(s){return i(s,this).then(s=>(s.sessionData&&this.updateSessionData(s.sessionData),s))}checkBalance(s){return n(s,this).then(s=>(s.sessionData&&this.updateSessionData(s.sessionData),s))}createOrder(){return r(this).then(s=>(s.sessionData&&this.updateSessionData(s.sessionData),s))}cancelOrder(s){return d(s.order,this).then(s=>(s.sessionData&&this.updateSessionData(s.sessionData),s))}getStoredSession(){const s=this.storage.get();return this.id===s?.id?s:this.session}storeSession(){this.storage.set({id:this.session.id,sessionData:this.session.sessionData})}removeStoredSession(){this.storage.remove()}constructor(s,t,e){u(this,"storage",void 0),u(this,"session",void 0),u(this,"clientKey",void 0),u(this,"loadingContext",void 0),u(this,"configuration",void 0),u(this,"_sessionsDonationInitiated",void 0);const i=h(s);if(!t)throw new Error("No clientKey available");if(!e)throw new Error("No loadingContext available");this.storage=new a("session","localStorage"),this.clientKey=t,this.loadingContext=e,this.session=i,this._sessionsDonationInitiated=!1,this.session.sessionData?this.storeSession():this.session=this.getStoredSession()}}export{D as default};
//# sourceMappingURL=CheckoutSession.js.map