Appendix 5
Generate Message
- Java
- PHP
- Node.js
- .Net
- Python
- Request
- Response
Step 1 : Sample Data Fields
Construct the data fields for the message.
Please refer to Notification Parameters for details of each field.
- Ensure
itemGivenIdandmrnare padded with spaces or 0 to meet the required fixed length.
String mti = "0025";
String resultCode = "00000";
String amount = "000000000200";
String itemGivenId = " ABCXYZ123"; // padded
String mid = "000010000012345";
String mrn = " 20251124014201000123456"; // padded
String paymentType = "PRE";
String paymentMethod = "01";
String approvalCode = "123456";
Step 2 : Combine Fields
Combine all the fields into a single variable as the data.
String data
= mti
+ resultCode
+ amount
+ itemGivenId
+ mid
+ mrn
+ paymentType
+ paymentMethod
+ approvalCode;
Step 1 : Sample Data Fields
Construct the data fields for the message.
Please refer to Notification Parameters for details of each field.
- Ensure
itemGivenIdandmrnare padded with spaces or 0 to meet the required fixed length.
Construct the data fields for the message.
String mti = "0026";
String resultCode = "00000";
Step 2 : Combine Fields
Combine all the fields into a single variable as the data.
String data
= mti
+ resultCode;
Step 3 : Generate Checksum
Pass the data created into a Checksum function to verify for errors.
public static String calculateXorChecksum(String input) {
int xor = 0;
for (int i = 0; i < input.length(); i++) {
xor ^= input.charAt(i); // XOR ASCII values
}
return String.format("%02X", xor & 0xFF); // 2-digit HEX
}
Step 4 : Build Message
The message should be constructed as:
STX + DATA + CHECKSUM + ETX
STX (Start of Text) and ETX (End of Text) are special characters used to mark:
STX: the start of the messageETX: the end of the message
String checksum = calculateXorChecksum(data);
String message = "\u0002" + data + checksum + "\u0003";
- Request
- Response
Step 1 : Sample Data Fields
Construct the data fields for the message.
Please refer to Notification Parameters for details of each field.
- Ensure
itemGivenIdandmrnare padded with spaces or 0 to meet the required fixed length.
Construct the data fields for the message.
$mti = "0025";
$resultCode = "00000";
$amount = "000000000200";
$itemGivenId = " ABCXYZ123"; // padded
$mid = "000010000012345";
$mrn = " 20251124014201000123456"; // padded
$paymentType = "PRE";
$paymentMethod = "01";
$approvalCode = "123456";
Step 2 : Combine Fields
Combine all the fields into a single variable as the data.
$data =
$mti
. $resultCode
. $amount
. $itemGivenId
. $mid
. $mrn
. $paymentType
. $paymentMethod
. $approvalCode;
Step 1 : Sample Data Fields
Construct the data fields for the message.
Please refer to Notification Parameters for details of each field.
- Ensure
itemGivenIdandmrnare padded with spaces or 0 to meet the required fixed length.
Construct the data fields for the message.
$mti = "0026";
$resultCode = "00000";
Step 2 : Combine Fields
Combine all the fields into a single variable as the data.
$data =
$mti
. $resultCode;
Step 3 : Generate Checksum
Pass the data created into a Checksum function to verify for errors.
function calculateXorChecksum($input) {
$xor = 0;
// Loop through each character
for ($i = 0; $i < strlen($input); $i++) {
$xor ^= ord($input[$i]); // XOR ASCII values
}
return strtoupper(str_pad(dechex($xor & 0xFF), 2, "0", STR_PAD_LEFT));
}
Step 4 : Build Message
The message should be constructed as:
STX + DATA + CHECKSUM + ETX
STX (Start of Text) and ETX (End of Text) are special characters used to mark:
STX: the start of the messageETX: the end of the message
$checksum = calculateXorChecksum($data);
$message = "\x02" . $data . $checksum . "\x03";
- Request
- Response
Step 1 : Sample Data Fields
Construct the data fields for the message.
Please refer to Notification Parameters for details of each field.
- Ensure
itemGivenIdandmrnare padded with spaces or 0 to meet the required fixed length.
Construct the data fields for the message.
const mti = "0025";
const resultCode = "00000";
const amount = "000000000200";
const itemGivenId = " ABCXYZ123"; // padded
const mid = "000010000012345";
const mrn = " 20251124014201000123456"; // padded
const paymentType = "PRE";
const paymentMethod = "01";
const approvalCode = "123456";
Step 2 : Combine Fields
Combine all the fields into a single variable as the data.
const data =
mti +
resultCode +
amount +
itemGivenId +
mid +
mrn +
paymentType +
paymentMethod +
approvalCode;
Step 1 : Sample Data Fields
Construct the data fields for the message.
Please refer to Notification Parameters for details of each field.
- Ensure
itemGivenIdandmrnare padded with spaces or 0 to meet the required fixed length.
Construct the data fields for the message.
const mti = "0026";
const resultCode = "00000";
Step 2 : Combine Fields
Combine all the fields into a single variable as the data.
const data =
mti +
resultCode;
Step 3 : Generate Checksum
Pass the data created into a Checksum function to verify for errors.
function calculateXorChecksum(input) {
let xor = 0;
for (let i = 0; i < input.length; i++) {
xor ^= input.charCodeAt(i); // XOR ASCII values
}
return xor.toString(16).toUpperCase().padStart(2, "0");
}
Step 4 : Build Message
The message should be constructed as:
STX + DATA + CHECKSUM + ETX
STX (Start of Text) and ETX (End of Text) are special characters used to mark:
STX: the start of the messageETX: the end of the message
const checksum = calculateXorChecksum(data);
const STX = String.fromCharCode(0x02);
const ETX = String.fromCharCode(0x03);
const message = STX + data + checksum + ETX;
- Request
- Response
Step 1 : Sample Data Fields
Construct the data fields for the message.
Please refer to Notification Parameters for details of each field.
- Ensure
itemGivenIdandmrnare padded with spaces or 0 to meet the required fixed length.
Construct the data fields for the message.
string mti = "0025";
string resultCode = "00000";
string amount = "000000000200";
string itemGivenId = " ABCXYZ123"; // padded
string mid = "000010000012345";
string mrn = " 20251124014201000123456"; // padded
string paymentType = "PRE";
string paymentMethod = "01";
string approvalCode = "123456";
Step 2 : Combine Fields
Combine all the fields into a single variable as the data.
string data =
mti +
resultCode +
amount +
itemGivenId +
mid +
mrn +
paymentType +
paymentMethod +
approvalCode;
Step 1 : Sample Data Fields
Construct the data fields for the message.
Please refer to Notification Parameters for details of each field.
- Ensure
itemGivenIdandmrnare padded with spaces or 0 to meet the required fixed length.
Construct the data fields for the message.
string mti = "0026";
string resultCode = "00000";
Step 2 : Combine Fields
Combine all the fields into a single variable as the data.
string data =
mti +
resultCode;
Step 3 : Generate Checksum
Pass the data created into a Checksum function to verify for errors.
static string CalculateXorChecksum(string input)
{
int xor = 0;
foreach (char c in input)
{
xor ^= (int)c; // XOR ASCII values
}
return xor.ToString("X2"); // 2-digit uppercase hex
}
Step 4 : Build Message
The message should be constructed as:
STX + DATA + CHECKSUM + ETX
STX (Start of Text) and ETX (End of Text) are special characters used to mark:
STX: the start of the messageETX: the end of the message
string checksum = CalculateXorChecksum(data);
char STX = (char)0x02;
char ETX = (char)0x03;
string message = STX + data + checksum + ETX;
- Request
- Response
Step 1 : Sample Data Fields
Construct the data fields for the message.
Please refer to Notification Parameters for details of each field.
- Ensure
itemGivenIdandmrnare padded with spaces or 0 to meet the required fixed length.
Construct the data fields for the message.
mti = "0025"
resultCode = "00000"
amount = "000000000200"
itemGivenId = " ABCXYZ123" # padded
mid = "000010000012345"
mrn = " 20251124014201000123456" # padded
paymentType = "PRE"
paymentMethod = "01"
approvalCode = "123456"
Step 2 : Combine Fields
Combine all the fields into a single variable as the data.
data = (
mti
+ resultCode
+ amount
+ itemGivenId
+ mid
+ mrn
+ paymentType
+ paymentMethod
+ approvalCode
)
Step 1 : Sample Data Fields
Construct the data fields for the message.
Please refer to Notification Parameters for details of each field.
- Ensure
itemGivenIdandmrnare padded with spaces or 0 to meet the required fixed length.
Construct the data fields for the message.
mti = "0026"
resultCode = "00000"
Step 2 : Combine Fields
Combine all the fields into a single variable as the data.
data = (
mti
+ resultCode
)
Step 3 : Generate Checksum
Pass the data created into a Checksum function to verify for errors.
def calculate_xor_checksum(input_str):
xor = 0
for ch in input_str:
xor ^= ord(ch) # XOR ASCII values
return f"{xor:02X}" # 2-digit uppercase hex
Step 4 : Build Message
The message should be constructed as:
STX + DATA + CHECKSUM + ETX
STX (Start of Text) and ETX (End of Text) are special characters used to mark:
STX: the start of the messageETX: the end of the message
checksum = calculate_xor_checksum(data)
STX = chr(0x02)
ETX = chr(0x03)
message = STX + data + checksum + ETX