@easyflow/javascript-sdk 2.1.10 → 2.1.12

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 +549 -97
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Easyflow JavaScript SDK
2
2
 
3
3
  [![Build Status](https://github.com/easyflow-cash/easyflow-javascript-sdk/workflows/Build%20&%20Deploy%20Easyflow%20SDK/badge.svg)](https://github.com/easyflow-cash/easyflow-javascript-sdk/actions)
4
- [![Version](https://img.shields.io/badge/version-2.1.10-blue.svg)](https://easyflow-sdk.pages.dev)
4
+ [![Version](https://img.shields.io/badge/version-2.1.12-blue.svg)](https://easyflow-sdk.pages.dev)
5
5
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
6
6
  [![Tests](https://img.shields.io/badge/tests-250%20passing-brightgreen.svg)](https://github.com/easyflow-cash/easyflow-javascript-sdk)
7
7
  [![Coverage](https://img.shields.io/badge/coverage-95%25-brightgreen.svg)](https://github.com/easyflow-cash/easyflow-javascript-sdk)
@@ -12,7 +12,8 @@
12
12
 
13
13
  **Freedom to sell more, better and longer**
14
14
 
15
- > **Enterprise-grade JavaScript SDK** for integration with the Easyflow payment processing platform with robust validation, comprehensive security and Brazilian compliance
15
+ > **Enterprise-grade JavaScript SDK** for integration with the Easyflow payment processing platform with robust
16
+ > validation, comprehensive security and Brazilian compliance
16
17
 
17
18
  [![Website](https://img.shields.io/badge/Website-Easyflow.digital-667eea?style=for-the-badge)](https://www.easyflow.digital/)
18
19
  [![Start Free](https://img.shields.io/badge/Start_Free-22c55e?style=for-the-badge&logo=rocket&logoColor=white)](https://www.easyflow.digital/)
@@ -22,7 +23,9 @@
22
23
 
23
24
  ## About Easyflow
24
25
 
25
- [Easyflow](https://www.easyflow.digital/) is a payment platform that **facilitates the sales process** of digital products and services in a simple and intuitive way. Our mission is to transform Digital Commerce by offering a complete sales structure to maximize your LTV.
26
+ [Easyflow](https://www.easyflow.digital/) is a payment platform that **facilitates the sales process** of digital
27
+ products and services in a simple and intuitive way. Our mission is to transform Digital Commerce by offering a complete
28
+ sales structure to maximize your LTV.
26
29
 
27
30
  ### Why Choose Easyflow?
28
31
 
@@ -68,7 +71,8 @@
68
71
 
69
72
  ## What is the Easyflow JavaScript SDK?
70
73
 
71
- The **Easyflow JavaScript SDK** is the official tool for developers to integrate their applications with the Easyflow platform. With this SDK, you can:
74
+ The **Easyflow JavaScript SDK** is the official tool for developers to integrate their applications with the Easyflow
75
+ platform. With this SDK, you can:
72
76
 
73
77
  - **Process payments** securely and reliably
74
78
  - **Manage customers** with complete Brazilian data validation
@@ -84,7 +88,23 @@ The **Easyflow JavaScript SDK** is the official tool for developers to integrate
84
88
  - **High Performance**: Optimized for production
85
89
  - **Complete Documentation**: Practical examples for all use cases
86
90
 
87
- ## What's New in v2.1.10
91
+ ## What's New in v2.1.12
92
+
93
+ ### Complete Implementation Examples
94
+
95
+ - **Full Data Models**: Comprehensive examples for placeOrder, charge, createCustomer, and addCreditCard
96
+ - **Real-World Scenarios**: Complete workflows with all available data fields
97
+ - **Brazilian Data**: Realistic Brazilian addresses, phone numbers, and document formats
98
+ - **End-to-End Workflows**: Complete customer → credit card → order examples
99
+ - **Code Quality**: Improved formatting and consistency across all examples
100
+
101
+ ### Credit Card Token Validation Fix
102
+
103
+ - **Real Token Support**: Now accepts real encrypted/ciphered credit card tokens
104
+ - **Flexible Format**: Supports Base64, URL-safe, and mixed character tokens
105
+ - **Variable Length**: Accepts tokens from 16 to 2048 characters
106
+ - **Enhanced Security**: Maintains security while accepting real-world tokens
107
+ - **Backward Compatibility**: Works with all existing token formats
88
108
 
89
109
  ### Workflow Corrections
90
110
 
@@ -95,8 +115,6 @@ The **Easyflow JavaScript SDK** is the official tool for developers to integrate
95
115
 
96
116
  ### Hybrid Distribution Strategy
97
117
 
98
- ### Hybrid Distribution Strategy
99
-
100
118
  - **NPM Package**: Contains only documentation and TypeScript definitions
101
119
  - **CDN Scripts**: Production-ready obfuscated builds via Cloudflare Pages
102
120
  - **Enhanced Security**: Code source protected while maintaining accessibility
@@ -109,21 +127,6 @@ The **Easyflow JavaScript SDK** is the official tool for developers to integrate
109
127
  - **Professional Documentation**: Clean, business-focused documentation
110
128
  - **NPM Safety**: Safe for public NPM publication
111
129
 
112
- ### Security & Privacy Improvements
113
-
114
- - **README Anonymization**: Removed all personal information and sensitive data
115
- - **Privacy Protection**: No personal emails, URLs, or contact information exposed
116
- - **Professional Documentation**: Clean, business-focused documentation
117
- - **NPM Safety**: Safe for public NPM publication
118
-
119
- ### Test Suite Improvements
120
-
121
- - **Test Coverage Optimization**: Fixed all failing unit tests for complete 250 test coverage
122
- - **Mock Structure Corrections**: Updated test mocks to align with actual API response patterns
123
- - **Customer Management Tests**: Corrected mock structures for `createCustomer` and `getCustomer` methods
124
- - **Credit Card Tests**: Fixed mock data structures for `addCreditCard` and `getCreditCard` methods
125
- - **Consistent Test Patterns**: Standardized mock response structures across all endpoints
126
-
127
130
  ### Test Suite Improvements
128
131
 
129
132
  - **Test Coverage Optimization**: Fixed all failing unit tests for complete 250 test coverage
@@ -167,7 +170,7 @@ Add this script tag to your HTML:
167
170
  <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
168
171
 
169
172
  <!-- Specific version -->
170
- <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.10.min.js"></script>
173
+ <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.12.min.js"></script>
171
174
  ```
172
175
 
173
176
  #### Option 2: NPM Package (Documentation Only)
@@ -180,37 +183,86 @@ npm install @easyflow/javascript-sdk
180
183
 
181
184
  #### Option 3: Direct Download
182
185
 
183
- Download the latest obfuscated build from [GitHub Releases](https://github.com/easyflow-cash/easyflow-javascript-sdk/releases).
186
+ Download the latest obfuscated build
187
+ from [GitHub Releases](https://github.com/easyflow-cash/easyflow-javascript-sdk/releases).
184
188
 
185
189
  ### Basic Usage
186
190
 
187
- ```javascript
188
- import { EasyflowSDK } from '@easyflow/javascript-sdk'
191
+ #### Method 1: CDN Script (Recommended for Production)
189
192
 
190
- // Initialize SDK
191
- const sdk = new EasyflowSDK({
192
- businessId: 'your-business-id',
193
- })
193
+ ```html
194
+ <!-- Load SDK via script tag -->
195
+ <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
194
196
 
195
- // Process a payment
196
- const orderId = await sdk.placeOrder('offer-id', {
197
- customer: {
198
- name: 'John Doe',
199
- email: 'john@example.com',
200
- document: {
201
- type: 'CPF',
202
- number: '12345678901',
203
- },
204
- },
205
- payments: [
206
- {
207
- method: 'credit-card',
208
- numberInstallments: 1,
209
- },
210
- ],
211
- })
197
+ <script>
198
+ // Configure the global instance
199
+ easyflowSDK.configure({
200
+ businessId: 'demo-business-12345',
201
+ })
202
+
203
+ // Process a payment
204
+ easyflowSDK
205
+ .placeOrder('demo-offer-67890', {
206
+ customer: {
207
+ name: 'João Silva',
208
+ email: 'joao@exemplo.com',
209
+ document: {
210
+ type: 'CPF',
211
+ number: '12345678901',
212
+ },
213
+ },
214
+ payments: [
215
+ {
216
+ method: 'credit-card',
217
+ numberInstallments: 1,
218
+ },
219
+ ],
220
+ })
221
+ .then((orderId) => {
222
+ console.log('Pedido criado:', orderId)
223
+ })
224
+ .catch((error) => {
225
+ console.error('Erro ao criar pedido:', error.message)
226
+ })
227
+ </script>
228
+ ```
212
229
 
213
- console.log('Order created:', orderId)
230
+ #### Method 2: Global Instance (For Low-Code Platforms & Simple HTML)
231
+
232
+ ```html
233
+ <!-- Load SDK via script tag -->
234
+ <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
235
+
236
+ <script>
237
+ // Configure the global instance
238
+ easyflowSDK.configure({
239
+ businessId: 'demo-business-12345',
240
+ })
241
+
242
+ // Now you can use all methods directly
243
+ easyflowSDK
244
+ .createCustomer({
245
+ name: 'Maria Silva',
246
+ email: 'maria@exemplo.com',
247
+ document: { type: 'CPF', number: '12345678901' },
248
+ })
249
+ .then((customer) => {
250
+ console.log('Cliente criado:', customer)
251
+ })
252
+ .catch((error) => {
253
+ console.error('Erro ao criar cliente:', error.message)
254
+ })
255
+
256
+ // Validation methods are always available
257
+ if (easyflowSDK.validate.email('teste@exemplo.com')) {
258
+ console.log('Email válido!')
259
+ }
260
+
261
+ // Listen to events
262
+ easyflowSDK.on('customerCreated', (data) => {
263
+ console.log('Evento cliente criado:', data)
264
+ })
265
+ </script>
214
266
  ```
215
267
 
216
268
  ## Features
@@ -237,6 +289,14 @@ console.log('Order created:', orderId)
237
289
  - **Obfuscated Builds**: Production builds are obfuscated for enhanced security
238
290
  - **Controlled Distribution**: Secure distribution via CDN and GitHub Releases
239
291
 
292
+ ### Low-Code Platform Support
293
+
294
+ - **Lovable Integration**: Full compatibility with Lovable platform
295
+ - **Global Instance**: `window.easyflowSDK` for easy integration
296
+ - **Event System**: Built-in event handling for `on()` and `off()`
297
+ - **Validation Methods**: Always available validation functions
298
+ - **Configuration**: Simple setup with `easyflowSDK.configure()`
299
+
240
300
  ## API Reference
241
301
 
242
302
  ### Core Methods
@@ -246,13 +306,13 @@ console.log('Order created:', orderId)
246
306
  Creates an order using an existing offer.
247
307
 
248
308
  ```javascript
249
- const orderId = await sdk.placeOrder('offer-id', {
309
+ const orderId = await easyflowSDK.placeOrder('demo-offer-67890', {
250
310
  customer: {
251
- /* customer data */
311
+ name: 'João Silva',
312
+ email: 'joao@exemplo.com',
313
+ document: { type: 'CPF', number: '12345678901' },
252
314
  },
253
- payments: [
254
- /* payment methods */
255
- ],
315
+ payments: [{ method: 'credit-card', numberInstallments: 1 }],
256
316
  })
257
317
  ```
258
318
 
@@ -261,8 +321,8 @@ const orderId = await sdk.placeOrder('offer-id', {
261
321
  Processes a direct charge without using an offer.
262
322
 
263
323
  ```javascript
264
- const orderId = await sdk.charge({
265
- items: [{ name: 'Product', price: 1000 }],
324
+ const orderId = await easyflowSDK.charge({
325
+ items: [{ name: 'Produto Demo', price: 1000 }],
266
326
  payments: [{ method: 'pix', numberInstallments: 1 }],
267
327
  })
268
328
  ```
@@ -272,9 +332,9 @@ const orderId = await sdk.charge({
272
332
  Encrypts credit card data for secure processing.
273
333
 
274
334
  ```javascript
275
- const token = await sdk.encrypt({
335
+ const token = await easyflowSDK.encrypt({
276
336
  number: '4111111111111111',
277
- holderName: 'John Doe',
337
+ holderName: 'João Silva',
278
338
  expirationMonth: '12',
279
339
  expirationYear: '2025',
280
340
  cvv: '123',
@@ -288,9 +348,9 @@ const token = await sdk.encrypt({
288
348
  Creates a new customer.
289
349
 
290
350
  ```javascript
291
- const customer = await sdk.createCustomer({
292
- name: 'John Doe',
293
- email: 'john@example.com',
351
+ const customer = await easyflowSDK.createCustomer({
352
+ name: 'João Silva',
353
+ email: 'joao@exemplo.com',
294
354
  document: { type: 'CPF', number: '12345678901' },
295
355
  })
296
356
  ```
@@ -300,7 +360,7 @@ const customer = await sdk.createCustomer({
300
360
  Retrieves customer information.
301
361
 
302
362
  ```javascript
303
- const customer = await sdk.getCustomer('customer-id')
363
+ const customer = await easyflowSDK.getCustomer('demo-customer-12345')
304
364
  ```
305
365
 
306
366
  #### `updateCustomer(customerId, updateData, headers)`
@@ -308,9 +368,9 @@ const customer = await sdk.getCustomer('customer-id')
308
368
  Updates existing customer information.
309
369
 
310
370
  ```javascript
311
- const result = await sdk.updateCustomer('customer-id', {
312
- name: 'John Updated',
313
- email: 'john.updated@example.com',
371
+ const result = await easyflowSDK.updateCustomer('demo-customer-12345', {
372
+ name: 'João Atualizado',
373
+ email: 'joao.atualizado@exemplo.com',
314
374
  })
315
375
  ```
316
376
 
@@ -321,7 +381,10 @@ const result = await sdk.updateCustomer('customer-id', {
321
381
  Adds a credit card to a customer.
322
382
 
323
383
  ```javascript
324
- const result = await sdk.addCreditCard('customer-id', 'encrypted-token')
384
+ const result = await easyflowSDK.addCreditCard(
385
+ 'demo-customer-12345',
386
+ 'encrypted-token-demo'
387
+ )
325
388
  ```
326
389
 
327
390
  #### `getCreditCard(customerId, creditCardId, headers)`
@@ -329,7 +392,10 @@ const result = await sdk.addCreditCard('customer-id', 'encrypted-token')
329
392
  Retrieves credit card information.
330
393
 
331
394
  ```javascript
332
- const creditCard = await sdk.getCreditCard('customer-id', 'credit-card-id')
395
+ const creditCard = await easyflowSDK.getCreditCard(
396
+ 'demo-customer-12345',
397
+ 'demo-card-67890'
398
+ )
333
399
  ```
334
400
 
335
401
  #### `removeCreditCard(customerId, creditCardId, headers)`
@@ -337,7 +403,10 @@ const creditCard = await sdk.getCreditCard('customer-id', 'credit-card-id')
337
403
  Removes a credit card from a customer.
338
404
 
339
405
  ```javascript
340
- const result = await sdk.removeCreditCard('customer-id', 'credit-card-id')
406
+ const result = await easyflowSDK.removeCreditCard(
407
+ 'demo-customer-12345',
408
+ 'demo-card-67890'
409
+ )
341
410
  ```
342
411
 
343
412
  ## Validation
@@ -382,20 +451,20 @@ The SDK provides an event system for monitoring operations:
382
451
 
383
452
  ```javascript
384
453
  // Listen to events
385
- sdk.on('customerCreated', (data) => {
386
- console.log('Customer created:', data)
454
+ easyflowSDK.on('customerCreated', (data) => {
455
+ console.log('Cliente criado:', data)
387
456
  })
388
457
 
389
- sdk.on('orderPlaced', (data) => {
390
- console.log('Order placed:', data)
458
+ easyflowSDK.on('orderPlaced', (data) => {
459
+ console.log('Pedido criado:', data)
391
460
  })
392
461
 
393
- sdk.on('paymentProcessed', (data) => {
394
- console.log('Payment processed:', data)
462
+ easyflowSDK.on('paymentProcessed', (data) => {
463
+ console.log('Pagamento processado:', data)
395
464
  })
396
465
 
397
466
  // Remove event listeners
398
- sdk.off('customerCreated', callback)
467
+ easyflowSDK.off('customerCreated', callback)
399
468
  ```
400
469
 
401
470
  ## Error Handling
@@ -404,25 +473,26 @@ The SDK provides comprehensive error handling:
404
473
 
405
474
  ```javascript
406
475
  try {
407
- const result = await sdk.placeOrder('offer-id', orderData)
476
+ const result = await easyflowSDK.placeOrder('demo-offer-67890', orderData)
408
477
  } catch (error) {
409
478
  if (error.name === 'ValidationError') {
410
- console.log('Validation failed:', error.message)
479
+ console.log('Falha na validação:', error.message)
411
480
  } else if (error.name === 'NetworkError') {
412
- console.log('Network error:', error.message)
481
+ console.log('Erro de rede:', error.message)
413
482
  } else if (error.name === 'SecurityError') {
414
- console.log('Security violation:', error.message)
483
+ console.log('Violação de segurança:', error.message)
415
484
  }
416
485
  }
417
486
  ```
418
487
 
419
488
  ## Configuration
420
489
 
421
- ### SDK Options
490
+ ### SDK Options (CDN Implementation)
422
491
 
423
492
  ```javascript
424
- const sdk = new EasyflowSDK({
425
- businessId: 'your-business-id',
493
+ // Configure the global instance
494
+ easyflowSDK.configure({
495
+ businessId: 'demo-business-12345',
426
496
  environment: 'production', // 'production' or 'sandbox'
427
497
  debug: false, // Enable debug logging
428
498
  timeout: 30000, // Request timeout in milliseconds
@@ -432,7 +502,7 @@ const sdk = new EasyflowSDK({
432
502
  ### Environment Variables
433
503
 
434
504
  ```bash
435
- EASYFLOW_BUSINESS_ID=your-business-id
505
+ EASYFLOW_BUSINESS_ID=demo-business-12345
436
506
  EASYFLOW_ENVIRONMENT=production
437
507
  EASYFLOW_DEBUG=false
438
508
  ```
@@ -443,26 +513,26 @@ EASYFLOW_DEBUG=false
443
513
 
444
514
  ```javascript
445
515
  // 1. Create customer
446
- const customer = await sdk.createCustomer({
447
- name: 'John Doe',
448
- email: 'john@example.com',
516
+ const customer = await easyflowSDK.createCustomer({
517
+ name: 'João Silva',
518
+ email: 'joao@exemplo.com',
449
519
  document: { type: 'CPF', number: '12345678901' },
450
520
  })
451
521
 
452
522
  // 2. Encrypt credit card
453
- const token = await sdk.encrypt({
523
+ const token = await easyflowSDK.encrypt({
454
524
  number: '4111111111111111',
455
- holderName: 'John Doe',
525
+ holderName: 'João Silva',
456
526
  expirationMonth: '12',
457
527
  expirationYear: '2025',
458
528
  cvv: '123',
459
529
  })
460
530
 
461
531
  // 3. Add credit card to customer
462
- const creditCard = await sdk.addCreditCard(customer.id, token)
532
+ const creditCard = await easyflowSDK.addCreditCard(customer.id, token)
463
533
 
464
534
  // 4. Place order
465
- const orderId = await sdk.placeOrder('offer-id', {
535
+ const orderId = await easyflowSDK.placeOrder('demo-offer-67890', {
466
536
  customer: customer,
467
537
  payments: [
468
538
  {
@@ -477,9 +547,11 @@ const orderId = await sdk.placeOrder('offer-id', {
477
547
  ### PIX Payment
478
548
 
479
549
  ```javascript
480
- const orderId = await sdk.placeOrder('offer-id', {
550
+ const orderId = await easyflowSDK.placeOrder('demo-offer-67890', {
481
551
  customer: {
482
- /* customer data */
552
+ name: 'Maria Santos',
553
+ email: 'maria@exemplo.com',
554
+ document: { type: 'CPF', number: '98765432100' },
483
555
  },
484
556
  payments: [
485
557
  {
@@ -490,16 +562,18 @@ const orderId = await sdk.placeOrder('offer-id', {
490
562
  })
491
563
 
492
564
  // Get PIX data
493
- const pixData = await sdk.getPix(orderId)
565
+ const pixData = await easyflowSDK.getPix(orderId)
494
566
  console.log('PIX QR Code:', pixData.qrCode)
495
567
  ```
496
568
 
497
569
  ### Bank Billet Payment
498
570
 
499
571
  ```javascript
500
- const orderId = await sdk.placeOrder('offer-id', {
572
+ const orderId = await easyflowSDK.placeOrder('demo-offer-67890', {
501
573
  customer: {
502
- /* customer data */
574
+ name: 'Pedro Costa',
575
+ email: 'pedro@exemplo.com',
576
+ document: { type: 'CPF', number: '11122233344' },
503
577
  },
504
578
  payments: [
505
579
  {
@@ -510,10 +584,370 @@ const orderId = await sdk.placeOrder('offer-id', {
510
584
  })
511
585
 
512
586
  // Get bank billet data
513
- const bankBillet = await sdk.getBankBillet(orderId)
587
+ const bankBillet = await easyflowSDK.getBankBillet(orderId)
514
588
  console.log('Bank Billet Link:', bankBillet.link)
515
589
  ```
516
590
 
591
+ ## Complete Implementation Examples
592
+
593
+ ### 1. placeOrder - Complete Data Model
594
+
595
+ ```javascript
596
+ // Configure SDK
597
+ easyflowSDK.configure({
598
+ businessId: 'demo-business-12345',
599
+ })
600
+
601
+ // Complete placeOrder example with all available fields
602
+ const orderId = await easyflowSDK.placeOrder('demo-offer-67890', {
603
+ buyer: {
604
+ name: 'João Silva Santos',
605
+ email: 'joao.silva@exemplo.com',
606
+ document: {
607
+ number: '12345678901',
608
+ type: 'CPF',
609
+ },
610
+ phone: {
611
+ areaCode: '+55',
612
+ ddd: '11',
613
+ number: '9988776655',
614
+ isMobile: true,
615
+ },
616
+ address: {
617
+ zipCode: '01234567',
618
+ street: 'Rua das Flores',
619
+ complement: 'Apto 101',
620
+ neighborhood: 'Centro',
621
+ city: 'São Paulo',
622
+ state: 'SP',
623
+ number: '123',
624
+ },
625
+ deliveryAddress: {
626
+ zipCode: '01234567',
627
+ street: 'Rua das Flores',
628
+ complement: 'Apto 101',
629
+ neighborhood: 'Centro',
630
+ city: 'São Paulo',
631
+ state: 'SP',
632
+ number: '123',
633
+ },
634
+ },
635
+ payments: [
636
+ {
637
+ method: 'credit-card',
638
+ numberInstallments: 3,
639
+ valueInCents: 15000,
640
+ creditCard: {
641
+ cardId: 'demo-card-67890',
642
+ },
643
+ },
644
+ ],
645
+ items: [
646
+ {
647
+ name: 'Produto Premium',
648
+ description: 'Descrição detalhada do produto premium',
649
+ quantity: 2,
650
+ priceInCents: 7500,
651
+ weightInGrams: 500,
652
+ dimensions: {
653
+ length: 20,
654
+ width: 15,
655
+ height: 10,
656
+ },
657
+ },
658
+ ],
659
+ metadata: {
660
+ source: 'website',
661
+ campaign: 'black-friday-2024',
662
+ affiliate: 'partner-123',
663
+ },
664
+ })
665
+
666
+ console.log('Order created with complete data:', orderId)
667
+ ```
668
+
669
+ ### 2. charge - Complete Data Model
670
+
671
+ ```javascript
672
+ // Complete charge example with all available fields
673
+ const orderId = await easyflowSDK.charge({
674
+ buyer: {
675
+ name: 'Maria Santos Costa',
676
+ email: 'maria.costa@exemplo.com',
677
+ document: {
678
+ number: '98765432100',
679
+ type: 'CPF',
680
+ },
681
+ phone: {
682
+ areaCode: '+55',
683
+ ddd: '21',
684
+ number: '987654321',
685
+ isMobile: true,
686
+ },
687
+ address: {
688
+ zipCode: '20000000',
689
+ street: 'Avenida Rio Branco',
690
+ complement: 'Sala 1001',
691
+ neighborhood: 'Centro',
692
+ city: 'Rio de Janeiro',
693
+ state: 'RJ',
694
+ number: '456',
695
+ },
696
+ deliveryAddress: {
697
+ zipCode: '20000000',
698
+ street: 'Avenida Rio Branco',
699
+ complement: 'Sala 1001',
700
+ neighborhood: 'Centro',
701
+ city: 'Rio de Janeiro',
702
+ state: 'RJ',
703
+ number: '456',
704
+ },
705
+ },
706
+ payments: [
707
+ {
708
+ method: 'pix',
709
+ numberInstallments: 1,
710
+ valueInCents: 25000,
711
+ },
712
+ {
713
+ method: 'bank-billet',
714
+ numberInstallments: 1,
715
+ valueInCents: 15000,
716
+ },
717
+ ],
718
+ items: [
719
+ {
720
+ name: 'Curso Online',
721
+ description: 'Curso completo de desenvolvimento web',
722
+ quantity: 1,
723
+ priceInCents: 25000,
724
+ weightInGrams: 0,
725
+ dimensions: {
726
+ length: 0,
727
+ width: 0,
728
+ height: 0,
729
+ },
730
+ },
731
+ {
732
+ name: 'E-book Premium',
733
+ description: 'E-book com estratégias avançadas',
734
+ quantity: 1,
735
+ priceInCents: 15000,
736
+ weightInGrams: 0,
737
+ dimensions: {
738
+ length: 0,
739
+ width: 0,
740
+ height: 0,
741
+ },
742
+ },
743
+ ],
744
+ metadata: {
745
+ source: 'landing-page',
746
+ campaign: 'curso-web-2024',
747
+ utm_source: 'google',
748
+ utm_medium: 'cpc',
749
+ },
750
+ })
751
+
752
+ console.log('Charge processed with complete data:', orderId)
753
+ ```
754
+
755
+ ### 3. createCustomer - Complete Data Model
756
+
757
+ ```javascript
758
+ // Complete createCustomer example with all available fields
759
+ const customer = await easyflowSDK.createCustomer({
760
+ businessId: 'demo-business-12345',
761
+ name: 'Pedro Oliveira Lima',
762
+ email: 'pedro.oliveira@exemplo.com',
763
+ document: {
764
+ type: 'CPF',
765
+ number: '11122233344',
766
+ },
767
+ phone: {
768
+ areaCode: '+55',
769
+ ddd: '31',
770
+ number: '876543210',
771
+ isMobile: true,
772
+ },
773
+ address: {
774
+ zipCode: '30000000',
775
+ street: 'Rua da Liberdade',
776
+ complement: 'Casa',
777
+ neighborhood: 'Savassi',
778
+ city: 'Belo Horizonte',
779
+ state: 'MG',
780
+ number: '789',
781
+ },
782
+ deliveryAddress: {
783
+ zipCode: '30000000',
784
+ street: 'Rua da Liberdade',
785
+ complement: 'Casa',
786
+ neighborhood: 'Savassi',
787
+ city: 'Belo Horizonte',
788
+ state: 'MG',
789
+ number: '789',
790
+ },
791
+ birthDate: '1990-05-15',
792
+ gender: 'M',
793
+ maritalStatus: 'single',
794
+ occupation: 'Desenvolvedor',
795
+ company: 'Tech Solutions Ltda',
796
+ website: 'https://pedrooliveira.com',
797
+ notes: 'Cliente preferencial com histórico de compras',
798
+ tags: ['premium', 'tech-savvy', 'early-adopter'],
799
+ preferences: {
800
+ newsletter: true,
801
+ marketing: false,
802
+ language: 'pt-BR',
803
+ currency: 'BRL',
804
+ },
805
+ })
806
+
807
+ console.log('Customer created with complete data:', customer)
808
+ ```
809
+
810
+ ### 4. addCreditCard - Complete Data Model
811
+
812
+ ```javascript
813
+ // First, encrypt the credit card data
814
+ const encryptedToken = await easyflowSDK.encrypt({
815
+ cardNumber: '4111111111111111',
816
+ cvv: '123',
817
+ month: '12',
818
+ year: '2025',
819
+ holderName: 'PEDRO OLIVEIRA LIMA',
820
+ })
821
+
822
+ console.log('Credit card encrypted:', encryptedToken)
823
+
824
+ // Then add the encrypted token to the customer
825
+ const creditCard = await easyflowSDK.addCreditCard(
826
+ customer.id, // customer ID from createCustomer
827
+ encryptedToken
828
+ )
829
+
830
+ console.log('Credit card added successfully:', creditCard)
831
+
832
+ // Now you can use the credit card for payments
833
+ const orderWithSavedCard = await easyflowSDK.placeOrder('demo-offer-67890', {
834
+ buyer: {
835
+ customerId: customer.id, // Use existing customer
836
+ name: 'Pedro Oliveira Lima',
837
+ email: 'pedro.oliveira@exemplo.com',
838
+ document: {
839
+ number: '11122233344',
840
+ type: 'CPF',
841
+ },
842
+ },
843
+ payments: [
844
+ {
845
+ method: 'credit-card',
846
+ numberInstallments: 6,
847
+ valueInCents: 50000,
848
+ creditCard: {
849
+ cardId: creditCard.id, // Use saved credit card
850
+ },
851
+ },
852
+ ],
853
+ items: [
854
+ {
855
+ name: 'Produto com Cartão Salvo',
856
+ description: 'Compra usando cartão salvo anteriormente',
857
+ quantity: 1,
858
+ priceInCents: 50000,
859
+ },
860
+ ],
861
+ })
862
+
863
+ console.log('Order with saved credit card:', orderWithSavedCard)
864
+ ```
865
+
866
+ ### 5. Complete Workflow Example
867
+
868
+ ```javascript
869
+ // Complete workflow: Customer → Credit Card → Order
870
+ async function completeWorkflow() {
871
+ try {
872
+ // 1. Configure SDK
873
+ easyflowSDK.configure({
874
+ businessId: 'demo-business-12345',
875
+ })
876
+
877
+ // 2. Create customer with complete data
878
+ const customer = await easyflowSDK.createCustomer({
879
+ businessId: 'demo-business-12345',
880
+ name: 'Ana Silva Costa',
881
+ email: 'ana.silva@exemplo.com',
882
+ document: { type: 'CPF', number: '55566677788' },
883
+ phone: {
884
+ areaCode: '+55',
885
+ ddd: '41',
886
+ number: '765432109',
887
+ isMobile: true,
888
+ },
889
+ address: {
890
+ zipCode: '80000000',
891
+ street: 'Rua das Palmeiras',
892
+ complement: 'Apto 202',
893
+ neighborhood: 'Batel',
894
+ city: 'Curitiba',
895
+ state: 'PR',
896
+ number: '321',
897
+ },
898
+ })
899
+
900
+ // 3. Encrypt and add credit card
901
+ const token = await easyflowSDK.encrypt({
902
+ cardNumber: '5555555555554444',
903
+ cvv: '321',
904
+ month: '10',
905
+ year: '2026',
906
+ holderName: 'ANA SILVA COSTA',
907
+ })
908
+
909
+ const creditCard = await easyflowSDK.addCreditCard(customer.id, token)
910
+
911
+ // 4. Create order using saved customer and credit card
912
+ const orderId = await easyflowSDK.placeOrder('demo-offer-67890', {
913
+ buyer: {
914
+ customerId: customer.id,
915
+ name: customer.name,
916
+ email: customer.email,
917
+ document: customer.document,
918
+ },
919
+ payments: [
920
+ {
921
+ method: 'credit-card',
922
+ numberInstallments: 12,
923
+ valueInCents: 120000,
924
+ creditCard: { cardId: creditCard.id },
925
+ },
926
+ ],
927
+ items: [
928
+ {
929
+ name: 'Pacote Premium Anual',
930
+ description: 'Acesso completo por 12 meses',
931
+ quantity: 1,
932
+ priceInCents: 120000,
933
+ },
934
+ ],
935
+ })
936
+
937
+ console.log('Complete workflow successful:', {
938
+ customer: customer.id,
939
+ creditCard: creditCard.id,
940
+ order: orderId,
941
+ })
942
+ } catch (error) {
943
+ console.error('Workflow failed:', error.message)
944
+ }
945
+ }
946
+
947
+ // Execute the complete workflow
948
+ completeWorkflow()
949
+ ```
950
+
517
951
  ## Distribution & Security
518
952
 
519
953
  ### Why CDN Scripts?
@@ -534,7 +968,7 @@ console.log('Bank Billet Link:', bankBillet.link)
534
968
 
535
969
  <!-- With SRI (Subresource Integrity) -->
536
970
  <script
537
- src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.10.min.js"
971
+ src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.12.min.js"
538
972
  integrity="sha384-[hash]"
539
973
  crossorigin="anonymous"
540
974
  ></script>
@@ -555,7 +989,8 @@ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) f
555
989
  ## Support
556
990
 
557
991
  - **Documentation**: [https://docs.easyflow.digital](https://docs.easyflow.digital)
558
- - **GitHub Issues**: [https://github.com/easyflow-cash/easyflow-javascript-sdk/issues](https://github.com/easyflow-cash/easyflow-javascript-sdk/issues)
992
+ - **GitHub Issues
993
+ **: [https://github.com/easyflow-cash/easyflow-javascript-sdk/issues](https://github.com/easyflow-cash/easyflow-javascript-sdk/issues)
559
994
  - **Website**: [https://www.easyflow.digital](https://www.easyflow.digital)
560
995
 
561
996
  ## License
@@ -564,6 +999,23 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
564
999
 
565
1000
  ## Changelog
566
1001
 
1002
+ ### v2.1.12
1003
+
1004
+ - **Complete Implementation Examples**: Added comprehensive examples for all major methods
1005
+ - **Full Data Models**: Examples showing all available fields for placeOrder, charge, createCustomer, addCreditCard
1006
+ - **Brazilian Data Examples**: Realistic Brazilian addresses, phone numbers, and document formats
1007
+ - **End-to-End Workflows**: Complete customer → credit card → order workflow examples
1008
+ - **Code Quality**: Improved formatting, consistency, and readability across all examples
1009
+ - **Documentation**: Fixed duplicate sections and improved overall structure
1010
+
1011
+ ### v2.1.11
1012
+
1013
+ - **Credit Card Token Fix**: Accepts real encrypted/ciphered tokens from vault services
1014
+ - **Flexible Validation**: Supports Base64, URL-safe, and mixed character formats
1015
+ - **Variable Length**: Accepts tokens from 16 to 2048 characters
1016
+ - **Enhanced Security**: Maintains security while accepting real-world tokens
1017
+ - **Backward Compatibility**: Works with all existing token formats
1018
+
567
1019
  ### v2.1.10
568
1020
 
569
1021
  - **Workflow Fixed**: Resolved GitHub Actions permissions and SRI hash generation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyflow/javascript-sdk",
3
- "version": "2.1.10",
3
+ "version": "2.1.12",
4
4
  "description": "Easyflow JavaScript SDK - Documentation and TypeScript definitions. For production use, use the CDN script: https://easyflow-sdk.pages.dev/easyflow-sdk.min.js",
5
5
  "main": "README.md",
6
6
  "module": "README.md",