# Request
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Directpay|OneTimePayment</title>
</head>
<div id="card_container"></div>
<body>
<script src="https://cdn.directpay.lk/dev/v1/directpayCardPayment.js?v=1"></script>
<script>
DirectPayCardPayment.init({
container: 'card_container', //<div id="card_container"></div>
merchantId: 'xxxxxxx', //your merchant_id
amount: "100.00",
refCode: "DP12345", //unique referance code form merchant
currency: 'LKR',
type: 'ONE_TIME_PAYMENT',
customerEmail: 'abc@mail.com',
customerMobile: '+94712345674',
description: 'test products', //product or service description
debug: true,
responseCallback: responseCallback,
errorCallback: errorCallback,
logo: 'https://test.com/directpay_logo.png',
apiKey: 'xxxxxxxxxxx'
});
//response callback.
function responseCallback(result) {
console.log("successCallback-Client", result);
alert(JSON.stringify(result));
}
//error callback
function errorCallback(result) {
console.log("successCallback-Client", result);
alert(JSON.stringify(result));
}
</script>
</body>
</html>
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
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
# Parameters
Field | Type | Description | Allow values | Mandatory | Length |
---|---|---|---|---|---|
container | String | Card container display area | Yes | ||
merchantId | String | Merchant ID. Get Merchant ID. | Yes | 6 | |
amount | String | Transaction amount. | Yes | ||
refCode | String | Every transaction need unique reference. | Yes | 20 | |
currency | String | Transaction currency code. | USD, LKR | Yes | 3 |
type | String | Every transaction need unique reference. | RECURRING, ONE_TIME_PAYMENT | Yes | |
customerEmail | String | Customer email address | Yes | 100 | |
customerMobile | String | Customer mobile number | Yes | 10 | |
description | String | Description about selling product or service. | Yes | 100 | |
debug | Boolean | In debug true model show all errors in console | Yes | ||
responseCallback | Function | After finish response will be received to this function | Yes | ||
errorCallback | Function | After finish errors response will be received to this function | Yes | ||
logo | Url | Merchant logo, url must be HTTPS | No | ||
apiKey | String | Merchant apikey. Get Api Token. | Yes |
# Browser Response
- SuccessResponse
- ErrorResponse
- TransactionFailed
{
"status": 200,
"data": {
"transactionId": 1234,
"status": "SUCCESS",
"description": "Approved",
"dateTime": "2019-08-05 12:21:54",
"reference": 1564987851614,
"amount": "100.00",
"card": {
"number": "xxxx-xxxx-xxxx-xxxx"
}
}
}
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
# Get response from server
TIP
Set Confirmation endpoint using directpay portal. After every transaction, HTTP JSON POST request with following format will be sent to the given endpoint
{
"status": 200,
"type": "INIT_TRN",
"paymentCategory": "ONE_TIME",
"data": {
"transactionId": 880,
"status": "SUCCESS",
"description": "Approved",
"dateTime": "2020-06-23 15:12:48",
"reference": 1592905349263,
"amount": "2.00",
"currency": "LKR",
"card": {
"number": "xxxx-xxxx-xxxx-1118"
}
}
}
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