# Card adding
# Request
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Directpay|CardAdd</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',
type: 'ADD_CARD',
currency: 'LKR',
refCode: '1566895327605', //Unique value for identify the card holder.
customerEmail: 'abc@mail.com',
customerMobile: '+94712584756',
cardNickname: 'My Card',
debug: true,
responseCallback: responseCallback,
errorCallback: errorCallback,
logo: 'https://www.roarafrica.com/wp-content/uploads/2017/11/sample-logo.png',
apiKey: 'xxxxxxxx',
});
//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
43
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
# Browser Response
- Success response
- Error response
- Card adding failed
{
"status":200,
"data":{
"cardList":[
{
"brand":"VISA",
"cardId":797,
"mask":"450875xxxxxx1019",
"nickName":"my card 1",
"reference":"1566895327605",
"issuer": "bank"
},
{
"brand":"MASTERCARD",
"cardId":798,
"mask":"512345xxxxxx0008",
"nickName":"my card 2",
"reference":"1566895327605",
"issuer": "bank"
}
],
"newCard":{
"brand":"MASTERCARD",
"cardId":799,
"mask":"222300xxxxxx0007",
"nickName":"my card 3",
"reference":"1566895327605",
"issuer": "bank"
},
"status":"SUCCESS"
}
}
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
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
# Get response from server
TIP
Set Confirmation endpoint using directpay portal. After every card adding, HTTP JSON POST request with following format will be sent to the given endpoint
- SuccessResponse
- ErrorResponse
{
"status":200,
"type":"CARD_ADD",
"paymentCategory":"CARD_ADD",
"data":{
"status":"SUCCESS",
"reference":"156689532v",
"newCard":{
"brand":"MASTERCARD",
"cardId":1198,
"expiry":"12-25",
"id":1198,
"issuer":"MASTERCARD - MEMBER TEST FACILITY",
"mask":"547350xxxxxx1018",
"nickName":1604598443623,
"reference":"156689532v"
},
"cardList":[
{
"brand":"MASTERCARD",
"cardId":1198,
"expiry":"12-25",
"id":1198,
"issuer":"MASTERCARD - MEMBER TEST FACILITY",
"mask":"547350xxxxxx1018",
"nickName":"1604598443623",
"reference":"156689532v"
}
]
}
}
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
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