> 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/sdk/sbinit-function.md).

# SBInit Function

## Description

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

## SBInit Function Example (HTML)

<pre class="language-html"><code class="lang-html"><strong>&#x3C;!DOCTYPE html>
</strong>&#x3C;html lang="en">
&#x3C;head>
  &#x3C;script defer src="https://checkout.startbutton.tech/version/latest/sb-web-sdk.min.js">&#x3C;/script>
  &#x3C;meta charset="UTF-8">
  &#x3C;title>Title&#x3C;/title>
&#x3C;/head>
&#x3C;body>

&#x3C;button onclick="runSdk()">Trigger SDK&#x3C;/button>

&#x3C;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'
      }
    })
  }
&#x3C;/script>

&#x3C;/body>
&#x3C;/html>
</code></pre>

## 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 of the payment                                           | Number   | Amount to charge in fractional units (e.g., 1000 = ₦10                                                                                                                    |
| channels  | Payment channels to be used. for accepted value please refer to | String   | [Payment Methods](https://startbutton.gitbook.io/startbutton-product-api/startbutton-api-doc/accept-payments#specify-payment-method)                                      |
| 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   | <p>Transaction currency (e.g., NGN, GHS).<br><br>See <a href="/startbutton-product-api/startbutton-api-doc/available-currencies.md">here</a> for supported currencies</p> |
| email     | Email of the payer.                                             | String   | <customer@gmail.com>                                                                                                                                                      |
| metadata  | Additional information that you may need for further processing | Object   | -                                                                                                                                                                         |

## Documentation

For more information please check out our [documentation](https://startbutton.gitbook.io/startbutton-product-api/startbutton-api-doc)
