@easyflow/javascript-sdk 2.1.11 → 2.1.13

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 +460 -29
  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.11-blue.svg)](https://easyflow-sdk.pages.dev)
4
+ [![Version](https://img.shields.io/badge/version-2.1.13-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,15 @@ 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.11
91
+ ## What's New in v2.1.13
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
88
100
 
89
101
  ### Credit Card Token Validation Fix
90
102
 
@@ -96,8 +108,6 @@ The **Easyflow JavaScript SDK** is the official tool for developers to integrate
96
108
 
97
109
  ### Workflow Corrections
98
110
 
99
- ### Workflow Corrections
100
-
101
111
  - **GitHub Actions Fixed**: Resolved release workflow permissions and SRI hash generation
102
112
  - **CDN Deployment**: Automated deployment to Cloudflare Pages working correctly
103
113
  - **Release Automation**: GitHub releases created automatically with proper SRI hashes
@@ -105,8 +115,6 @@ The **Easyflow JavaScript SDK** is the official tool for developers to integrate
105
115
 
106
116
  ### Hybrid Distribution Strategy
107
117
 
108
- ### Hybrid Distribution Strategy
109
-
110
118
  - **NPM Package**: Contains only documentation and TypeScript definitions
111
119
  - **CDN Scripts**: Production-ready obfuscated builds via Cloudflare Pages
112
120
  - **Enhanced Security**: Code source protected while maintaining accessibility
@@ -119,21 +127,6 @@ The **Easyflow JavaScript SDK** is the official tool for developers to integrate
119
127
  - **Professional Documentation**: Clean, business-focused documentation
120
128
  - **NPM Safety**: Safe for public NPM publication
121
129
 
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
130
  ### Test Suite Improvements
138
131
 
139
132
  - **Test Coverage Optimization**: Fixed all failing unit tests for complete 250 test coverage
@@ -177,7 +170,7 @@ Add this script tag to your HTML:
177
170
  <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
178
171
 
179
172
  <!-- Specific version -->
180
- <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.11.min.js"></script>
173
+ <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.12.min.js"></script>
181
174
  ```
182
175
 
183
176
  #### Option 2: NPM Package (Documentation Only)
@@ -190,7 +183,8 @@ npm install @easyflow/javascript-sdk
190
183
 
191
184
  #### Option 3: Direct Download
192
185
 
193
- 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).
194
188
 
195
189
  ### Basic Usage
196
190
 
@@ -594,6 +588,426 @@ const bankBillet = await easyflowSDK.getBankBillet(orderId)
594
588
  console.log('Bank Billet Link:', bankBillet.link)
595
589
  ```
596
590
 
591
+ ## Complete Implementation Examples
592
+
593
+ ### 1. placeOrder - Complete Data Model
594
+
595
+ #### placeOrder com PIX
596
+
597
+ ```javascript
598
+ // Configure SDK
599
+ easyflowSDK.configure({
600
+ businessId: 'demo-business-12345',
601
+ })
602
+
603
+ // Complete placeOrder example with PIX payment
604
+ const orderId = await easyflowSDK.placeOrder(
605
+ '3df92ac7-9d7f-4948-b54f-7e082492f6d2',
606
+ {
607
+ buyer: {
608
+ name: 'João Silva Santos',
609
+ email: 'joao.silva@exemplo.com',
610
+ document: {
611
+ number: '12345678901',
612
+ type: 'CPF',
613
+ },
614
+ phone: {
615
+ areaCode: '+55',
616
+ ddd: '11',
617
+ number: '9988776655',
618
+ isMobile: true,
619
+ },
620
+ address: {
621
+ zipCode: '01234567',
622
+ street: 'Rua das Flores',
623
+ complement: 'Apto 101',
624
+ neighborhood: 'Centro',
625
+ city: 'São Paulo',
626
+ state: 'SP',
627
+ number: '123',
628
+ },
629
+ },
630
+ payments: [
631
+ {
632
+ method: 'pix',
633
+ numberInstallments: 1,
634
+ },
635
+ ],
636
+ offerItems: [
637
+ {
638
+ offerItemId: '3df92ac7-9d7f-4948-b54f-7e082492f6d2',
639
+ quantity: 1,
640
+ },
641
+ ],
642
+ metadata: [],
643
+ }
644
+ )
645
+
646
+ console.log('Order created with PIX payment:', orderId)
647
+ ```
648
+
649
+ #### placeOrder com Cartão de Crédito
650
+
651
+ ```javascript
652
+ // Complete placeOrder example with credit card payment
653
+ const orderId = await easyflowSDK.placeOrder(
654
+ '3df92ac7-9d7f-4948-b54f-7e082492f6d2',
655
+ {
656
+ buyer: {
657
+ name: 'João Silva Santos',
658
+ email: 'joao.silva@exemplo.com',
659
+ document: {
660
+ number: '12345678901',
661
+ type: 'CPF',
662
+ },
663
+ phone: {
664
+ areaCode: '+55',
665
+ ddd: '11',
666
+ number: '9988776655',
667
+ isMobile: true,
668
+ },
669
+ address: {
670
+ zipCode: '01234567',
671
+ street: 'Rua das Flores',
672
+ complement: 'Apto 101',
673
+ neighborhood: 'Centro',
674
+ city: 'São Paulo',
675
+ state: 'SP',
676
+ number: '123',
677
+ },
678
+ },
679
+ payments: [
680
+ {
681
+ method: 'credit-card',
682
+ numberInstallments: 1,
683
+ creditCard: {
684
+ cardId: 'demo-credit-card-67890', // cardId e token são opcionais, mas pelo menos 1 deve ser fornecido
685
+ token: 'demo-credit-card-token-here',
686
+ last4Numbers: '1234',
687
+ holderName: 'JOAO SILVA SANTOS',
688
+ expiresAtMonth: '12',
689
+ expiresAtYear: '2025',
690
+ flag: 'visa',
691
+ },
692
+ },
693
+ ],
694
+ offerItems: [
695
+ {
696
+ offerItemId: '3df92ac7-9d7f-4948-b54f-7e082492f6d2',
697
+ quantity: 1,
698
+ },
699
+ ],
700
+ metadata: [],
701
+ }
702
+ )
703
+
704
+ console.log('Order created with credit card payment:', orderId)
705
+ ```
706
+
707
+ ### 2. charge - Complete Data Model
708
+
709
+ #### charge com Cartão de Crédito
710
+
711
+ ```javascript
712
+ // Complete charge example with credit card payment
713
+ const orderId = await easyflowSDK.charge({
714
+ buyer: {
715
+ name: 'João Silva Santos',
716
+ email: 'joao.silva@exemplo.com',
717
+ document: {
718
+ number: '12345678901',
719
+ type: 'CPF',
720
+ },
721
+ phone: {
722
+ areaCode: '+55',
723
+ ddd: '11',
724
+ number: '9988776655',
725
+ isMobile: true,
726
+ },
727
+ address: {
728
+ zipCode: '01234567',
729
+ street: 'Rua das Flores',
730
+ complement: 'Apto 101',
731
+ neighborhood: 'Centro',
732
+ city: 'São Paulo',
733
+ state: 'SP',
734
+ number: '123',
735
+ },
736
+ customerId: 'demo-customer-12345', // ID do cliente existente (opcional)
737
+ },
738
+ payments: [
739
+ {
740
+ method: 'credit-card',
741
+ numberInstallments: 1,
742
+ valueInCents: 500,
743
+ creditCard: {
744
+ cardId: 'demo-card-id-here', // cardId e token são opcionais, mas pelo menos 1 deve ser fornecido
745
+ token: 'demo-token-credit-card-here',
746
+ },
747
+ },
748
+ ],
749
+ items: [
750
+ {
751
+ description: 'Carregador de celular com cabo USB-C',
752
+ name: 'Carregador de Celular',
753
+ quantity: 1,
754
+ priceInCents: 500,
755
+ },
756
+ ],
757
+ businessId: 'demo-business-12345',
758
+ })
759
+
760
+ console.log('Charge processed with credit card:', orderId)
761
+ ```
762
+
763
+ #### charge com PIX
764
+
765
+ ```javascript
766
+ // Complete charge example with PIX payment
767
+ const orderId = await easyflowSDK.charge({
768
+ buyer: {
769
+ name: 'João Silva Santos',
770
+ email: 'joao.silva@exemplo.com',
771
+ document: {
772
+ number: '12345678901',
773
+ type: 'CPF',
774
+ },
775
+ phone: {
776
+ areaCode: '+55',
777
+ ddd: '11',
778
+ number: '9988776655',
779
+ isMobile: true,
780
+ },
781
+ address: {
782
+ zipCode: '01234567',
783
+ street: 'Rua das Flores',
784
+ complement: 'Apto 101',
785
+ neighborhood: 'Centro',
786
+ city: 'São Paulo',
787
+ state: 'SP',
788
+ number: '123',
789
+ },
790
+ customerId: 'demo-customer-12345', // ID do cliente existente (opcional)
791
+ },
792
+ payments: [
793
+ {
794
+ method: 'pix',
795
+ numberInstallments: 1,
796
+ valueInCents: 500,
797
+ },
798
+ ],
799
+ items: [
800
+ {
801
+ description: 'Carregador de celular com cabo USB-C',
802
+ name: 'Carregador de Celular',
803
+ quantity: 1,
804
+ priceInCents: 500,
805
+ },
806
+ ],
807
+ businessId: 'demo-business-12345',
808
+ })
809
+
810
+ console.log('Charge processed with PIX:', orderId)
811
+ ```
812
+
813
+ ### 3. createCustomer - Complete Data Model
814
+
815
+ ```javascript
816
+ // Complete createCustomer example with all available fields
817
+ const customer = await easyflowSDK.createCustomer({
818
+ businessId: 'demo-business-12345',
819
+ name: 'João Silva Santos',
820
+ email: 'joao.silva@exemplo.com',
821
+ document: {
822
+ type: 'CPF',
823
+ number: '12345678901',
824
+ },
825
+ phone: {
826
+ areaCode: '+55',
827
+ ddd: '11',
828
+ number: '9988776655',
829
+ isMobile: true,
830
+ },
831
+ address: {
832
+ zipCode: '01234567',
833
+ street: 'Rua das Flores',
834
+ complement: 'Apto 101',
835
+ neighborhood: 'Centro',
836
+ city: 'São Paulo',
837
+ state: 'SP',
838
+ number: '123',
839
+ },
840
+ deliveryAddress: {
841
+ zipCode: '01234567',
842
+ street: 'Rua das Flores',
843
+ complement: 'Apto 101',
844
+ neighborhood: 'Centro',
845
+ city: 'São Paulo',
846
+ state: 'SP',
847
+ number: '123',
848
+ },
849
+ birthDate: '1990-05-15',
850
+ gender: 'M',
851
+ maritalStatus: 'single',
852
+ occupation: 'Desenvolvedor',
853
+ company: 'Tech Solutions Ltda',
854
+ website: 'https://joaosilva.com',
855
+ notes: 'Cliente preferencial com histórico de compras',
856
+ tags: ['premium', 'tech-savvy', 'early-adopter'],
857
+ preferences: {
858
+ newsletter: true,
859
+ marketing: false,
860
+ language: 'pt-BR',
861
+ currency: 'BRL',
862
+ },
863
+ })
864
+
865
+ console.log('Customer created with complete data:', customer)
866
+ ```
867
+
868
+ ### 4. addCreditCard - Complete Data Model
869
+
870
+ ```javascript
871
+ // First, encrypt the credit card data
872
+ const encryptedToken = await easyflowSDK.encrypt({
873
+ cardNumber: '4111111111111111',
874
+ cvv: '123',
875
+ month: '12',
876
+ year: '2025',
877
+ holderName: 'PEDRO OLIVEIRA LIMA',
878
+ })
879
+
880
+ console.log('Credit card encrypted:', encryptedToken)
881
+
882
+ // Then add the encrypted token to the customer
883
+ const creditCard = await easyflowSDK.addCreditCard(
884
+ customer.id, // customer ID from createCustomer
885
+ encryptedToken
886
+ )
887
+
888
+ console.log('Credit card added successfully:', creditCard)
889
+
890
+ // Now you can use the credit card for payments
891
+ const orderWithSavedCard = await easyflowSDK.placeOrder(
892
+ '3df92ac7-9d7f-4948-b54f-7e082492f6d2',
893
+ {
894
+ buyer: {
895
+ customerId: customer.id, // Use existing customer
896
+ name: 'João Silva Santos',
897
+ email: 'joao.silva@exemplo.com',
898
+ document: {
899
+ number: '12345678901',
900
+ type: 'CPF',
901
+ },
902
+ },
903
+ payments: [
904
+ {
905
+ method: 'credit-card',
906
+ numberInstallments: 6,
907
+ creditCard: {
908
+ cardId: creditCard.id, // Use saved credit card
909
+ },
910
+ },
911
+ ],
912
+ offerItems: [
913
+ {
914
+ offerItemId: '3df92ac7-9d7f-4948-b54f-7e082492f6d2',
915
+ quantity: 1,
916
+ },
917
+ ],
918
+ metadata: [],
919
+ }
920
+ )
921
+
922
+ console.log('Order with saved credit card:', orderWithSavedCard)
923
+ ```
924
+
925
+ ### 5. Complete Workflow Example
926
+
927
+ ```javascript
928
+ // Complete workflow: Customer → Credit Card → Order
929
+ async function completeWorkflow() {
930
+ try {
931
+ // 1. Configure SDK
932
+ easyflowSDK.configure({
933
+ businessId: 'demo-business-12345',
934
+ })
935
+
936
+ // 2. Create customer with complete data
937
+ const customer = await easyflowSDK.createCustomer({
938
+ businessId: 'demo-business-12345',
939
+ name: 'Ana Silva Costa',
940
+ email: 'ana.silva@exemplo.com',
941
+ document: { type: 'CPF', number: '55566677788' },
942
+ phone: {
943
+ areaCode: '+55',
944
+ ddd: '41',
945
+ number: '765432109',
946
+ isMobile: true,
947
+ },
948
+ address: {
949
+ zipCode: '80000000',
950
+ street: 'Rua das Palmeiras',
951
+ complement: 'Apto 202',
952
+ neighborhood: 'Batel',
953
+ city: 'Curitiba',
954
+ state: 'PR',
955
+ number: '321',
956
+ },
957
+ })
958
+
959
+ // 3. Encrypt and add credit card
960
+ const token = await easyflowSDK.encrypt({
961
+ cardNumber: '5555555555554444',
962
+ cvv: '321',
963
+ month: '10',
964
+ year: '2026',
965
+ holderName: 'ANA SILVA COSTA',
966
+ })
967
+
968
+ const creditCard = await easyflowSDK.addCreditCard(customer.id, token)
969
+
970
+ // 4. Create order using saved customer and credit card
971
+ const orderId = await easyflowSDK.placeOrder(
972
+ '3df92ac7-9d7f-4948-b54f-7e082492f6d2',
973
+ {
974
+ buyer: {
975
+ customerId: customer.id,
976
+ name: customer.name,
977
+ email: customer.email,
978
+ document: customer.document,
979
+ },
980
+ payments: [
981
+ {
982
+ method: 'credit-card',
983
+ numberInstallments: 12,
984
+ creditCard: { cardId: creditCard.id },
985
+ },
986
+ ],
987
+ offerItems: [
988
+ {
989
+ offerItemId: '3df92ac7-9d7f-4948-b54f-7e082492f6d2',
990
+ quantity: 1,
991
+ },
992
+ ],
993
+ metadata: [],
994
+ }
995
+ )
996
+
997
+ console.log('Complete workflow successful:', {
998
+ customer: customer.id,
999
+ creditCard: creditCard.id,
1000
+ order: orderId,
1001
+ })
1002
+ } catch (error) {
1003
+ console.error('Workflow failed:', error.message)
1004
+ }
1005
+ }
1006
+
1007
+ // Execute the complete workflow
1008
+ completeWorkflow()
1009
+ ```
1010
+
597
1011
  ## Distribution & Security
598
1012
 
599
1013
  ### Why CDN Scripts?
@@ -610,11 +1024,11 @@ console.log('Bank Billet Link:', bankBillet.link)
610
1024
  <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
611
1025
 
612
1026
  <!-- Versioned (recommended for production) -->
613
- <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.8.min.js"></script>
1027
+ <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.13.min.js"></script>
614
1028
 
615
1029
  <!-- With SRI (Subresource Integrity) -->
616
1030
  <script
617
- src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.11.min.js"
1031
+ src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.12.min.js"
618
1032
  integrity="sha384-[hash]"
619
1033
  crossorigin="anonymous"
620
1034
  ></script>
@@ -635,7 +1049,8 @@ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) f
635
1049
  ## Support
636
1050
 
637
1051
  - **Documentation**: [https://docs.easyflow.digital](https://docs.easyflow.digital)
638
- - **GitHub Issues**: [https://github.com/easyflow-cash/easyflow-javascript-sdk/issues](https://github.com/easyflow-cash/easyflow-javascript-sdk/issues)
1052
+ - **GitHub Issues
1053
+ **: [https://github.com/easyflow-cash/easyflow-javascript-sdk/issues](https://github.com/easyflow-cash/easyflow-javascript-sdk/issues)
639
1054
  - **Website**: [https://www.easyflow.digital](https://www.easyflow.digital)
640
1055
 
641
1056
  ## License
@@ -644,6 +1059,22 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
644
1059
 
645
1060
  ## Changelog
646
1061
 
1062
+ ### v2.1.13
1063
+
1064
+ - **Code Formatting**: Improved readability of placeOrder examples with better line breaks
1065
+ - **Documentation**: Enhanced formatting for complex method calls
1066
+ - **Examples**: Better visual structure for placeOrder, charge, and workflow examples
1067
+ - **Consistency**: Unified formatting across all code examples
1068
+
1069
+ ### v2.1.12
1070
+
1071
+ - **Complete Implementation Examples**: Added comprehensive examples for all major methods
1072
+ - **Full Data Models**: Examples showing all available fields for placeOrder, charge, createCustomer, addCreditCard
1073
+ - **Brazilian Data Examples**: Realistic Brazilian addresses, phone numbers, and document formats
1074
+ - **End-to-End Workflows**: Complete customer → credit card → order workflow examples
1075
+ - **Code Quality**: Improved formatting, consistency, and readability across all examples
1076
+ - **Documentation**: Fixed duplicate sections and improved overall structure
1077
+
647
1078
  ### v2.1.11
648
1079
 
649
1080
  - **Credit Card Token Fix**: Accepts real encrypted/ciphered tokens from vault services
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyflow/javascript-sdk",
3
- "version": "2.1.11",
3
+ "version": "2.1.13",
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",