@depay/widgets 10.2.16 → 11.1.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
@@ -3,7 +3,7 @@
3
3
  You can either load the `@depay/widgets` package via CDN:
4
4
 
5
5
  ```
6
- <script defer async src="https://integrate.depay.com/widgets/v10.js"></script>
6
+ <script defer async src="https://integrate.depay.com/widgets/v11.js"></script>
7
7
  ```
8
8
 
9
9
  or you install `@depay/widgets` via the package manager of your choice and ship it as part of your application bundle:
@@ -32,6 +32,30 @@ yarn add ethers react react-dom
32
32
  npm install ethers react react-dom --save
33
33
  ```
34
34
 
35
+ ## Platform specific packaging
36
+
37
+ In case you want to use and package only specific platforms, use the platform-specific package:
38
+
39
+ ### EVM platform specific packaging
40
+
41
+ ```
42
+ yarn add @depay/widgets-evm
43
+ ```
44
+
45
+ ```javascript
46
+ import DePayWidgets from '@depay/widgets-evm'
47
+ ```
48
+
49
+ ### Solana platform specific packaging
50
+
51
+ ```
52
+ yarn add @depay/widgets-solana
53
+ ```
54
+
55
+ ```javascript
56
+ import DePayWidgets from '@depay/widgets-solana'
57
+ ```
58
+
35
59
  ## Server-side rendering
36
60
 
37
61
  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.
@@ -46,7 +70,7 @@ https://app.depay.com/integrations/new
46
70
 
47
71
  For a more low-key technical example/demo page have a look at:
48
72
 
49
- https://depayfi.github.io/widgets/dev.bundle.html
73
+ https://depayfi.github.io/widgets/demo.bundle.html
50
74
 
51
75
  ## Support
52
76
 
@@ -55,41 +79,15 @@ https://depayfi.github.io/widgets/dev.bundle.html
55
79
  - [Ethereum](https://ethereum.org)
56
80
  - [BNB Smart Chain](https://www.binance.org/smartChain)
57
81
  - [Polygon](https://polygon.technology)
82
+ - [Solana](https://solana.com)
58
83
 
59
84
  ### Wallets
60
85
 
61
- DePay supports the most popular crypto wallets:
62
-
63
- - [MetaMask](https://metamask.io)
64
- - [Coinbase Wallet](https://wallet.coinbase.com)
65
-
66
- 100+ additional wallets via [WalletConnect](https://walletconnect.org), such as:
67
- - [Trust Wallet](https://trustwallet.com)
68
- - [DeFi Wallet by crypto.com](https://crypto.com/defi-wallet)
69
- - [1inch Wallet](https://1inch.io/wallet/)
70
- - [imToken Wallet](https://www.token.im)
71
- - [TokenPocket](https://www.tokenpocket.pro/en)
72
- - [Pillar](https://www.pillar.fi/)
73
- - [Math Wallet](https://mathwallet.org/)
74
- - [Ledger Live](https://www.ledger.com/ledger-live)
75
- - [Argent Wallet](https://www.argent.xyz)
76
- - [AlphaWallet](https://alphawallet.com/)
77
- - [Unstoppable Wallet](https://unstoppable.money)
78
- - [Atomic Wallet](https://atomicwallet.io)
79
- - [Rainbow](https://rainbow.me/)
80
- - and more...
81
-
82
- ## DePay Payments
83
-
84
- DePay Payments allows you to accept and perform crypto payments.
85
-
86
- ### Preparation
86
+ DePay supports [most crypto wallets](https://depay.com/wallets).
87
87
 
88
- In order to receive decentralized payments on any blockchain you need to have your own wallet on that particular blockchain first:
88
+ ## DePayWidgets: Payments
89
89
 
90
- - [Create an Ethereum wallet](https://ethereum.org/en/wallets/)
91
- - [Create an BSC wallet](https://academy.binance.com/en/articles/how-to-get-started-with-binance-smart-chain-bsc)
92
- - [Create a Polygon wallet](https://wallet.polygon.technology/)
90
+ DePay Payments allows you to accept and perform crypto payments.
93
91
 
94
92
  ### Quick start
95
93
 
@@ -276,6 +274,21 @@ DePayWidgets.Payment.preload({
276
274
  });
277
275
  ```
278
276
 
277
+ #### title
278
+
279
+ `title`
280
+
281
+ Allows you to change the title of the widget:
282
+
283
+ ```javascript
284
+ DePayWidgets.Payment({
285
+
286
+ title: 'Donation'
287
+
288
+ //...
289
+ })
290
+ ```
291
+
279
292
  #### track
280
293
 
281
294
  `track`
@@ -550,8 +563,9 @@ A function that will be called once the payment has been validated by DePay Apis
550
563
  ```javascript
551
564
  DePayWidgets.Payment({
552
565
 
553
- validated: (successful)=> {
566
+ validated: (successful, data)=> {
554
567
  // successful (true or false)
568
+ // data (can contain transaction_id)
555
569
  }
556
570
  })
557
571
  ```
@@ -890,18 +904,10 @@ DePayWidgets.Payment({
890
904
  })
891
905
  ```
892
906
 
893
- ## DePay Sales
907
+ ## DePayWidgets: Sale
894
908
 
895
909
  DePay Sales allows you to sell tokens directly from your website or dApp with automatic any-to-any payment conversion (so people can use any token when buying your token directly off your website or dApp).
896
910
 
897
- ### Preparation
898
-
899
- In order to sell tokens in a decentralized way, that token needs to have a liquidity pool on a decentralized exchange:
900
-
901
- - [Create Uniswap v2 Liquidity Pool](https://app.uniswap.org/#/add/v2/ETH)
902
- - [Create Uniswap v2 Liquidity Pool (Polygon)](https://app.uniswap.org/#/add/v2/ETH?chain=polygon)
903
- - [Create Pancakeswap Liquidity Pool](https://pancakeswap.finance/add)
904
-
905
911
  ### Quick start
906
912
 
907
913
  ```javascript
@@ -1285,483 +1291,6 @@ DePayWidgets.Sale({
1285
1291
  })
1286
1292
  ```
1287
1293
 
1288
- ## DePay Donations
1289
-
1290
- DePay Donations allows you to accept donation payments made with thousands of different cryptocurrencies.
1291
-
1292
- ### Preparation
1293
-
1294
- In order to receive decentralized donation payments on any blockchain you need to have your own wallet on that particular blockchain first:
1295
-
1296
- - [Create an Ethereum wallet](https://ethereum.org/en/wallets/)
1297
- - [Create an BSC wallet](https://academy.binance.com/en/articles/how-to-get-started-with-binance-smart-chain-bsc)
1298
-
1299
- ### Quick start
1300
-
1301
- ```javascript
1302
- DePayWidgets.Donation({
1303
- accept: [{
1304
- blockchain: 'ethereum',
1305
- token: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb',
1306
- receiver: '0x4e260bB2b25EC6F3A59B478fCDe5eD5B8D783B02'
1307
- }]
1308
- });
1309
- ```
1310
-
1311
- ### Configuration
1312
-
1313
- You need to pass a configuration object to `DePayWidgets.Donation` which needs to at least contain the `accept` field:
1314
-
1315
- ```javascript
1316
- DePayWidgets.Donation({
1317
- accept: [{
1318
- blockchain: 'ethereum',
1319
- token: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb',
1320
- receiver: '0x4e260bB2b25EC6F3A59B478fCDe5eD5B8D783B02'
1321
- }]
1322
- });
1323
- ```
1324
-
1325
- You can also accept donations on multiple blockchains:
1326
-
1327
- ```javascript
1328
- DePayWidgets.Donation({
1329
- accept: [{
1330
- blockchain: 'ethereum',
1331
- token: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb',
1332
- receiver: '0x4e260bB2b25EC6F3A59B478fCDe5eD5B8D783B02'
1333
- },{
1334
- blockchain: 'bsc',
1335
- token: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb',
1336
- receiver: '0x4e260bB2b25EC6F3A59B478fCDe5eD5B8D783B02'
1337
- }]
1338
- });
1339
- ```
1340
-
1341
- #### accept
1342
-
1343
- `blockchain`
1344
-
1345
- The blockchain you want to receive the payment on.
1346
-
1347
- Currently supported:
1348
-
1349
- - `ethereum`
1350
- - `bsc` (Binance Smart Chain)
1351
-
1352
- `token`
1353
-
1354
- The address of the token you want to receive.
1355
-
1356
- Use our [donation configurator](https://depay.com/documentation/donations#donation-configurator) in order to simplify configuring this.
1357
-
1358
- `receiver`
1359
-
1360
- The address receiving the donation. Always double check that you've set the right address.
1361
-
1362
- #### amount
1363
-
1364
- When you want to control how the amount selection behaves, pass the `amount` configuration object,
1365
- alongside values for `start`, `min` and `step`.
1366
-
1367
- `start`: The amount that is initially selected.
1368
-
1369
- `min`: The minimum amount selectable.
1370
-
1371
- `step`: The number by which to increment/decrement changes to the amount.
1372
-
1373
- #### connected
1374
-
1375
- `connected`
1376
-
1377
- A function that will be called once the user connects a wallet.
1378
-
1379
- Will be called with the connected wallet address as the main argument:
1380
-
1381
- ```javascript
1382
- DePayWidgets.Donation({
1383
-
1384
- connected: (address)=> {
1385
- // do something with the address
1386
- }
1387
- });
1388
- ```
1389
-
1390
- #### fee
1391
-
1392
- You can configure a fee which will be applied to every payment with its own dedicated fee receiver address.
1393
-
1394
- The fee will be taken from the target token and target amount (after swap, depending on your `accept` configuration).
1395
-
1396
- `amount`: Either percentage (e.g. `5%`, or absolute amount as BigNumber string ('100000000000000000') or pure number (2.5)
1397
-
1398
- `receiver`: The address that is supposed to receive the fee.
1399
-
1400
- ```javascript
1401
- DePayWidgets.Donation({
1402
- accept: [...],
1403
- fee: {
1404
- amount: '3%',
1405
- receiver: '0x4e260bB2b25EC6F3A59B478fCDe5eD5B8D783B02'
1406
- }
1407
- });
1408
- ```
1409
-
1410
- #### closed
1411
-
1412
- `closed`
1413
-
1414
- A function that will be called once the user closes the widget (no matter if before or after the payment).
1415
-
1416
- ```javascript
1417
- DePayWidgets.Donation({
1418
-
1419
- closed: ()=> {
1420
- // do something if user closed the widget
1421
- }
1422
- });
1423
- ```
1424
-
1425
- #### sent
1426
-
1427
- `sent`
1428
-
1429
- A function that will be called once the payment has been sent to the network (but still needs to be mined/confirmed).
1430
-
1431
- 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)
1432
-
1433
- ```javascript
1434
- DePayWidgets.Donation({
1435
-
1436
- sent: (transaction)=> {
1437
- // called when payment transaction has been sent to the network
1438
- }
1439
- });
1440
- ```
1441
-
1442
- #### succeeded
1443
-
1444
- `succeeded`
1445
-
1446
- A function that will be called once the payment has succeeded on the network (checked client-side).
1447
-
1448
- The widget will call this function passing a transaction as single argument (see: [depay-web3-wallets](https://github.com/depayfi/depay-web3-wallets#transaction) for more details)
1449
-
1450
- ```javascript
1451
- DePayWidgets.Donation({
1452
-
1453
- succeeded: (transaction)=> {
1454
- // called when payment transaction has been confirmed once by the network
1455
- }
1456
- });
1457
- ```
1458
-
1459
- #### validated
1460
-
1461
- `validated`
1462
-
1463
- A function that will be called once the payment has been validated by DePay Apis (server-side).
1464
-
1465
- ```javascript
1466
- DePayWidgets.Payment({
1467
-
1468
- validated: (successful)=> {
1469
- // successful (true or false)
1470
- }
1471
- })
1472
- ```
1473
-
1474
- #### failed
1475
-
1476
- `failed`
1477
-
1478
- A function that will be called if the payment execution failed on the blockchain (after it has been sent/submitted).
1479
-
1480
- The widget will call this function passing a transaction as single argument (see: [depay-web3-wallets](https://github.com/depayfi/depay-web3-wallets#transaction) for more details)
1481
-
1482
- ```javascript
1483
- DePayWidgets.Donation({
1484
-
1485
- failed: (transaction)=> {
1486
- // called when payment transaction failed on the blockchain
1487
- // handled by the widget, no need to display anything
1488
- }
1489
- });
1490
- ```
1491
-
1492
- #### critical
1493
-
1494
- `critical`
1495
-
1496
- A function that will be called if the widget throws a critical internal error that it can't handle and display on its own:
1497
-
1498
- ```javascript
1499
- DePayWidgets.Donation({
1500
-
1501
- critical: (error)=> {
1502
- // render and display the error with error.toString()
1503
- }
1504
- });
1505
- ```
1506
-
1507
- #### error
1508
-
1509
- `error`
1510
-
1511
- A function that will be called if the widget throws a non-critical internal error that it can and will handle and display on its own:
1512
-
1513
- ```javascript
1514
- DePayWidgets.Donation({
1515
-
1516
- error: (error)=> {
1517
- // maybe do some internal tracking with error.toString()
1518
- // no need to display anything as widget takes care of displaying the error
1519
- }
1520
- });
1521
- ```
1522
-
1523
- #### providers
1524
-
1525
- Allows to set providers to be used for making RPC calls to the individual blockchains:
1526
-
1527
- ```javascript
1528
- DePayWidgets.Donation({
1529
-
1530
- providers: {
1531
- ethereum: ['http://localhost:8545'],
1532
- bsc: ['http://localhost:8545']
1533
- }
1534
- });
1535
- ```
1536
-
1537
- #### currency
1538
-
1539
- Allows you to enforce displayed local currency (instead of automatically detecting it):
1540
-
1541
- ```javascript
1542
- DePayWidgets.Donation({
1543
-
1544
- currency: 'USD'
1545
-
1546
- });
1547
- ```
1548
-
1549
- #### whitelist
1550
-
1551
- Allows only the configured tokens to be eligible as means of payment (from the sender):
1552
-
1553
- ```javacript
1554
- DePayWidgets.Donation({
1555
-
1556
- whitelist: {
1557
- ethereum: [
1558
- '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', // ETH
1559
- '0xdac17f958d2ee523a2206206994597c13d831ec7', // USDT
1560
- '0x6b175474e89094c44da98b954eedeac495271d0f' // DAI
1561
- ],
1562
- bsc: [
1563
- '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', // BNB
1564
- '0xe9e7cea3dedca5984780bafc599bd69add087d56', // BUSD
1565
- '0x55d398326f99059ff775485246999027b3197955' // BSC-USD
1566
- ],
1567
- polygon: [
1568
- '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', // MATIC
1569
- '0x2791bca1f2de4661ed88a30c99a7a9449aa84174', // USDC
1570
- ]
1571
- }
1572
- })
1573
- ```
1574
-
1575
- #### blacklist
1576
-
1577
- Allows to blacklist tokens so that they will not be suggested as means of payment (from the sender):
1578
-
1579
- ```javacript
1580
- DePayWidgets.Donation({
1581
-
1582
- blacklist: {
1583
- ethereum: [
1584
- '0x82dfDB2ec1aa6003Ed4aCBa663403D7c2127Ff67', // akSwap
1585
- '0x1368452Bfb5Cd127971C8DE22C58fBE89D35A6BF', // JNTR/e
1586
- '0xC12D1c73eE7DC3615BA4e37E4ABFdbDDFA38907E', // KICK
1587
- ],
1588
- bsc: [
1589
- '0x119e2ad8f0c85c6f61afdf0df69693028cdc10be', // Zepe
1590
- '0xb0557906c617f0048a700758606f64b33d0c41a6', // Zepe
1591
- '0x5190b01965b6e3d786706fd4a999978626c19880', // TheEver
1592
- '0x68d1569d1a6968f194b4d93f8d0b416c123a599f', // AABek
1593
- '0xa2295477a3433f1d06ba349cde9f89a8b24e7f8d', // AAX
1594
- '0xbc6675de91e3da8eac51293ecb87c359019621cf', // AIR
1595
- '0x5558447b06867ffebd87dd63426d61c868c45904', // BNBW
1596
- '0x569b2cf0b745ef7fad04e8ae226251814b3395f9', // BSCTOKEN
1597
- '0x373233a38ae21cf0c4f9de11570e7d5aa6824a1e', // ALPACA
1598
- '0x7269163f2b060fb90101f58cf724737a2759f0bb', // PUPDOGE
1599
- '0xb16600c510b0f323dee2cb212924d90e58864421', // FLUX
1600
- '0x2df0b14ee90671021b016dab59f2300fb08681fa', // SAFEMOON.is
1601
- '0xd22202d23fe7de9e3dbe11a2a88f42f4cb9507cf', // MNEB
1602
- '0xfc646d0b564bf191b3d3adf2b620a792e485e6da', // PIZA
1603
- '0xa58950f05fea2277d2608748412bf9f802ea4901', // WSG
1604
- '0x12e34cdf6a031a10fe241864c32fb03a4fdad739' // FREE
1605
- ]
1606
- }
1607
- })
1608
- ```
1609
-
1610
- #### container
1611
-
1612
- `container`
1613
-
1614
- Allows you to pass a container element that is supposed to contain the widget:
1615
-
1616
- ```javascript
1617
- DePayWidgets.Dontaion({
1618
- container: document.getElementById('my-container')
1619
- })
1620
- ```
1621
-
1622
- Make sure to set the css value `position: relative;` for the container element. Otherwise it can not contain the widget.
1623
-
1624
- React example:
1625
-
1626
- ```javascript
1627
- let CustomComponentWithWidget = (props)=>{
1628
- let container = useRef()
1629
-
1630
- useEffect(()=>{
1631
- if(container.current) {
1632
- DePayWidgets.Payment({ ...defaultArguments, document,
1633
- container: container.current
1634
- })
1635
- }
1636
- }, [container])
1637
-
1638
- return(
1639
- <div ref={container} style={{ position: 'relative', border: '1px solid black', width: "600px", height: "600px" }}></div>
1640
- )
1641
- }
1642
- ```
1643
-
1644
- #### style
1645
-
1646
- `style`
1647
-
1648
- Allows you to change the style of the widget.
1649
-
1650
- ```javascript
1651
- DePayWidgets.Donation({
1652
-
1653
- style: {
1654
- colors: {
1655
- primary: '#ffd265',
1656
- text: '#e1b64a',
1657
- buttonText: '#000000',
1658
- icons: '#ffd265'
1659
- },
1660
- fontFamily: '"Cardo", serif !important',
1661
- css: `
1662
- @import url("https://fonts.googleapis.com/css2?family=Cardo:wght@400;700&display=swap");
1663
-
1664
- .ReactDialogBackground {
1665
- background: rgba(0,0,0,0.8);
1666
- }
1667
- `
1668
- }
1669
- });
1670
- ```
1671
-
1672
- ##### colors
1673
-
1674
- `colors`
1675
-
1676
- Allows you to set color values:
1677
-
1678
- ```javascript
1679
- DePayWidgets.Donation({
1680
-
1681
- style: {
1682
- colors: {
1683
- primary: '#ffd265',
1684
- text: '#ffd265',
1685
- buttonText: '#000000',
1686
- icons: '#ffd265'
1687
- }
1688
- }
1689
- });
1690
- ```
1691
-
1692
- ##### fontFamily
1693
-
1694
- `fontFamily`
1695
-
1696
- Allows you to set the font-family:
1697
-
1698
- ```javascript
1699
- DePayWidgets.Donation({
1700
-
1701
- style: {
1702
- fontFamily: '"Cardo", serif !important'
1703
- }
1704
- });
1705
- ```
1706
-
1707
- ##### css
1708
-
1709
- `css`
1710
-
1711
- Allows you to inject CSS:
1712
-
1713
- ```javascript
1714
- DePayWidgets.Donation({
1715
-
1716
- style: {
1717
- css: `
1718
- @import url("https://fonts.googleapis.com/css2?family=Cardo:wght@400;700&display=swap");
1719
-
1720
- .ReactDialogBackground {
1721
- background: rgba(0,0,0,0.8);
1722
- }
1723
- `
1724
- }
1725
- });
1726
- ```
1727
-
1728
- #### unmount
1729
-
1730
- `unmount`
1731
-
1732
- Allows you to unmount (the React safe way) the entire widget from the outside:
1733
-
1734
- ```javascript
1735
- let { unmount } = await DePayWidgets.Donation({})
1736
-
1737
- unmount()
1738
- ```
1739
-
1740
- #### closable
1741
-
1742
- `closable`
1743
-
1744
- Makes the widget unclosable:
1745
-
1746
- ```javascript
1747
- DePayWidgets.Donation({
1748
- closable: false
1749
- })
1750
-
1751
- ```
1752
-
1753
- #### integration
1754
-
1755
- `integration`
1756
-
1757
- Labels donations to track them per integration.
1758
-
1759
- ```javascript
1760
- DePayWidgets.Donation({
1761
- integration: 'fe690fbc-1740-4894-b12c-23a72abec54d'
1762
- })
1763
- ```
1764
-
1765
1294
  ## DePay Connect
1766
1295
 
1767
1296
  DePay Connect allows you to have your users connect their crypto wallet to your dApp or website.
@@ -2035,5 +1564,5 @@ test:cypress:debug
2035
1564
  Test and debug single cypress file:
2036
1565
 
2037
1566
  ```
2038
- yarn test:cypress:debug --spec "cypress/e2e/Payment/track.js"
1567
+ yarn test:cypress:debug --spec "cypress/e2e/Payment/main.solana.js"
2039
1568
  ```