# Request
<form method="POST" action="https://testpay.directpay.lk/">
<label>Type</label>
<input type="text" name="_type" id="_type" value="ONE_TIME">
<label>Merchant Id</label>
<input type="hidden" name="_mId" id="_mId" value="xxxxxxxx">
<label>Amount</label>
<input type="text" name="_amount" id="_amount" value="100.00">
<label>First Name</label>
<input type="text" name="_firstName" id="_firstName" value="john">
<label>Last name</label>
<input type="text" name="_lastName" id="_lastName" value="doe">
<label>Email</label>
<input type="text" name="_email" id="_email" value="abc@mail.com">
<label>Referance</label>
<input type="text" name="_reference" id="_reference" value="ref1234">
<label>Description</label>
<input type="text" name="_description" id="_description" value="My Product">
<label>Return Url</label>
<input type="hidden" name="_returnUrl" id="_returnUrl" value="https://test.com">
<label>Cancel Url</label>
<input type="hidden" name="_cancelUrl" id="_cancelUrl" value="https://test.com">
<label>Response Url</label>
<input type="hidden" name="_responseUrl" id="_responseUrl" value="https://test.com">
<label>Currency</label>
<input type="text" name="_currency" id="_currency" value="LKR">
<label>Order Id</label>
<input type="text" name="_orderId" id="_orderId" value="1234">
<label>Plugin Version</label>
<input type="hidden" name="_pluginVersion" id="_pluginVersion" value="1.0">
<label>Plugin Name</label>
<input type="hidden" name="_pluginName" id="_pluginName" value="CUSTOM">
<label>Api Key</label>
<input type="hidden" name="api_key" id="api_key" value="12312321">
<input type="hidden" name="signature" id="signature" value="jb231j3b2jbj2cbjeh">
<button type="submit" >Pay</button>
</form>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Parameter
Field | Type | Description | Allow values |
---|---|---|---|
_amount | Decimal | Transaction amount. | |
_currency | String | Currency code | LKR, USD |
# Response
BrowserRedirectResponse
http://response.com?orderId=DP12355&trnId=935&status=SUCCESS&desc=Approved&type=ONE_TIME
1
ServerResponse
{
"type": "ONE_TIME",
"orderId": "DP12355",
"trnId": 935,
"status": "SUCCESS",
"desc": "Approved",
"signature": "nOaZaqtRdvozz6bcDkw4brFVb8gQ2TPxXDGA1FEboX5shYNTJgMVfsK0icGgmixJO7YpWDOls8aLwlP7V6XsmhHd3ISEbPXB8oySq/5DyrS3bQw2tjuGq/Z35MJIw/4oLY+UwuFb43pw9rmQzvzSxciQ9ATHbjhCWqDOQ0ZF2D1i+oZv34i6xsXgS3VOCuUtgUnLfQBFxhVu/xcTxtQcCA9hLpXpKQA+QyvuVyyfD5JQTmfsSv/EZElic8F8YqN5WrxBQRxsppniUSPKoJgJLahVswyYCMg3MHSsefYPJiWilhnsZlOl1bcx6bSujWfm93acHBao+l/3KZUeouunYQ=="
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
- PHP
# Signature generate
<?php
$dataString = $merchant . $amount . $currency . $pluginName . $pluginVersion . $returnUrl . $cancelUrl . $orderId .
$reference . $firstName . $lastName . $email . $description . $apiKey . $responseUrl;
$pkeyid = openssl_get_privatekey($pri_key);
$signResult = openssl_sign($dataString, $signature, $pkeyid, OPENSSL_ALGO_SHA256);
$signatureEncoded = base64_encode($signature);
?>
1
2
3
4
5
6
7
2
3
4
5
6
7
# Signature verify
<?php
$dataString = $json_obj->orderId.$json_obj->trnId.$json_obj->status.$json_obj->desc;
$signature = $json_obj->signature;
$keyfile = "file://" . __DIR__ . "/../keys/public_key.pem";
$pubKeyid = openssl_get_publickey($keyfile);
$signatureVerify = openssl_verify($dataString, base64_decode($signature), $pubKeyid, OPENSSL_ALGO_SHA256);
if ($signatureVerify == 1) {
echo("Signature valid"."\n");
} elseif ($signatureVerify == 0) {
echo("Signature invalid 1"."\n");
} else {
echo("Signature invalid 2"."\n");
}
?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16