@opengis/pay 1.1.12 → 1.1.13

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.
@@ -0,0 +1,33 @@
1
+ import request from 'request-promise';
2
+
3
+ import { config, pgClients } from '@opengis/fastify-table/utils.js';
4
+
5
+ const { host, payeeId } = config.integrations?.pay || {};
6
+
7
+ export default async function updateTrxStatus({
8
+ pg = pgClients.client, paymentId,
9
+ }) {
10
+ const data = pg.pk?.['billing.payments'] && paymentId ? await pg.query('select * from billing.payments where payment_id=$1', [paymentId]).then(el => el.rows?.[0] || {}) : undefined;
11
+ if (!paymentId || !host || !payeeId || !data) throw new Error('not enough params');
12
+
13
+ const formData = {
14
+ method: 'result',
15
+ login: 'WDISHOP',
16
+ password: 'wdi451',
17
+ payeeId,
18
+ shopOrderNumber: paymentId,
19
+ // shopbillId,
20
+ id: paymentId,
21
+ };
22
+ const response = await request({
23
+ url: `${host}/gateway/`,
24
+ method: 'POST',
25
+ formData,
26
+ followAllRedirects: false,
27
+ jar: true,
28
+ timeout: 6000,
29
+ simple: false, // prevent not 2xx code trigger catch
30
+ resolveWithFullResponse: true,
31
+ });
32
+ return response;
33
+ }