APIs for Businesses (Test)
Home
Services
  • Checkout / Deeplink
  • Merchant Proxy
Home
Services
  • Checkout / Deeplink
  • Merchant Proxy
Default module
Default module
  1. CHECKOUT/ DEEPLINK
  • CHECKOUT/ DEEPLINK
    • CHECKOUT/ DEEPLINK
      • Overview
      • Webhook
      • Full Example
      • FAQ
      • MOBILE SDKS
        • Flutter SDK
        • iOS SDK
        • Android SDK
      • WEB SDKS
        • Web SDK
      • Transaction Initiation
        POST
      • Transaction Verification
        POST
      • Authorization
        POST
  • test
    • CHECKOUT/ DEEPLINK
      • Overview
      • Webhook
      • Full Example
      • FAQ
      • MOBILE SDKS
        • Flutter SDK
        • iOS SDK
        • Android SDK
      • WEB SDKS
        • Web SDK
      • Transaction Initiation
      • Transaction Verification
      • Authorization
  • Merchant Proxy
    • Merchant Proxy
      • Overview
      • Full Example
      • FAQ
      • Proxy
      • Webhook
      • test
  • Bill24 Proxy
    • Bill24 Proxy
      • Overview
      • Full Example
      • FAQ
      • Test
      • Push Customer
      • Push Bill
      • Get Queue
      • Get Queue Detail
      • Webhook
      • Create Payment
      • Get Payment
  1. CHECKOUT/ DEEPLINK

Full Example

Integration Process

Process flow how to integrate with Bill24 SDKs

Online Payment-For Merchant.jpg


How to get started.

1 Autorization 🔗

In this section, you will initiate an authorization request. Upon successful authorization, Bill24 will provide a token key. This key grants you access to the API.

Sample code for:

C#

// Remember to switch to your live API url in production.
 var client = new RestClient("https://bankapi-demo.bill24.net/security/authorize");
    client.Timeout = -1;
    
// Add request header
var request = new RestRequest(Method.POST);
    request.AddHeader("Accept", "application/json");
    request.AddHeader("Content-Type", "application/json");
    
// Define the body of the request
var body = @"{" + "\n" +
    @"  ""email"": ""demobank@gmail.com""," + "\n" +
    @"  ""password"": ""demobank""," + "\n" +
    @"  ""clientId"": ""bank_client""," + "\n" +
    @"  ""secret"": ""Wuq98rPLwYfvDJ2e""," + "\n" +
    @"  ""refreshToken"": """"" + "\n" +
@"}";
request.AddParameter("application/json", body,  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
PHP
<?php

$curl = curl_init();
// Remember to switch to your live API url in production.
// Define the body of the request
curl_setopt_array($curl, array(
       CURLOPT_URL => 'https://bankapi-demo.bill24.net/security/authorize',
       CURLOPT_RETURNTRANSFER => true,
       CURLOPT_ENCODING => '',
       CURLOPT_MAXREDIRS => 10,
       CURLOPT_TIMEOUT => 0,
       CURLOPT_FOLLOWLOCATION => true,
       CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
       CURLOPT_CUSTOMREQUEST => 'POST',
       CURLOPT_POSTFIELDS =>'{
          "email": "demobank@gmail.com",
          "password": "demobank",
          "clientId": "bank_client",
          "secret": "Wuq98rPLwYfvDJ2e",
          "refreshToken": ""
}',

     CURLOPT_HTTPHEADER => array(
          'Accept: application/json',
          'Content-Type: application/json'
   ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Python
import http.client
import json

# Remember to switch to your live API url in production.
# Change to your credential.
conn = http.client.HTTPSConnection("bankapi-demo.bill24.net")
payload = json.dumps({
   "email": "demobank@gmail.com",
   "password": "demobank",
   "clientId": "bank_client",
   "secret": "Wuq98rPLwYfvDJ2e",
   "refreshToken": ""
})
headers = {
   'Accept': 'application/json',
   'Content-Type': 'application/json'
}
conn.request("POST", "/security/authorize", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Sample response json data.

{
    "issuer": "http://192.168.197.7:40107",
    "token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjZCOUY3RDZBMjA2MTQxQz....",
    //The token will expire in 1 hour.
    "refreshToken": "7DFB50A51E1B2CE420B154DE041FD1D3BC5777C07F43D427D328EB37E9A7C112",
    "tokenExpireTime": "2023-08-24T16:42:21.9110603+07:00",
    "userId": "0b2e17be-d225-4f79-b6a9-98fa811a769c",
    "email": "admin@ubill24.com",
    "fullname": "Administrator",
    "permissions": null,
    "isNeedChangePassword": false,
    "passwordNeverExpire": false,
    "passwordExpireIn": 2147483647,
    "isPasswordExpire": false
}

2 Transaction Initiation 🔗

In this section, you will call Transaction Initiation to get tran_id & payment_link.

Sample code for:

C#

// Remember to switch to your live API url in production.
var client = new RestClient("https://merchantapi-demo.bill24.io/transaction/v2/init");
    client.Timeout = -1;

// Add request header
var request = new RestRequest(Method.POST);
    request.AddHeader("Accept", "application/json");
    request.AddHeader("token", "[token]");
    request.AddHeader("Content-Type", "application/json");

// Provide dynamic `identify_code`
var body = @"{" + "\n" +
    @"   ""identity_code"": ""test001dfdfA""," + "\n" +
    @"  ""purpose_of_transaction"": ""13""," + "\n" +
    @"  ""device_code"": ""1113""," + "\n" +
    @"  ""description"": """"," + "\n" +
    @"  ""currency"": ""KHR""," + "\n" +
    @"  ""amount"": 10000," + "\n" +
    @"  ""language"": ""km""," + "\n" +
    @"  ""cancel_url"": """"," + "\n" +
    @"  ""redirect_url"": ""https://bill24.com.kh/""," + "\n" +
    @"  ""channel_code"": ""CH1""," + "\n" +
    @"  ""user_ref"": ""x111""," + "\n" +
    @"  ""customers"": [" + "\n" +
    @"    {" + "\n" +
    @"      ""branch_code"": ""GB""," + "\n" +
    @"      ""branch_name"": ""BBB""," + "\n" +
    @"      ""customer_code"": ""C01""," + "\n" +
    @"      ""customer_name"": ""BOT""," + "\n" +
    @"      ""customer_name_latin"": ""BOT""," + "\n" +
    @"      ""bill_no"": ""123""," + "\n" +
    @"      ""amount"": 10000" + "\n" +
    @"    }" + "\n" +
    @"]" + "\n" +
@"}";
request.AddParameter("application/json", body,  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

PHP
<?php

<?php

$curl = curl_init();

// Remember to switch to your live API url in production.
// Add request header
// Provide dynamic `identify_code`
curl_setopt_array($curl, array(
   CURLOPT_URL => 'https://merchantapi-demo.bill24.io/transaction/v2/init',
   CURLOPT_RETURNTRANSFER => true,
   CURLOPT_ENCODING => '',
   CURLOPT_MAXREDIRS => 10,
   CURLOPT_TIMEOUT => 0,
   CURLOPT_FOLLOWLOCATION => true,
   CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
   CURLOPT_CUSTOMREQUEST => 'POST',
   CURLOPT_POSTFIELDS =>'{
   "identity_code": "test001dfdfA",
  "purpose_of_transaction": "13",
  "device_code": "1113",
  "description": "",
  "currency": "KHR",
  "amount": 10000,
  "language": "km",
  "cancel_url": "",
  "redirect_url": "https://bill24.com.kh/",
  "channel_code": "CH1",
  "user_ref": "x111",
  "customers": [
    {
      "branch_code": "GB",
      "branch_name": "BBB",
      "customer_code": "C01",
      "customer_name": "BOT",
      "customer_name_latin": "BOT",
      "bill_no": "123",
      "amount": 10000
    }
]
}',
   CURLOPT_HTTPHEADER => array(
      'Accept: application/json',
      'token: [token]',
      'Content-Type: application/json'
   ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


Python
import http.client
import json

# Remember to switch to your live API url in production.
# Define the body of the request
# Provide dynamic `identify_code`
conn = http.client.HTTPSConnection("merchantapi-demo.bill24.io")
payload = json.dumps({
   "identity_code": "test001dfdfA",
   "purpose_of_transaction": "13",
   "device_code": "1113",
   "description": "",
   "currency": "KHR",
   "amount": 10000,
   "language": "km",
   "cancel_url": "",
   "redirect_url": "https://bill24.com.kh/",
   "channel_code": "CH1",
   "user_ref": "x111",
   "customers": [
      {
         "branch_code": "GB",
         "branch_name": "BBB",
         "customer_code": "C01",
         "customer_name": "BOT",
         "customer_name_latin": "BOT",
         "bill_no": "123",
         "amount": 10000
      }
   ]
})
headers = {
   'Accept': 'application/json',
   'token': '[token]',
   'Content-Type': 'application/json'
}
conn.request("POST", "/transaction/v2/init", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Sample response json data.

{
    "code": "SUCCESS",
    "message": "Transaction init successful",
    "message_kh": "បង្កើតប្រតិបត្តិការជោគជ័យ",
    "data": {
        "tran_id": "7B9807BB3854",
        "identity_code": "test001dfdfA",
        "payment_link": "https://checkout-demo.bill24.io/checkout/7B9807BB3854",
        "khqr_string": "00020101021230400016amkbkhppxxx@amkb010477770208TESTKHQR..."
    }
}

3 Transaction Verification 🔗

In this section, you will call Transaction Verification to verify payment status.

Sample code for:

C#

// Remember to switch to your live API url in production.
var client = new RestClient("https://merchantapi-demo.bill24.io/transaction/v2/verify");
    client.Timeout = -1;

// Add request header
var request = new RestRequest(Method.POST);
    request.AddHeader("Accept", "application/json");
    request.AddHeader("Authorization", "Bearer [your token]");
    request.AddHeader("Content-Type", "application/json");

// Define the body of the request
var body = @"{" + "\n" +
    @"  ""identity_code"": ""0000012""," + "\n" +
    @"  ""purpose_of_transaction"": ""INV0000012""," + "\n" +
    @"  ""tran_id"": """"," + "\n" +
    @"  ""bank_ref"": """"" + "\n" +
@"}";

request.AddParameter("application/json", body,  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
PHP
<?php

$curl = curl_init();

// Remember to switch to your live API url in production.
// Add request header
// Define the body of the request
curl_setopt_array($curl, array(
   CURLOPT_URL => 'https://merchantapi-demo.bill24.io/transaction/v2/verify',
   CURLOPT_RETURNTRANSFER => true,
   CURLOPT_ENCODING => '',
   CURLOPT_MAXREDIRS => 10,
   CURLOPT_TIMEOUT => 0,
   CURLOPT_FOLLOWLOCATION => true,
   CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
   CURLOPT_CUSTOMREQUEST => 'POST',
   CURLOPT_POSTFIELDS =>'{
  "identity_code": "0000012",
  "purpose_of_transaction": "INV0000012",
  "tran_id": "",
  "bank_ref": ""
}',
   CURLOPT_HTTPHEADER => array(
      'Accept: application/json',
      'Authorization: Bearer [your token]',
      'Content-Type: application/json'
   ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


Python
import http.client
import json

# Remember to switch to your live API url in production.
# Add request header
# Define the body of the request
conn = http.client.HTTPSConnection("merchantapi-demo.bill24.io")
payload = json.dumps({
   "identity_code": "0000012",
   "purpose_of_transaction": "INV0000012",
   "tran_id": "",
   "bank_ref": ""
})
headers = {
   'Accept': 'application/json',
   'Authorization': 'Bearer [your token]',
   'Content-Type': 'application/json'
}
conn.request("POST", "/transaction/v2/verify", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Sample response json data.

{
    "code": "SUCCESS",
    "message": "Transaction found",
    "message_kh": "ប្រតិបត្តិការបានរកឃើញ",
    "data": {
        "device_code": "1113",
        "channel_code": "CH1",
        "customers": [
            {
                "branch_code": "GB",
                "branch_name": "BBB",
                "customer_code": "C01",
                "customer_name": "BOT",
                "customer_name_latin": "BOT",
                "bill_no": "123",
                "amount": 10000
            }
        ],
        "tran_id": "5DD2B215208D",
        "tran_date": "2023-12-27T17:09:50.253174",
        "tran_amount": 10000,
        "fee_amount": 800,
        "total_amount": 10800,
        "currency": "KHR",
        "identity_code": "0000012",
        "bank_code": "",
        "bank_ref": "",
        "purpose_of_transaction": "INV0000012",
        "status": "pending",
        "description": ""
    }
}

Modified at 2024-01-17 04:50:58
Previous
Webhook
Next
FAQ