> For the complete documentation index, see [llms.txt](https://startbutton.gitbook.io/startbutton-product-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://startbutton.gitbook.io/startbutton-product-api/sdk/sbinit-function.md).

# SBInit Function

The SBInit function initializes a payment flow on the Startbutton platform. The JavaScript SDK provides a fast and secure popup payment experience, with support for multiple payment channels.

### Description

The `SBInit` function is used to initialize a payment process using the specified parameters.

### SBInit Function example

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <script defer src="https://checkout.startbutton.tech/version/latest/sb-web-sdk.min.js"></script>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>

<button onclick="runSdk()">Trigger SDK</button>

<script>

  function runSdk() {
    SBInit({
      phone: '080123456789',
      key: 'sb_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
      amount: 564300,
      channels: ['card'],
      env: 'test',
      success: (res) => {
        console.log(res)
      },
      close: () => {
        console.log('closed')
      },
      error: (res) => {
        console.log(res)
      },
      currency: 'NGN',
      email: 'talktotester@gmail.com',
      metadata: {
        itemId: 'HTY9898999UI'
      }
    })
  }
</script>

</body>
</html>
```

### Parameters

| Parameter | Desc                                                            | Type     | Accepted Values                                                                                                                           |
| --------- | --------------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| phone     | Phone number of the merchant.                                   | String   | -                                                                                                                                         |
| key       | Merchant public key for authentication                          | String   | Your public API key                                                                                                                       |
| amount    | Amount to charge, in fractional units                           | Number   | For example, `1000 = ₦10`.                                                                                                                |
| channels  | Payment channels to be used. for accepted value please refer to | String   | [Restricting Payment Methods](/startbutton-product-api/collections/accept-payments-overview/restricting-payment-methods.md)               |
| success   | Callback function for successful payment.                       | Function | -                                                                                                                                         |
| error     | Callback function for error handling.                           | Function | -                                                                                                                                         |
| close     | Callback function when payment modal is closed.                 | Function | -                                                                                                                                         |
| currency  | Currency of the payment. accepted values.                       | String   | Transaction currency, for example `NGN` or `GHS`. See [Available Currencies](/startbutton-product-api/reference/available-currencies.md). |
| email     | Email of the payer.                                             | String   | <customer@gmail.com>                                                                                                                      |
| metadata  | Additional information that you may need for further processing | Object   | -                                                                                                                                         |

### Documentation

For more information, see the [Introduction](/startbutton-product-api/introduction.md).
