> For the complete documentation index, see [llms.txt](https://konnadex-docs.gitbook.io/konnadex-technologies/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://konnadex-docs.gitbook.io/konnadex-technologies/payments/accept-payment.md).

# 📡Accept Payment

Konnadex is a software development kit that allows for ease of crypto payment integration on the web. Accept crypto USDT payments using Binance smart chain (BSC), Ethereum, and Polygon blockchain.

**USAGE**

Currently, anyone can use konnadex SDK via a simple hyperlink integration on a new or existing web page.

**Installing**

Using CDN:

```javascript
// Some code for the CDN
<script src="https://cdn.jsdelivr.net/gh/konnadex/konnadex-pay@main/index.min.js"></script>
```

**Example**

After the Konnadex script has been loaded, a global `konnadexCheckout` the object is injected into the global `window` object for ease of availability.

**Creating an instance**

```javascript
const pay = new KonnadexCheckout({
  key: "KDX_PUBK_TEST_9juOi233pYQUax0vB5wudw+H32SZttKUIyfZh/7xQZWiPbI1",
  reference: "test-test-ref", //Use your actual reference key
  env: "PRODUCTION", // This supports "DEVELOPMENT" or "PRODUCTION"
  currency: ["NGN","USD","EUR","GBP","GHS","AUD","JPY"]
  amount: "2000.42",
  network: "BINANCE", // optional[default: BINANCE]
  cryptoCurrency: "USDT", // USDT | CNGN
  defaultTab: "contract", // contract | transfer 
  theme: 'light', // This supports "Light" and "Dark" Theme
  metadata: {
    email: "jd@doe.com",
    fullname: "John Doe",
    description:"",
    phone: ""
  },
  onSuccess: success,
  onError: error,
  onClose,
});
```

**Setup event handlers and Open Konnadex Pay**

Emit config data, prepare UI dialog for transactions, and open the dialog

```javascript
pay.initializePay();
```

**Instance Configuration**

Konnadex is initialized with a configuration object which is required to set up and open up the Konnadex dialog. See below for specifications on the configuration object.

```javascript
{
  key: "KDX_PUBK_TEST_9juOi233pYQUax0vB5wudw+H32SZttKUIyfZh/7xQZWiPbI1",
  reference: "test-test-ref",//unique
  metadata: {
    email: "jd@doe.com",
    fullname: "John Doe",
    description:"",
  },
  theme: 'light',
  env:"PRODUCTION",
  currency: "NGN",
  amount: "2000.42",
  network: "BINANCE", // optional[default: BINANCE]
  cryptoCurrency: "USDT", // USDT | CNGN
  defaultTab: "contract", // contract | transfer 
  // `onSuccess` callBack function on transaction successful
  onSuccess: function(transactionData){}, // no-default, optional, function

   // `onClose` callBack function on modal close
  onClose: function(closeEvent){}, // no-default, optional, function

   // `onError` callBack function on transaction successful
  onError: function(error){}, // no-default, optional, function
  // `transfer` Allow third party wallet transfers

  transfer: true, // default false, not required, boolean

}
```

**Supported Networks and token**

<table><thead><tr><th width="203">Network</th><th>ChainId</th><th>USDT</th><th>cNGN</th></tr></thead><tbody><tr><td>Ethereum</td><td>1</td><td><p></p><p>✅</p></td><td>❌</td></tr><tr><td>Binance Smart Chain</td><td>56</td><td><p></p><p>✅</p></td><td>✅</td></tr><tr><td>Polygon Mainnet</td><td>137</td><td><p></p><p>✅</p></td><td>✅</td></tr><tr><td>Mumbai</td><td>80001</td><td><p></p><p>✅</p></td><td>✅</td></tr><tr><td>BSC Testnet</td><td>97</td><td><p></p><p>✅</p></td><td>✅</td></tr><tr><td>Goerli Testnet</td><td>5</td><td><p></p><p>✅</p></td><td>✅</td></tr><tr><td>Lisk Mainnet</td><td>1135</td><td>✅</td><td>❌</td></tr><tr><td>Lisk Sepolia Testnet</td><td>4202</td><td>✅</td><td>❌</td></tr><tr><td>Asset Chain Testnet</td><td>42421</td><td>✅</td><td>✅</td></tr></tbody></table>

**Full Example**

Create an HTML file, and paste this script below then get the bag.

```html
<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<html>
  <head>
    <meta charset="utf-8" />
    <title>Getting Started</title>
    <script src="https://cdn.jsdelivr.net/gh/konnadex/konnadex-pay@main/index.min.js"></script>
  </head>

  <body>
    <div id="pay-widget-wrapper">
      Welcome to my website, pay for the item now.
      <button id="button">Pay Now</button>
    </div>
    <script>
      const pay = new KonnadexCheckout({
        key: "KDX_PUBK_TEST_9juOi233pYQUax0vB5wudw+H32SZttKUIyfZh/7xQZWiPbI1", //Get a public key
        reference: "test-test-ref", //Use your actual reference key
         metadata: {
          email: "jd@doe.com",
          fullname: "John Doe",
          description:"",
        },
        theme: 'light', // This supports "Light" and "Dark" Theme
        env: "PRODUCTION", // This supports "DEVELOPMENT" or "PRODUCTION"
        currency: ["NGN","USD","EUR","GBP","GHS","AUD","JPY"]
        amount: "2000.42",
        network: "BINANCE", // optional[default: BINANCE]
        cryptoCurrency: "USDT", // USDT | CNGN
        defaultTab: "contract", // contract | transfer 
        onSuccess: success,
        onError: error,
        onClose,
      });

      function success(data) {
        console.log(data);
      }

      function error(data) {
        console.log(data);
      }

      function onClose(data) {
        console.log(data);
      }
      const button = document.querySelector("#button");

      button.addEventListener("click", function () {
        pay.initializePay();
      });
    </script>
  </body>
</html>
```
