@opengis/pay 1.3.2 → 2.0.0

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.
Files changed (34) hide show
  1. package/README.md +45 -12
  2. package/module/pay/pt/marketplace-service-payment-client-template.html +5 -5
  3. package/package.json +9 -7
  4. package/plugin.js +2 -0
  5. package/server/migrations/7_transactions.sql +35 -0
  6. package/server/plugins/hook.js +27 -10
  7. package/server/plugins/payment/createPayment.js +29 -0
  8. package/server/plugins/payment/createTransaction.js +26 -0
  9. package/server/plugins/payment/liqpay.checkStatus.js +43 -0
  10. package/server/plugins/payment/liqpay.createTransaction.js +103 -0
  11. package/server/plugins/payment/monopay.checkStatus.js +48 -0
  12. package/server/plugins/payment/monopay.createTransaction.js +116 -0
  13. package/server/plugins/payment/paymentInfo.js +26 -0
  14. package/server/plugins/payment/portmone.checkStatus.js +51 -0
  15. package/server/plugins/payment/portmone.createTransaction.js +94 -0
  16. package/server/plugins/payment/processTransaction.js +73 -0
  17. package/server/routes/{portmone → core}/controllers/payment.info.js +32 -29
  18. package/server/routes/core/index.mjs +12 -0
  19. package/server/routes/liqpay/controllers/liqpay.redirect.js +25 -115
  20. package/server/routes/liqpay/controllers/liqpay.status.js +31 -150
  21. package/server/routes/monopay/controllers/monopay.redirect.js +25 -117
  22. package/server/routes/monopay/controllers/monopay.status.js +8 -56
  23. package/server/routes/portmone/controllers/portmone.redirect.js +27 -116
  24. package/server/routes/portmone/controllers/portmone.status.js +36 -136
  25. package/server/routes/portmone/index.mjs +5 -6
  26. package/utils.js +11 -0
  27. package/server/migrations/1_users.sql +0 -121
  28. package/server/migrations/2_accounts.sql +0 -59
  29. package/server/migrations/3_utils.sql +0 -74
  30. package/server/migrations/4_subscriptions.sql +0 -36
  31. package/server/migrations/5_payments.sql +0 -39
  32. package/server/migrations/6_invoices.sql +0 -55
  33. package/server/routes/liqpay/utils/check.status.js +0 -34
  34. package/server/routes/portmone/utils/portmone.check.status.js +0 -34
@@ -1,34 +0,0 @@
1
- import LiqPay from 'liqpayjs-sdk';
2
- import request from 'request-promise';
3
-
4
- import config from '../../../../config.js';
5
-
6
- const { publicKey, privateKey } = config.integrations?.liqpay || {};
7
-
8
- const liqpay = new LiqPay(publicKey, privateKey);
9
- const host = 'https://www.liqpay.ua';
10
-
11
- export default async function liqpayCheckStatus(id) {
12
- if (!publicKey || !privateKey) return {};
13
-
14
- const options = {
15
- public_key: publicKey, // in case of liqpay.api is auto-assigned
16
- action: 'status',
17
- version: '3',
18
- order_id: id,
19
- };
20
- /* const result = liqpay.api('request', options); */
21
-
22
- const data = Buffer.from(JSON.stringify(options)).toString('base64');
23
- const signature = liqpay.str_to_sign(privateKey + data + privateKey);
24
-
25
- const response = await request(`${host}/api/request`, {
26
- method: 'POST',
27
- form: { data, signature },
28
- headers: {
29
- 'Content-Type': 'application/x-www-form-urlencoded',
30
- },
31
- });
32
- const result = response?.startsWith?.('{') ? JSON.parse(response) : response;
33
- return result;
34
- }
@@ -1,34 +0,0 @@
1
- import request from 'request-promise';
2
-
3
- import config from '../../../../config.js';
4
- import pgClients from '../../../plugins/pg/pgClients.js';
5
-
6
- const { host, payeeId } = config.integrations?.pay || {};
7
-
8
- export default async function updateTrxStatus({
9
- pg = pgClients.client, paymentId,
10
- }) {
11
- 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;
12
- if (!paymentId || !host || !payeeId || !data) throw new Error('not enough params');
13
-
14
- const formData = {
15
- method: 'result',
16
- login: 'WDISHOP',
17
- password: 'wdi451',
18
- payeeId,
19
- shopOrderNumber: paymentId,
20
- // shopbillId,
21
- id: paymentId,
22
- };
23
- const response = await request({
24
- url: `${host}/gateway/`,
25
- method: 'POST',
26
- formData,
27
- followAllRedirects: false,
28
- jar: true,
29
- timeout: 6000,
30
- simple: false, // prevent not 2xx code trigger catch
31
- resolveWithFullResponse: true,
32
- });
33
- return response;
34
- }