# Make payment using card
# Request
- PHP
<?php
$curl = curl_init();
//key order must be same order generate signature dataString
$requestBody = [
"merchantId" => "xxxxxxx",
"reference" => "1566895327605",
"type" => "CARD_PAY",
"cardId" => "791",
"refCode" => "1234",
"amount" => "100.00",
"currency" => "LKR"
];
curl_setopt_array($curl, array(
CURLOPT_URL => "https://dev.directpay.lk/v1/mpg/api/external/cardManagement",
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($requestBody),
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"Signature: xxxxx",
"x-api-key: xxxx"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
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
34
35
36
37
38
39
40
41
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
# 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 | |
refCode | Integer | Unique value for identify the card holder. | |
reference | String | Reference for identify transaction. | |
currency | String | Currency type. | |
amount | Decimal | Transaction amount. | |
cardId | Integer | Listed cards selected card id | |
type | String | API request type | CARD_PAY |
# Response
SuccessResponse
{
"status": 200,
"data": {
"transactionId": 85,
"status": "SUCCESS",
"description": "Approved",
"dateTime": "2019-09-09 11:26:52",
"reference": "trn0001",
"amount": "100.00",
"card": {
"number": "222300xxxxxx0007"
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
ErrorResponse
{
"status": 200,
"data": {
"transactionId": 85,
"status": "FAILED",
"description": "Approved",
"dateTime": "2019-09-09 11:26:52",
"reference": "trn0001",
"amount": "100.00",
"card": {
"number": "222300xxxxxx0007"
}
}
}
,
{
"status": 400,
"data": {
"error": "ValidationException",
"message": "Cannot verify the Request!"
}
}
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