@moneybar.online/moneybar 3.3.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,10 +54,11 @@ const VALUE_FIRST_CONFIG = {
54
54
  url: 'your-supabase-url',
55
55
  anonKey: 'your-anon-key'
56
56
  },
57
- payment: {
57
+ payment: [{
58
+ provider: 'dodo',
58
59
  productId: 'your-product-id',
59
60
  mode: 'test'
60
- },
61
+ }],
61
62
  theme: {
62
63
  name: 'emerald', // Trustworthy, fresh
63
64
  primaryColor: '#059669'
@@ -86,10 +87,11 @@ const FEEDBACK_INTELLIGENCE_CONFIG = {
86
87
  url: 'your-supabase-url',
87
88
  anonKey: 'your-anon-key'
88
89
  },
89
- payment: {
90
+ payment: [{
91
+ provider: 'dodo',
90
92
  productId: 'your-product-id',
91
93
  mode: 'test'
92
- },
94
+ }],
93
95
  // KEY FEATURE: Feedback collection on cancel/exit
94
96
  feedback: {
95
97
  form: {
@@ -136,10 +138,11 @@ const INSTANT_PAYMENT_CONFIG = {
136
138
  url: 'your-supabase-url',
137
139
  anonKey: 'your-anon-key'
138
140
  },
139
- payment: {
141
+ payment: [{
142
+ provider: 'dodo',
140
143
  productId: 'your-product-id',
141
144
  mode: 'test'
142
- },
145
+ }],
143
146
  theme: {
144
147
  name: 'dark', // Modern, premium feel
145
148
  primaryColor: '#7c3aed'
@@ -184,10 +187,11 @@ window.APP_CONFIG = {
184
187
  },
185
188
 
186
189
  // REQUIRED: Payment configuration
187
- payment: {
190
+ payment: [{
191
+ provider: 'dodo',
188
192
  productId: 'your-dodo-payments-product-id',
189
193
  mode: 'test' // Change to 'live' for production
190
- },
194
+ }],
191
195
 
192
196
  // OPTIONAL: UI Theme (29 themes available)
193
197
  theme: {
package/package.json CHANGED
@@ -1,17 +1,16 @@
1
1
  {
2
2
  "name": "@moneybar.online/moneybar",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "The navbar of monetization. Fix the 3 money-blocking stages: forced sign-ins, silent drop-offs, and broken payment flows. Turn browsers into buyers.",
5
- "main": "dist/index.cjs.js",
5
+ "main": "dist/index.esm.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "browser": "dist/index.browser.js",
8
- "unpkg": "dist/index.umd.js",
8
+ "unpkg": "dist/index.bundle.js",
9
9
  "types": "dist/index.d.ts",
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
13
13
  "import": "./dist/index.esm.js",
14
- "require": "./dist/index.cjs.js",
15
14
  "browser": "./dist/index.browser.js",
16
15
  "types": "./dist/index.d.ts"
17
16
  }
package/src/index.ts CHANGED
@@ -333,26 +333,37 @@ export class MoneyBar {
333
333
  throw new Error('Payment configuration not provided');
334
334
  }
335
335
 
336
+ const payment = this.config.payment?.find(p => p.provider === 'dodo');
337
+ if (!payment) {
338
+ throw new Error('No dodo payment provider configured');
339
+ }
340
+
336
341
  const requestBody = {
337
342
  email: this.currentUser.email,
338
- product_id: this.config.payment.productId,
339
- mode: this.config.payment.mode || 'test',
343
+ product_id: payment.productId,
344
+ mode: payment.mode || 'test',
340
345
  app_id: this.config.appId,
341
346
  return_url: `${window.location.origin}${window.location.pathname}?payment=success`
342
347
  };
343
348
 
344
- console.log(`🔥 [SUPABASE API] createPayment called for email: ${this.currentUser.email} | Time: ${new Date().toISOString()}`);
349
+ console.log(`🔥 [PAYMENT API] createPayment called for provider: ${payment.provider}, email: ${this.currentUser.email} | Time: ${new Date().toISOString()}`);
345
350
 
346
351
  try {
347
- const response = await fetch(`${this.config.supabase.url}/functions/v1/create-payment`, {
348
- method: 'POST',
349
- headers: {
350
- 'Content-Type': 'application/json',
351
- 'Authorization': `Bearer ${this.config.supabase.anonKey}`
352
- },
353
- body: JSON.stringify(requestBody)
354
- });
355
- console.log(`🔥 [SUPABASE API] createPayment response: ${response.status}`);
352
+ // Route to appropriate payment API based on provider
353
+ let response;
354
+ if (payment.provider === 'dodo') {
355
+ response = await fetch(`${this.config.supabase.url}/functions/v1/create-payment`, {
356
+ method: 'POST',
357
+ headers: {
358
+ 'Content-Type': 'application/json',
359
+ 'Authorization': `Bearer ${this.config.supabase.anonKey}`
360
+ },
361
+ body: JSON.stringify(requestBody)
362
+ });
363
+ } else {
364
+ throw new Error(`Payment provider '${payment.provider}' is not yet supported`);
365
+ }
366
+ console.log(`🔥 [PAYMENT API] createPayment response for ${payment.provider}: ${response.status}`);
356
367
 
357
368
  if (this.config.options?.debug) {
358
369
  //console.log('🔍 DEBUG: createPayment response status:', response.status);
@@ -3010,7 +3021,15 @@ User Agent: ${feedbackData.userAgent}
3010
3021
  }
3011
3022
 
3012
3023
  // Validate product ID format
3013
- const productId = this.config.payment.productId;
3024
+ const payment = this.config.payment?.find(p => p.provider === 'dodo');
3025
+ if (!payment) {
3026
+ this.paymentConnectionFailed = true;
3027
+ if (this.config.options?.debug) {
3028
+ console.warn('No dodo payment provider configured');
3029
+ }
3030
+ return;
3031
+ }
3032
+ const productId = payment.productId;
3014
3033
  if (!productId || !productId.startsWith('pdt_') || productId.length < 10) {
3015
3034
  this.paymentConnectionFailed = true;
3016
3035
  if (this.config.options?.debug) {
package/src/types.ts CHANGED
@@ -11,11 +11,14 @@ export interface MoneyBarConfig {
11
11
  anonKey: string;
12
12
  };
13
13
 
14
- /** DodoPayments product configuration */
15
- payment?: {
14
+ /** Payment configuration - extensible for multiple providers */
15
+ payment?: Array<{
16
+ provider: 'dodo' | 'stripe' | 'paypal' | 'square' | 'paddle'; // Extensible for future providers
16
17
  productId: string;
17
18
  mode?: 'test' | 'live';
18
- };
19
+ apiKey?: string; // For providers that need API keys
20
+ publishableKey?: string; // For client-side keys (Stripe, etc.)
21
+ }>;
19
22
 
20
23
  /** Optional: Feedback form configuration */
21
24
  feedback?: {