SDK & UI library
Software Development Kits
Our SDKs remove the need to handle sensitive data by enabling you to validate and encrypt your data and finally create a checkout request. Check the out here:
Checkout JavaScript Library
The Checkout JavaScript Library is small library that makes creating an Express experience (modal / redirect) easier.
For the best experience on Express modal checkout we highly recommend the use of this library.
Installation
Adding the library is as easy as adding a JavaScript tag. Simply add the CDN link https://cdn.cellulant.africa/js/tingg-checkout-library.js via a JavaScript tag. See the example below:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
...
<script src="https://cdn.cellulant.africa/js/tingg-checkout-library.js"></script>
</body>
</html>
The script adds a Tingg
object on the browser's window object. Accessing window.Tingg
exposes some APIs used to render the Express checkout UI.
Usage
After the CDN has been included, add a button i.e "PAY NOW" that will trigger a HTTP request to your back-end endpoint that returns a checkout URL.
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<main>
<button id="pay-button" onclick="createCheckoutRequest()">
PAY NOW!
</button>
</main>
<script src="https://cdn.cellulant.africa/js/tingg-checkout-library.js"></script>
<script>
function createCheckoutRequest() {
// 1. Create your checkout payload
var payload = {
customer_first_name: "John",
customer_last_name: "Doe",
msisdn: "254700000000",
account_number: "ref-qwerty",
request_amount: "100",
merchant_transaction_id: "1234567890",
service_code: "<YOUR TINGG SERVICE CODE>",
country_code: "KEN",
currency_code: "KES",
callback_url: "https://webhook.site/...",
fail_redirect_url: "https://webhook.site/...",
success_redirect_url: "https://webhook.site/.."
};
// 2. Create a payment URL on the server
const req = window.fetch('<YOUR ENCRYPTION ENDPOINT>', {
method: "POST",
body: JSON.stringify(payload)
});
if (!req.ok) {
console.log("Request failed. Payload could not be encrypted...");
return;
}
req
.then(fucntion (resp) {
return resp.json()
})
.then(function (data) {
window.Tingg.renderCheckout({
environment: "testing",
checkout_type: "modal",
checkout_url: {
long_url: data.long_url,
short_url: data.short_url
},
onClose: () => {
console.log("Close called!");
window.Tingg.close();
},
onSuccess: (data) => {
console.log("Success", data);
},
onFailed: (data) => {
console.log("Failed", data);
}
});
})
}
</script>
</body>
</html>
For the callback functions to take effect, the
success_redirect_url
&fail_redirect_url
need to have the same domain origin with your e-commerce site.Example: If your e-commerce shop/ site has the domain https://acme.example/checkout then the
**success_redirect_url**
and**fail_redirect_url**
should start with the SAME domain i.e https://acme.example/... for the onSuccess and onFailed callbacks to be triggered.
onClose()
function
onClose()
functionThis function is called when the close button is clicked. To close the modal, you'll have to explicitly call window.Tingg.close()
after any business logic.
NOTE: window.Tingg.close()
can be called anywhere & at any time you wish to close the modal in your custom pages, components & widgets.
onSuccess(data)
function
onSuccess(data)
functionThis function is called when the payment has been fully paid.
onFailed(data)
function
onFailed(data)
functionThis function is called when the checkout request expires without it being fully paid.
Both onSuccess and onFailed receive a single parameter data with the follow fields:
{
"request_status_code": "178",
"merchant_transaction_id": "skt3hf-3000.csb.app358",
"checkout_request_id": 235815,
"service_code": "JOHNDOEONLINE",
"account_number": "skt3hf",
"currency_code": "KES",
"request_amount": "100",
"amount_paid": "100.00",
"payments": '[
{
"id": 48019,
"msisdn": 254700000000,
"payment_option_transaction_id": "25bb34d4-b4ad-40ae-aa1f-be0909eb2dbb",
"account_number": "skt3hf",
"customer_name": "Customer",
"amount_paid": 100,
"gateway_transaction_id": "542246309118099456",
"date_payment_received": "2024-02-05 10:33:16",
"gateway_overall_status": 139,
"currency_id": "70",
"country_id": "117",
"service_id": "161",
"payer_narration": "Simulate payment",
"checkout_request_id": 235815,
"merchant_receipt": "",
"receiver_narration": "",
"date_payment_acknowledged": null,
"created_at": "2024-02-05 07:33:17",
"payment_option_id": 1
}
]',
"failed_payments": "[]",
"request_date": "2024-02-05 07:32:08",
"payment_status_description": "Request fully paid",
"msisdn": 2547000000000,
"customer_email": "[email protected]",
"request_description": "",
"type": "success"
}
Field | Type | Description |
---|---|---|
request_status_code | string |number | Overall request code indicating the status of the request |
merchant_transaction_id | string | The unique merchant reference for the request you raised for the request as provided in the checkout payload |
checkout_request_id | string |number | A unique identifier on Tingg’s end. |
service_code | string | Unique Tingg code identifying the service the payment request was raised for |
account_number | string | The reference the customer was paying for as provided in the checkout payload |
currency_code | string | ISO Currency code of the payment made |
request_amount | string |number | The converted amount for the request raised by the merchant |
amount_paid | string |number | Amount the customer paid for the request |
payments | array | An array of successful payments made to the request |
failed_payments | array | An array of failed payments made to the request |
request_date | string | Date when the request was raised in |
payment_status_description | string | Description of the status given back on the overall payment |
msisdn | string | The mobile number the person came with from the merchant site |
customer_email | string | Customer's email address. |
request_description | string | Shows the description of the item being purchased. |
type | string | success or failed |
CMS Plugins
A WooCommerce plugin that allows businesses to collect from their WordPress shops / store. Read more about it on the Wordpress Plugins store
Shopify
Coming soon
Updated 6 months ago