@easyflow/javascript-sdk 2.1.7
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.
- package/.babelrc +5 -0
- package/.github/workflows/deploy-sdk-cf.yml +49 -0
- package/.github/workflows/release-sdk-cdn.yml +144 -0
- package/.github/workflows/release-sdk.yml +112 -0
- package/.prettierrc +6 -0
- package/CDN-DEPLOYMENT.md +175 -0
- package/DEMO.md +258 -0
- package/DEPLOYMENT.md +224 -0
- package/INTEGRATION-GUIDE.md +521 -0
- package/README.md +1013 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/easyflow-javascript-sdk/index.html +116 -0
- package/coverage/easyflow-javascript-sdk/libs/constants.mjs.html +268 -0
- package/coverage/easyflow-javascript-sdk/libs/errors.mjs.html +271 -0
- package/coverage/easyflow-javascript-sdk/libs/exception-handler.mjs.html +148 -0
- package/coverage/easyflow-javascript-sdk/libs/fingerprint.mjs.html +895 -0
- package/coverage/easyflow-javascript-sdk/libs/http.mjs.html +502 -0
- package/coverage/easyflow-javascript-sdk/libs/index.html +266 -0
- package/coverage/easyflow-javascript-sdk/libs/logger.mjs.html +568 -0
- package/coverage/easyflow-javascript-sdk/libs/sanitizer.mjs.html +1099 -0
- package/coverage/easyflow-javascript-sdk/libs/security.mjs.html +733 -0
- package/coverage/easyflow-javascript-sdk/libs/types.mjs.html +508 -0
- package/coverage/easyflow-javascript-sdk/libs/utils.mjs.html +379 -0
- package/coverage/easyflow-javascript-sdk/libs/validator.mjs.html +2623 -0
- package/coverage/easyflow-javascript-sdk/sdk.mjs.html +2434 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +131 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/easyflow-javascript-sdk/index.html +116 -0
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/constants.mjs.html +268 -0
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/errors.mjs.html +271 -0
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/exception-handler.mjs.html +148 -0
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/fingerprint.mjs.html +895 -0
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/http.mjs.html +502 -0
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/index.html +266 -0
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/logger.mjs.html +568 -0
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/sanitizer.mjs.html +1099 -0
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/security.mjs.html +733 -0
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/types.mjs.html +508 -0
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/utils.mjs.html +379 -0
- package/coverage/lcov-report/easyflow-javascript-sdk/libs/validator.mjs.html +2623 -0
- package/coverage/lcov-report/easyflow-javascript-sdk/sdk.mjs.html +2434 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +131 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +1429 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/dist/435.easyflow-sdk.min.js +1 -0
- package/dist/easyflow-sdk.min.js +1 -0
- package/dist/easyflow-sdk.min.js.LICENSE.txt +1 -0
- package/dist/index.html +756 -0
- package/docs/index.html +775 -0
- package/examples/lovable-integration.html +410 -0
- package/index.html +981 -0
- package/jest.config.js +37 -0
- package/jsdoc.json +42 -0
- package/libs/auto-integration.mjs +333 -0
- package/libs/constants.mjs +61 -0
- package/libs/constants.spec.js +198 -0
- package/libs/errors.mjs +62 -0
- package/libs/errors.spec.js +178 -0
- package/libs/exception-handler.mjs +21 -0
- package/libs/exception-handler.spec.js +237 -0
- package/libs/fingerprint.mjs +270 -0
- package/libs/http.mjs +163 -0
- package/libs/http.spec.js +427 -0
- package/libs/integration-wrapper.mjs +285 -0
- package/libs/logger.mjs +161 -0
- package/libs/logger.spec.js +389 -0
- package/libs/sanitizer.mjs +340 -0
- package/libs/sanitizer.spec.js +583 -0
- package/libs/security.mjs +217 -0
- package/libs/types.mjs +141 -0
- package/libs/utils.mjs +368 -0
- package/libs/utils.spec.js +231 -0
- package/libs/validator.mjs +952 -0
- package/libs/validator.spec.js +615 -0
- package/mocks/offer.mock.js +77 -0
- package/package.json +72 -0
- package/scripts/publish-npm.sh +82 -0
- package/sdk.mjs +945 -0
- package/sdk.spec.js +796 -0
- package/test-setup.cjs +211 -0
- package/test.html +154 -0
- package/webpack.config.cjs +41 -0
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
# 🚀 Easyflow SDK - Guia de Integração Low-Code/No-Code
|
|
2
|
+
|
|
3
|
+
Este guia mostra como integrar o Easyflow SDK em plataformas low-code/no-code de forma **NO BRAINER** - simples, segura e eficiente.
|
|
4
|
+
|
|
5
|
+
## 🎯 **Plataformas Suportadas**
|
|
6
|
+
|
|
7
|
+
- ✅ **[Lovable.dev](https://lovable.dev/)** - Desenvolvimento por chat com IA
|
|
8
|
+
- ✅ **Bubble** - Plataforma de aplicações visuais
|
|
9
|
+
- ✅ **Webflow** - Design e desenvolvimento web
|
|
10
|
+
- ✅ **Zapier** - Automação de workflows
|
|
11
|
+
- ✅ **Make.com** - Plataforma de integração
|
|
12
|
+
- ✅ **Outras plataformas** que suportem JavaScript
|
|
13
|
+
|
|
14
|
+
## 🚀 **Integração NO BRAINER**
|
|
15
|
+
|
|
16
|
+
### **1. Inclusão do SDK**
|
|
17
|
+
|
|
18
|
+
Adicione o SDK em qualquer plataforma com uma única linha:
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<!-- Cloudflare Pages (Recomendado) -->
|
|
22
|
+
<script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
|
|
23
|
+
|
|
24
|
+
<!-- Ou via jsDelivr -->
|
|
25
|
+
<script src="https://cdn.jsdelivr.net/npm/@easyflow/javascript-sdk@latest/dist/easyflow-sdk.min.js"></script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### **2. Inicialização Automática**
|
|
29
|
+
|
|
30
|
+
O SDK se inicializa automaticamente e expõe todas as funcionalidades:
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
// Todas as funcionalidades disponíveis automaticamente
|
|
34
|
+
window.easyflowSDK = {
|
|
35
|
+
// Clientes
|
|
36
|
+
createCustomer: function (data) {
|
|
37
|
+
/* ... */
|
|
38
|
+
},
|
|
39
|
+
getCustomer: function (id) {
|
|
40
|
+
/* ... */
|
|
41
|
+
},
|
|
42
|
+
updateCustomer: function (id, data) {
|
|
43
|
+
/* ... */
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
// Pagamentos
|
|
47
|
+
placeOrder: function (offerId, data) {
|
|
48
|
+
/* ... */
|
|
49
|
+
},
|
|
50
|
+
charge: function (data) {
|
|
51
|
+
/* ... */
|
|
52
|
+
},
|
|
53
|
+
encrypt: function (data) {
|
|
54
|
+
/* ... */
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
// Cartões de crédito
|
|
58
|
+
addCreditCard: function (customerId, token) {
|
|
59
|
+
/* ... */
|
|
60
|
+
},
|
|
61
|
+
getCreditCard: function (customerId, cardId) {
|
|
62
|
+
/* ... */
|
|
63
|
+
},
|
|
64
|
+
removeCreditCard: function (customerId, cardId) {
|
|
65
|
+
/* ... */
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
// Validação
|
|
69
|
+
validate: {
|
|
70
|
+
/* ... */
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
// Sanitização
|
|
74
|
+
sanitize: {
|
|
75
|
+
/* ... */
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## 🎨 **Integração por Plataforma**
|
|
81
|
+
|
|
82
|
+
### **Lovable.dev**
|
|
83
|
+
|
|
84
|
+
#### **1. Incluir o SDK**
|
|
85
|
+
|
|
86
|
+
No seu projeto Lovable, adicione o script:
|
|
87
|
+
|
|
88
|
+
```html
|
|
89
|
+
<script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### **2. Usar nas Ações**
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
// Criar cliente
|
|
96
|
+
const customerResult = await easyflowSDK.createCustomer({
|
|
97
|
+
name: 'João Silva',
|
|
98
|
+
email: 'joao@exemplo.com',
|
|
99
|
+
document: {
|
|
100
|
+
type: 'CPF',
|
|
101
|
+
number: '12345678909',
|
|
102
|
+
},
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
if (customerResult.success) {
|
|
106
|
+
// Cliente criado com sucesso
|
|
107
|
+
const customerId = customerResult.data.id
|
|
108
|
+
|
|
109
|
+
// Processar pagamento
|
|
110
|
+
const paymentResult = await easyflowSDK.placeOrder('offer-123', {
|
|
111
|
+
buyer: customerResult.data,
|
|
112
|
+
payments: [
|
|
113
|
+
{
|
|
114
|
+
method: 'credit-card',
|
|
115
|
+
creditCard: {
|
|
116
|
+
number: '4111111111111111',
|
|
117
|
+
holderName: 'João Silva',
|
|
118
|
+
month: '12',
|
|
119
|
+
year: '2025',
|
|
120
|
+
cvv: '123',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### **3. Configurar Callbacks**
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
// Callbacks para eventos
|
|
132
|
+
easyflowSDK.on('customerCreated', function (customer) {
|
|
133
|
+
console.log('Cliente criado:', customer)
|
|
134
|
+
// Atualizar UI do Lovable
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
easyflowSDK.on('paymentProcessed', function (result) {
|
|
138
|
+
console.log('Pagamento processado:', result)
|
|
139
|
+
// Redirecionar ou atualizar status
|
|
140
|
+
})
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### **Bubble**
|
|
144
|
+
|
|
145
|
+
#### **1. Incluir o SDK**
|
|
146
|
+
|
|
147
|
+
No Bubble, adicione o script no HTML personalizado:
|
|
148
|
+
|
|
149
|
+
```html
|
|
150
|
+
<script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### **2. JavaScript Personalizado**
|
|
154
|
+
|
|
155
|
+
```javascript
|
|
156
|
+
// Configurar callbacks para eventos do Bubble
|
|
157
|
+
easyflowSDK.on('customerCreated', function (customer) {
|
|
158
|
+
// Atualizar campo no Bubble
|
|
159
|
+
bubble_fn_updateCustomer(customer)
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
easyflowSDK.on('paymentProcessed', function (result) {
|
|
163
|
+
// Atualizar status do pagamento
|
|
164
|
+
bubble_fn_updatePaymentStatus(result)
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
// Função para criar cliente no Bubble
|
|
168
|
+
async function bubbleCreateCustomer(customerData) {
|
|
169
|
+
const result = await easyflowSDK.createCustomer(customerData)
|
|
170
|
+
return result
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### **3. Usar nas Ações do Bubble**
|
|
175
|
+
|
|
176
|
+
```javascript
|
|
177
|
+
// No Bubble, chame a função personalizada
|
|
178
|
+
const customerData = {
|
|
179
|
+
name: CurrentCell's Customer's Name,
|
|
180
|
+
email: CurrentCell's Customer's Email,
|
|
181
|
+
document: {
|
|
182
|
+
type: 'CPF',
|
|
183
|
+
number: CurrentCell's Customer's CPF
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const result = await bubbleCreateCustomer(customerData);
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### **Webflow**
|
|
191
|
+
|
|
192
|
+
#### **1. Incluir o SDK**
|
|
193
|
+
|
|
194
|
+
No Webflow, adicione o script no HTML personalizado:
|
|
195
|
+
|
|
196
|
+
```html
|
|
197
|
+
<script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### **2. JavaScript Personalizado**
|
|
201
|
+
|
|
202
|
+
```javascript
|
|
203
|
+
// Configurar formulário de checkout
|
|
204
|
+
document
|
|
205
|
+
.getElementById('checkout-form')
|
|
206
|
+
.addEventListener('submit', async function (e) {
|
|
207
|
+
e.preventDefault()
|
|
208
|
+
|
|
209
|
+
const formData = new FormData(this)
|
|
210
|
+
const customerData = {
|
|
211
|
+
name: formData.get('name'),
|
|
212
|
+
email: formData.get('email'),
|
|
213
|
+
document: {
|
|
214
|
+
type: 'CPF',
|
|
215
|
+
number: formData.get('cpf'),
|
|
216
|
+
},
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Validar dados
|
|
220
|
+
if (easyflowSDK.validate.customer(customerData)) {
|
|
221
|
+
const result = await easyflowSDK.createCustomer(customerData)
|
|
222
|
+
if (result.success) {
|
|
223
|
+
// Redirecionar para pagamento
|
|
224
|
+
window.location.href = '/checkout?customer=' + result.data.id
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
})
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### **Zapier**
|
|
231
|
+
|
|
232
|
+
#### **1. Endpoint Webhook**
|
|
233
|
+
|
|
234
|
+
Crie um endpoint para receber webhooks do Zapier:
|
|
235
|
+
|
|
236
|
+
```javascript
|
|
237
|
+
// Endpoint para Zapier webhook
|
|
238
|
+
app.post('/zapier/easyflow', async (req, res) => {
|
|
239
|
+
try {
|
|
240
|
+
const { action, data } = req.body
|
|
241
|
+
|
|
242
|
+
switch (action) {
|
|
243
|
+
case 'createCustomer':
|
|
244
|
+
const customerResult = await easyflowSDK.createCustomer(data)
|
|
245
|
+
res.json(customerResult)
|
|
246
|
+
break
|
|
247
|
+
|
|
248
|
+
case 'processPayment':
|
|
249
|
+
const paymentResult = await easyflowSDK.charge(data)
|
|
250
|
+
res.json(paymentResult)
|
|
251
|
+
break
|
|
252
|
+
|
|
253
|
+
default:
|
|
254
|
+
res.status(400).json({ error: 'Ação não suportada' })
|
|
255
|
+
}
|
|
256
|
+
} catch (error) {
|
|
257
|
+
res.status(500).json({ error: error.message })
|
|
258
|
+
}
|
|
259
|
+
})
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
#### **2. Configurar no Zapier**
|
|
263
|
+
|
|
264
|
+
1. **Trigger**: Escolha o evento que dispara a ação
|
|
265
|
+
2. **Action**: Configure o webhook para o endpoint
|
|
266
|
+
3. **Data Mapping**: Mapeie os campos necessários
|
|
267
|
+
|
|
268
|
+
## 🛡️ **Segurança e Validação**
|
|
269
|
+
|
|
270
|
+
### **Validação Automática**
|
|
271
|
+
|
|
272
|
+
```javascript
|
|
273
|
+
// Validar dados antes de enviar
|
|
274
|
+
const emailValid = easyflowSDK.validate.email('joao@exemplo.com')
|
|
275
|
+
const cpfValid = easyflowSDK.validate.cpf('12345678909')
|
|
276
|
+
|
|
277
|
+
if (emailValid && cpfValid) {
|
|
278
|
+
// Dados válidos, prosseguir
|
|
279
|
+
const result = await easyflowSDK.createCustomer(customerData)
|
|
280
|
+
} else {
|
|
281
|
+
// Mostrar erro na UI
|
|
282
|
+
showError('Dados inválidos')
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### **Sanitização Automática**
|
|
287
|
+
|
|
288
|
+
```javascript
|
|
289
|
+
// Sanitizar dados de entrada
|
|
290
|
+
const sanitizedData = easyflowSDK.sanitize.customer(customerData)
|
|
291
|
+
const result = await easyflowSDK.createCustomer(sanitizedData)
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## 📱 **Exemplos de Uso Comum**
|
|
295
|
+
|
|
296
|
+
### **Formulário de Cadastro**
|
|
297
|
+
|
|
298
|
+
```javascript
|
|
299
|
+
// Formulário de cadastro de cliente
|
|
300
|
+
async function handleCustomerRegistration(formData) {
|
|
301
|
+
try {
|
|
302
|
+
// Validar dados
|
|
303
|
+
const customerData = {
|
|
304
|
+
name: formData.get('name'),
|
|
305
|
+
email: formData.get('email'),
|
|
306
|
+
document: {
|
|
307
|
+
type: 'CPF',
|
|
308
|
+
number: formData.get('cpf'),
|
|
309
|
+
},
|
|
310
|
+
phone: {
|
|
311
|
+
areaCode: '+55',
|
|
312
|
+
ddd: formData.get('ddd'),
|
|
313
|
+
number: formData.get('phone'),
|
|
314
|
+
isMobile: true,
|
|
315
|
+
},
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Validar antes de enviar
|
|
319
|
+
if (!easyflowSDK.validate.customer(customerData)) {
|
|
320
|
+
throw new Error('Dados inválidos')
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Criar cliente
|
|
324
|
+
const result = await easyflowSDK.createCustomer(customerData)
|
|
325
|
+
|
|
326
|
+
if (result.success) {
|
|
327
|
+
// Sucesso - redirecionar para checkout
|
|
328
|
+
window.location.href = `/checkout?customer=${result.data.id}`
|
|
329
|
+
} else {
|
|
330
|
+
// Erro
|
|
331
|
+
showError(result.error.message)
|
|
332
|
+
}
|
|
333
|
+
} catch (error) {
|
|
334
|
+
showError('Erro ao criar cliente: ' + error.message)
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### **Processamento de Pagamento**
|
|
340
|
+
|
|
341
|
+
```javascript
|
|
342
|
+
// Processar pagamento
|
|
343
|
+
async function processPayment(offerId, customerId, paymentData) {
|
|
344
|
+
try {
|
|
345
|
+
// Obter dados do cliente
|
|
346
|
+
const customerResult = await easyflowSDK.getCustomer(customerId)
|
|
347
|
+
|
|
348
|
+
if (!customerResult.success) {
|
|
349
|
+
throw new Error('Cliente não encontrado')
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// Criar pedido
|
|
353
|
+
const orderResult = await easyflowSDK.placeOrder(offerId, {
|
|
354
|
+
buyer: customerResult.data,
|
|
355
|
+
payments: [paymentData],
|
|
356
|
+
})
|
|
357
|
+
|
|
358
|
+
if (orderResult.success) {
|
|
359
|
+
// Pagamento processado com sucesso
|
|
360
|
+
showSuccess('Pagamento processado com sucesso!')
|
|
361
|
+
|
|
362
|
+
// Redirecionar para página de sucesso
|
|
363
|
+
window.location.href = `/success?order=${orderResult.data.id}`
|
|
364
|
+
} else {
|
|
365
|
+
throw new Error(orderResult.error.message)
|
|
366
|
+
}
|
|
367
|
+
} catch (error) {
|
|
368
|
+
showError('Erro ao processar pagamento: ' + error.message)
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
## 🔧 **Configuração Avançada**
|
|
374
|
+
|
|
375
|
+
### **Configurar Callbacks**
|
|
376
|
+
|
|
377
|
+
```javascript
|
|
378
|
+
// Configurar callbacks para eventos
|
|
379
|
+
easyflowSDK.on('customerCreated', function (customer) {
|
|
380
|
+
console.log('🎉 Cliente criado:', customer)
|
|
381
|
+
// Atualizar UI
|
|
382
|
+
})
|
|
383
|
+
|
|
384
|
+
easyflowSDK.on('paymentProcessed', function (result) {
|
|
385
|
+
console.log('💳 Pagamento processado:', result)
|
|
386
|
+
// Atualizar status
|
|
387
|
+
})
|
|
388
|
+
|
|
389
|
+
easyflowSDK.on('error', function (error) {
|
|
390
|
+
console.error('❌ Erro:', error)
|
|
391
|
+
// Mostrar erro na UI
|
|
392
|
+
})
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### **Configurações Personalizadas**
|
|
396
|
+
|
|
397
|
+
```javascript
|
|
398
|
+
// Configurar opções personalizadas
|
|
399
|
+
easyflowSDK.configure({
|
|
400
|
+
enableDebug: true,
|
|
401
|
+
globalScope: 'window',
|
|
402
|
+
})
|
|
403
|
+
|
|
404
|
+
// Verificar status
|
|
405
|
+
const status = easyflowSDK.getStatus()
|
|
406
|
+
console.log('Status:', status)
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
## 📊 **Monitoramento e Debug**
|
|
410
|
+
|
|
411
|
+
### **Habilitar Debug**
|
|
412
|
+
|
|
413
|
+
```javascript
|
|
414
|
+
// Habilitar logs de debug
|
|
415
|
+
easyflowSDK.configure({ enableDebug: true })
|
|
416
|
+
|
|
417
|
+
// Ver logs no console
|
|
418
|
+
// ✅ Easyflow SDK Integration Wrapper inicializado com sucesso
|
|
419
|
+
// 🌐 Easyflow SDK exposto globalmente como "easyflowSDK"
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### **Verificar Status**
|
|
423
|
+
|
|
424
|
+
```javascript
|
|
425
|
+
// Verificar status do SDK
|
|
426
|
+
const status = easyflowSDK.getStatus()
|
|
427
|
+
console.log('Status:', {
|
|
428
|
+
initialized: status.initialized,
|
|
429
|
+
businessId: status.businessId,
|
|
430
|
+
sdkVersion: status.sdkVersion,
|
|
431
|
+
wrapperVersion: status.wrapperVersion,
|
|
432
|
+
})
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
## 🚨 **Tratamento de Erros**
|
|
436
|
+
|
|
437
|
+
### **Estrutura de Resposta**
|
|
438
|
+
|
|
439
|
+
```javascript
|
|
440
|
+
// Todas as chamadas retornam a mesma estrutura
|
|
441
|
+
const result = await easyflowSDK.createCustomer(customerData)
|
|
442
|
+
|
|
443
|
+
if (result.success) {
|
|
444
|
+
// Sucesso
|
|
445
|
+
console.log('Dados:', result.data)
|
|
446
|
+
} else {
|
|
447
|
+
// Erro
|
|
448
|
+
console.error('Erro:', result.error)
|
|
449
|
+
console.error('Código:', result.error.code)
|
|
450
|
+
console.error('Tipo:', result.error.type)
|
|
451
|
+
}
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
### **Tratamento de Erros Comum**
|
|
455
|
+
|
|
456
|
+
```javascript
|
|
457
|
+
// Tratar erros específicos
|
|
458
|
+
try {
|
|
459
|
+
const result = await easyflowSDK.createCustomer(customerData)
|
|
460
|
+
|
|
461
|
+
if (!result.success) {
|
|
462
|
+
switch (result.error.code) {
|
|
463
|
+
case 'VALIDATION_ERROR':
|
|
464
|
+
showError('Dados inválidos: ' + result.error.message)
|
|
465
|
+
break
|
|
466
|
+
case 'NETWORK_ERROR':
|
|
467
|
+
showError('Erro de conexão. Tente novamente.')
|
|
468
|
+
break
|
|
469
|
+
default:
|
|
470
|
+
showError('Erro inesperado: ' + result.error.message)
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
} catch (error) {
|
|
474
|
+
showError('Erro ao processar: ' + error.message)
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
## 📚 **Recursos Adicionais**
|
|
479
|
+
|
|
480
|
+
### **Validação de Dados**
|
|
481
|
+
|
|
482
|
+
- ✅ **Email**: Validação de formato e segurança
|
|
483
|
+
- ✅ **CPF**: Algoritmo oficial brasileiro
|
|
484
|
+
- ✅ **CNPJ**: Validação empresarial
|
|
485
|
+
- ✅ **Telefone**: Formato brasileiro com DDD
|
|
486
|
+
- ✅ **Endereço**: Validação completa de endereços
|
|
487
|
+
|
|
488
|
+
### **Sanitização de Dados**
|
|
489
|
+
|
|
490
|
+
- ✅ **Input**: Remoção de caracteres perigosos
|
|
491
|
+
- ✅ **Headers**: Filtragem de headers maliciosos
|
|
492
|
+
- ✅ **Objetos**: Sanitização recursiva de dados
|
|
493
|
+
|
|
494
|
+
### **Segurança Integrada**
|
|
495
|
+
|
|
496
|
+
- ✅ **SRI**: Subresource Integrity para CDNs
|
|
497
|
+
- ✅ **HTTPS**: Forçamento de conexões seguras
|
|
498
|
+
- ✅ **Rate Limiting**: Proteção contra abuso
|
|
499
|
+
- ✅ **Validação**: Verificação de todos os inputs
|
|
500
|
+
|
|
501
|
+
## 🎯 **Próximos Passos**
|
|
502
|
+
|
|
503
|
+
1. **Escolha sua plataforma** (Lovable, Bubble, Webflow, etc.)
|
|
504
|
+
2. **Inclua o SDK** com uma linha de código
|
|
505
|
+
3. **Configure callbacks** para eventos importantes
|
|
506
|
+
4. **Implemente validação** antes de enviar dados
|
|
507
|
+
5. **Teste a integração** com dados de exemplo
|
|
508
|
+
6. **Deploy em produção** com confiança
|
|
509
|
+
|
|
510
|
+
## 📞 **Suporte**
|
|
511
|
+
|
|
512
|
+
- **Documentação**: [docs.easyflow.digital](https://docs.easyflow.digital)
|
|
513
|
+
- **GitHub**: [Issues](https://github.com/easyflow-cash/easyflow-javascript-sdk/issues)
|
|
514
|
+
- **Email**: [diego@easyflow.digital](mailto:diego@easyflow.digital)
|
|
515
|
+
- **Website**: [easyflow.digital](https://easyflow.digital)
|
|
516
|
+
|
|
517
|
+
---
|
|
518
|
+
|
|
519
|
+
**Easyflow SDK** - Transformando integrações de pagamento em experiências **NO BRAINER** 🚀
|
|
520
|
+
|
|
521
|
+
**Mantenedor**: [Diego Moura](https://github.com/dmourainatel) - Co-Founder/CTO
|