adp-sdk 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +0 -0
- package/adapay-core/Http.js +210 -0
- package/adapay-core/Logger.js +67 -0
- package/adapay-core/Message.js +130 -0
- package/adapay-core/Utils.js +10 -0
- package/adapay-core/Version.js +1 -0
- package/adapay-core/index.js +13 -0
- package/main.js +9 -0
- package/merchant/BatchInput.js +46 -0
- package/merchant/Config.js +33 -0
- package/merchant/Entry.js +60 -0
- package/merchant/MerProfile.js +54 -0
- package/merchant/Merchant.js +73 -0
- package/merchant/Version.js +1 -0
- package/merchant/index.js +15 -0
- package/package.json +23 -0
- package/pay/Account.js +18 -0
- package/pay/AdaPay.js +109 -0
- package/pay/AdapayTools.js +35 -0
- package/pay/Checkout.js +32 -0
- package/pay/Config.js +35 -0
- package/pay/CorpMember.js +40 -0
- package/pay/Drawcash.js +32 -0
- package/pay/FastPay.js +74 -0
- package/pay/FreezeAccount.js +32 -0
- package/pay/Member.js +74 -0
- package/pay/Payment.js +61 -0
- package/pay/PaymentConfirm.js +46 -0
- package/pay/PaymentReverse.js +46 -0
- package/pay/Refund.js +32 -0
- package/pay/SettleAccount.js +116 -0
- package/pay/Transfer.js +32 -0
- package/pay/UnFreezeAccount.js +32 -0
- package/pay/Version.js +1 -0
- package/pay/Wallet.js +18 -0
- package/pay/index.js +41 -0
package/README.md
ADDED
File without changes
|
@@ -0,0 +1,210 @@
|
|
1
|
+
var fs = require('fs');
|
2
|
+
var axios = require('axios');
|
3
|
+
var crypto = require('crypto');
|
4
|
+
var Logger = require('./Logger');
|
5
|
+
var Version = require('./Version');
|
6
|
+
var httpConfig = {};
|
7
|
+
axios.defaults.timeout = 60000;
|
8
|
+
function post(url, params, config) {
|
9
|
+
return new Promise(function (resolve, reject) {
|
10
|
+
httpConfig = config;
|
11
|
+
let info = buildRequestInfo(url, 'post', params);
|
12
|
+
axios.defaults.headers = info.header;
|
13
|
+
axios
|
14
|
+
.post(url, info.params)
|
15
|
+
.then(function (res) {
|
16
|
+
let signature = res.data.signature;
|
17
|
+
if (signature) {
|
18
|
+
let data = buildResponseData(res);
|
19
|
+
data instanceof Error === true ? reject(data) : resolve(data);
|
20
|
+
} else {
|
21
|
+
Logger.error('signature is wrong!');
|
22
|
+
reject(new Error('signature is wrong!'));
|
23
|
+
}
|
24
|
+
})
|
25
|
+
.catch(function (error) {
|
26
|
+
Logger.error(error);
|
27
|
+
if (error && error.response.data) {
|
28
|
+
resolve(error.response.data.data || error.response.data);
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
reject(error.toString());
|
32
|
+
});
|
33
|
+
});
|
34
|
+
}
|
35
|
+
function uploadFile(url, params, formData, config) {
|
36
|
+
return new Promise(function (resolve, reject) {
|
37
|
+
httpConfig = config;
|
38
|
+
let info = buildRequestInfo(url, 'upload', params);
|
39
|
+
var headers = formData.getHeaders();
|
40
|
+
headers['Authorization'] = info.header['Authorization'];
|
41
|
+
headers['Signature'] = info.header['Signature'];
|
42
|
+
headers['sdk_version'] = info.header['sdk_version'];
|
43
|
+
axios.defaults.headers = headers;
|
44
|
+
axios
|
45
|
+
.post(url, formData)
|
46
|
+
.then(function (res) {
|
47
|
+
let signature = res.data.signature;
|
48
|
+
if (signature) {
|
49
|
+
let data = buildResponseData(res);
|
50
|
+
data instanceof Error === true ? reject(data) : resolve(data);
|
51
|
+
} else {
|
52
|
+
Logger.error('signature is wrong!');
|
53
|
+
reject(new Error('signature is wrong!'));
|
54
|
+
}
|
55
|
+
})
|
56
|
+
.catch(function (error) {
|
57
|
+
Logger.error(error);
|
58
|
+
if (error && error.response.data) {
|
59
|
+
resolve(error.response.data.data || error.response.data);
|
60
|
+
return;
|
61
|
+
}
|
62
|
+
reject(error.toString());
|
63
|
+
});
|
64
|
+
});
|
65
|
+
}
|
66
|
+
function get(url, params, config) {
|
67
|
+
return new Promise(function (resolve, reject) {
|
68
|
+
httpConfig = config;
|
69
|
+
let info = buildRequestInfo(url, 'get', params);
|
70
|
+
axios.defaults.headers = info.header;
|
71
|
+
url = url + '?' + sortByASCII(params);
|
72
|
+
axios
|
73
|
+
.get(url)
|
74
|
+
.then(function (res) {
|
75
|
+
let signature = res.data.signature;
|
76
|
+
if (signature) {
|
77
|
+
let data = buildResponseData(res);
|
78
|
+
data instanceof Error === true ? reject(data) : resolve(data);
|
79
|
+
} else {
|
80
|
+
Logger.error('signature is wrong!');
|
81
|
+
reject(new Error('signature is wrong!'));
|
82
|
+
}
|
83
|
+
})
|
84
|
+
.catch(function (error) {
|
85
|
+
Logger.error(error);
|
86
|
+
if (error && error.response.data) {
|
87
|
+
resolve(error.response.data.data || error.response.data);
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
reject(error.toString());
|
91
|
+
});
|
92
|
+
});
|
93
|
+
}
|
94
|
+
function buildRequestInfo(url, method, params) {
|
95
|
+
let header = { Authorization: httpConfig.api_key, Signature: '', sdk_version: `node_${Version.version}` };
|
96
|
+
let plain_text = url;
|
97
|
+
if (method == 'post') {
|
98
|
+
plain_text = plain_text + JSON.stringify(params);
|
99
|
+
header['Content-type'] = 'application/json';
|
100
|
+
} else if (method == 'get') {
|
101
|
+
plain_text = plain_text + sortByASCII(params);
|
102
|
+
} else if (method == 'upload') {
|
103
|
+
plain_text = plain_text + sortByASCII(params);
|
104
|
+
header['Content-type'] = 'multipart/form-data';
|
105
|
+
}
|
106
|
+
let private_key = httpConfig.private_key;
|
107
|
+
if (!(typeof private_key === 'string' && private_key.length > 0)) {
|
108
|
+
private_key = readFile(httpConfig.private_key_path);
|
109
|
+
httpConfig.private_key = private_key;
|
110
|
+
}
|
111
|
+
let cipher_text = rsaSign(private_key, plain_text);
|
112
|
+
header['Signature'] = cipher_text;
|
113
|
+
return { header, params };
|
114
|
+
}
|
115
|
+
function buildResponseData(resp) {
|
116
|
+
let resp_json = resp.data;
|
117
|
+
let public_key = httpConfig.public_key;
|
118
|
+
if (!(typeof public_key === 'string' && public_key.length > 0)) {
|
119
|
+
public_key = readFile(httpConfig.public_key_path);
|
120
|
+
httpConfig.public_key = public_key;
|
121
|
+
}
|
122
|
+
let data = resp_json.data || '';
|
123
|
+
let signature = resp_json.signature || '';
|
124
|
+
if (rsaDesign(signature, public_key, data)) {
|
125
|
+
return data;
|
126
|
+
}
|
127
|
+
let err = new Error('check signature error !');
|
128
|
+
Logger.error(err);
|
129
|
+
return err;
|
130
|
+
}
|
131
|
+
function verifySign(resp_json, sign, config) {
|
132
|
+
httpConfig = config;
|
133
|
+
let public_key = httpConfig.public_key;
|
134
|
+
if (!(typeof public_key === 'string' && public_key.length > 0)) {
|
135
|
+
public_key = readFile(httpConfig.public_key_path);
|
136
|
+
httpConfig.public_key = public_key;
|
137
|
+
}
|
138
|
+
let data = resp_json.data || '';
|
139
|
+
let signature = sign || '';
|
140
|
+
if (rsaDesign(signature, public_key, data)) {
|
141
|
+
return data;
|
142
|
+
}
|
143
|
+
let err = new Error('check signature error !');
|
144
|
+
Logger.error(err);
|
145
|
+
return err;
|
146
|
+
}
|
147
|
+
function sortByASCII(obj) {
|
148
|
+
var arr = new Array();
|
149
|
+
var num = 0;
|
150
|
+
for (var i in obj) {
|
151
|
+
arr[num] = i;
|
152
|
+
num++;
|
153
|
+
}
|
154
|
+
var sortArr = arr.sort((a, b) => {
|
155
|
+
return a > b ? 1 : -1;
|
156
|
+
});
|
157
|
+
var sortStrArr = [];
|
158
|
+
for (var i in sortArr) {
|
159
|
+
let s1 = sortArr[i];
|
160
|
+
let s2 = obj[s1];
|
161
|
+
let s3 = s1 + '=' + s2;
|
162
|
+
sortStrArr.push(s3);
|
163
|
+
}
|
164
|
+
let string = sortStrArr.join('&');
|
165
|
+
return string;
|
166
|
+
}
|
167
|
+
function readFile(filePath) {
|
168
|
+
try {
|
169
|
+
var data = fs.readFileSync(filePath, 'utf8');
|
170
|
+
return data;
|
171
|
+
} catch (error) {
|
172
|
+
Logger.error(error);
|
173
|
+
return '';
|
174
|
+
}
|
175
|
+
}
|
176
|
+
function rsaSign(private_key, message) {
|
177
|
+
try {
|
178
|
+
let mKey = fillPrivateKeyMarker(private_key);
|
179
|
+
let signer = crypto.createSign('RSA-SHA1');
|
180
|
+
let sign = signer.update(new Buffer(message, 'utf-8')).sign(mKey, 'base64');
|
181
|
+
return sign;
|
182
|
+
} catch (error) {
|
183
|
+
Logger.error(error);
|
184
|
+
return '';
|
185
|
+
}
|
186
|
+
}
|
187
|
+
function rsaDesign(signature, my_rsa_public, message) {
|
188
|
+
try {
|
189
|
+
let mpublic = fillPublicKeyMarker(my_rsa_public);
|
190
|
+
let verify = crypto.createVerify('RSA-SHA1');
|
191
|
+
let design = verify.update(new Buffer(message, 'utf-8')).verify(mpublic, signature, 'base64');
|
192
|
+
return design;
|
193
|
+
} catch (error) {
|
194
|
+
Logger.error(error);
|
195
|
+
return false;
|
196
|
+
}
|
197
|
+
}
|
198
|
+
function fillPublicKeyMarker(public_key) {
|
199
|
+
if (public_key.indexOf('BEGIN PUBLIC KEY') > 0) {
|
200
|
+
return public_key;
|
201
|
+
}
|
202
|
+
return '-----BEGIN PUBLIC KEY-----\n' + public_key + '\n-----END PUBLIC KEY-----';
|
203
|
+
}
|
204
|
+
function fillPrivateKeyMarker(private_key) {
|
205
|
+
if (private_key.indexOf('BEGIN PRIVATE KEY') > 0) {
|
206
|
+
return private_key;
|
207
|
+
}
|
208
|
+
return '-----BEGIN PRIVATE KEY-----\n' + private_key + '\n-----END PRIVATE KEY-----';
|
209
|
+
}
|
210
|
+
module.exports = { httpConfig, post, get, uploadFile, rsaSign, rsaDesign, readFile, verifySign };
|
@@ -0,0 +1,67 @@
|
|
1
|
+
var log4js = require('log4js');
|
2
|
+
let programName = 'Adapay';
|
3
|
+
var Config = {};
|
4
|
+
function setConfig(params) {
|
5
|
+
Config = params;
|
6
|
+
}
|
7
|
+
function initDefineLogger(categories) {
|
8
|
+
log4js.configure({
|
9
|
+
appenders: {
|
10
|
+
console: { type: 'console' },
|
11
|
+
log_file: { type: 'file', filename: Config.log_file_path + `/logs/${programName}.log`, maxLogSize: 20971520, backups: 3, encoding: 'utf-8' },
|
12
|
+
data_file: { type: 'dateFile', filename: Config.log_file_path + `/logs/${programName}`, alwaysIncludePattern: true, daysToKeep: 10, pattern: '-yyyy-MM-dd-hh.log', encoding: 'utf-8' },
|
13
|
+
error_file: { type: 'dateFile', filename: Config.log_file_path + `/logs/${programName}_error`, alwaysIncludePattern: true, daysToKeep: 10, pattern: '_yyyy-MM-dd.log', encoding: 'utf-8' }
|
14
|
+
},
|
15
|
+
categories: {
|
16
|
+
default: { appenders: ['data_file', 'console', 'log_file'], level: 'info' },
|
17
|
+
production: { appenders: ['data_file'], level: 'info' },
|
18
|
+
console: { appenders: ['console'], level: 'debug' },
|
19
|
+
debug: { appenders: ['console', 'log_file'], level: 'debug' },
|
20
|
+
error_log: { appenders: ['error_file'], level: 'error' },
|
21
|
+
error_console: { appenders: ['console', 'error_file'], level: 'error' }
|
22
|
+
}
|
23
|
+
});
|
24
|
+
var logger = log4js.getLogger(categories);
|
25
|
+
return logger;
|
26
|
+
}
|
27
|
+
function initErrorLogger() {
|
28
|
+
log4js.configure({
|
29
|
+
appenders: {
|
30
|
+
console: { type: 'console' },
|
31
|
+
log_file: { type: 'file', filename: Config.log_file_path + `/logs/${programName}.log`, maxLogSize: 20971520, backups: 3, encoding: 'utf-8' },
|
32
|
+
data_file: { type: 'dateFile', filename: Config.log_file_path + `/logs/${programName}`, alwaysIncludePattern: true, daysToKeep: 10, pattern: '-yyyy-MM-dd-hh.log', encoding: 'utf-8' },
|
33
|
+
error_file: { type: 'dateFile', filename: Config.log_file_path + `/logs/${programName}_error`, alwaysIncludePattern: true, daysToKeep: 10, pattern: '_yyyy-MM-dd.log', encoding: 'utf-8' }
|
34
|
+
},
|
35
|
+
categories: {
|
36
|
+
default: { appenders: ['data_file', 'console', 'log_file'], level: 'info' },
|
37
|
+
production: { appenders: ['data_file'], level: 'info' },
|
38
|
+
console: { appenders: ['console'], level: 'debug' },
|
39
|
+
debug: { appenders: ['console', 'log_file'], level: 'debug' },
|
40
|
+
error_log: { appenders: ['error_file'], level: 'error' },
|
41
|
+
error_console: { appenders: ['console', 'error_file'], level: 'error' }
|
42
|
+
}
|
43
|
+
});
|
44
|
+
var logger = log4js.getLogger('error_log');
|
45
|
+
return logger;
|
46
|
+
}
|
47
|
+
var defineLogger = null;
|
48
|
+
var errorLogger = null;
|
49
|
+
function info(info) {
|
50
|
+
if (!defineLogger) {
|
51
|
+
defineLogger = initDefineLogger(Config.log_console_enable ? 'default' : 'production');
|
52
|
+
}
|
53
|
+
defineLogger.info(info);
|
54
|
+
}
|
55
|
+
function warn(warning) {
|
56
|
+
if (!defineLogger) {
|
57
|
+
defineLogger = initDefineLogger(Config.log_console_enable ? 'default' : 'production');
|
58
|
+
}
|
59
|
+
defineLogger.warn(warning);
|
60
|
+
}
|
61
|
+
function error(error) {
|
62
|
+
if (!errorLogger) {
|
63
|
+
errorLogger = initErrorLogger(Config.log_console_enable ? 'error_console' : 'error_log');
|
64
|
+
}
|
65
|
+
errorLogger.error(error);
|
66
|
+
}
|
67
|
+
module.exports = { setConfig, info, warn, error };
|
@@ -0,0 +1,130 @@
|
|
1
|
+
var mqtt = require('mqtt');
|
2
|
+
var Http = require('./Http');
|
3
|
+
var Logger = require('./Logger');
|
4
|
+
var EventEmitter = require('events');
|
5
|
+
var crypto = require('crypto');
|
6
|
+
var uuid = require('uuid');
|
7
|
+
var Utils = require('./Utils');
|
8
|
+
const default_public_key =
|
9
|
+
'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwN6xgd6Ad8v2hIIsQVnbt8a3JituR8o4Tc3B5WlcFR55bz4OMqrG/356Ur3cPbc2Fe8ArNd/0gZbC9q56Eb16JTkVNA/fye4SXznWxdyBPR7+guuJZHc/VW2fKH2lfZ2P3Tt0QkKZZoawYOGSMdIvO+WqK44updyax0ikK6JlNQIDAQAB';
|
10
|
+
var messageConfig = {
|
11
|
+
base_url: 'https://api.adapay.tech',
|
12
|
+
instance_id: 'post-cn-0pp18zowf0m',
|
13
|
+
access_key: 'LTAIOP5RkeiuXieW',
|
14
|
+
group_id: 'GID_CRHS_ASYN',
|
15
|
+
client_id: '',
|
16
|
+
broker_url: 'post-cn-0pp18zowf0m.mqtt.aliyuncs.com',
|
17
|
+
log_file_path: './',
|
18
|
+
log_level: 'warn',
|
19
|
+
log_console_enable: false,
|
20
|
+
prod_mode: '1',
|
21
|
+
debug: false,
|
22
|
+
connect_timeout: 30000,
|
23
|
+
api_key: '',
|
24
|
+
private_key_path: '',
|
25
|
+
private_key: '',
|
26
|
+
public_key_path: '',
|
27
|
+
public_key: default_public_key
|
28
|
+
};
|
29
|
+
class PayMessage extends EventEmitter {
|
30
|
+
constructor(config, path) {
|
31
|
+
super(config);
|
32
|
+
Object.assign(messageConfig, config);
|
33
|
+
Logger.setConfig(messageConfig);
|
34
|
+
this._setMerchantPath(path);
|
35
|
+
var hash = crypto.createHash('md5');
|
36
|
+
hash.update(messageConfig.api_key + uuid.v1);
|
37
|
+
messageConfig.client_id = messageConfig.group_id + '@@@' + hash.digest('hex');
|
38
|
+
this._initConfig();
|
39
|
+
}
|
40
|
+
_setMerchantPath(path) {
|
41
|
+
try {
|
42
|
+
this._cleanConfig();
|
43
|
+
if (typeof path === 'string' && path.length > 0) {
|
44
|
+
var jsonString = Utils.readFile(path);
|
45
|
+
var json = JSON.parse(jsonString);
|
46
|
+
if (json) {
|
47
|
+
if (messageConfig.prod_mode == 1) {
|
48
|
+
messageConfig.api_key = json.api_key_live;
|
49
|
+
} else {
|
50
|
+
messageConfig.api_key = json.api_key_test;
|
51
|
+
}
|
52
|
+
messageConfig.public_key = json.rsa_public_key || messageConfig.default_public_key;
|
53
|
+
messageConfig.private_key = json.rsa_private_key;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
Logger.info(messageConfig);
|
57
|
+
} catch (error) {
|
58
|
+
Logger.error(error);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
_cleanConfig() {
|
62
|
+
messageConfig.prod_mode = '1';
|
63
|
+
messageConfig.api_key = '';
|
64
|
+
messageConfig.private_key_path = '';
|
65
|
+
messageConfig.private_key = '';
|
66
|
+
messageConfig.public_key_path = '';
|
67
|
+
messageConfig.public_key = '';
|
68
|
+
messageConfig.base_url = 'https://api.adapay.tech';
|
69
|
+
}
|
70
|
+
async _initConfig() {
|
71
|
+
if (typeof messageConfig.client_id === 'string' && messageConfig.client_id.length > 0) {
|
72
|
+
this.client_id = messageConfig.client_id;
|
73
|
+
} else {
|
74
|
+
var hash = crypto.createHash('md5');
|
75
|
+
hash.update(messageConfig.api_key + uuid.v1);
|
76
|
+
this.client_id = messageConfig.group_id + '@@@' + hash.digest('hex');
|
77
|
+
}
|
78
|
+
this.topic = 'topic_crhs_sender/' + messageConfig.api_key;
|
79
|
+
this.username = 'Token|' + messageConfig.access_key + '|' + messageConfig.instance_id;
|
80
|
+
this.token = await this._requestToken();
|
81
|
+
this.password = 'R|' + this.token;
|
82
|
+
this._mqttConnect();
|
83
|
+
}
|
84
|
+
_mqttConnect() {
|
85
|
+
let self = this;
|
86
|
+
let options = { username: this.username, password: this.password, clientId: this.client_id, keepalive: 90, connectTimeout: messageConfig.connect_timeout };
|
87
|
+
this.client = mqtt.connect('tcp://' + messageConfig.broker_url + ':1883', options);
|
88
|
+
this.client.on('connect', function () {
|
89
|
+
self._subscribe();
|
90
|
+
self.emit('connect');
|
91
|
+
});
|
92
|
+
this.client.on('error', function (err) {
|
93
|
+
Logger.info('mqtt connect error: ' + err.toString());
|
94
|
+
self.emit('error', err);
|
95
|
+
setTimeout(function () {
|
96
|
+
self._mqttConnect();
|
97
|
+
}, 3000);
|
98
|
+
});
|
99
|
+
this.client.on('message', function (topic, message) {
|
100
|
+
Logger.info('mqtt connect message: ' + message.toString());
|
101
|
+
self.emit('message', topic, message);
|
102
|
+
});
|
103
|
+
}
|
104
|
+
_subscribe() {
|
105
|
+
let self = this;
|
106
|
+
self.client.subscribe(this.topic, { qos: 0 }, function (error, granted) {
|
107
|
+
if (error) {
|
108
|
+
Logger.info('mqtt subscribe error: ' + error.toString());
|
109
|
+
self._subscribe();
|
110
|
+
}
|
111
|
+
self.emit('subscribe', error, granted);
|
112
|
+
});
|
113
|
+
}
|
114
|
+
async _requestToken() {
|
115
|
+
let expire_time = 30000000000;
|
116
|
+
try {
|
117
|
+
let resJson = await Http.post(messageConfig.base_url + '/v1/token/apply', { expire_time: expire_time }, messageConfig);
|
118
|
+
let data = JSON.parse(resJson);
|
119
|
+
if (data && data.status === 'succeeded') {
|
120
|
+
return data.token;
|
121
|
+
}
|
122
|
+
Logger.info('PayMessage: token request failed');
|
123
|
+
return '';
|
124
|
+
} catch (error) {
|
125
|
+
Logger.info(error.toString);
|
126
|
+
return '';
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
module.exports = PayMessage;
|
@@ -0,0 +1 @@
|
|
1
|
+
module.exports = { version: 'v1.0.7' };
|
@@ -0,0 +1,13 @@
|
|
1
|
+
const Http = require('./Http.js');
|
2
|
+
const Logger = require('./Logger.js');
|
3
|
+
const Message = require('./Message.js');
|
4
|
+
const Utils = require('./Utils.js');
|
5
|
+
const Version = require('./Version.js');
|
6
|
+
|
7
|
+
module.exports = {
|
8
|
+
Http,
|
9
|
+
Logger,
|
10
|
+
Message,
|
11
|
+
Utils,
|
12
|
+
Version
|
13
|
+
};
|
package/main.js
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
var Http = require('../adapay-core/Http');
|
2
|
+
var Logger = require('../adapay-core/Logger');
|
3
|
+
var Config = require('./Config');
|
4
|
+
function merConf(kwargs) {
|
5
|
+
return new Promise(function (resolve, reject) {
|
6
|
+
let url = Config.base_url + `/v1/batchInput/merConf`;
|
7
|
+
Http.post(url, kwargs, Config)
|
8
|
+
.then(function (result) {
|
9
|
+
Logger.info(result);
|
10
|
+
resolve(result);
|
11
|
+
})
|
12
|
+
.catch(function (error) {
|
13
|
+
Logger.error(error);
|
14
|
+
reject(error);
|
15
|
+
});
|
16
|
+
});
|
17
|
+
}
|
18
|
+
function queryMerConf(kwargs) {
|
19
|
+
return new Promise(function (resolve, reject) {
|
20
|
+
let url = Config.base_url + `/v1/batchInput/merConf`;
|
21
|
+
Http.get(url, kwargs, Config)
|
22
|
+
.then(function (result) {
|
23
|
+
Logger.info(result);
|
24
|
+
resolve(result);
|
25
|
+
})
|
26
|
+
.catch(function (error) {
|
27
|
+
Logger.error(error);
|
28
|
+
reject(error);
|
29
|
+
});
|
30
|
+
});
|
31
|
+
}
|
32
|
+
function merResidentModify(kwargs) {
|
33
|
+
return new Promise(function (resolve, reject) {
|
34
|
+
let url = Config.base_url + `/v1/batchInput/merResidentModify`;
|
35
|
+
Http.post(url, kwargs, Config)
|
36
|
+
.then(function (result) {
|
37
|
+
Logger.info(result);
|
38
|
+
resolve(result);
|
39
|
+
})
|
40
|
+
.catch(function (error) {
|
41
|
+
Logger.error(error);
|
42
|
+
reject(error);
|
43
|
+
});
|
44
|
+
});
|
45
|
+
}
|
46
|
+
module.exports = { merConf, queryMerConf, merResidentModify };
|
@@ -0,0 +1,33 @@
|
|
1
|
+
const default_public_key =
|
2
|
+
'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwN6xgd6Ad8v2hIIsQVnbt8a3JituR8o4Tc3B5WlcFR55bz4OMqrG/356Ur3cPbc2Fe8ArNd/0gZbC9q56Eb16JTkVNA/fye4SXznWxdyBPR7+guuJZHc/VW2fKH2lfZ2P3Tt0QkKZZoawYOGSMdIvO+WqK44updyax0ikK6JlNQIDAQAB';
|
3
|
+
var debug = false;
|
4
|
+
var prod_mode = '1';
|
5
|
+
var config_dirname = '';
|
6
|
+
var config_global = {};
|
7
|
+
var api_key = '';
|
8
|
+
var private_key_path = '';
|
9
|
+
var private_key = '';
|
10
|
+
var public_key_path = '';
|
11
|
+
var public_key = default_public_key;
|
12
|
+
var connect_timeout = 30000;
|
13
|
+
var base_url = 'https://api.adapay.tech';
|
14
|
+
var log_file_path = './';
|
15
|
+
var log_level = 'warn';
|
16
|
+
var log_console_enable = false;
|
17
|
+
module.exports = {
|
18
|
+
default_public_key,
|
19
|
+
debug,
|
20
|
+
prod_mode,
|
21
|
+
config_dirname,
|
22
|
+
config_global,
|
23
|
+
api_key,
|
24
|
+
private_key_path,
|
25
|
+
private_key,
|
26
|
+
public_key_path,
|
27
|
+
public_key,
|
28
|
+
connect_timeout,
|
29
|
+
base_url,
|
30
|
+
log_file_path,
|
31
|
+
log_level,
|
32
|
+
log_console_enable
|
33
|
+
};
|
@@ -0,0 +1,60 @@
|
|
1
|
+
var Http = require('../adapay-core/Http');
|
2
|
+
var Logger = require('../adapay-core/Logger');
|
3
|
+
var Config = require('./Config');
|
4
|
+
function batchEntrys(kwargs) {
|
5
|
+
return new Promise(function (resolve, reject) {
|
6
|
+
let url = Config.base_url + `/v1/batchEntrys/userEntry`;
|
7
|
+
Http.post(url, kwargs, Config)
|
8
|
+
.then(function (result) {
|
9
|
+
Logger.info(result);
|
10
|
+
resolve(result);
|
11
|
+
})
|
12
|
+
.catch(function (error) {
|
13
|
+
Logger.error(error);
|
14
|
+
reject(error);
|
15
|
+
});
|
16
|
+
});
|
17
|
+
}
|
18
|
+
function queryEntry(kwargs) {
|
19
|
+
return new Promise(function (resolve, reject) {
|
20
|
+
let url = Config.base_url + `/v1/batchEntrys/userEntry`;
|
21
|
+
Http.get(url, kwargs, Config)
|
22
|
+
.then(function (result) {
|
23
|
+
Logger.info(result);
|
24
|
+
resolve(result);
|
25
|
+
})
|
26
|
+
.catch(function (error) {
|
27
|
+
Logger.error(error);
|
28
|
+
reject(error);
|
29
|
+
});
|
30
|
+
});
|
31
|
+
}
|
32
|
+
function createApplication(kwargs) {
|
33
|
+
return new Promise(function (resolve, reject) {
|
34
|
+
let url = Config.base_url + `/v1/batchEntrys/application`;
|
35
|
+
Http.post(url, kwargs, Config)
|
36
|
+
.then(function (result) {
|
37
|
+
Logger.info(result);
|
38
|
+
resolve(result);
|
39
|
+
})
|
40
|
+
.catch(function (error) {
|
41
|
+
Logger.error(error);
|
42
|
+
reject(error);
|
43
|
+
});
|
44
|
+
});
|
45
|
+
}
|
46
|
+
function queryApplication(kwargs) {
|
47
|
+
return new Promise(function (resolve, reject) {
|
48
|
+
let url = Config.base_url + `/v1/batchEntrys/application`;
|
49
|
+
Http.get(url, kwargs, Config)
|
50
|
+
.then(function (result) {
|
51
|
+
Logger.info(result);
|
52
|
+
resolve(result);
|
53
|
+
})
|
54
|
+
.catch(function (error) {
|
55
|
+
Logger.error(error);
|
56
|
+
reject(error);
|
57
|
+
});
|
58
|
+
});
|
59
|
+
}
|
60
|
+
module.exports = { batchEntrys, queryEntry, createApplication, queryApplication };
|
@@ -0,0 +1,54 @@
|
|
1
|
+
var Http = require('../adapay-core/Http');
|
2
|
+
var Logger = require('../adapay-core/Logger');
|
3
|
+
var Config = require('./Config');
|
4
|
+
var FormData = require('form-data');
|
5
|
+
const fs = require('fs');
|
6
|
+
function merProfilePicture(kwargs, filePath) {
|
7
|
+
return new Promise(function (resolve, reject) {
|
8
|
+
let url = Config.base_url + `/v1/merProfile/merProfilePicture`;
|
9
|
+
let data = new FormData();
|
10
|
+
for (var key in kwargs) {
|
11
|
+
data.append(key, kwargs[key], '');
|
12
|
+
}
|
13
|
+
const file = fs.createReadStream(filePath);
|
14
|
+
data.append('file', file);
|
15
|
+
Http.uploadFile(url, kwargs, data, Config)
|
16
|
+
.then(function (result) {
|
17
|
+
Logger.info(result);
|
18
|
+
resolve(result);
|
19
|
+
})
|
20
|
+
.catch(function (error) {
|
21
|
+
Logger.error(error);
|
22
|
+
reject(error);
|
23
|
+
});
|
24
|
+
});
|
25
|
+
}
|
26
|
+
function merProfileForAudit(kwargs) {
|
27
|
+
return new Promise(function (resolve, reject) {
|
28
|
+
let url = Config.base_url + `/v1/merProfile/merProfileForAudit`;
|
29
|
+
Http.post(url, kwargs, Config)
|
30
|
+
.then(function (result) {
|
31
|
+
Logger.info(result);
|
32
|
+
resolve(result);
|
33
|
+
})
|
34
|
+
.catch(function (error) {
|
35
|
+
Logger.error(error);
|
36
|
+
reject(error);
|
37
|
+
});
|
38
|
+
});
|
39
|
+
}
|
40
|
+
function queryProfileInfoAuditStatus(kwargs) {
|
41
|
+
return new Promise(function (resolve, reject) {
|
42
|
+
let url = Config.base_url + `/v1/merProfile/merProfile`;
|
43
|
+
Http.get(url, kwargs, Config)
|
44
|
+
.then(function (result) {
|
45
|
+
Logger.info(result);
|
46
|
+
resolve(result);
|
47
|
+
})
|
48
|
+
.catch(function (error) {
|
49
|
+
Logger.error(error);
|
50
|
+
reject(error);
|
51
|
+
});
|
52
|
+
});
|
53
|
+
}
|
54
|
+
module.exports = { merProfilePicture, merProfileForAudit, queryProfileInfoAuditStatus };
|