@depay/widgets 8.0.3 → 8.0.5
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 +16 -28
- package/dist/esm/index.bundle.js +16 -25
- package/dist/umd/index.bundle.js +16 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -364,33 +364,9 @@ Those values are supposed to be set by your backend not the widget nor the front
|
|
|
364
364
|
|
|
365
365
|
Make sure you read the [Payment Tracking API](https://depay.com/documentation/api#payments) for further details on how to integrate payment tracking.
|
|
366
366
|
|
|
367
|
-
Payment tracking requests will be attempted
|
|
367
|
+
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
368
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
##### Asynchronous Validation
|
|
372
|
-
|
|
373
|
-
For improving user experience, we recommend performing payment validation asynchronously as in certain situation in can take up to multiple minutes.
|
|
374
|
-
|
|
375
|
-
You can configure the widget to track/validate the payment asynchronously:
|
|
376
|
-
|
|
377
|
-
```javascript
|
|
378
|
-
DePayWidgets.Payment({
|
|
379
|
-
|
|
380
|
-
track: {
|
|
381
|
-
endpoint: '/track',
|
|
382
|
-
async: true
|
|
383
|
-
}
|
|
384
|
-
})
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
Which will release the user right after the payment has been confirmed on the user's machine.
|
|
388
|
-
|
|
389
|
-
It still tracks and validates the payment asynchronously and calls back your endpoints as soon as it has been validated.
|
|
390
|
-
|
|
391
|
-
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).
|
|
392
|
-
|
|
393
|
-
##### Additional Polling
|
|
369
|
+
##### Polling
|
|
394
370
|
|
|
395
371
|
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.
|
|
396
372
|
|
|
@@ -501,7 +477,7 @@ DePayWidgets.Payment({
|
|
|
501
477
|
|
|
502
478
|
A function that will be called once the payment has been sent to the network (but still needs to be mined/confirmed).
|
|
503
479
|
|
|
504
|
-
The widget will call this function with a transaction as single argument (see: [depay-web3-wallets](https://github.com/depayfi/depay-web3-wallets#transaction) for more details)
|
|
480
|
+
The widget will call this function with a transaction as single argument (see: [depay-web3-wallets](https://github.com/depayfi/depay-web3-wallets#transaction) for more details about the structure)
|
|
505
481
|
|
|
506
482
|
```javascript
|
|
507
483
|
DePayWidgets.Payment({
|
|
@@ -1796,7 +1772,18 @@ BODY
|
|
|
1796
1772
|
}
|
|
1797
1773
|
```
|
|
1798
1774
|
|
|
1799
|
-
The `/login` endpoint needs to recover the address for `message` and `signature
|
|
1775
|
+
The `/login` endpoint needs to recover the address for `message` and `signature`.
|
|
1776
|
+
|
|
1777
|
+
e.g. your backend could use node + ethers.js to recover the signature
|
|
1778
|
+
|
|
1779
|
+
```javascript
|
|
1780
|
+
const ethers = require('ethers')
|
|
1781
|
+
const hashedMessage = ethers.utils.hashMessage(inputs.message)
|
|
1782
|
+
const address = ethers.utils.recoverAddress(hashedMessage, inputs.signature)
|
|
1783
|
+
return address
|
|
1784
|
+
```
|
|
1785
|
+
|
|
1786
|
+
make sure you return the recovered address back to the widget:
|
|
1800
1787
|
|
|
1801
1788
|
```
|
|
1802
1789
|
POST /login
|
|
@@ -1804,6 +1791,7 @@ RESPONSE
|
|
|
1804
1791
|
"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
|
|
1805
1792
|
```
|
|
1806
1793
|
|
|
1794
|
+
|
|
1807
1795
|
Which will resolve the `DePayWidgets.Login` request to the resolved account:
|
|
1808
1796
|
|
|
1809
1797
|
```javascript
|