@depay/widgets 8.0.7 → 9.0.0

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
@@ -22,6 +22,22 @@ and load the DePayWidgets package wherever you need it:
22
22
  import DePayWidgets from '@depay/widgets'
23
23
  ```
24
24
 
25
+ Make sure you install DePay widgets peer dependencies, too, in case your project does not have them installed yet:
26
+
27
+ ```
28
+ yarn add ethers react react-dom
29
+ ```
30
+
31
+ ```
32
+ npm install ethers react react-dom --save
33
+ ```
34
+
35
+ ## Server-side rendering
36
+
37
+ Make sure you load this library as a client-side script for client-side rendering (CSR), in case you are using a server-side rendering (SSR) framework like next.js.
38
+
39
+ Next.js: https://dev.to/elisabethleonhardt/how-to-use-client-side-only-packages-with-ssr-in-gatsby-and-nextjs-3pfa
40
+
25
41
  ## Demo
26
42
 
27
43
  To easily configure DePay Payment Widgets please use our configurator here:
@@ -366,6 +382,28 @@ Make sure you read the [Payment Tracking API](https://depay.com/documentation/ap
366
382
 
367
383
  Payment tracking requests will be attempted indefinitely. After 2 minutes a warning dialog will be presented to users asking them to ensure an internet connection so that the payment tracking can be performed.
368
384
 
385
+ ##### Asynchronous Validation
386
+
387
+ For user flows where you can release the user immediatelly, we recommend performing payment validation asynchronously as in certain situation in can take up to multiple minutes to validate a payment:
388
+
389
+ You can configure the widget to track/validate the payment asynchronously:
390
+
391
+ ```javascript
392
+ DePayWidgets.Payment({
393
+
394
+ track: {
395
+ endpoint: '/track',
396
+ async: true
397
+ }
398
+ })
399
+ ```
400
+
401
+ Which will release the user right after the payment transaction has been confirmed on the user's machine.
402
+
403
+ It still tracks and validates the payment asynchronously (in the background) and calls back your endpoints as soon as it has been validated.
404
+
405
+ This allows you to release the user immediately, showing him some confirmation and reconfirming his payment in an asynchronous step (like a notification or email).
406
+
369
407
  ##### Polling
370
408
 
371
409
  In order to ensure a 100% coverage that users are released and forwarded within your payment flow, you will need to implement polling in addition to tracking.
@@ -464,7 +502,7 @@ Allows you to stop the payment if this methods returns false.
464
502
  ```javascript
465
503
  DePayWidgets.Payment({
466
504
 
467
- before: (payment)=> {
505
+ before: async (payment)=> {
468
506
  alert('Something went wrong')
469
507
  return false // stops payment
470
508
  }
@@ -661,22 +699,6 @@ DePayWidgets.Payment({
661
699
  })
662
700
  ```
663
701
 
664
- #### event
665
-
666
- `event`
667
-
668
- If set to `ifSwapped`, emits a [payment event](https://github.com/depayfi/depay-evm-router#depayrouterv1paymentevent02) if payments are routed through [router smart contract](https://github.com/depayfi/depay-evm-router).
669
- Payments are routed through the DePayPaymentRouter if swapping tokens is required in order to perform the payment. If payments are not routed through the router, e.g. direct transfer, no event is emited if `event` is set to `ifSwapped`.
670
-
671
-
672
- ```javascript
673
- DePayWidgets.Payment({
674
-
675
- event: 'ifSwapped'
676
-
677
- })
678
- ```
679
-
680
702
  #### container
681
703
 
682
704
  `container`
@@ -1948,5 +1970,5 @@ test:cypress:debug
1948
1970
  Test and debug single cypress file:
1949
1971
 
1950
1972
  ```
1951
- yarn test:cypress:debug --spec "cypress/e2e/Payment/amount.js"
1973
+ yarn test:cypress:debug --spec "cypress/e2e/Payment/track.js"
1952
1974
  ```