# Request
- PHP
<?php
//key order must be same order generate signature dataString
$requestBody = [
"merchantId" => "xxxxxxx",
"type" => "TRANSACTION_STATUS",
"transactionId" => "1234",
"merchantReference" => "DP1234"
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://dev.directpay.lk/v1/mpg/api/external/transaction/paymentStatus",
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 => json_encode($requestBody),
CURLOPT_HTTPHEADER => array(
"signature: xxxxxxxxx",
"x-api-key: xxxxxxxxx",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
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
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
# Header
Field | Type | Description |
---|---|---|
Content-Type | String | application/json |
Signature | String | Signature generated for the data |
x-api-key | String | Merchant api key |
# Parameter
Field | Type | Description | Allowed values |
---|---|---|---|
merchantId | String | Merchant ID | |
transactionId | String | Directpay transaction id | |
type | String | API request type | TRANSACTION_STATUS |
merchantReference | String | Merchant orderId / reference |
# Response
Transaction
{
"status": 200,
"type": "TRANSACTION_STATUS",
"paymentCategory": "TRANSACTION_STATUS",
"data": [
{
"status": "SUCCESS",
"bankerResponseDesc": null,
"transactionId": 934,
"amount": "100.00",
"currency": "LKR",
"dateTime": "2020-07-02 16:43:36",
"payer": {
"name": "UserA UserA",
"card": "222300xxxxxx0007"
}
}
]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Transaction with schedule data
{
"status": 200,
"type": "TRANSACTION_STATUS",
"paymentCategory": "TRANSACTION_STATUS",
"data": [
{
"status": "SUCCESS",
"bankerResponseDesc": null,
"transactionId": 934,
"amount": "100.00",
"currency": "LKR",
"dateTime": "2020-07-02 16:43:36",
"payer": {
"name": "UserA UserA",
"card": "222300xxxxxx0007"
},
"schedule": {
"amount": "100.00",
"currency": "LKR",
"interval": "Monthly",
"nextPaymentDate": "2020-08-20 16:43:36",
"endDate": "2020-09-20 00:00:00",
"startDate": "2020-08-20 00:00:00",
"state": "CONFIRMED",
"lastPaymentStatus": "SUCCESS",
"lastPaymentStatusDescription": "SUCCESS",
"isRetry": "YES",
"retryAttempts": 2,
"doFirstPayment": "NO"
}
}
]
}
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
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
ErrorResponse
{
"status": 400,
"data": {
"error": "ValidationException",
"message": "MerchantId required!"
}
}
,
{
"status": 400,
"type": "-",
"paymentCategory": "-",
"data": {
"code": "VALIDATION_EXCEPTION",
"message": "Invalid type."
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17