curl --request POST \
--url https://staging-payments.commerce.asia/api/services/app/PaymentGateway/InitialSession \
--header 'Abp-TenantId: <abp-tenantid>' \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--header 'cap-signature: <cap-signature>' \
--data '
{
"currencyCode": "MYR",
"amount": 100,
"referenceCode": "<string>",
"ipAddress": "<string>",
"returnUrl": "https://returnurl.com/",
"timestamp": 1621851652617,
"description": "Order details",
"userAgent": "<string>",
"callbackUrl": "https://callback.com/",
"Customer": {
"email": "email@gmail.com",
"mobileNo": "0123456789",
"name": "name",
"username": "username",
"identificationNumber": "<string>"
},
"SubMerchant": {
"uniqueId": "<string>",
"name": "<string>"
},
"PlatformCharge": {
"partnerId": "<string>",
"amount": 123
},
"virtualAccountCode": "<string>",
"RequestPaymentExtraInfo": {
"ChannelGroupId": 123,
"HiddenChannel": [
0
],
"WhitelistChannelGroup": [
123
],
"WhitelistChannel": [
123
]
},
"expiredInMinutes": 30,
"tenantId": 123
}
'import requests
url = "https://staging-payments.commerce.asia/api/services/app/PaymentGateway/InitialSession"
payload = {
"currencyCode": "MYR",
"amount": 100,
"referenceCode": "<string>",
"ipAddress": "<string>",
"returnUrl": "https://returnurl.com/",
"timestamp": 1621851652617,
"description": "Order details",
"userAgent": "<string>",
"callbackUrl": "https://callback.com/",
"Customer": {
"email": "email@gmail.com",
"mobileNo": "0123456789",
"name": "name",
"username": "username",
"identificationNumber": "<string>"
},
"SubMerchant": {
"uniqueId": "<string>",
"name": "<string>"
},
"PlatformCharge": {
"partnerId": "<string>",
"amount": 123
},
"virtualAccountCode": "<string>",
"RequestPaymentExtraInfo": {
"ChannelGroupId": 123,
"HiddenChannel": [0],
"WhitelistChannelGroup": [123],
"WhitelistChannel": [123]
},
"expiredInMinutes": 30,
"tenantId": 123
}
headers = {
"Abp-TenantId": "<abp-tenantid>",
"Authorization": "<authorization>",
"cap-signature": "<cap-signature>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Abp-TenantId': '<abp-tenantid>',
Authorization: '<authorization>',
'cap-signature': '<cap-signature>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
currencyCode: 'MYR',
amount: 100,
referenceCode: '<string>',
ipAddress: '<string>',
returnUrl: 'https://returnurl.com/',
timestamp: 1621851652617,
description: 'Order details',
userAgent: '<string>',
callbackUrl: 'https://callback.com/',
Customer: {
email: 'email@gmail.com',
mobileNo: '0123456789',
name: 'name',
username: 'username',
identificationNumber: '<string>'
},
SubMerchant: {uniqueId: '<string>', name: '<string>'},
PlatformCharge: {partnerId: '<string>', amount: 123},
virtualAccountCode: '<string>',
RequestPaymentExtraInfo: {
ChannelGroupId: 123,
HiddenChannel: [0],
WhitelistChannelGroup: [123],
WhitelistChannel: [123]
},
expiredInMinutes: 30,
tenantId: 123
})
};
fetch('https://staging-payments.commerce.asia/api/services/app/PaymentGateway/InitialSession', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://staging-payments.commerce.asia/api/services/app/PaymentGateway/InitialSession",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'currencyCode' => 'MYR',
'amount' => 100,
'referenceCode' => '<string>',
'ipAddress' => '<string>',
'returnUrl' => 'https://returnurl.com/',
'timestamp' => 1621851652617,
'description' => 'Order details',
'userAgent' => '<string>',
'callbackUrl' => 'https://callback.com/',
'Customer' => [
'email' => 'email@gmail.com',
'mobileNo' => '0123456789',
'name' => 'name',
'username' => 'username',
'identificationNumber' => '<string>'
],
'SubMerchant' => [
'uniqueId' => '<string>',
'name' => '<string>'
],
'PlatformCharge' => [
'partnerId' => '<string>',
'amount' => 123
],
'virtualAccountCode' => '<string>',
'RequestPaymentExtraInfo' => [
'ChannelGroupId' => 123,
'HiddenChannel' => [
0
],
'WhitelistChannelGroup' => [
123
],
'WhitelistChannel' => [
123
]
],
'expiredInMinutes' => 30,
'tenantId' => 123
]),
CURLOPT_HTTPHEADER => [
"Abp-TenantId: <abp-tenantid>",
"Authorization: <authorization>",
"Content-Type: application/json",
"cap-signature: <cap-signature>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://staging-payments.commerce.asia/api/services/app/PaymentGateway/InitialSession"
payload := strings.NewReader("{\n \"currencyCode\": \"MYR\",\n \"amount\": 100,\n \"referenceCode\": \"<string>\",\n \"ipAddress\": \"<string>\",\n \"returnUrl\": \"https://returnurl.com/\",\n \"timestamp\": 1621851652617,\n \"description\": \"Order details\",\n \"userAgent\": \"<string>\",\n \"callbackUrl\": \"https://callback.com/\",\n \"Customer\": {\n \"email\": \"email@gmail.com\",\n \"mobileNo\": \"0123456789\",\n \"name\": \"name\",\n \"username\": \"username\",\n \"identificationNumber\": \"<string>\"\n },\n \"SubMerchant\": {\n \"uniqueId\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"PlatformCharge\": {\n \"partnerId\": \"<string>\",\n \"amount\": 123\n },\n \"virtualAccountCode\": \"<string>\",\n \"RequestPaymentExtraInfo\": {\n \"ChannelGroupId\": 123,\n \"HiddenChannel\": [\n 0\n ],\n \"WhitelistChannelGroup\": [\n 123\n ],\n \"WhitelistChannel\": [\n 123\n ]\n },\n \"expiredInMinutes\": 30,\n \"tenantId\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Abp-TenantId", "<abp-tenantid>")
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("cap-signature", "<cap-signature>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://staging-payments.commerce.asia/api/services/app/PaymentGateway/InitialSession")
.header("Abp-TenantId", "<abp-tenantid>")
.header("Authorization", "<authorization>")
.header("cap-signature", "<cap-signature>")
.header("Content-Type", "application/json")
.body("{\n \"currencyCode\": \"MYR\",\n \"amount\": 100,\n \"referenceCode\": \"<string>\",\n \"ipAddress\": \"<string>\",\n \"returnUrl\": \"https://returnurl.com/\",\n \"timestamp\": 1621851652617,\n \"description\": \"Order details\",\n \"userAgent\": \"<string>\",\n \"callbackUrl\": \"https://callback.com/\",\n \"Customer\": {\n \"email\": \"email@gmail.com\",\n \"mobileNo\": \"0123456789\",\n \"name\": \"name\",\n \"username\": \"username\",\n \"identificationNumber\": \"<string>\"\n },\n \"SubMerchant\": {\n \"uniqueId\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"PlatformCharge\": {\n \"partnerId\": \"<string>\",\n \"amount\": 123\n },\n \"virtualAccountCode\": \"<string>\",\n \"RequestPaymentExtraInfo\": {\n \"ChannelGroupId\": 123,\n \"HiddenChannel\": [\n 0\n ],\n \"WhitelistChannelGroup\": [\n 123\n ],\n \"WhitelistChannel\": [\n 123\n ]\n },\n \"expiredInMinutes\": 30,\n \"tenantId\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://staging-payments.commerce.asia/api/services/app/PaymentGateway/InitialSession")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Abp-TenantId"] = '<abp-tenantid>'
request["Authorization"] = '<authorization>'
request["cap-signature"] = '<cap-signature>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"currencyCode\": \"MYR\",\n \"amount\": 100,\n \"referenceCode\": \"<string>\",\n \"ipAddress\": \"<string>\",\n \"returnUrl\": \"https://returnurl.com/\",\n \"timestamp\": 1621851652617,\n \"description\": \"Order details\",\n \"userAgent\": \"<string>\",\n \"callbackUrl\": \"https://callback.com/\",\n \"Customer\": {\n \"email\": \"email@gmail.com\",\n \"mobileNo\": \"0123456789\",\n \"name\": \"name\",\n \"username\": \"username\",\n \"identificationNumber\": \"<string>\"\n },\n \"SubMerchant\": {\n \"uniqueId\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"PlatformCharge\": {\n \"partnerId\": \"<string>\",\n \"amount\": 123\n },\n \"virtualAccountCode\": \"<string>\",\n \"RequestPaymentExtraInfo\": {\n \"ChannelGroupId\": 123,\n \"HiddenChannel\": [\n 0\n ],\n \"WhitelistChannelGroup\": [\n 123\n ],\n \"WhitelistChannel\": [\n 123\n ]\n },\n \"expiredInMinutes\": 30,\n \"tenantId\": 123\n}"
response = http.request(request)
puts response.read_body{
"redirectionType": 1,
"redirectUrl": "string",
"sessionNumber": "string"
}Hosted Session Checkout
Payment gateway hosted session checkout.
The following input parameters are expected to be provided by the merchant to initiate a hosted checkout session. Unlike Direct Integration, this endpoint does not take a channelId — the customer selects their own payment method on CommercePay’s hosted payment page.
curl --request POST \
--url https://staging-payments.commerce.asia/api/services/app/PaymentGateway/InitialSession \
--header 'Abp-TenantId: <abp-tenantid>' \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--header 'cap-signature: <cap-signature>' \
--data '
{
"currencyCode": "MYR",
"amount": 100,
"referenceCode": "<string>",
"ipAddress": "<string>",
"returnUrl": "https://returnurl.com/",
"timestamp": 1621851652617,
"description": "Order details",
"userAgent": "<string>",
"callbackUrl": "https://callback.com/",
"Customer": {
"email": "email@gmail.com",
"mobileNo": "0123456789",
"name": "name",
"username": "username",
"identificationNumber": "<string>"
},
"SubMerchant": {
"uniqueId": "<string>",
"name": "<string>"
},
"PlatformCharge": {
"partnerId": "<string>",
"amount": 123
},
"virtualAccountCode": "<string>",
"RequestPaymentExtraInfo": {
"ChannelGroupId": 123,
"HiddenChannel": [
0
],
"WhitelistChannelGroup": [
123
],
"WhitelistChannel": [
123
]
},
"expiredInMinutes": 30,
"tenantId": 123
}
'import requests
url = "https://staging-payments.commerce.asia/api/services/app/PaymentGateway/InitialSession"
payload = {
"currencyCode": "MYR",
"amount": 100,
"referenceCode": "<string>",
"ipAddress": "<string>",
"returnUrl": "https://returnurl.com/",
"timestamp": 1621851652617,
"description": "Order details",
"userAgent": "<string>",
"callbackUrl": "https://callback.com/",
"Customer": {
"email": "email@gmail.com",
"mobileNo": "0123456789",
"name": "name",
"username": "username",
"identificationNumber": "<string>"
},
"SubMerchant": {
"uniqueId": "<string>",
"name": "<string>"
},
"PlatformCharge": {
"partnerId": "<string>",
"amount": 123
},
"virtualAccountCode": "<string>",
"RequestPaymentExtraInfo": {
"ChannelGroupId": 123,
"HiddenChannel": [0],
"WhitelistChannelGroup": [123],
"WhitelistChannel": [123]
},
"expiredInMinutes": 30,
"tenantId": 123
}
headers = {
"Abp-TenantId": "<abp-tenantid>",
"Authorization": "<authorization>",
"cap-signature": "<cap-signature>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Abp-TenantId': '<abp-tenantid>',
Authorization: '<authorization>',
'cap-signature': '<cap-signature>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
currencyCode: 'MYR',
amount: 100,
referenceCode: '<string>',
ipAddress: '<string>',
returnUrl: 'https://returnurl.com/',
timestamp: 1621851652617,
description: 'Order details',
userAgent: '<string>',
callbackUrl: 'https://callback.com/',
Customer: {
email: 'email@gmail.com',
mobileNo: '0123456789',
name: 'name',
username: 'username',
identificationNumber: '<string>'
},
SubMerchant: {uniqueId: '<string>', name: '<string>'},
PlatformCharge: {partnerId: '<string>', amount: 123},
virtualAccountCode: '<string>',
RequestPaymentExtraInfo: {
ChannelGroupId: 123,
HiddenChannel: [0],
WhitelistChannelGroup: [123],
WhitelistChannel: [123]
},
expiredInMinutes: 30,
tenantId: 123
})
};
fetch('https://staging-payments.commerce.asia/api/services/app/PaymentGateway/InitialSession', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://staging-payments.commerce.asia/api/services/app/PaymentGateway/InitialSession",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'currencyCode' => 'MYR',
'amount' => 100,
'referenceCode' => '<string>',
'ipAddress' => '<string>',
'returnUrl' => 'https://returnurl.com/',
'timestamp' => 1621851652617,
'description' => 'Order details',
'userAgent' => '<string>',
'callbackUrl' => 'https://callback.com/',
'Customer' => [
'email' => 'email@gmail.com',
'mobileNo' => '0123456789',
'name' => 'name',
'username' => 'username',
'identificationNumber' => '<string>'
],
'SubMerchant' => [
'uniqueId' => '<string>',
'name' => '<string>'
],
'PlatformCharge' => [
'partnerId' => '<string>',
'amount' => 123
],
'virtualAccountCode' => '<string>',
'RequestPaymentExtraInfo' => [
'ChannelGroupId' => 123,
'HiddenChannel' => [
0
],
'WhitelistChannelGroup' => [
123
],
'WhitelistChannel' => [
123
]
],
'expiredInMinutes' => 30,
'tenantId' => 123
]),
CURLOPT_HTTPHEADER => [
"Abp-TenantId: <abp-tenantid>",
"Authorization: <authorization>",
"Content-Type: application/json",
"cap-signature: <cap-signature>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://staging-payments.commerce.asia/api/services/app/PaymentGateway/InitialSession"
payload := strings.NewReader("{\n \"currencyCode\": \"MYR\",\n \"amount\": 100,\n \"referenceCode\": \"<string>\",\n \"ipAddress\": \"<string>\",\n \"returnUrl\": \"https://returnurl.com/\",\n \"timestamp\": 1621851652617,\n \"description\": \"Order details\",\n \"userAgent\": \"<string>\",\n \"callbackUrl\": \"https://callback.com/\",\n \"Customer\": {\n \"email\": \"email@gmail.com\",\n \"mobileNo\": \"0123456789\",\n \"name\": \"name\",\n \"username\": \"username\",\n \"identificationNumber\": \"<string>\"\n },\n \"SubMerchant\": {\n \"uniqueId\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"PlatformCharge\": {\n \"partnerId\": \"<string>\",\n \"amount\": 123\n },\n \"virtualAccountCode\": \"<string>\",\n \"RequestPaymentExtraInfo\": {\n \"ChannelGroupId\": 123,\n \"HiddenChannel\": [\n 0\n ],\n \"WhitelistChannelGroup\": [\n 123\n ],\n \"WhitelistChannel\": [\n 123\n ]\n },\n \"expiredInMinutes\": 30,\n \"tenantId\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Abp-TenantId", "<abp-tenantid>")
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("cap-signature", "<cap-signature>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://staging-payments.commerce.asia/api/services/app/PaymentGateway/InitialSession")
.header("Abp-TenantId", "<abp-tenantid>")
.header("Authorization", "<authorization>")
.header("cap-signature", "<cap-signature>")
.header("Content-Type", "application/json")
.body("{\n \"currencyCode\": \"MYR\",\n \"amount\": 100,\n \"referenceCode\": \"<string>\",\n \"ipAddress\": \"<string>\",\n \"returnUrl\": \"https://returnurl.com/\",\n \"timestamp\": 1621851652617,\n \"description\": \"Order details\",\n \"userAgent\": \"<string>\",\n \"callbackUrl\": \"https://callback.com/\",\n \"Customer\": {\n \"email\": \"email@gmail.com\",\n \"mobileNo\": \"0123456789\",\n \"name\": \"name\",\n \"username\": \"username\",\n \"identificationNumber\": \"<string>\"\n },\n \"SubMerchant\": {\n \"uniqueId\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"PlatformCharge\": {\n \"partnerId\": \"<string>\",\n \"amount\": 123\n },\n \"virtualAccountCode\": \"<string>\",\n \"RequestPaymentExtraInfo\": {\n \"ChannelGroupId\": 123,\n \"HiddenChannel\": [\n 0\n ],\n \"WhitelistChannelGroup\": [\n 123\n ],\n \"WhitelistChannel\": [\n 123\n ]\n },\n \"expiredInMinutes\": 30,\n \"tenantId\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://staging-payments.commerce.asia/api/services/app/PaymentGateway/InitialSession")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Abp-TenantId"] = '<abp-tenantid>'
request["Authorization"] = '<authorization>'
request["cap-signature"] = '<cap-signature>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"currencyCode\": \"MYR\",\n \"amount\": 100,\n \"referenceCode\": \"<string>\",\n \"ipAddress\": \"<string>\",\n \"returnUrl\": \"https://returnurl.com/\",\n \"timestamp\": 1621851652617,\n \"description\": \"Order details\",\n \"userAgent\": \"<string>\",\n \"callbackUrl\": \"https://callback.com/\",\n \"Customer\": {\n \"email\": \"email@gmail.com\",\n \"mobileNo\": \"0123456789\",\n \"name\": \"name\",\n \"username\": \"username\",\n \"identificationNumber\": \"<string>\"\n },\n \"SubMerchant\": {\n \"uniqueId\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"PlatformCharge\": {\n \"partnerId\": \"<string>\",\n \"amount\": 123\n },\n \"virtualAccountCode\": \"<string>\",\n \"RequestPaymentExtraInfo\": {\n \"ChannelGroupId\": 123,\n \"HiddenChannel\": [\n 0\n ],\n \"WhitelistChannelGroup\": [\n 123\n ],\n \"WhitelistChannel\": [\n 123\n ]\n },\n \"expiredInMinutes\": 30,\n \"tenantId\": 123\n}"
response = http.request(request)
puts response.read_body{
"redirectionType": 1,
"redirectUrl": "string",
"sessionNumber": "string"
}Headers
Your unique Merchant ID assigned by CommercePay.
Your API credentials used for authentication (typically a Bearer token).
A unique security hash used to verify the integrity of the request body. See Generate Signature for how to generate this.
Body
Currency code with a 3-letter ISO 4217 standard code
3"MYR"
Please take note: The Amount parameter only accepts integer units. For example, 1000 is equivalent to 10.00 for the backend.
Invalid Format: 1,000.00
100
Merchant Reference Code
50Customer’s IP address captured by the merchant system
50Return URL supplied by the merchant server for the payment response and used by CommercePay to redirect the customer's browser back to the desired page on the Merchant’s site
500"https://returnurl.com/"
new Date().getTime()
1621851652617
Transaction Description
100"Order details"
[Conditional] Customer’s user agent. It is recommended to input for a better user experience for specific channels due to different platforms such as desktop, mobile, or app view. Example channels impact: ShopeePay
200Callback URL is host-to-host communication. CommercePay sends the transaction response to the merchant callback server based on the callback URL given. If the URL is provided, the callback will be triggered; otherwise, it would not trigger. Refer to the Merchant Callback URL to know more
500"https://callback.com/"
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Optional: Only Authorized Partners by CommercePay are allowed to charge platform fees to the merchant
Show child attributes
Show child attributes
Code to identify virtual account to make payment.
30[Optional]
Show child attributes
Show child attributes
Set the session expired in minutes
30
Fill in tenant id
