Thawani Checkout API Documentation

Introduction

  • Congratulation on considering Thawani Checkout as one of your Payment Service Providers. Thawani Checkout is a payment gateway that allows you to collect payments from your customers.
  • Merchant
    • Prepare a valid JSON request as per the integration documentation.
    • Sending request to the proper endpoint server that is mentioned in the integration documentation.
    • Redirect user to the provided payment link upon the successful generation of the link.
    • Update Merchant invoices and/or payment system.
    • Check periodically/once for changes on payment status.

    Thawani
    • Return back the payment link to the merchant.
    • Process user’s card payment or in-app payment.
    • Send OTP through the user bank card’s phone number that is registered in the bank.
    • Send payment result response bank.
    • Once the integration is completed, a test entry will be made and we will print the receipt for checking and verification – to be signed be the merchant before sending the production API and public key.

    Important Notes
    • The code sample is for demonstration purposes only. It should NOT be used as a base to develop the integration.
    • Thawani does NOT supply any plugin for any eCommerce platform.
    • All communication MUST be through emails ONLY.
    • Please provide an email that will direct all automatic communications and notifications.
    • Secret and Publishable keys are only for your company/organization purposes, NOT to be shared.
    • We do our level best to serve as much merchants as possible from Sunday to Thursday between 9:00AM until 3:00PM and in working days only.
  • In order to move your system to production environment, you need to meet the following requirements:

    • - SSL Certificate.
    • - Customer information passed on metadata (Name, Contact number, & Email address).
    • - Payment display dialogue box should contain message that indicates accepts card payments
  • Before using the eCommerce, you must make sure that configuration in the Merchant portal is set properly. There are 3 main functions:
    • Integration Keys: generate integration keys (secret and publishable key)
    • Webhook URL: Set the webhook URL to receive the payment notification
    • Payment Methods: Set what payments can be received in Thawani Checkout.
  • You MUST provide Secret and Publishable Keys in order to call any request in Thawani Checkout. Each merchant will have his unique keys which he can generate from the merchant portal directly. For testing purposes, below is the keys that will help you while integrating. Note that this is in UAT ONLY. If you need to move to production, then contact Thawani Sales to register with Thawani as a merchant and get your own keys.

    secret_key: rRQ26GcsZzoEhbrP2HZvLYDbn9C9et

    publishable_key: HGvTMLDssJghr9tlN9gr4DVYt0qyBy

Session

  • This endpoint is the first step to create the payment link. Sending the proper parameters in the request will result in returning a set of values that include session_id which will be used later to redirect the user to complete the payment.
  • To redirect the user to pay, a URL MUST be constructed in the specific format.
  • This endpoint will return all information about sessions as per the limit. Limit is a number of records to be returned in descended order.
  • This endpoint will return all information about sessions as per the passed reference number parameter.
  • This endpoint will return all information about sessions as per the passed receipt number parameter.
  • This endpoint will return all information about sessions as per the limit. Limit is a number of records to be returned order in descended order.

Test Cards

  • For testing purposes, we provide the developer with a card that will always respond with success.
  • For testing purposes, we provide the developer with a card that will always respond with failure.

Support

  • If you require a support in integrating with Thawani eCommerce, please visit our developer’s portal in the following web address:
    https://developer.thawani.om/
    Or send your inquiries to our dedicated support team with the following email address:
    [email protected]"

Thawani Checkout Introduction

Thawani Checkout Introduction

Images

Workflow

Thawani Checkout Overall Workflow.
Preview image description

Thawani Checkout Introduction Code Example

Roles and Responsibilities

Roles and Responsibilities

Roles and Responsibilities Code Example

Checklist

Checklist

Checklist Code Example

Merchant Portal Configuration

Merchant Portal Configuration

Images

Keys

This window will allow you to generate secret_key and publishable_key for each branch so it can be used in the integration of the payment with Thawani Checkout.
Preview image description

Webhooks

Here you can configure the webhook (callback URL) where all results of payments from Thawani Checkout will be sent to this URL.
Preview image description

Payment Methods

Select which payment method are accepted in Thawani Checkout.
Preview image description

Merchant Portal Configuration Code Example

Secret and Publishable Keys

Secret and Publishable Keys

Secret and Publishable Keys Code Example

Create Session

Method
HTTP Method Environment
POST UAT

https://uatcheckout.thawani.om/api/v1/checkout/session

POST PRODUCTION

https://checkout.thawani.om/api/v1/checkout/session

Header Parameters
Parameter Description
Content-type Application/json
Secret_key Secret key that obtainable from the merchant portal
Body / Fields
Field Name Required Data Type
client_reference_id Yes Numerical

Description: A Number that references the client. This MUST be provided by the merchant.

customer_id No String

Description: Customer token that has been created using the create customer endpoint.

products Yes JSON

Description: Values that define the checkout price and what the customer is charged for. It must contain the following data:

  • name: Name of the product
  • unit_amount: selling price per unit
  • quantity: number of units
success_url Yes URL

Description: Valid URL to redirect the user after a successful payment.

cancel_url Yes URL

Description: Valid URL to redirect the user after failed payment attempt.

metadata No JSON

Description: Extra fields that allow to store additional information about the transaction and it is limited to 10 fields only.

JSON Examples
Example Name
Request in JSON format

{
    "client_reference_id":"",
    "customer_id":"",
    "products":[
    {
    "name":"Product A",
    "unit_amount":1000,"quantity":1
},{
    "name":"Product B",
    "unit_amount":2000,"quantity":1
}
],"success_url":"",
    "cancel_url":"",
    "metadata":{
    "option 1":"",
    "option 2":""
}
}

Respond in JSON format

{
    "success":true,"code":2004,"description":"Session generated successfully",
    "data":{
    "session_id":"",
    "client_reference_id":"",
    "customer_id":"",
    "products":[
    {
    "name":"Product A",
    "unit_amount":1000,"quantity":1
},{
    "name":"Product B",
    "unit_amount":2000,"quantity":1
}
],"total_amount":3000,"currency":"OMR",
    "success_url":"",
    "cancel_url":"",
    "payment_status":"unpaid",
    "metadata":{
    "option 1":"",
    "option 2":""
},"created_at":"2020-11-11T07:47:38.7032265Z",
    "expire_at":"2020-11-12T07:47:38.6693043Z"
}
}

Notes
  • Selling Price in Product parameter must be as an Integer value e.g. for ( 0.200 OMR ) you have to input ( 200 ) likewise if you want to request (20/- OMR) you have to input ( 20000 ). Decimals are NOT allowed.
  • Our system will do the calculation for the line total and the overall amount base on the given details in the request.
  • The session will be created to be used once only.
  • Expiry Date will be by default for ONE day only.

Create Session

Images

Mobile View

Preview image description

Desktop and Tablet View

Preview image description

Create Session Code Example

Code Example

PHP

												$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => "https://uatcheckout.thawani.om/api/v1/checkout/session",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => '{"client_reference_id": "123123","customer_id": "","products": [{"name": "Mobile Phone","unit_amount": 2000,"quantity": 3},{"name": "Kage","unit_amount": 1500,"quantity": 1}],"success_url": "https://google.com","cancel_url": "https://youtube.com","metadata": {"customer": "Thawani User","order_id": 10}}',
  CURLOPT_HTTPHEADER => [
    "Content-Type: application/json",
    "thawani-api-key: rRQ26GcsZzoEhbrP2HZvLYDbn9C9et"
  ],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
	echo "cURL Error #:" . $err;
} else {
	echo $response;
}
											

JS

												const settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://uatcheckout.thawani.om/api/v1/checkout/session",
  "method": "POST",
  "headers": {
    "thawani-api-key": "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et",
    "Content-Type": "application/json"
  },
  "processData": false,
  "data": "{"client_reference_id": "123123","customer_id": "cus_qe92dhBJdaLUEWGI","products": [{"name": "Mobile Phone","unit_amount": 2000,"quantity": 3},{"name": "Kage","unit_amount": 1500,"quantity": 1}],"success_url": "https://google.com","cancel_url": "https://youtube.com","metadata": {"customer": "Thawani User","order_id": 10}}"
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
											

PYTHON

												import http.client

conn = http.client.HTTPSConnection("uatcheckout.thawani.om")

payload = "{"client_reference_id": "123123","customer_id": "cus_qe92dhBJdaLUEWGI","products": [{"name": "Mobile Phone","unit_amount": 2000,"quantity": 3},{"name": "Kage","unit_amount": 1500,"quantity": 1}],"success_url": "https://google.com","cancel_url": "https://youtube.com","metadata": {"customer": "Thawani User","order_id": 10}}"

headers = {
    'thawani-api-key': "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et",
    'Content-Type': "application/json"
    }

conn.request("POST", "/api/v1/checkout/session", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
											

JAVA

												HttpResponse response = Unirest.post("https://uatcheckout.thawani.om/api/v1/checkout/session")
  .header("thawani-api-key", "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et")
  .header("Content-Type", "application/json")
  .body("{"client_reference_id": "123123","customer_id": "cus_qe92dhBJdaLUEWGI","products": [{"name": "Mobile Phone","unit_amount": 2000,"quantity": 3},{"name": "Kage","unit_amount": 1500,"quantity": 1}],"success_url": "https://google.com","cancel_url": "https://youtube.com","metadata": {"customer": "Thawani User","order_id": 10}}")
  .asString();
											

HTTP

												POST /api/v1/checkout/session HTTP/1.1
Thawani-Api-Key: rRQ26GcsZzoEhbrP2HZvLYDbn9C9et
Content-Type: application/json
Host: uatcheckout.thawani.om
Content-Length: 383

{
	"client_reference_id": "123123",
	"customer_id": "cus_qe92dhBJdaLUEWGI",
	"products": [
		{
			"name": "Mobile Phone",
			"unit_amount": 2000,
			"quantity": 3
		},
		{
			"name": "Kage",
			"unit_amount": 1500,
			"quantity": 1
		}
	],
	"success_url": "https://google.com",
	"cancel_url": "https://youtube.com",
	"metadata": {
		"customer": "Thawani User",
		"order_id": 10
	}
}

											

NODEJS

												const http = require("https");

const options = {
  "method": "POST",
  "hostname": "uatcheckout.thawani.om",
  "port": null,
  "path": "/api/v1/checkout/session",
  "headers": {
    "thawani-api-key": "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et",
    "Content-Type": "application/json",
    "Content-Length": "383"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({
  client_reference_id: '123123',
  customer_id: 'cus_qe92dhBJdaLUEWGI',
  products: [
    {name: 'Mobile Phone', unit_amount: 2000, quantity: 3},
    {name: 'Kage', unit_amount: 1500, quantity: 1}
  ],
  success_url: 'https://google.com',
  cancel_url: 'https://youtube.com',
  metadata: {customer: 'Thawani User', order_id: 10}
}));
req.end();
											

GO

												package main

import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://uatcheckout.thawani.om/api/v1/checkout/session"

	payload := strings.NewReader("{"client_reference_id": "123123","customer_id": "cus_qe92dhBJdaLUEWGI","products": [{"name": "Mobile Phone","unit_amount": 2000,"quantity": 3},{"name": "Kage","unit_amount": 1500,"quantity": 1}],"success_url": "https://google.com","cancel_url": "https://youtube.com","metadata": {"customer": "Thawani User","order_id": 10}}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("thawani-api-key", "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
											

CSHARP

												var client = new RestClient("https://uatcheckout.thawani.om/api/v1/checkout/session");
var request = new RestRequest(Method.POST);
request.AddHeader("thawani-api-key", "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("undefined", "{"client_reference_id": "123123","customer_id": "cus_qe92dhBJdaLUEWGI","products": [{"name": "Mobile Phone","unit_amount": 2000,"quantity": 3},{"name": "Kage","unit_amount": 1500,"quantity": 1}],"success_url": "https://google.com","cancel_url": "https://youtube.com","metadata": {"customer": "Thawani User","order_id": 10}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
											

RUBY

												require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://uatcheckout.thawani.om/api/v1/checkout/session")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["thawani-api-key"] = 'rRQ26GcsZzoEhbrP2HZvLYDbn9C9et'
request["Content-Type"] = 'application/json'
request.body = "{"client_reference_id": "123123","customer_id": "cus_qe92dhBJdaLUEWGI","products": [{"name": "Mobile Phone","unit_amount": 2000,"quantity": 3},{"name": "Kage","unit_amount": 1500,"quantity": 1}],"success_url": "https://google.com","cancel_url": "https://youtube.com","metadata": {"customer": "Thawani User","order_id": 10}}"

response = http.request(request)
puts response.read_body
											

Redirect User to Pay

Method
HTTP Method Environment
GET UAT

http://uatcheckout.thawani.om/pay/< session-id >?key=< publishable-key >

GET PRODUCTION

http://checkout.thawani.om/pay/< session-id >?key=< publishable-key >

Notes
  • < publishable-key > will be found in the Merchant portal under “Developers” section.

Redirect User to Pay

Redirect User to Pay Code Example

Get Single Session Details

Method
HTTP Method Environment
GET UAT

https://uatcheckout.thawani.om/api/v1/checkout/session/

GET PRODUCTION

https://checkout.thawani.om/api/v1/checkout/session/

Header Parameters
Parameter Description
Secret_key Secret key that obtainable from the merchant portal
Body / Fields
Field Name Required Data Type
Session_id Yes Numerical

Description: Number that reference the client. This MUST be provided by the merchant.

URL Examples
Example Name
Full Session Information Request URL

https://uatcheckout.thawani.om/api/v1/checkout/session/< session-id >

JSON Examples
Example Name
Respond in JSON format

{
    "success":true,"code":2000,"description":"Session retrieved successfully",
    "data":{
    "session_id":"",
    "client_reference_id":"",
    "customer_id":"< your-custommer-id-here >",
    "products":[
    {
    "name":"Product A",
    "unit_amount":1000,"quantity":1
},{
    "name":"Product B",
    "unit_amount":2000,"quantity":1
}
],"total_amount":3000,"currency":"OMR",
    "success_url":"",
    "cancel_url":"",
    "payment_status":"unpaid",
    "metadata":{
    "option 1":"",
    "option 2":""
},"created_at":"2020-11-11T07:47:38.7032265Z",
    "expire_at":"2020-11-12T07:47:38.6693043Z"
}
}

Notes
  • Selling Price in Product parameter must be as an Integer value e.g. for ( 0.200 OMR ) you have to input ( 200 ) likewise if you want to request (20/- OMR) you have to input ( 20000 ). Decimals are NOT allowed.
  • Our system will do the calculation for the line total and the overall amount base on the given details in the request.
  • The session will be created to be used once only.
  • Expiry Date will be by default for ONE day only.

Get Single Session Details

Get Single Session Details Code Example

Code Example

PHP

												$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://uatcheckout.thawani.om/api/v1/checkout/session/checkout_NaHO04OY2D0BWTDHJBV4Zr2X1cYywNuJnPxxJt9zGzy2Ps8kf2",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => [
    "thawani-api-key: rRQ26GcsZzoEhbrP2HZvLYDbn9C9et"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
											

JS

												const settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://uatcheckout.thawani.om/api/v1/checkout/session/checkout_940RmwSubopVnPj5HadK6NZ5blpUdrx0mCSOGPqDd5YVei8eTS",
  "method": "GET",
  "headers": {
    "thawani-api-key": "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et"
  }
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
											

PYTHON

												import http.client

conn = http.client.HTTPSConnection("uatcheckout.thawani.om")

payload = ""

headers = {
	'thawani-api-key': "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et"
}

conn.request("GET", "/api/v1/checkout/session/checkout_940RmwSubopVnPj5HadK6NZ5blpUdrx0mCSOGPqDd5YVei8eTS", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
											

JAVA

												HttpResponse response = Unirest.get("https://uatcheckout.thawani.om/api/v1/checkout/session/checkout_940RmwSubopVnPj5HadK6NZ5blpUdrx0mCSOGPqDd5YVei8eTS")
  .header("thawani-api-key", "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et")
  .asString();
											

HTTP

												GET /api/v1/checkout/session/checkout_940RmwSubopVnPj5HadK6NZ5blpUdrx0mCSOGPqDd5YVei8eTS HTTP/1.1
Thawani-Api-Key: rRQ26GcsZzoEhbrP2HZvLYDbn9C9et
Host: uatcheckout.thawani.om
											

NODEJS

												const http = require("https");

const options = {
  "method": "GET",
  "hostname": "uatcheckout.thawani.om",
  "port": null,
  "path": "/api/v1/checkout/session/checkout_940RmwSubopVnPj5HadK6NZ5blpUdrx0mCSOGPqDd5YVei8eTS",
  "headers": {
    "thawani-api-key": "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et",
    "Content-Length": "0"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
											

GO

												package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://uatcheckout.thawani.om/api/v1/checkout/session/checkout_940RmwSubopVnPj5HadK6NZ5blpUdrx0mCSOGPqDd5YVei8eTS"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("thawani-api-key", "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
											

CSHARP

												var client = new RestClient("https://uatcheckout.thawani.om/api/v1/checkout/session/checkout_940RmwSubopVnPj5HadK6NZ5blpUdrx0mCSOGPqDd5YVei8eTS");
var request = new RestRequest(Method.GET);
request.AddHeader("thawani-api-key", "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et");
IRestResponse response = client.Execute(request);
											

RUBY

												require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://uatcheckout.thawani.om/api/v1/checkout/session/checkout_940RmwSubopVnPj5HadK6NZ5blpUdrx0mCSOGPqDd5YVei8eTS")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["thawani-api-key"] = 'rRQ26GcsZzoEhbrP2HZvLYDbn9C9et'

response = http.request(request)
puts response.read_body
											

Get Single Session Details by Reference Number

Method
HTTP Method Environment
GET UAT

https://uatcheckout.thawani.om/api/v1/checkout/reference/

GET PRODUCTION

https://checkout.thawani.om/api/v1/checkout/reference/

Header Parameters
Parameter Description
Secret_key Secret key that obtainable from the merchant portal
Body / Fields
Field Name Required Data Type
reference_number Yes Numerical

Description: Reference number that the merchant will be passing in the initial create session. This must be provided by the merchant.

URL Examples
Example Name
Full Session Information by Reference Request URL

https://uatcheckout.thawani.om/api/v1/checkout/reference/< reference-number >

JSON Examples
Example Name
Respond in JSON format

{
    "success":true,"code":2000,"description":"Session retrieved successfully",
    "data":{
    "session_id":"",
    "client_reference_id":"",
    "customer_id":"< your-custommer-id-here >",
    "products":[
    {
    "name":"Product A",
    "unit_amount":1000,"quantity":1
},{
    "name":"Product B",
    "unit_amount":2000,"quantity":1
}
],"total_amount":3000,"currency":"OMR",
    "success_url":"",
    "cancel_url":"",
    "payment_status":"unpaid",
    "metadata":{
    "option 1":"",
    "option 2":""
},"created_at":"2020-11-11T07:47:38.7032265Z",
    "expire_at":"2020-11-12T07:47:38.6693043Z"
}
}

Get Single Session Details by Reference Number

Get Single Session Details by Reference Number Code Example

Code Example

PHP

												$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://uatcheckout.thawani.om/api/v1/checkout/reference/1234567890",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => [
    "thawani-api-key: rRQ26GcsZzoEhbrP2HZvLYDbn9C9et"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
											

JS

												const settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://uatcheckout.thawani.om/api/v1/checkout/reference/1234567890",
  "method": "GET",
  "headers": {
    "thawani-api-key": "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et"
  }
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
											

PYTHON

												import http.client

conn = http.client.HTTPSConnection("uatcheckout.thawani.om")

payload = ""

headers = {
	'thawani-api-key': "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et"
}

conn.request("GET", "/api/v1/checkout/reference/1234567890", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
											

JAVA

												HttpResponse response = Unirest.get("https://uatcheckout.thawani.om/api/v1/checkout/reference/1234567890")
  .header("thawani-api-key", "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et")
  .asString();
											

HTTP

												GET /api/v1/checkout/reference/1234567890 HTTP/1.1
Thawani-Api-Key: rRQ26GcsZzoEhbrP2HZvLYDbn9C9et
Host: uatcheckout.thawani.om
											

NODEJS

												const http = require("https");

const options = {
  "method": "GET",
  "hostname": "uatcheckout.thawani.om",
  "port": null,
  "path": "/api/v1/checkout/reference/1234567890",
  "headers": {
    "thawani-api-key": "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et",
    "Content-Length": "0"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
											

GO

												package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://uatcheckout.thawani.om/api/v1/checkout/reference/1234567890"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("thawani-api-key", "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
											

CSHARP

												var client = new RestClient("https://uatcheckout.thawani.om/api/v1/checkout/reference/1234567890");
var request = new RestRequest(Method.GET);
request.AddHeader("thawani-api-key", "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et");
IRestResponse response = client.Execute(request);
											

RUBY

												require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://uatcheckout.thawani.om/api/v1/checkout/reference/1234567890")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["thawani-api-key"] = 'rRQ26GcsZzoEhbrP2HZvLYDbn9C9et'

response = http.request(request)
puts response.read_body
											

Get Single Session Details by Receipt Number

Method
HTTP Method Environment
GET UAT

https://uatcheckout.thawani.om/api/v1/checkout/receipt/

GET PRODUCTION

https://checkout.thawani.om/api/v1/checkout/receipt/

Header Parameters
Parameter Description
Secret_key Secret key that obtainable from the merchant portal
Body / Fields
Field Name Required Data Type
receipt_number Yes Numerical

Description: Receipt number that Thawani will generate. Can be found in the merchant portal.

URL Examples
Example Name
Full Session Information by Receipt Request URL

https://uatcheckout.thawani.om/api/v1/checkout/receipt/< receipt-number >

JSON Examples
Example Name
Respond in JSON format

{
    "success":true,"code":2000,"description":"Session retrieved successfully",
    "data":{
    "session_id":"",
    "client_reference_id":"",
    "customer_id":"< your-custommer-id-here >",
    "products":[
    {
    "name":"Product A",
    "unit_amount":1000,"quantity":1
},{
    "name":"Product B",
    "unit_amount":2000,"quantity":1
}
],"total_amount":3000,"currency":"OMR",
    "success_url":"",
    "cancel_url":"",
    "payment_status":"unpaid",
    "metadata":{
    "option 1":"",
    "option 2":""
},"created_at":"2020-11-11T07:47:38.7032265Z",
    "expire_at":"2020-11-12T07:47:38.6693043Z"
}
}

Get Single Session Details by Receipt Number

Get Single Session Details by Receipt Number Code Example

Code Example

PHP

												$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://uatcheckout.thawani.om/api/v1/checkout/receipt/1234567890",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => [
    "thawani-api-key: rRQ26GcsZzoEhbrP2HZvLYDbn9C9et"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
											

JS

												const settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://uatcheckout.thawani.om/api/v1/checkout/receipt/1234567890",
  "method": "GET",
  "headers": {
    "thawani-api-key": "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et"
  }
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
											

PYTHON

												import http.client

conn = http.client.HTTPSConnection("uatcheckout.thawani.om")

payload = ""

headers = {
	'thawani-api-key': "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et"
}

conn.request("GET", "/api/v1/checkout/receipt/1234567890", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
											

JAVA

												HttpResponse response = Unirest.get("https://uatcheckout.thawani.om/api/v1/checkout/receipt/1234567890")
  .header("thawani-api-key", "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et")
  .asString();
											

HTTP

												GET /api/v1/checkout/receipt/1234567890 HTTP/1.1
Thawani-Api-Key: rRQ26GcsZzoEhbrP2HZvLYDbn9C9et
Host: uatcheckout.thawani.om
											

NODEJS

												const http = require("https");

const options = {
  "method": "GET",
  "hostname": "uatcheckout.thawani.om",
  "port": null,
  "path": "/api/v1/checkout/receipt/1234567890",
  "headers": {
    "thawani-api-key": "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et",
    "Content-Length": "0"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
											

GO

												package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://uatcheckout.thawani.om/api/v1/checkout/receipt/1234567890"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("thawani-api-key", "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
											

CSHARP

												var client = new RestClient("https://uatcheckout.thawani.om/api/v1/checkout/receipt/1234567890");
var request = new RestRequest(Method.GET);
request.AddHeader("thawani-api-key", "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et");
IRestResponse response = client.Execute(request);
											

RUBY

												require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://uatcheckout.thawani.om/api/v1/checkout/receipt/1234567890")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["thawani-api-key"] = 'rRQ26GcsZzoEhbrP2HZvLYDbn9C9et'

response = http.request(request)
puts response.read_body
											

Get All Sessions

Method
HTTP Method Environment
GET UAT

https://uatcheckout.thawani.om/api/v1/checkout/session/

GET PRODUCTION

https://checkout.thawani.om/api/v1/checkout/session/

Header Parameters
Parameter Description
Secret_key Secret key that obtainable from the merchant portal
Body / Fields
Field Name Required Data Type
Limit Yes Numerical

Description: Number of records to be returned in descended order.

Skip Yes Numerical

Description: Number of pages to be skipped. It is used for pagination purposes.

URL Examples
Example Name
Full Sessions Information Request URL

https://uatcheckout.thawani.om/api/v1/checkout/session?limit=5&skip=1

Respond

The respond from the endpoint is the same as the get session of a single transaction but this will be in array format.

JSON Examples
Example Name
Respond in JSON format

[
    {
    "success":true,"code":2000,"description":"Session retrieved successfully",
    "data":{
    "session_id":"",
    "client_reference_id":"",
    "customer_id":"< your-custommer-id-here >",
    "products":[
    {
    "name":"Product A",
    "unit_amount":1000,"quantity":1
},{
    "name":"Product B",
    "unit_amount":2000,"quantity":1
}
],"total_amount":3000,"currency":"OMR",
    "success_url":"",
    "cancel_url":"",
    "payment_status":"unpaid",
    "metadata":{
    "option 1":"",
    "option 2":""
},"created_at":"2020-11-11T07:47:38.7032265Z",
    "expire_at":"2020-11-12T07:47:38.6693043Z"
}
},{
    "success":true,"code":2000,"description":"Session retrieved successfully",
    "data":{
    "session_id":"",
    "client_reference_id":"",
    "customer_id":"< your-custommer-id-here >",
    "products":[
    {
    "name":"Product A",
    "unit_amount":1000,"quantity":1
},{
    "name":"Product B",
    "unit_amount":2000,"quantity":1
}
],"total_amount":3000,"currency":"OMR",
    "success_url":"",
    "cancel_url":"",
    "payment_status":"unpaid",
    "metadata":{
    "option 1":"",
    "option 2":""
},"created_at":"2020-11-11T07:47:38.7032265Z",
    "expire_at":"2020-11-12T07:47:38.6693043Z"
}
}
]

Notes
  • Selling Price in Product parameter must be as an Integer value e.g. for ( 0.200 OMR ) you have to input ( 200 ) likewise if you want to request (20/- OMR) you have to input ( 20000 ). Decimals are NOT allowed.
  • Our system will do the calculation for the line total and the overall amount base on the given details in the request.
  • The session will be created to be used once only.
  • Expiry Date will be by default for ONE day only.

Get All Sessions

Get All Sessions Code Example

Code Example

PHP

												$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://uatcheckout.thawani.om/api/v1/checkout/session?limit=5&skip=1",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => [
    "thawani-api-key: rRQ26GcsZzoEhbrP2HZvLYDbn9C9et"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
											

JS

												const settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://uatcheckout.thawani.om/api/v1/checkout/session?limit=5&skip=1",
  "method": "GET",
  "headers": {
    "thawani-api-key": "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et"
  }
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
											

PYTHON

												import http.client

conn = http.client.HTTPSConnection("uatcheckout.thawani.om")

payload = ""

headers = {
    'thawani-api-key': "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et"
}

conn.request("GET", "/api/v1/checkout/session?limit=5&skip=1", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
											

JAVA

												HttpResponse response = Unirest.get("https://uatcheckout.thawani.om/api/v1/checkout/session?limit=5&skip=1")
  .header("thawani-api-key", "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et")
  .asString();
											

HTTP

												GET /api/v1/checkout/session?limit=5&skip=1 HTTP/1.1
Thawani-Api-Key: rRQ26GcsZzoEhbrP2HZvLYDbn9C9et
Host: uatcheckout.thawani.om
											

NODEJS

												const http = require("https");

const options = {
  "method": "GET",
  "hostname": "uatcheckout.thawani.om",
  "port": null,
  "path": "/api/v1/checkout/session?limit=5&skip=1",
  "headers": {
    "thawani-api-key": "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et",
    "Content-Length": "0"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
											

GO

												package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://uatcheckout.thawani.om/api/v1/checkout/session?limit=5&skip=1"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("thawani-api-key", "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
											

CSHARP

												var client = new RestClient("https://uatcheckout.thawani.om/api/v1/checkout/session?limit=5&skip=1");
var request = new RestRequest(Method.GET);
request.AddHeader("thawani-api-key", "rRQ26GcsZzoEhbrP2HZvLYDbn9C9et");
IRestResponse response = client.Execute(request);
											

RUBY

												require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://uatcheckout.thawani.om/api/v1/checkout/session?limit=5&skip=1")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["thawani-api-key"] = 'rRQ26GcsZzoEhbrP2HZvLYDbn9C9et'

response = http.request(request)
puts response.read_body
											

Success Card

Success Card

Images

Success

Preview image description

Success Card Code Example

Decline Card

Decline Card

Images

Decline

Preview image description

Decline Card Code Example

Need some support? We got you covered

Need some support? We got you covered

Need some support? We got you covered Code Example