SBInit Function

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 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

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 (e.g., NGN, GHS). See here for supported currencies

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

Last updated