# Request
<form method="POST" action="https://testpay.directpay.lk/">
<label>Type</label>
<input type="text" name="_type" id="_type" value="RECURRING" />
<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>Reference</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"
/>
<label>Start Date</label>
<input
class="form-control"
type="text"
name="_startDate"
id="_startDate"
value="2020-08-20"
/>
<label>End Date</label>
<input
class="form-control"
type="text"
name="_endDate"
id="_endDate"
value="2020-10-20"
/>
<label>Interval</label>
<select class="form-control" id="_interval" name="_interval">
<option value="0">YEARLY</option>
<option value="1">BIANNUAL</option>
<option value="2">QUARTERLY</option>
<option value="3" selected>MONTHLY</option>
<option value="4">WEEKLY</option>
<option value="5">DAILY</option>
</select>
<label>Do first Payment</label>
<select id="_doFirstPayment" name="_doFirstPayment">
<option value="1">Yes</option>
<option value="0">No</option>
</select>
<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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Parameter
Field | Type | Description | Allow values |
---|---|---|---|
_amount | Decimal | Transaction amount. | |
_currency | String | Currency code | LKR, USD |
_startDate | String | Starting date of the recurring payment. | yyyy-mm-dd |
_endDate | String | End date of the recurring payment. | yyyy-mm-dd |
_interval | String | Frequency of payment. 0-YEARLY, 1-BIANNUAL, 2-QUARTERLY, 3-MONTHLY, 4-WEEKLY, 5-DAILY | o, 1, 2, 3, 4, 5 |
_doFirstPayment | Number | Recurring initiate time transaction. /1-Yes, 0-No | 1, 0 |
# Response
BrowserRedirectResponse
http://response.com?orderId=DP12355&trnId=936&status=SUCCESS&desc=Approved&type=RECURRING
1
ServerResponse
{
"type": "RECURRING",
"orderId": "DP12355",
"trnId": 936,
"status": "SUCCESS",
"desc": "Approved",
"signature": "insfXE4UhD5tvbvetQnMgXMCwybzDUURmdEqaWpigX7tNCHfhUUi6JbJKmWjOZk2Ibrj9skEtTNQIe6lCZQPci3y4CCEQ9Yaj60BlXWGoQePQ8+3NzxGK9Zl2pO242bnYxI/wP2wvVCv0edb5t7LVulg115snEDziQyVkjMxfxP2ZewgYP9LPuCDG2IUF9sHSHM7AuJAkK5ZfSQlURfdT3rNa0zqJa/Cu6FWM2usU+PpLONIDegW33v51AsAotRXiuyAeKhw+AWWXxsjLi/qXQzGgfH0y84WeEOzjHGdl1OszxxaVAG8qLU/aKcDdOKSp1E1mENe4B6O6iifbA4DWg==",
"recurring": {
"id": "1234",
"interval": "Monthly",
"isRetry": true,
"retryAttempts": 2,
"startingDate": "2020-08-20 00:00:00",
"nextPaymentDate": "2020-08-20 10:22:55",
"lastDate": "2020-09-20",
"doFirstPayment": "1",
"recurringAmount": "100.00"
},
"card": {
"expiry": "12-25",
"number": "xxxx-xxxx-xxxx-1118"
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
- PHP
# Signature generate
<?php
$dataString = $merchant . $amount . $currency . $pluginName . $pluginVersion . $returnUrl . $cancelUrl . $orderId .
$reference . $firstName . $lastName . $email . $description . $apiKey . $responseUrl . $startDate . $endDate .
$interval . $doFirstPayment;
$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
8
2
3
4
5
6
7
8
# 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
← One Time Card Adding →