Developer - API Documentation

Introduction

This section describes the Bluemoney payment gateway API.


Bluemoney API is easy to integrate into your business software. It uses well-formatted URLs, accepts cURL requests, and returns JSON responses.

You can use the API in test mode, which does not affect your live data. The API key is used to authenticate requests and determine whether a payment request is valid. For test mode, use the sandbox URL. For live mode, use the live URL from the Initiate Payment section.

Supported Currencies

This section describes the currencies supported by Bluemoney


Bluemoney supports transactions in the currencies below. Additional currencies may be added in the future.

Currency Name Currency Symbol Currency Code
United States Dollar $ USD
Botswana Pula P BWP
Zambian Kwacha K ZMW

Get API Keys

This section describes how to get your API keys.


Log in to your Bluemoney merchant account. If you do not have one, Click here

The next step is to find the API Keys menu in your dashboard sidebar and click it.

You will find two API keys there: Public Key and Secret Key. Use these keys to initiate API requests. You can generate new API keys at any time by clicking the Generate API Key button. Do not share these keys with anyone.

Initiate Payment

This section describes the process of initiating a payment.


To initiate a payment, follow the example code and use the parameters carefully. You need to make a request to the following API endpoints.

Live Endpoint: https://www.bluemoney.co.bw/payment/initiate

Test Endpoint: https://www.bluemoney.co.bw/sandbox/payment/initiate

Test Mode Mail: [email protected]

Test Mode Verification Code: 222666

Request Method: POST

Send the request to the endpoint with the following parameters.

Param Name Param Type Description
public_key string (50) Required Your public API key.
identifier string (20) Required Identifier used to identify the payment on your end.
currency string (4) Required Currency code must be uppercase (for example, USD, EUR).
amount decimal Required Payment amount.
details string (100) Required Details of your payment or transaction.
ipn_url string Required The URL for instant payment notifications.
success_url string Required Redirect URL after a successful payment.
cancel_url string Required Redirect URL when payment is canceled.
site_logo string/url Required Your business site logo.
checkout_theme string Optional Checkout form theme: dark/light. Default theme is light.
customer_name string (30) Required Customer name.
customer_email string (30) Required A valid customer email address.
Example PHP code
<?php
    $parameters = [
        'identifier' => 'DFU80XZIKS',
        'currency' => 'USD',
        'amount' => 100.00,
        'details' => 'Purchase T-shirt',
        'ipn_url' => 'http://example.com/ipn_url.php',
        'cancel_url' => 'http://example.com/cancel_url.php',
        'success_url' => 'http://example.com/success_url.php',
        'public_key' => 'your_public_key',
        'site_logo' => 'https://www.bluemoney.co.bw/assets/images/logoIcon/logo.png',
        'checkout_theme' => 'dark',
        'customer_name' => 'John Doe',
        'customer_email' => '[email protected]',

    ];

    //live endpoint
    $url = "https://www.bluemoney.co.bw/payment/initiate";

    //test endpoint
    $url = "https://www.bluemoney.co.bw/sandbox/payment/initiate";

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POSTFIELDS,  $parameters);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch);
    curl_close($ch);

    //$result contains the response back.
?>
Example Responses
//Error Response.
{
    "error": "true",
    "message": "Invalid API key"
}

//Success Response.
{
    "success": "ok",
    "message": "Payment initiated. Redirect to URL.",
    "url":"http://example.com/initiate/payment/checkout?payment_id=eJSAASDxdrt4DASDASVNASJA7893232432cvmdsamnvASF"
}

Validate Payment and IPN

This section describes how to receive instant payment notifications.


To validate payments, follow the example code and use the parameters carefully.

Endpoint: Your business application IPN URL.

Request Method: POST

You will receive the following parameters.

Param Name Description
status Payment success status.
identifier Identifier used to identify the payment on your end.
signature A hash signature used to verify the payment on your end.
data Contains basic information such as charges, amount, currency, payment transaction ID, etc.
Example PHP code
<?php
    // Receive the response parameters
    $status = $_POST['status'];
    $signature = $_POST['signature'];
    $identifier = $_POST['identifier'];
    $data = $_POST['data'];

    // Generate your signature
    $customKey = $data['amount'].$identifier;
    $secret = 'YOUR_SECRET_KEY';
    $mySignature = strtoupper(hash_hmac('sha256', $customKey , $secret));

    $myIdentifier = 'YOUR_GIVEN_IDENTIFIER';

    if($status == "success" && $signature == $mySignature &&  $identifier ==  $myIdentifier){
        // your business logic
    }
?>

We use cookies on our website to improve your user experience. You can accept them all or manage your cookie preferences below to control your privacy. learn more

Allow
Install Bluemoney for faster access.