@easyflow/javascript-sdk 2.1.25 → 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.
package/README.md CHANGED
@@ -1,1251 +1,254 @@
1
- # Easyflow JavaScript SDK
1
+ # 🚀 Easyflow SDK - E2E Test Project
2
2
 
3
- [![Version](https://img.shields.io/badge/version-2.1.19-blue.svg)](https://easyflow-sdk.pages.dev)
4
- [![License](https://img.shields.io/badge/license-ISC-green.svg)](LICENSE)
5
- [![Tests](https://img.shields.io/badge/tests-251%20passing-brightgreen.svg)](https://easyflow-sdk.pages.dev)
6
- [![Coverage](https://img.shields.io/badge/coverage-95%25-brightgreen.svg)](https://easyflow-sdk.pages.dev)
3
+ ## 📋 Overview
7
4
 
8
- <div align="center">
5
+ Este é um projeto **React + TypeScript** que demonstra a integração **end-to-end** do Easyflow SDK via NPM, simulando exatamente como uma plataforma como o **Lovable** faria a integração.
9
6
 
10
- ![Easyflow Logo](https://www.easyflow.digital/wp-content/uploads/2023/12/logo-easyflow.png)
7
+ ## 🎯 Objetivo
11
8
 
12
- **Freedom to sell more, better and longer**
9
+ **Provar que o SDK funciona perfeitamente** quando instalado via NPM em projetos TypeScript/React, com:
13
10
 
14
- > **Enterprise-grade JavaScript SDK** for integration with the Easyflow payment processing platform with robust
15
- > validation, comprehensive security and Brazilian compliance
11
+ - **Import direto** via NPM
12
+ - **Tipos TypeScript** funcionando
13
+ - ✅ **Build com Vite** sem erros
14
+ - ✅ **Integração simples** e direta
15
+ - ✅ **Funcionalidades completas** do SDK
16
+ - ✅ **Interface real** para testar todos os métodos
16
17
 
17
- [![Website](https://img.shields.io/badge/Website-Easyflow.digital-667eea?style=for-the-badge)](https://www.easyflow.digital/)
18
- [![Start Free](https://img.shields.io/badge/Start_Free-22c55e?style=for-the-badge&logo=rocket&logoColor=white)](https://www.easyflow.digital/)
19
- [![Documentation](https://img.shields.io/badge/Documentation-3b82f6?style=for-the-badge&logo=book&logoColor=white)](https://docs.easyflow.digital)
18
+ ## 🚀 Como Funciona
20
19
 
21
- </div>
22
-
23
- ## About Easyflow
24
-
25
- [Easyflow](https://www.easyflow.digital/) is a payment platform that **facilitates the sales process** of digital
26
- products and services in a simple and intuitive way. Our mission is to transform Digital Commerce by offering a complete
27
- sales structure to maximize your LTV.
28
-
29
- ### Why Choose Easyflow?
30
-
31
- - **Outstanding approval rate**: 95% to 98% credit card approval rate
32
- - **High conversion checkout**: Fastest loading in the market
33
- - **Simplified recurrence**: Recurring payments with your own rules
34
- - **Bank-level security**: PCI Compliance and advanced encryption
35
- - **Same-day withdrawal**: Same day, no bureaucracy
36
- - **Simple integrations**: Webhooks and API with few clicks
37
-
38
- ### Payment Methods
39
-
40
- - **Credit Card**: Highest approval rate in the market
41
- - **PIX**: Instant Brazilian payment
42
- - **Bank Billet**: For those who prefer to pay via bank
43
-
44
- ### Main Features
45
-
46
- - **Optimized checkout** for maximum conversion
47
- - **AI-powered sales recovery** (up to 40% increase)
48
- - **Upsell, downsell and cross-sell** to increase average ticket
49
- - **Automated payment splitting** for co-producers
50
- - **Smart metrics and insights** in real time
51
- - **Integration with CRM, ERPs** and third-party platforms
52
-
53
- ### Plans and Fees
54
-
55
- **Clear and fair rate: 6.99% + R$2.50**
56
-
57
- - **Revenue +100k per month?** [Click here for special conditions](https://www.easyflow.digital/)
58
- - **You only pay when you generate results**
59
- - **No hidden fees or surprises**
60
-
61
- ## Try It Now
62
-
63
- <div align="center">
64
-
65
- [![Test SDK](https://img.shields.io/badge/Test_SDK_Online-667eea?style=for-the-badge&logo=javascript&logoColor=white)](https://easyflow-sdk.pages.dev)
66
-
67
- **Experience the Easyflow SDK in action with our interactive demo**
68
-
69
- </div>
70
-
71
- ## What is the Easyflow JavaScript SDK?
72
-
73
- The **Easyflow JavaScript SDK** is the official tool for developers to integrate their applications with the Easyflow
74
- platform. With this SDK, you can:
75
-
76
- - **Process payments** securely and reliably
77
- - **Manage customers** with complete Brazilian data validation
78
- - **Create offers** and process orders automatically
79
- - **Implement recurrence** with custom rules
80
- - **Integrate with any system** via REST API
81
-
82
- ### SDK Advantages
83
-
84
- - **100% Plug & Play**: Works with any type of business
85
- - **Brazilian Compliance**: CPF/CNPJ, phone, address validation
86
- - **Enterprise Security**: Multiple layers of protection
87
- - **High Performance**: Optimized for production
88
- - **Complete Documentation**: Practical examples for all use cases
89
-
90
- ## What's New in v2.1.19
91
-
92
- ### Complete Implementation Examples
93
-
94
- - **Full Data Models**: Comprehensive examples for placeOrder, charge, createCustomer, and addCreditCard
95
- - **Real-World Scenarios**: Complete workflows with all available data fields
96
- - **Brazilian Data**: Realistic Brazilian addresses, phone numbers, and document formats
97
- - **End-to-End Workflows**: Complete customer → credit card → order examples
98
- - **Code Quality**: Improved formatting and consistency across all examples
99
-
100
- ### Credit Card Token Validation Fix
101
-
102
- - **Real Token Support**: Now accepts real encrypted/ciphered credit card tokens
103
- - **Flexible Format**: Supports Base64, URL-safe, and mixed character tokens
104
- - **Variable Length**: Accepts tokens from 16 to 2048 characters
105
- - **Enhanced Security**: Maintains security while accepting real-world tokens
106
- - **Backward Compatibility**: Works with all existing token formats
107
-
108
- ### Workflow Corrections
109
-
110
- - **GitHub Actions Fixed**: Resolved release workflow permissions and SRI hash generation
111
- - **CDN Deployment**: Automated deployment to Cloudflare Pages working correctly
112
- - **Release Automation**: GitHub releases created automatically with proper SRI hashes
113
- - **Build Process**: Streamlined build and deployment pipeline
114
-
115
- ### Hybrid Distribution Strategy
116
-
117
- - **NPM Package**: Contains only documentation and TypeScript definitions
118
- - **CDN Scripts**: Production-ready obfuscated builds via Cloudflare Pages and jsDelivr
119
- - **Enhanced Security**: Code source protected while maintaining accessibility
120
- - **Better UX**: Easy discovery via NPM, secure usage via CDN
121
-
122
- ### Security & Privacy Improvements
123
-
124
- - **README Anonymization**: Removed all personal information and sensitive data
125
- - **Privacy Protection**: No personal emails, URLs, or contact information exposed
126
- - **Professional Documentation**: Clean, business-focused documentation
127
- - **NPM Safety**: Safe for public NPM publication
128
-
129
- ### Test Suite Improvements
130
-
131
- - **Test Coverage Optimization**: Fixed all failing unit tests for complete 250 test coverage
132
- - **Mock Structure Corrections**: Updated test mocks to align with actual API response patterns
133
- - **Customer Management Tests**: Corrected mock structures for `createCustomer` and `getCustomer` methods
134
- - **Credit Card Tests**: Fixed mock data structures for `addCreditCard` and `getCreditCard` methods
135
- - **Consistent Test Patterns**: Standardized mock response structures across all endpoints
136
-
137
- ### API Response Pattern Standardization
138
-
139
- - **Customer Methods**: Properly handle `response.data.customer` structure
140
- - **Credit Card Methods**: Correctly process `response.data.creditCard` structure
141
- - **Order Methods**: Maintain existing `response.data` pattern
142
- - **Improved Reliability**: Enhanced test reliability and maintainability
143
-
144
- ### Enhanced ID Validation Support
145
-
146
- - **Multiple ID Format Support**: Now accepts UUID v4, UUID v7, and MongoDB ObjectId formats
147
- - **UUID v4**: Standard format `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx` (y = 8,9,A,B)
148
- - **UUID v7**: Modern format `xxxxxxxx-xxxx-7xxx-yxxx-xxxxxxxxxxxx` (y = 8,9,A,B)
149
- - **MongoDB ObjectId**: 24-character hexadecimal format `507f1f77bcf86cd799439011`
150
- - **Strict Validation**: Rejects any other formats for enhanced security
151
-
152
- ## Quick Start
153
-
154
- ### Installation
155
-
156
- #### Option 1: CDN Script (Recommended)
157
-
158
- Add this script tag to your HTML:
159
-
160
- ```html
161
- <!-- Latest version -->
162
- <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
163
-
164
- <!-- Specific version -->
165
- <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.19.min.js"></script>
166
- ```
167
-
168
- #### Option 2: CDN jsDelivr (Alternative)
169
-
170
- ```html
171
- <!-- Latest version -->
172
- <script src="https://cdn.jsdelivr.net/npm/@easyflow/javascript-sdk@latest/dist/easyflow-sdk.min.js"></script>
173
-
174
- <!-- Specific version -->
175
- <script src="https://cdn.jsdelivr.net/npm/@easyflow/javascript-sdk@2.1.20/dist/easyflow-sdk.min.js"></script>
176
- ```
177
-
178
- #### Option 3: NPM Package (Documentation Only)
20
+ ### **1. Instalação via NPM**
179
21
 
180
22
  ```bash
181
- npm install @easyflow/javascript-sdk
23
+ npm install @easyflow/javascript-sdk@latest
182
24
  ```
183
25
 
184
- **Note**: The NPM package contains only documentation. For production use, use the CDN scripts above.
185
-
186
- ### Basic Usage
187
-
188
- ```javascript
189
- // Configure the global instance
190
- easyflowSDK.configure({
191
- businessId: 'demo-business-12345',
192
- })
193
-
194
- // Process a payment
195
- easyflowSDK
196
- .placeOrder('demo-offer-67890', {
197
- customer: {
198
- name: 'João Silva',
199
- email: 'joao@exemplo.com',
200
- document: {
201
- type: 'CPF',
202
- number: '12345678901',
203
- },
204
- },
205
- payments: [
206
- {
207
- method: 'credit-card',
208
- numberInstallments: 1,
209
- },
210
- ],
211
- })
212
- .then((orderId) => {
213
- console.log('Pedido criado:', orderId)
214
- })
215
- .catch((error) => {
216
- console.error('Erro ao criar pedido:', error.message)
217
- })
218
- ```
26
+ ### **2. Import Direto**
219
27
 
220
- ## 📚 Documentation
221
-
222
- - **[INDEX.md](INDEX.md)** - Central documentation hub
223
- - **[DATA-STRUCTURES.md](DATA-STRUCTURES.md)** - Complete data structure reference
224
- - **[PLATFORM-INTEGRATION.md](PLATFORM-INTEGRATION.md)** - Platform integration guide with `initializeForPlatform`
225
-
226
- ## Features
227
-
228
- ### Payment Processing
229
-
230
- - **Credit Card**: Highest approval rate with advanced fraud detection
231
- - **PIX**: Instant Brazilian payment method
232
- - **Bank Billet**: Traditional bank payment option
233
- - **Recurring Payments**: Custom subscription rules
234
-
235
- ### Customer Management
236
-
237
- - **Complete Validation**: CPF/CNPJ, phone, address validation
238
- - **Data Sanitization**: XSS protection and input cleaning
239
- - **Secure Storage**: Encrypted sensitive data handling
240
-
241
- ### Security Features
242
-
243
- - **PCI Compliance**: Bank-level security standards
244
- - **Fingerprinting**: Advanced fraud detection
245
- - **Rate Limiting**: Protection against abuse
246
- - **Input Validation**: Comprehensive data validation
247
- - **Obfuscated Builds**: Production builds are obfuscated for enhanced security
248
- - **Controlled Distribution**: Secure distribution via CDN (Cloudflare Pages + jsDelivr)
249
-
250
- ## API Reference
251
-
252
- ### Core Methods
253
-
254
- #### `placeOrder(offerId, data, headers)`
255
-
256
- Creates an order using an existing offer.
257
-
258
- ```javascript
259
- const orderId = await easyflowSDK.placeOrder('demo-offer-67890', {
260
- buyer: {
261
- customerId: customer.id,
262
- name: 'E. R.',
263
- email: 'e***o@gmail.com',
264
- document: {
265
- number: '***202266**',
266
- type: 'CPF',
267
- },
268
- phone: {
269
- areaCode: '+55',
270
- ddd: '92',
271
- number: '*****2191',
272
- isMobile: true,
273
- },
274
- address: {
275
- zipCode: '37537***',
276
- street: 'Rua R. C. M. de A.',
277
- complement: '',
278
- neighborhood: 'M. do S.',
279
- city: 'Santa Rita do Sapucaí',
280
- state: 'MG',
281
- number: '***',
282
- },
283
- },
284
- payments: [
285
- {
286
- method: 'credit-card',
287
- creditCard: {
288
- token: 'valid token here',
289
- },
290
- numberInstallments: 1,
291
- },
292
- ],
293
- metadata: [],
294
- })
28
+ ```typescript
29
+ import EasyflowSDK from '@easyflow/javascript-sdk'
295
30
  ```
296
31
 
297
- #### `charge(data, headers)`
298
-
299
- Processes a direct charge without using an offer.
300
-
301
- ```javascript
302
- const orderId = await easyflowSDK.charge({
303
- buyer: {
304
- name: 'João Silva Santos',
305
- email: 'joao.silva@exemplo.com',
306
- document: {
307
- number: '12345678901',
308
- type: 'CPF',
309
- },
310
- phone: {
311
- areaCode: '+55',
312
- ddd: '11',
313
- number: '9988776655',
314
- isMobile: true,
315
- },
316
- address: {
317
- zipCode: '01234567',
318
- street: 'Rua das Flores',
319
- complement: 'Apto 101',
320
- neighborhood: 'Centro',
321
- city: 'São Paulo',
322
- state: 'SP',
323
- number: '123',
324
- },
325
- customerId: 'demo-customer-12345', // ID do cliente existente (opcional)
326
- },
327
- payments: [
328
- {
329
- method: 'credit-card',
330
- numberInstallments: 1,
331
- valueInCents: 500,
332
- creditCard: {
333
- cardId: 'demo-card-id-here', // cardId e token são opcionais, mas pelo menos 1 deve ser fornecido
334
- token: 'demo-token-credit-card-here',
335
- },
336
- },
337
- ],
338
- items: [
339
- {
340
- description: 'Carregador de celular com cabo USB-C',
341
- name: 'Carregador de Celular',
342
- quantity: 1,
343
- priceInCents: 500,
344
- },
345
- ],
346
- })
347
- ```
32
+ ### **3. Inicialização Simples**
348
33
 
349
- #### `encrypt(creditCardData, headers)`
350
-
351
- Encrypts credit card data for secure processing.
352
-
353
- ```javascript
354
- const token = await easyflowSDK.encrypt({
355
- number: '4111111111111111',
356
- holderName: 'João Silva',
357
- expirationMonth: '12',
358
- expirationYear: '2025',
359
- cvv: '123',
360
- })
34
+ ```typescript
35
+ const sdk = new EasyflowSDK('business-id')
361
36
  ```
362
37
 
363
- ### Customer Management
38
+ ### **4. Uso Direto**
364
39
 
365
- #### `createCustomer(customerData, headers)`
40
+ ```typescript
41
+ // Criar cliente
42
+ const customer = await sdk.createCustomer(customerData)
366
43
 
367
- Creates a new customer.
44
+ // Criar pedido
45
+ const order = await sdk.placeOrder(offerId, orderData)
368
46
 
369
- ```javascript
370
- const customer = await easyflowSDK.createCustomer({
371
- name: 'João Silva',
372
- email: 'joao@exemplo.com',
373
- document: { type: 'CPF', number: '12345678901' },
374
- })
375
- ```
47
+ // Processar pagamento
48
+ const charge = await sdk.charge(paymentData)
376
49
 
377
- #### `getCustomer(customerId, headers)`
50
+ // Adicionar cartão
51
+ const creditCard = await sdk.addCreditCard(cardData)
378
52
 
379
- Retrieves customer information.
380
-
381
- ```javascript
382
- const customer = await easyflowSDK.getCustomer('demo-customer-12345')
53
+ // Remover cartão
54
+ const result = await sdk.removeCreditCard(cardId)
383
55
  ```
384
56
 
385
- #### `updateCustomer(customerId, updateData, headers)`
57
+ ## 🧪 Interface de Teste Completa
386
58
 
387
- Updates existing customer information.
59
+ ### **⚙️ Configuração do SDK**
388
60
 
389
- ```javascript
390
- const result = await easyflowSDK.updateCustomer('demo-customer-12345', {
391
- name: 'João Atualizado',
392
- email: 'joao.atualizado@exemplo.com',
393
- })
394
- ```
61
+ - **Input para Business ID** - Digite seu ID da Easyflow
62
+ - **Botão de Inicialização** - Cria instância do SDK
63
+ - **Status de Configuração** - Confirma se o SDK está funcionando
395
64
 
396
- ### Credit Card Management
65
+ ### **👤 Formulário de Cliente**
397
66
 
398
- #### `addCreditCard(customerId, creditCardToken, headers)`
67
+ - **Nome completo** - Nome do cliente
68
+ - **Email** - Email do cliente
69
+ - **Tipo de documento** - CPF ou CNPJ
70
+ - **Número do documento** - CPF/CNPJ do cliente
71
+ - **DDD** - Código de área do telefone
72
+ - **Número do telefone** - Telefone do cliente
73
+ - **Botão Criar Cliente** - Chama `sdk.createCustomer()`
399
74
 
400
- Adds a credit card to a customer.
75
+ ### **💳 Formulário de Cartão de Crédito**
401
76
 
402
- ```javascript
403
- const result = await easyflowSDK.addCreditCard(
404
- 'demo-customer-12345',
405
- 'encrypted-token-demo'
406
- )
407
- ```
408
-
409
- #### `getCreditCard(customerId, creditCardId, headers)`
77
+ - **Número do cartão** - Número do cartão
78
+ - **Nome do titular** - Nome impresso no cartão
79
+ - **Mês de expiração** - MM (ex: 12)
80
+ - **Ano de expiração** - YYYY (ex: 2025)
81
+ - **CVV** - Código de segurança
82
+ - **Botão Adicionar Cartão** - Chama `sdk.addCreditCard()`
83
+ - **Botão Remover Cartão** - Chama `sdk.removeCreditCard()`
410
84
 
411
- Retrieves credit card information.
85
+ ### **📦 Formulário de Pedido**
412
86
 
413
- ```javascript
414
- const creditCard = await easyflowSDK.getCreditCard(
415
- 'demo-customer-12345',
416
- 'demo-card-67890'
417
- )
418
- ```
87
+ - **ID da Oferta** - ID da oferta no sistema
88
+ - **Número de parcelas** - Quantidade de parcelas
89
+ - **Botão Criar Pedido** - Chama `sdk.placeOrder()`
419
90
 
420
- #### `removeCreditCard(customerId, creditCardId, headers)`
91
+ ### **💳 Formulário de Pagamento**
421
92
 
422
- Removes a credit card from a customer.
93
+ - **Valor em centavos** - Valor do pagamento (ex: 10000 = R$ 100,00)
94
+ - **Número de parcelas** - Quantidade de parcelas
95
+ - **Botão Processar Pagamento** - Chama `sdk.charge()`
423
96
 
424
- ```javascript
425
- const result = await easyflowSDK.removeCreditCard(
426
- 'demo-customer-12345',
427
- 'demo-card-67890'
428
- )
429
- ```
97
+ ### **📊 Status do SDK**
430
98
 
431
- ## Validation
99
+ - **Botão Status** - Chama `sdk.getStatus()`
432
100
 
433
- ### ID Validation
101
+ ## 🔧 Tecnologias
434
102
 
435
- All entity IDs must follow specific formats:
103
+ - **React 18** + **TypeScript**
104
+ - **Vite** (build tool)
105
+ - **Easyflow SDK** (via NPM)
106
+ - **CSS Modules** com design moderno
436
107
 
437
- - **UUID v4**: `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx` (y = 8,9,A,B)
438
- - **UUID v7**: `xxxxxxxx-xxxx-7xxx-yxxx-xxxxxxxxxxxx` (y = 8,9,A,B)
439
- - **MongoDB ObjectId**: 24-character hexadecimal format
108
+ ## 📁 Estrutura
440
109
 
441
- ```javascript
442
- // Valid IDs
443
- Validator.validateOrderId('f47ac10b-58cc-4372-a567-0e02b2c3d479') // UUID v4
444
- Validator.validateOrderId('01890b24-2d7f-7c3f-8f1a-123456789abc') // UUID v7
445
- Validator.validateOrderId('507f1f77bcf86cd799439011') // MongoDB ObjectId
446
110
  ```
447
-
448
- ### Data Validation
449
-
450
- Comprehensive validation for all input data:
451
-
452
- ```javascript
453
- // Customer validation
454
- Validator.validateCustomer({
455
- name: 'John Doe',
456
- email: 'john@example.com',
457
- document: { type: 'CPF', number: '12345678901' },
458
- })
459
-
460
- // Payment validation
461
- Validator.validateOrderData({
462
- items: [{ name: 'Product', price: 1000 }],
463
- payments: [{ method: 'credit-card', numberInstallments: 1 }],
464
- })
111
+ e2e/
112
+ └── react-ts-e2e/
113
+ ├── src/
114
+ │ ├── App.tsx # Interface completa de integração
115
+ │ ├── App.css # Estilos modernos e responsivos
116
+ │ └── main.tsx # Entry point
117
+ ├── package.json # Dependências + SDK
118
+ ├── tsconfig.json # Config TypeScript
119
+ ├── vite.config.ts # Config Vite
120
+ └── README.md # Documentação do projeto E2E
465
121
  ```
466
122
 
467
- ## Events
468
-
469
- The SDK provides an event system for monitoring operations:
123
+ ## 🚀 Como Executar
470
124
 
471
- ```javascript
472
- // Listen to events
473
- easyflowSDK.on('customerCreated', (data) => {
474
- console.log('Cliente criado:', data)
475
- })
125
+ ### **1. Instalar Dependências**
476
126
 
477
- easyflowSDK.on('orderPlaced', (data) => {
478
- console.log('Pedido criado:', data)
479
- })
480
-
481
- easyflowSDK.on('paymentProcessed', (data) => {
482
- console.log('Pagamento processado:', data)
483
- })
484
-
485
- // Remove event listeners
486
- easyflowSDK.off('customerCreated', callback)
127
+ ```bash
128
+ cd e2e/react-ts-e2e
129
+ npm install
487
130
  ```
488
131
 
489
- ## Error Handling
490
-
491
- The SDK provides comprehensive error handling:
132
+ ### **2. Executar em Desenvolvimento**
492
133
 
493
- ```javascript
494
- try {
495
- const result = await easyflowSDK.placeOrder('demo-offer-67890', orderData)
496
- } catch (error) {
497
- if (error.name === 'ValidationError') {
498
- console.log('Falha na validação:', error.message)
499
- } else if (error.name === 'NetworkError') {
500
- console.log('Erro de rede:', error.message)
501
- } else if (error.name === 'SecurityError') {
502
- console.log('Violação de segurança:', error.message)
503
- }
504
- }
134
+ ```bash
135
+ npm run dev
505
136
  ```
506
137
 
507
- ## Configuration
508
-
509
- ### Business ID
510
-
511
- The `businessId` parameter is a required configuration that identifies your business within the Easyflow platform. You
512
- can find this value in your business configuration at [https://app.easyflow.digital/](https://app.easyflow.digital/).
138
+ ### **3. Build de Produção**
513
139
 
514
- **Important:** Never share your business ID publicly. Keep it secure and use it only in your application code.
515
-
516
- ### SDK Options
517
-
518
- ```javascript
519
- // Configure the global instance
520
- easyflowSDK.configure({
521
- businessId: 'demo-business-12345',
522
- environment: 'production', // 'production' or 'sandbox'
523
- debug: false, // Enable debug logging
524
- timeout: 30000, // Request timeout in milliseconds
525
- })
140
+ ```bash
141
+ npm run build
526
142
  ```
527
143
 
528
- ### Environment Variables
144
+ ### **4. Preview do Build**
529
145
 
530
146
  ```bash
531
- EASYFLOW_BUSINESS_ID=demo-business-12345
532
- EASYFLOW_ENVIRONMENT=production
533
- EASYFLOW_DEBUG=false
147
+ npm run preview
534
148
  ```
535
149
 
536
- ## Examples
537
-
538
- ### Complete Checkout Flow
539
-
540
- ```javascript
541
- // 1. Create customer
542
- const customer = await easyflowSDK.createCustomer({
543
- name: 'João Silva',
544
- email: 'joao@exemplo.com',
545
- document: { type: 'CPF', number: '12345678901' },
546
- })
547
-
548
- // 2. Encrypt credit card
549
- const token = await easyflowSDK.encrypt({
550
- number: '4111111111111111',
551
- holderName: 'João Silva',
552
- expirationMonth: '12',
553
- expirationYear: '2025',
554
- cvv: '123',
555
- })
556
-
557
- // 3. Add credit card to customer
558
- const creditCard = await easyflowSDK.addCreditCard(customer.id, token)
559
-
560
- // 4. Place order
561
- const orderId = await easyflowSDK.placeOrder('demo-offer-67890', {
562
- buyer: {
563
- customerId: customer.id,
564
- name: 'E. R.',
565
- email: 'e***o@gmail.com',
566
- document: {
567
- number: '***202266**',
568
- type: 'CPF',
569
- },
570
- phone: {
571
- areaCode: '+55',
572
- ddd: '92',
573
- number: '*****2191',
574
- isMobile: true,
575
- },
576
- address: {
577
- zipCode: '37537***',
578
- street: 'Rua R. C. M. de A.',
579
- complement: '',
580
- neighborhood: 'M. do S.',
581
- city: 'Santa Rita do Sapucaí',
582
- state: 'MG',
583
- number: '***',
584
- },
585
- },
586
- payments: [
587
- {
588
- method: 'credit-card',
589
- creditCard: {
590
- cardId: creditCard.id,
591
- },
592
- numberInstallments: 1,
593
- },
594
- ],
595
- metadata: [],
596
- })
597
- ```
150
+ ## 🔍 O que Prova
598
151
 
599
- ### PIX Payment
600
-
601
- ```javascript
602
- const orderId = await easyflowSDK.placeOrder('demo-offer-67890', {
603
- buyer: {
604
- name: 'E. R.',
605
- email: 'e***o@gmail.com',
606
- document: {
607
- number: '***202266**',
608
- type: 'CPF',
609
- },
610
- phone: {
611
- areaCode: '+55',
612
- ddd: '92',
613
- number: '*****2191',
614
- isMobile: true,
615
- },
616
- address: {
617
- zipCode: '37537***',
618
- street: 'Rua R. C. M. de A.',
619
- complement: '',
620
- neighborhood: 'M. do S.',
621
- city: 'Santa Rita do Sapucaí',
622
- state: 'MG',
623
- number: '***',
624
- },
625
- },
626
- payments: [
627
- {
628
- method: 'pix',
629
- numberInstallments: 1,
630
- },
631
- ],
632
- })
633
-
634
- // Get PIX data
635
- const pixData = await easyflowSDK.getPix(orderId)
636
- console.log('PIX QR Code:', pixData.qrCode)
637
- ```
152
+ ### **✅ Integração NPM**
638
153
 
639
- ### Bank Billet Payment
640
-
641
- ```javascript
642
- const orderId = await easyflowSDK.placeOrder('demo-offer-67890', {
643
- buyer: {
644
- name: 'E. R.',
645
- email: 'e***o@gmail.com',
646
- document: {
647
- number: '***202266**',
648
- type: 'CPF',
649
- },
650
- phone: {
651
- areaCode: '+55',
652
- ddd: '92',
653
- number: '*****2191',
654
- isMobile: true,
655
- },
656
- address: {
657
- zipCode: '37537***',
658
- street: 'Rua R. C. M. de A.',
659
- complement: '',
660
- neighborhood: 'M. do S.',
661
- city: 'Santa Rita do Sapucaí',
662
- state: 'MG',
663
- number: '***',
664
- },
665
- },
666
- metadata: [],
667
- payments: [
668
- {
669
- method: 'bank-billet',
670
- numberInstallments: 1,
671
- },
672
- ],
673
- })
674
-
675
- // Get bank billet data
676
- const bankBillet = await easyflowSDK.getBankBillet(orderId)
677
- console.log('Bank Billet Link:', bankBillet.link)
678
- ```
154
+ - SDK instalado via `npm install`
155
+ - Funciona em ambiente Node.js/npm
679
156
 
680
- ## Complete Implementation Examples
681
-
682
- ### 1. placeOrder - Complete Data Model
683
-
684
- #### placeOrder com PIX
685
-
686
- ```javascript
687
- // Configure SDK
688
- easyflowSDK.configure({
689
- businessId: 'demo-business-12345',
690
- })
691
-
692
- // Complete placeOrder example with PIX payment
693
- const orderId = await easyflowSDK.placeOrder(
694
- '3df92ac7-9d7f-4948-b54f-7e082492f6d2',
695
- {
696
- buyer: {
697
- name: 'João Silva Santos',
698
- email: 'joao.silva@exemplo.com',
699
- document: {
700
- number: '12345678901',
701
- type: 'CPF',
702
- },
703
- phone: {
704
- areaCode: '+55',
705
- ddd: '11',
706
- number: '9988776655',
707
- isMobile: true,
708
- },
709
- address: {
710
- zipCode: '01234567',
711
- street: 'Rua das Flores',
712
- complement: 'Apto 101',
713
- neighborhood: 'Centro',
714
- city: 'São Paulo',
715
- state: 'SP',
716
- number: '123',
717
- },
718
- },
719
- payments: [
720
- {
721
- method: 'pix',
722
- numberInstallments: 1,
723
- },
724
- ],
725
- metadata: [],
726
- }
727
- )
157
+ ### **✅ TypeScript**
728
158
 
729
- console.log('Order created with PIX payment:', orderId)
730
- ```
159
+ - Tipos completos disponíveis
160
+ - IntelliSense funcionando
161
+ - Compilação sem erros
731
162
 
732
- #### placeOrder com Cartão de Crédito
733
-
734
- ```javascript
735
- // Complete placeOrder example with credit card payment
736
- const orderId = await easyflowSDK.placeOrder(
737
- '3df92ac7-9d7f-4948-b54f-7e082492f6d2',
738
- {
739
- buyer: {
740
- name: 'João Silva Santos',
741
- email: 'joao.silva@exemplo.com',
742
- document: {
743
- number: '12345678901',
744
- type: 'CPF',
745
- },
746
- phone: {
747
- areaCode: '+55',
748
- ddd: '11',
749
- number: '9988776655',
750
- isMobile: true,
751
- },
752
- address: {
753
- zipCode: '01234567',
754
- street: 'Rua das Flores',
755
- complement: 'Apto 101',
756
- neighborhood: 'Centro',
757
- city: 'São Paulo',
758
- state: 'SP',
759
- number: '123',
760
- },
761
- },
762
- payments: [
763
- {
764
- method: 'credit-card',
765
- numberInstallments: 1,
766
- creditCard: {
767
- cardId: 'demo-credit-card-67890', // cardId e token são opcionais, mas pelo menos 1 deve ser fornecido
768
- token: 'demo-credit-card-token-here',
769
- last4Numbers: '1234',
770
- holderName: 'JOAO SILVA SANTOS',
771
- expiresAtMonth: '12',
772
- expiresAtYear: '2025',
773
- flag: 'visa',
774
- },
775
- },
776
- ],
777
- metadata: [],
778
- }
779
- )
163
+ ### **✅ Build Tools**
780
164
 
781
- console.log('Order created with credit card payment:', orderId)
782
- ```
165
+ - Vite compila sem problemas
166
+ - Webpack compatível
167
+ - ES Modules funcionando
783
168
 
784
- ### 2. charge - Complete Data Model
785
-
786
- #### charge com Cartão de Crédito
787
-
788
- ```javascript
789
- // Complete charge example with credit card payment
790
- const orderId = await easyflowSDK.charge({
791
- buyer: {
792
- name: 'João Silva Santos',
793
- email: 'joao.silva@exemplo.com',
794
- document: {
795
- number: '12345678901',
796
- type: 'CPF',
797
- },
798
- phone: {
799
- areaCode: '+55',
800
- ddd: '11',
801
- number: '9988776655',
802
- isMobile: true,
803
- },
804
- address: {
805
- zipCode: '01234567',
806
- street: 'Rua das Flores',
807
- complement: 'Apto 101',
808
- neighborhood: 'Centro',
809
- city: 'São Paulo',
810
- state: 'SP',
811
- number: '123',
812
- },
813
- customerId: 'demo-customer-12345', // ID do cliente existente (opcional)
814
- },
815
- payments: [
816
- {
817
- method: 'credit-card',
818
- numberInstallments: 1,
819
- valueInCents: 500,
820
- creditCard: {
821
- cardId: 'demo-card-id-here', // cardId e token são opcionais, mas pelo menos 1 deve ser fornecido
822
- token: 'demo-token-credit-card-here',
823
- },
824
- },
825
- ],
826
- items: [
827
- {
828
- description: 'Carregador de celular com cabo USB-C',
829
- name: 'Carregador de Celular',
830
- quantity: 1,
831
- priceInCents: 500,
832
- },
833
- ],
834
- })
835
-
836
- console.log('Charge processed with credit card:', orderId)
837
- ```
169
+ ### **✅ Runtime**
838
170
 
839
- #### charge com PIX
840
-
841
- ```javascript
842
- // Complete charge example with PIX payment
843
- const orderId = await easyflowSDK.charge({
844
- buyer: {
845
- name: 'João Silva Santos',
846
- email: 'joao.silva@exemplo.com',
847
- document: {
848
- number: '12345678901',
849
- type: 'CPF',
850
- },
851
- phone: {
852
- areaCode: '+55',
853
- ddd: '11',
854
- number: '9988776655',
855
- isMobile: true,
856
- },
857
- address: {
858
- zipCode: '01234567',
859
- street: 'Rua das Flores',
860
- complement: 'Apto 101',
861
- neighborhood: 'Centro',
862
- city: 'São Paulo',
863
- state: 'SP',
864
- number: '123',
865
- },
866
- customerId: 'demo-customer-12345', // ID do cliente existente (opcional)
867
- },
868
- payments: [
869
- {
870
- method: 'pix',
871
- numberInstallments: 1,
872
- valueInCents: 500,
873
- },
874
- ],
875
- items: [
876
- {
877
- description: 'Carregador de celular com cabo USB-C',
878
- name: 'Carregador de Celular',
879
- quantity: 1,
880
- priceInCents: 500,
881
- },
882
- ],
883
- businessId: 'demo-business-12345',
884
- })
885
-
886
- console.log('Charge processed with PIX:', orderId)
887
- ```
171
+ - SDK inicializa corretamente
172
+ - Métodos executam sem erros
173
+ - Tratamento de erros funcionando
888
174
 
889
- ### 3. createCustomer - Complete Data Model
890
-
891
- ```javascript
892
- // Complete createCustomer example with all available fields
893
- const customer = await easyflowSDK.createCustomer({
894
- name: 'João Silva Santos',
895
- email: 'joao.silva@exemplo.com',
896
- document: {
897
- type: 'CPF',
898
- number: '12345678901',
899
- },
900
- phone: {
901
- areaCode: '+55',
902
- ddd: '11',
903
- number: '9988776655',
904
- isMobile: true,
905
- },
906
- address: {
907
- zipCode: '01234567',
908
- street: 'Rua das Flores',
909
- complement: 'Apto 101',
910
- neighborhood: 'Centro',
911
- city: 'São Paulo',
912
- state: 'SP',
913
- number: '123',
914
- },
915
- deliveryAddress: {
916
- zipCode: '01234567',
917
- street: 'Rua das Flores',
918
- complement: 'Apto 101',
919
- neighborhood: 'Centro',
920
- city: 'São Paulo',
921
- state: 'SP',
922
- number: '123',
923
- },
924
- })
925
-
926
- console.log('Customer created with complete data:', customer)
927
- ```
175
+ ### **✅ Interface Completa**
928
176
 
929
- ### 4. addCreditCard - Complete Data Model
930
-
931
- ```javascript
932
- // First, encrypt the credit card data
933
- const encryptedToken = await easyflowSDK.encrypt({
934
- cardNumber: '4111111111111111',
935
- cvv: '123',
936
- month: '12',
937
- year: '2025',
938
- holderName: 'PEDRO OLIVEIRA LIMA',
939
- })
940
-
941
- console.log('Credit card encrypted:', encryptedToken)
942
-
943
- // Then add the encrypted token to the customer
944
- const creditCard = await easyflowSDK.addCreditCard(
945
- customer.id, // customer ID from createCustomer
946
- encryptedToken
947
- )
948
-
949
- console.log('Credit card added successfully:', creditCard)
950
-
951
- // Now you can use the credit card for payments
952
- const orderWithSavedCard = await easyflowSDK.placeOrder(
953
- '3df92ac7-9d7f-4948-b54f-7e082492f6d2',
954
- {
955
- buyer: {
956
- customerId: customer.id, // Use existing customer
957
- name: 'João Silva Santos',
958
- email: 'joao.silva@exemplo.com',
959
- document: {
960
- number: '12345678901',
961
- type: 'CPF',
962
- },
963
- },
964
- payments: [
965
- {
966
- method: 'credit-card',
967
- numberInstallments: 6,
968
- creditCard: {
969
- cardId: creditCard.id, // Use saved credit card
970
- },
971
- },
972
- ],
973
- offerItems: [
974
- {
975
- offerItemId: '3df92ac7-9d7f-4948-b54f-7e082492f6d2',
976
- quantity: 1,
977
- },
978
- ],
979
- metadata: [],
980
- }
981
- )
177
+ - Formulários funcionais
178
+ - Validação de dados
179
+ - Exibição de resultados
180
+ - Tratamento de erros
982
181
 
983
- console.log('Order with saved credit card:', orderWithSavedCard)
984
- ```
182
+ ## 🎯 Simulação Lovable
985
183
 
986
- ### 5. Complete Workflow Example
987
-
988
- ```javascript
989
- // Complete workflow: Customer → Credit Card → Order
990
- async function completeWorkflow() {
991
- try {
992
- // 1. Configure SDK
993
- easyflowSDK.configure({
994
- businessId: 'demo-business-12345',
995
- })
996
-
997
- // 2. Create customer with complete data
998
- const customer = await easyflowSDK.createCustomer({
999
- name: 'Ana Silva Costa',
1000
- email: 'ana.silva@exemplo.com',
1001
- document: { type: 'CPF', number: '55566677788' },
1002
- phone: {
1003
- areaCode: '+55',
1004
- ddd: '41',
1005
- number: '765432109',
1006
- isMobile: true,
1007
- },
1008
- address: {
1009
- zipCode: '80000000',
1010
- street: 'Rua das Palmeiras',
1011
- complement: 'Apto 202',
1012
- neighborhood: 'Batel',
1013
- city: 'Curitiba',
1014
- state: 'PR',
1015
- number: '321',
1016
- },
1017
- })
1018
-
1019
- // 3. Encrypt and add credit card
1020
- const token = await easyflowSDK.encrypt({
1021
- cardNumber: '5555555555554444',
1022
- cvv: '321',
1023
- month: '10',
1024
- year: '2026',
1025
- holderName: 'ANA SILVA COSTA',
1026
- })
1027
-
1028
- const creditCard = await easyflowSDK.addCreditCard(customer.id, token)
1029
-
1030
- // 4. Create order using saved customer and credit card
1031
- const orderId = await easyflowSDK.placeOrder(
1032
- '3df92ac7-9d7f-4948-b54f-7e082492f6d2',
1033
- {
1034
- buyer: {
1035
- customerId: customer.id,
1036
- name: customer.name,
1037
- email: customer.email,
1038
- document: customer.document,
1039
- },
1040
- payments: [
1041
- {
1042
- method: 'credit-card',
1043
- numberInstallments: 12,
1044
- creditCard: { cardId: creditCard.id },
1045
- },
1046
- ],
1047
- offerItems: [
1048
- {
1049
- offerItemId: '3df92ac7-9d7f-4948-b54f-7e082492f6d2',
1050
- quantity: 1,
1051
- },
1052
- ],
1053
- metadata: [],
1054
- }
1055
- )
1056
-
1057
- console.log('Complete workflow successful:', {
1058
- customer: customer.id,
1059
- creditCard: creditCard.id,
1060
- order: orderId,
1061
- })
1062
- } catch (error) {
1063
- console.error('Workflow failed:', error.message)
1064
- }
1065
- }
184
+ Este projeto simula exatamente como o **Lovable** integraria o SDK:
1066
185
 
1067
- // Execute the complete workflow
1068
- completeWorkflow()
1069
- ```
186
+ 1. **Instalação**: `npm install @easyflow/javascript-sdk`
187
+ 2. **Import**: `import EasyflowSDK from '@easyflow/javascript-sdk'`
188
+ 3. **Configuração**: `new EasyflowSDK('business-id')`
189
+ 4. **Uso**: Chamadas diretas aos métodos do SDK
190
+ 5. **Tratamento**: Gerenciamento de erros e resultados
191
+ 6. **Interface**: Formulários para testar cada método
1070
192
 
1071
- ## Distribution & Security
193
+ ## 📊 Resultados Esperados
1072
194
 
1073
- ### Why CDN Scripts?
195
+ - **SDK inicializa** sem erros
196
+ - ✅ **Tipos TypeScript** funcionando
197
+ - ✅ **Build Vite** compila sem problemas
198
+ - ✅ **Métodos do SDK** executam corretamente
199
+ - ✅ **Tratamento de erros** funcionando
200
+ - ✅ **Interface responsiva** e funcional
201
+ - ✅ **Formulários** validam e enviam dados
202
+ - ✅ **Resultados** são exibidos corretamente
1074
203
 
1075
- - **Obfuscated Builds**: Production code is obfuscated for security
1076
- - **Controlled Access**: Secure distribution via Cloudflare Pages and jsDelivr
1077
- - **Version Control**: Specific versions available for stability
1078
- - **Performance**: Global CDN for fast loading
204
+ ## 🔗 Links Relacionados
1079
205
 
1080
- ### Available CDN URLs
206
+ - **[SDK Principal](../../README.md)** - Documentação completa
207
+ - **[INDEX.md](../../INDEX.md)** - Hub de documentação
208
+ - **[PLATFORM-INTEGRATION.md](../../PLATFORM-INTEGRATION.md)** - Guia de integração
209
+ - **[NPM Package](https://www.npmjs.com/package/@easyflow/javascript-sdk)** - Package oficial
1081
210
 
1082
- #### Cloudflare Pages (Primary)
211
+ ---
1083
212
 
1084
- ```html
1085
- <!-- Latest version -->
1086
- <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
213
+ **Este projeto E2E prova que o Easyflow SDK funciona perfeitamente via NPM em projetos TypeScript/React com uma interface completa e funcional!** 🚀✨
1087
214
 
1088
- <!-- Versioned (recommended for production) -->
1089
- <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.19.min.js"></script>
215
+ ## 🚀 Quick Start
1090
216
 
1091
- <!-- With SRI (Subresource Integrity) -->
1092
- <script
1093
- src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.19.min.js"
1094
- integrity="sha384-[hash]"
1095
- crossorigin="anonymous"
1096
- ></script>
217
+ ### Via NPM
218
+
219
+ ```bash
220
+ npm install @easyflow/javascript-sdk
1097
221
  ```
1098
222
 
1099
- #### jsDelivr (Alternative)
223
+ ### Via CDN
1100
224
 
1101
225
  ```html
1102
- <!-- Latest version -->
1103
- <script src="https://cdn.jsdelivr.net/npm/@easyflow/javascript-sdk@latest/dist/easyflow-sdk.min.js"></script>
1104
-
1105
- <!-- Specific version -->
1106
- <script src="https://cdn.jsdelivr.net/npm/@easyflow/javascript-sdk@2.1.20/dist/easyflow-sdk.min.js"></script>
226
+ <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
1107
227
  ```
1108
228
 
1109
- ## Browser Support
1110
-
1111
- ## Node.js Support
1112
-
1113
- - **Node.js**: 18+
1114
- - **npm**: 8+
1115
- - **yarn**: 1.22+
1116
-
1117
- ## Contributing
1118
-
1119
- We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
1120
-
1121
- ## Support
1122
-
1123
- - **Documentation**: [https://docs.easyflow.digital](https://docs.easyflow.digital)
1124
- - **Website**: [https://www.easyflow.digital](https://www.easyflow.digital)
1125
- - **Contact**: [contato@easyflow.digital](mailto:contato@easyflow.digital)
229
+ ## 📚 TypeScript Integration
1126
230
 
1127
- ## License
231
+ Para projetos TypeScript, o SDK é exposto globalmente quando carregado via CDN. Adicione as seguintes declarações ao seu projeto:
1128
232
 
1129
- This project is licensed under the ISC License - see the [LICENSE](LICENSE) file for details.
1130
-
1131
- ## Author
1132
-
1133
- **Diego Moura** - Co-Found & CTO at Easyflow
1134
-
1135
- - **Email**: [contato@easyflow.digital](mailto:contato@easyflow.digital)
1136
- - **Website**: [https://www.easyflow.digital](https://www.easyflow.digital)
1137
-
1138
- ## Changelog
1139
-
1140
- ### v2.1.23
1141
-
1142
- - **SDK Simplification**: Removed all platform-specific integrations for cleaner, focused codebase
1143
- - **Streamlined Documentation**: Focused README on core SDK functionality and usage
1144
- - **Enhanced Security**: Maintained all security features while simplifying the codebase
1145
- - **Better Developer Experience**: Cleaner documentation focused on essential features
1146
-
1147
- ### v2.1.20
1148
-
1149
- - **jsDelivr CDN Fix**: Fixed npm package to include easyflow-sdk.min.js for proper jsDelivr CDN support
1150
- - **Package Structure**: Corrected package.json files field to include JavaScript build files
1151
- - **CDN Availability**: jsDelivr now properly serves the SDK at specific version URLs
1152
- - **Homepage Redirect**: Added automatic redirect from SDK homepage to NPM package for better discoverability
1153
-
1154
- ### v2.1.19
1155
-
1156
- - **Documentation Updates**: Removed all references to private repository
1157
- - **Business ID Information**: Added clear guidance on where to find BUSINESS_ID parameter
1158
- - **Contact Information**: Added official contact email for support
1159
- - **Author Information**: Updated author details and role information
1160
- - **Repository Cleanup**: Cleaned up all private repository references
1161
- - **CDN Options**: Added jsDelivr as alternative CDN option for installation
1162
-
1163
- ### v2.1.18
1164
-
1165
- - **Version Update**: Patch release for latest improvements
1166
- - **Documentation**: Updated version references and CDN URLs
1167
- - **Consistency**: All version references aligned to v2.1.18
1168
-
1169
- ### v2.1.17
1170
-
1171
- - **Complete Implementation Examples**: Added comprehensive examples for all major methods
1172
- - **Full Data Models**: Examples showing all available fields for placeOrder, charge, createCustomer, addCreditCard
1173
- - **Brazilian Data Examples**: Realistic Brazilian addresses, phone
1174
- - **Version Update**: Patch release for latest improvements
1175
- - **Documentation**: Updated version references and CDN URLs
1176
- - **Consistency**: All version references aligned to v2.1.17
1177
-
1178
- ### v2.1.14
1179
-
1180
- - **Version Update**: Patch release for latest improvements
1181
- - **Documentation**: Updated version references and CDN URLs
1182
- - **Consistency**: All version references aligned to v2.1.14
1183
-
1184
- ### v2.1.13
1185
-
1186
- - **Code Formatting**: Improved readability of placeOrder examples with better line breaks
1187
- - **Documentation**: Enhanced formatting for complex method calls
1188
- - **Examples**: Better visual structure for placeOrder, charge, and workflow examples
1189
- - **Consistency**: Unified formatting across all code examples
1190
-
1191
- ### v2.1.12
1192
-
1193
- - **Complete Implementation Examples**: Added comprehensive examples for all major methods
1194
- - **Full Data Models**: Examples showing all available fields for placeOrder, charge, createCustomer, addCreditCard
1195
- - **Brazilian Data Examples**: Realistic Brazilian addresses, phone numbers, and document formats
1196
- - **End-to-End Workflows**: Complete customer → credit card → order workflow examples
1197
- - **Code Quality**: Improved formatting, consistency, and readability across all examples
1198
- - **Documentation**: Fixed duplicate sections and improved overall structure
1199
-
1200
- ### v2.1.11
1201
-
1202
- - **Credit Card Token Fix**: Accepts real encrypted/ciphered tokens from vault services
1203
- - **Flexible Validation**: Supports Base64, URL-safe, and mixed character formats
1204
- - **Variable Length**: Accepts tokens from 16 to 2048 characters
1205
- - **Enhanced Security**: Maintains security while accepting real-world tokens
1206
- - **Backward Compatibility**: Works with all existing token formats
1207
-
1208
- ### v2.1.10
1209
-
1210
- - **Workflow Fixed**: Resolved GitHub Actions permissions and SRI hash generation
1211
- - **CDN Automation**: Automated deployment to Cloudflare Pages working correctly
1212
- - **Release Process**: GitHub releases created automatically with proper SRI hashes
1213
- - **Build Pipeline**: Streamlined build and deployment process
1214
-
1215
- ### v2.1.9
1216
-
1217
- - **Hybrid Distribution**: NPM for docs, CDN for secure obfuscated code
1218
- - **Enhanced Security**: Code source protected while maintaining accessibility
1219
- - **Better UX**: Easy discovery via NPM, secure usage via CDN
1220
- - **Documentation**: Complete setup and usage instructions
1221
-
1222
- ### v2.1.8
1223
-
1224
- - **Security & Privacy**: Anonymized README.md for safe NPM publication
1225
- - **Documentation**: Removed all personal information and sensitive data
1226
- - **Professional**: Clean, business-focused documentation
1227
-
1228
- ### v2.1.7
1229
-
1230
- - Fixed all failing unit tests for complete 250 test coverage
1231
- - Corrected mock structures for customer and credit card management
1232
- - Standardized API response patterns across all endpoints
1233
- - Enhanced test reliability and maintainability
1234
-
1235
- ### v2.1.6
1236
-
1237
- - Enhanced ID validation with UUID v4, UUID v7, and MongoDB ObjectId support
1238
- - Fixed iframe compatibility issues for low-code platforms
1239
- - Implemented complete event system with `on()` and `off()` methods
1240
- - Added global SDK instance for easier integration
233
+ ```typescript
234
+ // O SDK está sendo carregado via CDN e exposto globalmente como window.easyflowSDK
235
+ declare global {
236
+ interface Window {
237
+ easyflowSDK: any
238
+ EasyflowSDK: any
239
+ }
240
+ }
241
+ ```
1241
242
 
1242
- ### v2.1.5
243
+ ### Exemplo de Uso com TypeScript
1243
244
 
1244
- - Added browser fingerprinting for enhanced security
1245
- - Implemented automatic `x-fingerprint-id` header generation
1246
- - Enhanced security validation and error handling
1247
- - Improved documentation and examples
245
+ ```typescript
246
+ // Configurar o SDK
247
+ window.easyflowSDK.configure({ businessId: 'your-business-id' })
1248
248
 
1249
- ---
249
+ // Usar métodos do SDK
250
+ const customer = await window.easyflowSDK.createCustomer(customerData)
251
+ const payment = await window.easyflowSDK.charge(paymentData)
252
+ ```
1250
253
 
1251
- **Built with ❤️ by the Easyflow Team**
254
+ ## 🔧 Usage