@opengis/pay 2.0.8 → 2.0.9

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/pay",
3
- "version": "2.0.8",
3
+ "version": "2.0.9",
4
4
  "type": "module",
5
5
  "description": "pay plugins for billing",
6
6
  "main": "plugin.js",
@@ -14,6 +14,7 @@ const controller = {
14
14
 
15
15
  export default async function createTransaction({
16
16
  orderId, amount, referer, uid, debug, service, expiredDate, description, action, language, paytypes, currency, deliveryEmails, optionalParams,
17
+ splitRules, splitTicketsDynamicRequisites, splitTicketsOnly,
17
18
  }, pg = pgClients.client) {
18
19
  if (!service) throw new Error('not enough params: service');
19
20
  if (!controller[service]) { throw new Error('invalid params: service'); }
@@ -38,8 +39,12 @@ export default async function createTransaction({
38
39
  description,
39
40
  language,
40
41
  paytypes,
42
+ currency,
41
43
  deliveryEmails,
42
44
  optionalParams,
45
+ splitRules,
46
+ splitTicketsDynamicRequisites,
47
+ splitTicketsOnly,
43
48
  }, pg);
44
49
  return result;
45
50
  }
@@ -19,6 +19,7 @@ const liqpay = new LiqPay(publicKey, privateKey);
19
19
 
20
20
  export default async function liqpayCreateTransaction({
21
21
  id, orderId, amount, referer, uid, debug, expiredDate, description, paytypes, action = 'pay', currency = 'uah', language = 'uk', deliveryEmails, optionalParams,
22
+ splitRules, splitTicketsDynamicRequisites, splitTicketsOnly,
22
23
  }, pg = pgClients.client) {
23
24
  if (!referer) {
24
25
  throw new Error('not enough params: referer required');
@@ -102,6 +103,18 @@ export default async function liqpayCreateTransaction({
102
103
  } : undefined,
103
104
  };
104
105
 
106
+ if (splitTicketsDynamicRequisites) {
107
+ paymentOptions.split_tickets_dynamic_requisites = true;
108
+ }
109
+ if (splitTicketsOnly) {
110
+ paymentOptions.split_tickets_only = true;
111
+ }
112
+
113
+ // regular split rules are optional[], refer to LiqPay documentation
114
+ if (Array.isArray(splitRules) && splitRules.length) {
115
+ paymentOptions.split_rules = splitRules;
116
+ }
117
+
105
118
  // html interface for debug via browser only
106
119
  if (process.env.NODE_ENV !== 'test' && debug) {
107
120
  return liqpay.cnb_form(paymentOptions);
@@ -1,12 +1,14 @@
1
1
  import paymentInfo from './controllers/payment.info.js';
2
2
 
3
- export default async function plugin(app, opts) {
4
- app.route({
5
- method: 'GET',
6
- url: '/payment-info/:id',
7
- config: {
8
- policy: ['site'],
9
- },
10
- handler: paymentInfo,
11
- });
3
+ export default function plugin(app, { prefix = '/api' } = {}) {
4
+ if (!app.hasRoute({ method: 'GET', url: `${prefix}/payment-info/:id` })) {
5
+ app.route({
6
+ method: 'GET',
7
+ url: '/payment-info/:id',
8
+ config: {
9
+ policy: 'L1',
10
+ },
11
+ handler: paymentInfo,
12
+ });
13
+ }
12
14
  }
@@ -1,30 +1,37 @@
1
1
  import liqpayRedirect from './controllers/liqpay.redirect.js';
2
2
  import liqpayStatus from './controllers/liqpay.status.js';
3
3
 
4
- export default async function plugin(app, opts) {
5
- app.route({
6
- method: 'GET',
7
- url: '/liqpay-redirect',
8
- config: {
9
- policy: ['site'],
10
- },
11
- handler: liqpayRedirect,
12
- });
13
- // /payment-info/:id
14
- app.route({
15
- method: 'POST',
16
- url: '/liqpay/:id/:status',
17
- config: {
18
- policy: ['public'],
19
- },
20
- handler: liqpayStatus,
21
- });
22
- app.route({
23
- method: 'GET',
24
- url: '/liqpay/:id/:status',
25
- config: {
26
- policy: ['public'],
27
- },
28
- handler: liqpayStatus,
29
- });
4
+ export default function plugin(app, { prefix = '/api' } = {}) {
5
+ if (!app.hasRoute({ method: 'GET', url: `${prefix}/liqpay-redirect` })) {
6
+ app.route({
7
+ method: 'GET',
8
+ url: '/liqpay-redirect',
9
+ config: {
10
+ policy: 'L1',
11
+ },
12
+ handler: liqpayRedirect,
13
+ });
14
+ }
15
+
16
+ if (!app.hasRoute({ method: 'POST', url: `${prefix}/liqpay/:id/:status` })) {
17
+ app.route({
18
+ method: 'POST',
19
+ url: '/liqpay/:id/:status',
20
+ config: {
21
+ policy: 'L0',
22
+ },
23
+ handler: liqpayStatus,
24
+ });
25
+ }
26
+
27
+ if (!app.hasRoute({ method: 'GET', url: `${prefix}/liqpay/:id/:status` })) {
28
+ app.route({
29
+ method: 'GET',
30
+ url: '/liqpay/:id/:status',
31
+ config: {
32
+ policy: 'L0',
33
+ },
34
+ handler: liqpayStatus,
35
+ });
36
+ }
30
37
  }
@@ -14,19 +14,24 @@ const schema = {
14
14
  },
15
15
  };
16
16
 
17
- export default async function plugin(app, opts) {
18
- app.route({
19
- method: 'GET',
20
- url: '/monopay-redirect',
21
- config: { policy: ['site'] },
22
- schema,
23
- handler: monopayRedirect,
24
- });
25
- app.route({
26
- method: 'GET',
27
- url: '/monopay/:id/:status',
28
- config: { policy: ['public'] },
29
- schema,
30
- handler: monopayStatus,
31
- });
17
+ export default function plugin(app, { prefix = '/api' } = {}) {
18
+ if (!app.hasRoute({ method: 'GET', url: `${prefix}/monopay-redirect` })) {
19
+ app.route({
20
+ method: 'GET',
21
+ url: '/monopay-redirect',
22
+ config: { policy: 'L1' },
23
+ schema,
24
+ handler: monopayRedirect,
25
+ });
26
+ }
27
+
28
+ if (!app.hasRoute({ method: 'GET', url: `${prefix}/monopay/:id/:status` })) {
29
+ app.route({
30
+ method: 'GET',
31
+ url: '/monopay/:id/:status',
32
+ config: { policy: 'L0' },
33
+ schema,
34
+ handler: monopayStatus,
35
+ });
36
+ }
32
37
  }
@@ -1,29 +1,37 @@
1
1
  import portmoneRedirect from './controllers/portmone.redirect.js';
2
2
  import portmoneStatus from './controllers/portmone.status.js';
3
3
 
4
- export default async function plugin(app, opts) {
5
- app.route({
6
- method: 'GET',
7
- url: '/portmone-redirect',
8
- config: {
9
- policy: ['site'],
10
- },
11
- handler: portmoneRedirect,
12
- });
13
- app.route({
14
- method: 'POST',
15
- url: '/portmone/:id/:status',
16
- config: {
17
- policy: ['public'],
18
- },
19
- handler: portmoneStatus,
20
- });
21
- app.route({
22
- method: 'GET',
23
- url: '/portmone/:id/:status',
24
- config: {
25
- policy: ['public'],
26
- },
27
- handler: portmoneStatus,
28
- });
4
+ export default function plugin(app, { prefix = '/api' } = {}) {
5
+ if (!app.hasRoute({ method: 'GET', url: `${prefix}/portmone-redirect` })) {
6
+ app.route({
7
+ method: 'GET',
8
+ url: '/portmone-redirect',
9
+ config: {
10
+ policy: 'L1',
11
+ },
12
+ handler: portmoneRedirect,
13
+ });
14
+ }
15
+
16
+ if (!app.hasRoute({ method: 'POST', url: `${prefix}/portmone/:id/:status` })) {
17
+ app.route({
18
+ method: 'POST',
19
+ url: '/portmone/:id/:status',
20
+ config: {
21
+ policy: 'L0',
22
+ },
23
+ handler: portmoneStatus,
24
+ });
25
+ }
26
+
27
+ if (!app.hasRoute({ method: 'GET', url: `${prefix}/portmone/:id/:status` })) {
28
+ app.route({
29
+ method: 'GET',
30
+ url: '/portmone/:id/:status',
31
+ config: {
32
+ policy: 'L0',
33
+ },
34
+ handler: portmoneStatus,
35
+ });
36
+ }
29
37
  }