@moneybar.online/moneybar 3.8.0 → 3.9.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.
Files changed (2) hide show
  1. package/README.md +11 -92
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -21,7 +21,7 @@ npm install @moneybar.online/moneybar
21
21
  import { MoneyBar } from '@moneybar.online/moneybar';
22
22
 
23
23
  const moneyBar = new MoneyBar({
24
- actionFunction: 'generatePDF', // Function name that gets called
24
+ actionFunction: 'generatePDF',
25
25
  appId: 'my-pdf-app',
26
26
  freeAttemptLimit: 3,
27
27
  supabase: {
@@ -35,14 +35,8 @@ const moneyBar = new MoneyBar({
35
35
  }]
36
36
  });
37
37
 
38
- moneyBar.attachToButton('#action-btn', (userContext) => {
39
- // Call the specified action function
40
- if (typeof window[moneyBar.config.actionFunction] === 'function') {
41
- window[moneyBar.config.actionFunction](userContext);
42
- }
43
- });
38
+ moneyBar.attachToButton('#action-btn', generatePDF);
44
39
 
45
- // Define the function specified in actionFunction
46
40
  function generatePDF(userContext) {
47
41
  if (userContext.isPremium) {
48
42
  alert('Premium PDF generated with all features!');
@@ -52,47 +46,33 @@ function generatePDF(userContext) {
52
46
  }
53
47
  ```
54
48
 
55
- ### Option 2: CDN with Import Map (Recommended for HTML projects)
49
+ ### Option 2: CDN (Recommended for HTML projects)
56
50
  ```html
57
51
  <!DOCTYPE html>
58
52
  <html>
59
53
  <body>
60
54
  <button id="action-btn">Try Action</button>
61
55
 
62
- <!-- Import map for dependencies -->
63
- <script type="importmap">
64
- {
65
- "imports": {
66
- "@supabase/supabase-js": "https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2/+esm"
67
- }
68
- }
69
- </script>
70
-
71
- <!-- MoneyBar configuration -->
72
56
  <script type="module">
73
- import { MoneyBar } from 'https://cdn.jsdelivr.net/npm/@moneybar.online/moneybar/dist/index.browser.js';
57
+ import { MoneyBar } from 'https://cdn.jsdelivr.net/npm/@moneybar.online/moneybar@latest/dist/index.bundle.js';
74
58
 
75
59
  const moneyBar = new MoneyBar({
76
- actionFunction: 'myAction', // Function name that gets called
60
+ actionFunction: 'myAction',
77
61
  appId: 'my-app',
78
62
  freeAttemptLimit: 3,
79
63
  supabase: {
80
64
  url: 'your-supabase-url',
81
65
  anonKey: 'your-anon-key'
82
66
  },
83
- payment: {
84
- productId: 'your-product-id'
85
- }
67
+ payment: [{
68
+ provider: 'dodo',
69
+ productId: 'your-product-id',
70
+ mode: 'test'
71
+ }]
86
72
  });
87
73
 
88
- moneyBar.attachToButton('#action-btn', (userContext) => {
89
- // Call the specified action function
90
- if (typeof window[moneyBar.config.actionFunction] === 'function') {
91
- window[moneyBar.config.actionFunction](userContext);
92
- }
93
- });
74
+ moneyBar.attachToButton('#action-btn', myAction);
94
75
 
95
- // Define the function specified in actionFunction
96
76
  function myAction(userContext) {
97
77
  if (userContext.isPremium) {
98
78
  alert('Premium features unlocked!');
@@ -105,67 +85,6 @@ function generatePDF(userContext) {
105
85
  </html>
106
86
  ```
107
87
 
108
- ### Option 3: Self-Contained Bundle (No import map needed)
109
- ```html
110
- <!DOCTYPE html>
111
- <html>
112
- <body>
113
- <button id="action-btn">Try Action</button>
114
-
115
- <!-- Single file - no dependencies needed -->
116
- <script type="module">
117
- import { MoneyBar } from 'https://cdn.jsdelivr.net/npm/@moneybar.online/moneybar/dist/index.bundle.js';
118
-
119
- const moneyBar = new MoneyBar({
120
- actionFunction: 'myAction', // Function name that gets called
121
- appId: 'my-app',
122
- freeAttemptLimit: 3,
123
- supabase: {
124
- url: 'your-supabase-url',
125
- anonKey: 'your-anon-key'
126
- },
127
- payment: {
128
- productId: 'your-product-id'
129
- }
130
- });
131
-
132
- moneyBar.attachToButton('#action-btn', (userContext) => {
133
- // Call the specified action function
134
- if (typeof window[moneyBar.config.actionFunction] === 'function') {
135
- window[moneyBar.config.actionFunction](userContext);
136
- }
137
- });
138
-
139
- // Define the function specified in actionFunction
140
- function myAction(userContext) {
141
- // Your business logic here
142
- alert(`Action executed! Premium: ${userContext.isPremium}, Remaining: ${userContext.remaining}`);
143
- }
144
- </script>
145
- </body>
146
- </html>
147
- ```
148
-
149
- ### Option 4: UMD Script Tags (No modules)
150
- ```html
151
- <!DOCTYPE html>
152
- <html>
153
- <body>
154
- <button id="action-btn">Try Action</button>
155
-
156
- <!-- Traditional script tags -->
157
- <script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2/dist/umd/supabase.min.js"></script>
158
- <script src="https://cdn.jsdelivr.net/npm/@moneybar.online/moneybar/dist/index.umd.js"></script>
159
- <script>
160
- const moneyBar = new MoneyBar.MoneyBar({
161
- appId: 'my-app',
162
- // ... configuration
163
- });
164
- </script>
165
- </body>
166
- </html>
167
- ```
168
-
169
88
  ### Quick Start Template
170
89
  Copy `moneybar-config-template.js` and `example-template.html` from this package for a ready-to-use template.
171
90
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneybar.online/moneybar",
3
- "version": "3.8.0",
3
+ "version": "3.9.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
5
  "main": "dist/index.esm.js",
6
6
  "module": "dist/index.esm.js",