@depay/widgets 6.8.1 → 6.10.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
@@ -174,6 +174,27 @@ DePayWidgets.Payment({
174
174
 
175
175
  Checkout [DePay Web3 Payments](https://github.com/DePayFi/depay-web3-payments#pay-into-smart-contracts) and [DePay Router Smart Contract](https://github.com/DePayFi/depay-evm-router) for more details.
176
176
 
177
+ #### fee
178
+
179
+ You can configure a fee which will be applied to every payment with it's own dedicated fee receiver address.
180
+
181
+ The fee will be taken from the target token and target amount (after swap, depending on your `accept` configuration).
182
+
183
+ `amount`: Either percentage (e.g. `5%`, or absolute amount as BigNumber string ('100000000000000000') or pure number (2.5)
184
+
185
+ `receiver`: The address that is supposed to receive the fee.
186
+
187
+ ```javascript
188
+ DePayWidgets.Payment({
189
+ accept: [...],
190
+ fee: {
191
+ amount: '3%',
192
+ receiver: '0x4e260bB2b25EC6F3A59B478fCDe5eD5B8D783B02'
193
+ }
194
+ });
195
+ ```
196
+
197
+
177
198
  #### track
178
199
 
179
200
  `track`
@@ -234,6 +255,22 @@ Payment tracking requests will be attempted up to 3 times by the widget and will
234
255
 
235
256
  A failed payment tracking will also call the [error callback](#error) with `{code: "TRACKING_FAILED"}`.
236
257
 
258
+ ##### Additional Polling
259
+
260
+ 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.
261
+
262
+ The `track.poll` configuration either takes an `enpoint` or a `method` (similiar to track itself).
263
+
264
+ It will use the endpoint or the method to request a release every 5 seconds.
265
+
266
+ You need to make sure to respond to this request with a status `404` in case the user is not to be released just yet (payment and processing on your side are not complete yet)
267
+ or `200` if the payment has been completed and the processing on your side is done and the user can be released and forwarded withing your payment flow.
268
+
269
+ In case you want to redirect the user to the next step in your system the poll endpoint needs to respond with a body containing json like: `{ forward_to: 'https://example.com/next_step_url' }`.
270
+
271
+ It is not enough to rely on setting `forward_to` initially with the tracking request, you will also need to respond with `forward_to` when implementing polling
272
+ as the entire reason for polling is to cover cases where websockets fail and the initial `forward_to` can not be communicated to the client.
273
+
237
274
  #### connected
238
275
 
239
276
  `connected`