@wallfar/ocd-studio-core-sdk
Version:
Helper SDK for our OneClick Studio modules
26 lines (25 loc) • 1.13 kB
JavaScript
import { validatePromoCode as validatePromoCodeFirebase, createPaymentLinkStripe as createPaymentLinkFirebaseStripe } from './providers/firebase.js';
class WebshopServer {
constructor(config) {
this.config = config;
if (!this.config.defaultBrand)
this.config.defaultBrand = '';
if (!this.config.defaultCurrency)
this.config.defaultCurrency = 'USD';
if (!this.config.defaultLocale)
this.config.defaultLocale = 'en-US';
}
async validatePromoCode(code) {
if (this.config.provider === 'firebase') {
return await validatePromoCodeFirebase(this.config.firebase, code);
}
throw new Error(`Provider ${this.config.provider} not supported.`);
}
async createPaymentLink(checkoutData) {
if (this.config.provider === 'firebase' && this.config.paymentProvider === 'stripe') {
return await createPaymentLinkFirebaseStripe(this.config.firebase, this.config.stripe, checkoutData);
}
throw new Error(`Provider ${this.config.provider} not supported.`);
}
}
export default WebshopServer;