-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
156 lines (126 loc) · 8.26 KB
/
app.js
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
var request = require('request');
var baseUrl = "https://api.cipcert.goevo.com/REST/2.0.22"
var identityToken = "PHNhbWw6QXNzZXJ0aW9uIE1ham9yVmVyc2lvbj0iMSIgTWlub3JWZXJzaW9uPSIxIiBBc3NlcnRpb25JRD0iXzdmMjUzNjUxLTM4YTMtNDRjNS04Y2U1LWM2NjlmZWRlMDA0ZCIgSXNzdWVyPSJJcGNBdXRoZW50aWNhdGlvbiIgSXNzdWVJbnN0YW50PSIyMDE1LTAxLTE1VDA2OjA5OjM5LjE1NVoiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjEuMDphc3NlcnRpb24iPjxzYW1sOkNvbmRpdGlvbnMgTm90QmVmb3JlPSIyMDE1LTAxLTE1VDA2OjA5OjM5LjE1NVoiIE5vdE9uT3JBZnRlcj0iMjAxOC0wMS0xNVQwNjowOTozOS4xNTVaIj48L3NhbWw6Q29uZGl0aW9ucz48c2FtbDpBZHZpY2U+PC9zYW1sOkFkdmljZT48c2FtbDpBdHRyaWJ1dGVTdGF0ZW1lbnQ+PHNhbWw6U3ViamVjdD48c2FtbDpOYW1lSWRlbnRpZmllcj5BQTZGQzY5QzRERjAwMDAxPC9zYW1sOk5hbWVJZGVudGlmaWVyPjwvc2FtbDp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2dFJma2N3MTNuZzA4ajNtMTVRMXM0Tnk4ZG1PWGJ3PT08L1NpZ25hdHVyZVZhbHVlPjxLZXlJbmZvPjxvOlNlY3VyaXR5VG9rZW5SZWZlcmVuY2UgeG1sbnM6bz0iaHR0cDovL2RvY3Mub2FzaXMtb3Blbi5vcmcvd3NzLzIwMDQvMDEvb2FzaXMtMjAwNDAxLXdzcy13c3NlY3VyaXR5LXNlY2V4dC0xLjAueHNkIj48bzpLZXlJZGVudGlmaWVyIFZhbHVlVHlwZT0iaHR0cDovL2RvY3Mub2FzaXMtb3Blbi5vcmcvd3NzL29hc2lzLXdzcy1zb2FwLW1lc3NhZ2Utc2VjdXJpdHktMS4xI1RodW1icHJpbnRTSEExIj5iQkcwU0cvd2RCNWJ4eVpyYjEvbTVLakhLMU09PC9vOktleUlkZW50aWZpZXI+PC9vOlNlY3VyaXR5VG9rZW5SZWZlcmVuY2U+PC9LZXlJbmZvPjwvU2lnbmF0dXJlPjwvc2FtbDpBc3NlcnRpb24+";
var sessionToken = "not defined yet";
var paymentTransactionData = {
"$type": "AuthorizeAndCaptureTransaction,http://schemas.evosnap.com/CWS/v2.0/Transactions/Rest",
"Transaction": {
"$type": "BankcardTransactionPro,http://schemas.evosnap.com/CWS/v2.0/Transactions/Bankcard/Pro",
"TenderData": {
"CardData": {
"CardType": "MasterCard",
"CardholderName": "John Doe",
"PAN": "5454545454545454",
"Expire": "1215"
},
"CardSecurityData": {
"InternationalAVSData": {
"HouseNumber": "123",
"Street": "Fake St",
"City": "Denver",
"StateProvince": "CO",
"PostalCode": "80202",
"Country": "USA"
},
"InternationalAVSOverride": {
"SkipAVS": true
},
"CVDataProvided": "Provided",
"CVData": "111"
}
},
"TransactionData": {
"$type": "BankcardTransactionDataPro,http://schemas.evosnap.com/CWS/v2.0/Transactions/Bankcard/Pro",
"CustomerPresent": "Ecommerce",
"EntryMode": "Keyed",
"GoodsType": "DigitalGoods",
"OrderNumber": "1234",
"SignatureCaptured": false,
"Amount": "10.00",
"CurrencyCode": "EUR",
"TransactionDateTime": "2015-01-15T22:41:11.478-07:00",
"PartialApprovalCapable": "NotSet",
"TransactionCode": "NotSet",
"Is3DSecure": false,
"CardholderAuthenticationEntity": "NotSet",
"CardPresence": false
}
},
"ApplicationProfileId": "72446",
"MerchantProfileId": "SNAP_00001"
};
var printTruncated = function(longText) {
var delta = 40;
return longText.substring(0, delta)+"..."+longText.substring(longText.length-delta, longText.length);
}
var base64encoded = function(asciiText) {
var buffer = new Buffer(asciiText);
var base64encodedData = buffer.toString('base64');
return base64encodedData;
}
var paymentTransactionRequest = function() {
console.log("");
console.log("------------------------------------------------------");
console.log("---------- INIT PAYMENT TRANSACTION REQUEST ----------");
console.log("------------------------------------------------------");
console.log("");
var url = baseUrl + "/Txn/DF83D00001";
var sessionToken64encoded = base64encoded(sessionToken+":");
var options = {
method: "POST",
url: url,
rejectUnauthorized: false,
headers: {
"Content-Type": "application/json",
"Authorization": "Basic "+sessionToken64encoded
},
json: paymentTransactionData
};
console.log("sessionToken64encoded -> "+printTruncated(sessionToken64encoded));
console.log("");
console.log("payment transaction data");
console.log("------------------------");
console.log(paymentTransactionData);
console.log("");
console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
console.log("POST -> "+url)
console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
console.log("");
request(options, function(error, response, body) {
console.log("result of payment transaction request");
console.log("-------------------------------------");
console.log(body);
});
}
var autenticationRequest = function() {
console.log("");
console.log("------------------------------------------------------");
console.log("------------- INIT AUTENTICATION REQUEST -------------");
console.log("------------------------------------------------------");
console.log("");
var url = baseUrl + "/SvcInfo/token";
var identityToken64encoded = base64encoded(identityToken+":");
var options = {
method: "GET",
url: url,
rejectUnauthorized: false,
headers: {
"Content-Type": "application/json",
"Authorization": "Basic "+identityToken64encoded
}
};
console.log("identityToken -> "+printTruncated(identityToken));
console.log("identityToken64encoded -> "+printTruncated(identityToken64encoded));
console.log("");
console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
console.log("GET -> "+url)
console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
console.log("");
request(options, function(error, response, body) {
sessionToken = body.substring(1, body.length-1);
console.log("body -> "+printTruncated(body));
console.log("sessionToken -> "+printTruncated(sessionToken));
paymentTransactionRequest();
});
}
autenticationRequest();