@easyflow/javascript-sdk 2.1.14 → 2.1.16

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 +158 -37
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -307,12 +307,41 @@ Creates an order using an existing offer.
307
307
 
308
308
  ```javascript
309
309
  const orderId = await easyflowSDK.placeOrder('demo-offer-67890', {
310
- customer: {
311
- name: 'João Silva',
312
- email: 'joao@exemplo.com',
313
- document: { type: 'CPF', number: '12345678901' },
310
+ buyer: {
311
+ customerId: customer.id,
312
+ name: "E. R.",
313
+ email: "e***o@gmail.com",
314
+ document: {
315
+ number: "***202266**",
316
+ type: "CPF"
317
+ },
318
+ phone: {
319
+ areaCode: "+55",
320
+ ddd: "92",
321
+ number: "*****2191",
322
+ isMobile: true
323
+ },
324
+ address: {
325
+ zipCode: "37537***",
326
+ street: "Rua R. C. M. de A.",
327
+ complement: "",
328
+ neighborhood: "M. do S.",
329
+ city: "Santa Rita do Sapucaí",
330
+ state: "MG",
331
+ number: "***"
332
+ }
314
333
  },
315
- payments: [{ method: 'credit-card', numberInstallments: 1 }],
334
+ payments:
335
+ [
336
+ {
337
+ method: 'credit-card',
338
+ creditCard: {
339
+ token: 'valid token here',
340
+ },
341
+ numberInstallments: 1,
342
+ },
343
+ ],
344
+ metadata: [],
316
345
  })
317
346
  ```
318
347
 
@@ -322,8 +351,49 @@ Processes a direct charge without using an offer.
322
351
 
323
352
  ```javascript
324
353
  const orderId = await easyflowSDK.charge({
325
- items: [{ name: 'Produto Demo', price: 1000 }],
326
- payments: [{ method: 'pix', numberInstallments: 1 }],
354
+ buyer: {
355
+ name: 'João Silva Santos',
356
+ email: 'joao.silva@exemplo.com',
357
+ document: {
358
+ number: '12345678901',
359
+ type: 'CPF',
360
+ },
361
+ phone: {
362
+ areaCode: '+55',
363
+ ddd: '11',
364
+ number: '9988776655',
365
+ isMobile: true,
366
+ },
367
+ address: {
368
+ zipCode: '01234567',
369
+ street: 'Rua das Flores',
370
+ complement: 'Apto 101',
371
+ neighborhood: 'Centro',
372
+ city: 'São Paulo',
373
+ state: 'SP',
374
+ number: '123',
375
+ },
376
+ customerId: 'demo-customer-12345', // ID do cliente existente (opcional)
377
+ },
378
+ payments: [
379
+ {
380
+ method: 'credit-card',
381
+ numberInstallments: 1,
382
+ valueInCents: 500,
383
+ creditCard: {
384
+ cardId: 'demo-card-id-here', // cardId e token são opcionais, mas pelo menos 1 deve ser fornecido
385
+ token: 'demo-token-credit-card-here',
386
+ },
387
+ },
388
+ ],
389
+ items: [
390
+ {
391
+ description: 'Carregador de celular com cabo USB-C',
392
+ name: 'Carregador de Celular',
393
+ quantity: 1,
394
+ priceInCents: 500,
395
+ },
396
+ ],
327
397
  })
328
398
  ```
329
399
 
@@ -533,14 +603,41 @@ const creditCard = await easyflowSDK.addCreditCard(customer.id, token)
533
603
 
534
604
  // 4. Place order
535
605
  const orderId = await easyflowSDK.placeOrder('demo-offer-67890', {
536
- customer: customer,
537
- payments: [
538
- {
539
- method: 'credit-card',
540
- creditCardId: creditCard.creditCardId,
541
- numberInstallments: 1,
606
+ buyer: {
607
+ customerId: customer.id,
608
+ name: "E. R.",
609
+ email: "e***o@gmail.com",
610
+ document: {
611
+ number: "***202266**",
612
+ type: "CPF"
542
613
  },
543
- ],
614
+ phone: {
615
+ areaCode: "+55",
616
+ ddd: "92",
617
+ number: "*****2191",
618
+ isMobile: true
619
+ },
620
+ address: {
621
+ zipCode: "37537***",
622
+ street: "Rua R. C. M. de A.",
623
+ complement: "",
624
+ neighborhood: "M. do S.",
625
+ city: "Santa Rita do Sapucaí",
626
+ state: "MG",
627
+ number: "***"
628
+ }
629
+ },
630
+ payments:
631
+ [
632
+ {
633
+ method: 'credit-card',
634
+ creditCard: {
635
+ cardId: creditCard.id,
636
+ },
637
+ numberInstallments: 1,
638
+ },
639
+ ],
640
+ metadata: [],
544
641
  })
545
642
  ```
546
643
 
@@ -548,17 +645,35 @@ const orderId = await easyflowSDK.placeOrder('demo-offer-67890', {
548
645
 
549
646
  ```javascript
550
647
  const orderId = await easyflowSDK.placeOrder('demo-offer-67890', {
551
- customer: {
552
- name: 'Maria Santos',
553
- email: 'maria@exemplo.com',
554
- document: { type: 'CPF', number: '98765432100' },
648
+ buyer: {
649
+ name: "E. R.",
650
+ email: "e***o@gmail.com",
651
+ document: {
652
+ number: "***202266**",
653
+ type: "CPF"
654
+ },
655
+ phone: {
656
+ areaCode: "+55",
657
+ ddd: "92",
658
+ number: "*****2191",
659
+ isMobile: true
660
+ },
661
+ address: {
662
+ zipCode: "37537***",
663
+ street: "Rua R. C. M. de A.",
664
+ complement: "",
665
+ neighborhood: "M. do S.",
666
+ city: "Santa Rita do Sapucaí",
667
+ state: "MG",
668
+ number: "***"
669
+ }
555
670
  },
556
671
  payments: [
557
672
  {
558
673
  method: 'pix',
559
674
  numberInstallments: 1,
560
675
  },
561
- ],
676
+ ]
562
677
  })
563
678
 
564
679
  // Get PIX data
@@ -570,11 +685,30 @@ console.log('PIX QR Code:', pixData.qrCode)
570
685
 
571
686
  ```javascript
572
687
  const orderId = await easyflowSDK.placeOrder('demo-offer-67890', {
573
- customer: {
574
- name: 'Pedro Costa',
575
- email: 'pedro@exemplo.com',
576
- document: { type: 'CPF', number: '11122233344' },
688
+ buyer: {
689
+ name: "E. R.",
690
+ email: "e***o@gmail.com",
691
+ document: {
692
+ number: "***202266**",
693
+ type: "CPF"
694
+ },
695
+ phone: {
696
+ areaCode: "+55",
697
+ ddd: "92",
698
+ number: "*****2191",
699
+ isMobile: true
700
+ },
701
+ address: {
702
+ zipCode: "37537***",
703
+ street: "Rua R. C. M. de A.",
704
+ complement: "",
705
+ neighborhood: "M. do S.",
706
+ city: "Santa Rita do Sapucaí",
707
+ state: "MG",
708
+ number: "***"
709
+ }
577
710
  },
711
+ metadata: [],
578
712
  payments: [
579
713
  {
580
714
  method: 'bank-billet',
@@ -633,12 +767,6 @@ const orderId = await easyflowSDK.placeOrder(
633
767
  numberInstallments: 1,
634
768
  },
635
769
  ],
636
- offerItems: [
637
- {
638
- offerItemId: '3df92ac7-9d7f-4948-b54f-7e082492f6d2',
639
- quantity: 1,
640
- },
641
- ],
642
770
  metadata: [],
643
771
  }
644
772
  )
@@ -691,12 +819,6 @@ const orderId = await easyflowSDK.placeOrder(
691
819
  },
692
820
  },
693
821
  ],
694
- offerItems: [
695
- {
696
- offerItemId: '3df92ac7-9d7f-4948-b54f-7e082492f6d2',
697
- quantity: 1,
698
- },
699
- ],
700
822
  metadata: [],
701
823
  }
702
824
  )
@@ -753,8 +875,7 @@ const orderId = await easyflowSDK.charge({
753
875
  quantity: 1,
754
876
  priceInCents: 500,
755
877
  },
756
- ],
757
- businessId: 'demo-business-12345',
878
+ ]
758
879
  })
759
880
 
760
881
  console.log('Charge processed with credit card:', orderId)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyflow/javascript-sdk",
3
- "version": "2.1.14",
3
+ "version": "2.1.16",
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",