@easyflow/javascript-sdk 2.1.24 → 2.1.26

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.
@@ -0,0 +1,235 @@
1
+ # 🚀 Easyflow SDK - Platform Integration Guide
2
+
3
+ ## 📋 Overview
4
+
5
+ The Easyflow SDK provides a **dual initialization approach** to serve both traditional developers and low-code/no-code platforms. This guide explains the `initializeForPlatform` mechanism and how to use it effectively.
6
+
7
+ ## 🔧 Two Ways to Initialize
8
+
9
+ ### 1. **Traditional Initialization** (For Developers)
10
+
11
+ ```javascript
12
+ // Direct SDK instance - Full control
13
+ const sdk = new EasyflowSDK('your-business-id')
14
+
15
+ // Use all SDK methods directly
16
+ await sdk.createCustomer(customerData)
17
+ await sdk.placeOrder(offerId, orderData)
18
+ await sdk.charge(paymentData)
19
+ ```
20
+
21
+ ### 2. **Platform Integration** (For Low-Code/No-Code)
22
+
23
+ ```javascript
24
+ // Platform wrapper - Simplified API
25
+ const wrapper = EasyflowSDK.initializeForPlatform({
26
+ businessId: 'your-business-id',
27
+ enableDebug: true,
28
+ })
29
+
30
+ // Use simplified methods
31
+ await wrapper.createCustomer(customerData)
32
+ await wrapper.placeOrder(offerId, orderData)
33
+ await wrapper.charge(paymentData)
34
+ ```
35
+
36
+ ## 🎯 When to Use Each Approach
37
+
38
+ | **Use Case** | **Method** | **Benefits** |
39
+ | ------------------------ | ------------------------- | ----------------------------------------------- |
40
+ | **Full Control** | `new EasyflowSDK()` | Complete API access, custom error handling |
41
+ | **Platform Integration** | `initializeForPlatform()` | Simplified API, automatic callbacks, validation |
42
+ | **Quick Prototyping** | `initializeForPlatform()` | Faster setup, less configuration |
43
+ | **Production Apps** | `new EasyflowSDK()` | Better performance, more control |
44
+
45
+ ## ⚙️ Platform Integration Features
46
+
47
+ ### **Automatic Callbacks**
48
+
49
+ ```javascript
50
+ const wrapper = EasyflowSDK.initializeForPlatform({
51
+ businessId: 'your-business-id',
52
+ enableDebug: true,
53
+ })
54
+
55
+ // Set up event handlers
56
+ wrapper.on('customerCreated', (customer) => {
57
+ console.log('Customer created:', customer)
58
+ })
59
+
60
+ wrapper.on('paymentProcessed', (result, method) => {
61
+ console.log('Payment processed:', result, method)
62
+ })
63
+
64
+ wrapper.on('error', (error) => {
65
+ console.error('Error occurred:', error)
66
+ })
67
+ ```
68
+
69
+ ### **Simplified Validation**
70
+
71
+ ```javascript
72
+ // Automatic validation with friendly error messages
73
+ const validation = wrapper.validate('email', 'user@example.com')
74
+ if (!validation.valid) {
75
+ console.error('Validation failed:', validation.error)
76
+ }
77
+ ```
78
+
79
+ ### **Configuration Management**
80
+
81
+ ```javascript
82
+ // Update configuration on the fly
83
+ wrapper.configure({
84
+ enableDebug: false,
85
+ timeout: 30000,
86
+ })
87
+
88
+ // Get current status
89
+ const status = wrapper.getStatus()
90
+ console.log('Wrapper status:', status)
91
+ ```
92
+
93
+ ## 🔄 How It Works
94
+
95
+ ### **1. Method Call**
96
+
97
+ ```javascript
98
+ static initializeForPlatform(config) {
99
+ return initializeEasyflow(config)
100
+ }
101
+ ```
102
+
103
+ ### **2. Wrapper Creation**
104
+
105
+ ```javascript
106
+ function initializeEasyflow(config) {
107
+ return new EasyflowIntegrationWrapper(config)
108
+ }
109
+ ```
110
+
111
+ ### **3. Simplified Interface**
112
+
113
+ The wrapper provides:
114
+
115
+ - ✅ **Simplified method names**
116
+ - ✅ **Automatic error handling**
117
+ - ✅ **Built-in validation**
118
+ - ✅ **Event management**
119
+ - ✅ **Configuration persistence**
120
+
121
+ ## 📱 Platform Examples
122
+
123
+ ### **Bubble Integration**
124
+
125
+ ```javascript
126
+ // In Bubble's JavaScript actions
127
+ const easyflow = EasyflowSDK.initializeForPlatform({
128
+ businessId: bubble.get('business_id'),
129
+ enableDebug: true,
130
+ })
131
+
132
+ // Use in workflows
133
+ const customer = await easyflow.createCustomer({
134
+ name: bubble.get('customer_name'),
135
+ email: bubble.get('customer_email'),
136
+ })
137
+ ```
138
+
139
+ ### **Webflow Integration**
140
+
141
+ ```javascript
142
+ // In Webflow's custom code
143
+ const easyflow = EasyflowSDK.initializeForPlatform({
144
+ businessId: 'your-business-id',
145
+ })
146
+
147
+ // Handle form submissions
148
+ document
149
+ .getElementById('payment-form')
150
+ .addEventListener('submit', async (e) => {
151
+ e.preventDefault()
152
+ const result = await easyflow.charge(paymentData)
153
+ })
154
+ ```
155
+
156
+ ### **Custom Platform**
157
+
158
+ ```javascript
159
+ // For your own platform
160
+ class MyPlatform {
161
+ constructor() {
162
+ this.easyflow = EasyflowSDK.initializeForPlatform({
163
+ businessId: this.config.businessId,
164
+ enableDebug: this.config.debug,
165
+ })
166
+ }
167
+
168
+ async processPayment(data) {
169
+ return await this.easyflow.charge(data)
170
+ }
171
+ }
172
+ ```
173
+
174
+ ## 🛡️ Security & Validation
175
+
176
+ ### **Automatic Sanitization**
177
+
178
+ - All input data is automatically sanitized
179
+ - Dangerous characters and protocols are removed
180
+ - Sensitive information is handled securely
181
+
182
+ ### **Built-in Validation**
183
+
184
+ ```javascript
185
+ // Automatic validation for common data types
186
+ wrapper.validate('email', email) // Email format
187
+ wrapper.validate('cpf', cpf) // CPF validation
188
+ wrapper.validate('cnpj', cnpj) // CNPJ validation
189
+ wrapper.validate('phone', phone) // Phone format
190
+ wrapper.validate('address', address) // Address structure
191
+ wrapper.validate('customer', customer) // Customer data
192
+ ```
193
+
194
+ ## 📊 Performance Considerations
195
+
196
+ ### **Memory Usage**
197
+
198
+ - **Traditional SDK**: Lower memory footprint, direct access
199
+ - **Platform Wrapper**: Slightly higher memory due to additional features
200
+
201
+ ### **Execution Speed**
202
+
203
+ - **Traditional SDK**: Faster execution, no wrapper overhead
204
+ - **Platform Wrapper**: Minimal overhead, optimized for ease of use
205
+
206
+ ## 🔧 Configuration Options
207
+
208
+ ```javascript
209
+ const wrapper = EasyflowSDK.initializeForPlatform({
210
+ businessId: 'your-business-id', // Required
211
+ enableDebug: true, // Optional: Enable debug logs
212
+ timeout: 30000, // Optional: Request timeout (ms)
213
+ retryAttempts: 3, // Optional: Retry attempts
214
+ enableValidation: true, // Optional: Enable validation
215
+ enableCallbacks: true, // Optional: Enable callbacks
216
+ })
217
+ ```
218
+
219
+ ## 📚 Related Documentation
220
+
221
+ - **[README.md](README.md)** - Main SDK documentation
222
+ - **[INDEX.md](INDEX.md)** - Documentation hub
223
+ - **[DATA-STRUCTURES.md](DATA-STRUCTURES.md)** - Data structure reference
224
+ - **[API Reference](docs/index.html)** - Complete API documentation
225
+
226
+ ## 🚀 Getting Started
227
+
228
+ 1. **Choose your approach** based on your needs
229
+ 2. **Initialize the SDK** using the appropriate method
230
+ 3. **Configure callbacks** if using platform integration
231
+ 4. **Start building** your payment solution
232
+
233
+ ---
234
+
235
+ **Need help?** Check the main [README.md](README.md) or create an issue on GitHub.