@easyflow/javascript-sdk 2.1.12 → 2.1.14

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 +232 -159
  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.12-blue.svg)](https://easyflow-sdk.pages.dev)
4
+ [![Version](https://img.shields.io/badge/version-2.1.14-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)
@@ -88,7 +88,7 @@ platform. With this SDK, you can:
88
88
  - **High Performance**: Optimized for production
89
89
  - **Complete Documentation**: Practical examples for all use cases
90
90
 
91
- ## What's New in v2.1.12
91
+ ## What's New in v2.1.14
92
92
 
93
93
  ### Complete Implementation Examples
94
94
 
@@ -592,14 +592,125 @@ console.log('Bank Billet Link:', bankBillet.link)
592
592
 
593
593
  ### 1. placeOrder - Complete Data Model
594
594
 
595
+ #### placeOrder com PIX
596
+
595
597
  ```javascript
596
598
  // Configure SDK
597
599
  easyflowSDK.configure({
598
600
  businessId: 'demo-business-12345',
599
601
  })
600
602
 
601
- // Complete placeOrder example with all available fields
602
- const orderId = await easyflowSDK.placeOrder('demo-offer-67890', {
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({
603
714
  buyer: {
604
715
  name: 'João Silva Santos',
605
716
  email: 'joao.silva@exemplo.com',
@@ -622,134 +733,81 @@ const orderId = await easyflowSDK.placeOrder('demo-offer-67890', {
622
733
  state: 'SP',
623
734
  number: '123',
624
735
  },
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
- },
736
+ customerId: 'demo-customer-12345', // ID do cliente existente (opcional)
634
737
  },
635
738
  payments: [
636
739
  {
637
740
  method: 'credit-card',
638
- numberInstallments: 3,
639
- valueInCents: 15000,
741
+ numberInstallments: 1,
742
+ valueInCents: 500,
640
743
  creditCard: {
641
- cardId: 'demo-card-67890',
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',
642
746
  },
643
747
  },
644
748
  ],
645
749
  items: [
646
750
  {
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
- },
751
+ description: 'Carregador de celular com cabo USB-C',
752
+ name: 'Carregador de Celular',
753
+ quantity: 1,
754
+ priceInCents: 500,
657
755
  },
658
756
  ],
659
- metadata: {
660
- source: 'website',
661
- campaign: 'black-friday-2024',
662
- affiliate: 'partner-123',
663
- },
757
+ businessId: 'demo-business-12345',
664
758
  })
665
759
 
666
- console.log('Order created with complete data:', orderId)
760
+ console.log('Charge processed with credit card:', orderId)
667
761
  ```
668
762
 
669
- ### 2. charge - Complete Data Model
763
+ #### charge com PIX
670
764
 
671
765
  ```javascript
672
- // Complete charge example with all available fields
766
+ // Complete charge example with PIX payment
673
767
  const orderId = await easyflowSDK.charge({
674
768
  buyer: {
675
- name: 'Maria Santos Costa',
676
- email: 'maria.costa@exemplo.com',
769
+ name: 'João Silva Santos',
770
+ email: 'joao.silva@exemplo.com',
677
771
  document: {
678
- number: '98765432100',
772
+ number: '12345678901',
679
773
  type: 'CPF',
680
774
  },
681
775
  phone: {
682
776
  areaCode: '+55',
683
- ddd: '21',
684
- number: '987654321',
777
+ ddd: '11',
778
+ number: '9988776655',
685
779
  isMobile: true,
686
780
  },
687
781
  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',
782
+ zipCode: '01234567',
783
+ street: 'Rua das Flores',
784
+ complement: 'Apto 101',
700
785
  neighborhood: 'Centro',
701
- city: 'Rio de Janeiro',
702
- state: 'RJ',
703
- number: '456',
786
+ city: 'São Paulo',
787
+ state: 'SP',
788
+ number: '123',
704
789
  },
790
+ customerId: 'demo-customer-12345', // ID do cliente existente (opcional)
705
791
  },
706
792
  payments: [
707
793
  {
708
794
  method: 'pix',
709
795
  numberInstallments: 1,
710
- valueInCents: 25000,
711
- },
712
- {
713
- method: 'bank-billet',
714
- numberInstallments: 1,
715
- valueInCents: 15000,
796
+ valueInCents: 500,
716
797
  },
717
798
  ],
718
799
  items: [
719
800
  {
720
- name: 'Curso Online',
721
- description: 'Curso completo de desenvolvimento web',
801
+ description: 'Carregador de celular com cabo USB-C',
802
+ name: 'Carregador de Celular',
722
803
  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
- },
804
+ priceInCents: 500,
742
805
  },
743
806
  ],
744
- metadata: {
745
- source: 'landing-page',
746
- campaign: 'curso-web-2024',
747
- utm_source: 'google',
748
- utm_medium: 'cpc',
749
- },
807
+ businessId: 'demo-business-12345',
750
808
  })
751
809
 
752
- console.log('Charge processed with complete data:', orderId)
810
+ console.log('Charge processed with PIX:', orderId)
753
811
  ```
754
812
 
755
813
  ### 3. createCustomer - Complete Data Model
@@ -758,42 +816,42 @@ console.log('Charge processed with complete data:', orderId)
758
816
  // Complete createCustomer example with all available fields
759
817
  const customer = await easyflowSDK.createCustomer({
760
818
  businessId: 'demo-business-12345',
761
- name: 'Pedro Oliveira Lima',
762
- email: 'pedro.oliveira@exemplo.com',
819
+ name: 'João Silva Santos',
820
+ email: 'joao.silva@exemplo.com',
763
821
  document: {
764
822
  type: 'CPF',
765
- number: '11122233344',
823
+ number: '12345678901',
766
824
  },
767
825
  phone: {
768
826
  areaCode: '+55',
769
- ddd: '31',
770
- number: '876543210',
827
+ ddd: '11',
828
+ number: '9988776655',
771
829
  isMobile: true,
772
830
  },
773
831
  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',
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',
781
839
  },
782
840
  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',
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',
790
848
  },
791
849
  birthDate: '1990-05-15',
792
850
  gender: 'M',
793
851
  maritalStatus: 'single',
794
852
  occupation: 'Desenvolvedor',
795
853
  company: 'Tech Solutions Ltda',
796
- website: 'https://pedrooliveira.com',
854
+ website: 'https://joaosilva.com',
797
855
  notes: 'Cliente preferencial com histórico de compras',
798
856
  tags: ['premium', 'tech-savvy', 'early-adopter'],
799
857
  preferences: {
@@ -830,35 +888,36 @@ const creditCard = await easyflowSDK.addCreditCard(
830
888
  console.log('Credit card added successfully:', creditCard)
831
889
 
832
890
  // 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
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',
850
901
  },
851
902
  },
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
- })
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
+ )
862
921
 
863
922
  console.log('Order with saved credit card:', orderWithSavedCard)
864
923
  ```
@@ -909,30 +968,31 @@ async function completeWorkflow() {
909
968
  const creditCard = await easyflowSDK.addCreditCard(customer.id, token)
910
969
 
911
970
  // 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,
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,
933
979
  },
934
- ],
935
- })
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
+ )
936
996
 
937
997
  console.log('Complete workflow successful:', {
938
998
  customer: customer.id,
@@ -964,7 +1024,7 @@ completeWorkflow()
964
1024
  <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
965
1025
 
966
1026
  <!-- Versioned (recommended for production) -->
967
- <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.14.min.js"></script>
968
1028
 
969
1029
  <!-- With SRI (Subresource Integrity) -->
970
1030
  <script
@@ -999,6 +1059,19 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
999
1059
 
1000
1060
  ## Changelog
1001
1061
 
1062
+ ### v2.1.14
1063
+
1064
+ - **Version Update**: Patch release for latest improvements
1065
+ - **Documentation**: Updated version references and CDN URLs
1066
+ - **Consistency**: All version references aligned to v2.1.14
1067
+
1068
+ ### v2.1.13
1069
+
1070
+ - **Code Formatting**: Improved readability of placeOrder examples with better line breaks
1071
+ - **Documentation**: Enhanced formatting for complex method calls
1072
+ - **Examples**: Better visual structure for placeOrder, charge, and workflow examples
1073
+ - **Consistency**: Unified formatting across all code examples
1074
+
1002
1075
  ### v2.1.12
1003
1076
 
1004
1077
  - **Complete Implementation Examples**: Added comprehensive examples for all major methods
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyflow/javascript-sdk",
3
- "version": "2.1.12",
3
+ "version": "2.1.14",
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",