@gls_spain/gps-common 33.0.9 → 34.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.
@@ -2,9 +2,8 @@
2
2
  <project version="4">
3
3
  <component name="ChangeListManager">
4
4
  <list default="true" id="c2833e40-3178-44f3-9bc5-203849985c7f" name="Default Changelist" comment="">
5
- <change afterPath="$PROJECT_DIR$/errors/SaleDoesNotExistError.js" afterDir="false" />
6
- <change beforePath="$PROJECT_DIR$/errors/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/errors/index.js" afterDir="false" />
7
5
  <change beforePath="$PROJECT_DIR$/open-api-spec/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/open-api-spec/index.js" afterDir="false" />
6
+ <change beforePath="$PROJECT_DIR$/schemas/definitions/sales.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/sales.js" afterDir="false" />
8
7
  </list>
9
8
  <option name="SHOW_DIALOG" value="false" />
10
9
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -78,16 +77,6 @@
78
77
  </key>
79
78
  </component>
80
79
  <component name="RunManager" selected="JavaScript Debug.documentation.html (1)">
81
- <configuration name="index.test.js" type="JavaScriptTestRunnerJest" temporary="true" nameIsGenerated="true">
82
- <node-interpreter value="project" />
83
- <node-options value="" />
84
- <jest-package value="$PROJECT_DIR$/node_modules/jest" />
85
- <working-dir value="$PROJECT_DIR$" />
86
- <envs />
87
- <scope-kind value="TEST_FILE" />
88
- <test-file value="$PROJECT_DIR$/index.test.js" />
89
- <method v="2" />
90
- </configuration>
91
80
  <configuration name="documentation.html (1)" type="JavascriptDebugType" temporary="true" nameIsGenerated="true" uri="http://localhost:63342/gps-common/build/documentation/documentation.html" useBuiltInWebServerPort="true">
92
81
  <method v="2" />
93
82
  </configuration>
@@ -111,6 +100,16 @@
111
100
  <envs />
112
101
  <method v="2" />
113
102
  </configuration>
103
+ <configuration name="semantic-release" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
104
+ <package-json value="$PROJECT_DIR$/package.json" />
105
+ <command value="run" />
106
+ <scripts>
107
+ <script value="semantic-release" />
108
+ </scripts>
109
+ <node-interpreter value="project" />
110
+ <envs />
111
+ <method v="2" />
112
+ </configuration>
114
113
  <configuration name="test" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
115
114
  <package-json value="$PROJECT_DIR$/package.json" />
116
115
  <command value="run" />
@@ -123,11 +122,11 @@
123
122
  </configuration>
124
123
  <recent_temporary>
125
124
  <list>
126
- <item itemvalue="npm.commit" />
127
125
  <item itemvalue="npm.build-documentation" />
128
126
  <item itemvalue="JavaScript Debug.documentation.html (1)" />
127
+ <item itemvalue="npm.semantic-release" />
128
+ <item itemvalue="npm.commit" />
129
129
  <item itemvalue="npm.test" />
130
- <item itemvalue="Jest.index.test.js" />
131
130
  </list>
132
131
  </recent_temporary>
133
132
  </component>
@@ -589,7 +588,9 @@
589
588
  <workItem from="1595865087442" duration="564000" />
590
589
  <workItem from="1595914052000" duration="4102000" />
591
590
  <workItem from="1595939490548" duration="3433000" />
592
- <workItem from="1595961689372" duration="947000" />
591
+ <workItem from="1595961689372" duration="1814000" />
592
+ <workItem from="1595999862116" duration="11371000" />
593
+ <workItem from="1596052438845" duration="2652000" />
593
594
  </task>
594
595
  <servers />
595
596
  </component>
@@ -632,22 +633,22 @@
632
633
  <screen x="0" y="23" width="2048" height="1129" />
633
634
  </state>
634
635
  <state x="762" y="341" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.23.2048.1129@0.23.2048.1129" timestamp="1595577705727" />
635
- <state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1595963463155">
636
+ <state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1596055279837">
636
637
  <screen x="0" y="23" width="2048" height="1129" />
637
638
  </state>
638
- <state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="1595963463155" />
639
- <state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="1595963463154">
639
+ <state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="1596055279837" />
640
+ <state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="1596055279836">
640
641
  <screen x="0" y="23" width="2048" height="1129" />
641
642
  </state>
642
- <state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="1595963463154" />
643
- <state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="1595963463154">
643
+ <state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="1596055279836" />
644
+ <state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="1596055279836">
644
645
  <screen x="0" y="23" width="2048" height="1129" />
645
646
  </state>
646
- <state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="1595963463154" />
647
- <state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="1595963463155">
647
+ <state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="1596055279836" />
648
+ <state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="1596055279837">
648
649
  <screen x="0" y="23" width="2048" height="1129" />
649
650
  </state>
650
- <state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1595963463155" />
651
+ <state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1596055279837" />
651
652
  <state x="689" y="276" width="670" height="676" key="search.everywhere.popup" timestamp="1595579270021">
652
653
  <screen x="0" y="23" width="2048" height="1129" />
653
654
  </state>
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [34.0.0](https://github.com/GLS-Spain/gps-common/compare/v33.0.9...v34.0.0) (2020-07-29)
2
+
3
+
4
+ ### Features
5
+
6
+ * rework sales statuses, add sales payment fields, add callbacks and redirects endpoints ([8e6a5ef](https://github.com/GLS-Spain/gps-common/commit/8e6a5ef7b51d4d02591a2e945512ac4eb3f96e82))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * sales statuses have changed
12
+
1
13
  ## [33.0.9](https://github.com/GLS-Spain/gps-common/compare/v33.0.8...v33.0.9) (2020-07-28)
2
14
 
3
15
 
@@ -225,8 +225,8 @@ openApiSpec['x-tagGroups'] = [
225
225
  'Expeditions expiration',
226
226
  'GLS Spain integration',
227
227
  'GLS International integration',
228
- 'GLS SMS integration',
229
228
  'Ingenico integration',
229
+ 'GLS SMS integration',
230
230
  ],
231
231
  },
232
232
  {
@@ -247,6 +247,8 @@ openApiSpec['x-tagGroups'] = [
247
247
  'Sales',
248
248
  'Historic records',
249
249
  'Integrations',
250
+ 'Callbacks',
251
+ 'Redirects',
250
252
  ],
251
253
  },
252
254
  ];
@@ -515,11 +517,21 @@ under the \`glsInternationalExport\` name. Its \`networks\` field lists the netw
515
517
  to the international API. All other networks are ignored.`,
516
518
  },
517
519
  {
518
- name: 'GLS SMS integration', // todo
519
- description: `TODO`,
520
+ name: 'Ingenico integration',
521
+ description: `
522
+ Sales are paid using an [e-Commerce integration](https://epayments-support.ingenico.com/en/integration/all-sales-channels/integrate-with-e-commerce/)
523
+ with Ingenico ePayments.
524
+
525
+ Each sale has a \`payment.fullUrl\` field with a link to a page at Ingenico where the customer can pay for the sale. As the transaction
526
+ progresses Ingenico reports back to this API the changes in the payment process by using the
527
+ [ingenico callback](#tag/Integrations/paths/~1integrations~1ingenicoCallback/get) endpoint.
528
+
529
+ Since the URLs of the payment pages at Ingenico are very long, each sale also has a \`payment.shortId\` unique id that can be used in the
530
+ [redirect to ingenico](#tag/Integrations/paths/~1link~1{shortId}/get) endpoint, which is much shorter and redirects to the actual payment
531
+ page at Ingenico.`,
520
532
  },
521
533
  {
522
- name: 'Ingenico integration', // todo
534
+ name: 'GLS SMS integration', // todo
523
535
  description: `TODO`,
524
536
  },
525
537
  {
@@ -753,7 +765,7 @@ records. Since they are part of their expedition historic records, PODs do not h
753
765
 
754
766
  Customers can go to a parcel shop at any time and pay to have a package sent to an allowed destination.
755
767
 
756
- The allowed destinations and the price of the service can be found in the [\`defaults\` object](#tag/Config/paths/~1config~1defaults~1get/get).
768
+ The allowed destinations and the price of the service can be found in the [defaults object](#tag/Config/paths/~1config~1defaults~1get/get).
757
769
 
758
770
  The process for a sale is the following:
759
771
 
@@ -762,6 +774,22 @@ The process for a sale is the following:
762
774
  - If Ingenico responds that the customer has paid the API will use the GLS Spain integration to notify GLS of the new sale.
763
775
  - GLS Spain will then create a pickup expedition associated to the sale which will be picked up by a driver.
764
776
 
777
+ ### Status
778
+
779
+ The \`status.code\` property of a sale indicates the payment situation of a sale. It is a direct translation of the Ingenico integration
780
+ [transaction statuses](https://epayments-support.ingenico.com/en/get-started/payment-platform-user-guides/transaction-statuses/guide). The
781
+ possible values are:
782
+
783
+ - \`invalidOrIncomplete\`: the customer has not begun or is still completing the transaction, or the acquirer has not responded yet.
784
+ - \`cancelledByCustomer\`: the customer has cancelled the transaction.
785
+ - \`authorizationRefused\`: the acquirer declined the authorization due to insufficient funds, unsuccessful authentication, suspicion of fraud, etc.
786
+ - \`paymentRequested\`: the payment request has been accepted and the acquirer will transfer the funds.
787
+ - \`paymentDeleted\`: a refund request was made before the acquirer transferred the funds, so the transfer has been cancelled.
788
+ - \`refund\`: a refund request was made after the acquirer transferred the funds, so the payment has been refunded.
789
+
790
+ The \`status\` of a sale cannot be updated by directly using the API, instead it is updated when Ingenico reports back changes in the
791
+ transaction using the [callback endpoint](#tag/Integrations/paths/~1integrations~1ingenicoCallback/get).
792
+
765
793
  ## Sale schema
766
794
 
767
795
  <SchemaDefinition schemaRef="#/components/schemas/sale" />`,
@@ -794,6 +822,19 @@ of each record.
794
822
 
795
823
  <SchemaDefinition schemaRef="#/components/schemas/integration" />`,
796
824
  },
825
+ {
826
+ name: 'Callbacks',
827
+ description: `
828
+ This section contains endpoints that are not meant to be used by the API users, instead they meant for other systems (integrations, etc)
829
+ to report back information when they have it.
830
+ `,
831
+ },
832
+ {
833
+ name: 'Redirects',
834
+ description: `
835
+ This section contains endpoints that redirect to other URLs.
836
+ `,
837
+ },
797
838
  ];
798
839
 
799
840
  const headers = {
@@ -3307,6 +3348,106 @@ ${securitySchemes.superAdminRole}`,
3307
3348
  },
3308
3349
  },
3309
3350
  },
3351
+ '/callbacks/ingenico': {
3352
+ get: {
3353
+ tags: ['Callbacks'],
3354
+ summary: 'Ingenico payment feedback',
3355
+ description: `
3356
+ Sales are paid by customers via an Ingenico page where they can enter the payment data. When the payment status changes (paid, cancelled,
3357
+ refused, etc) Ingenico reports these changes back to the API via this endpoint.
3358
+
3359
+ The endpoint does not require any authorization, instead the URL query parameters include a hash digest that the API will use to validate
3360
+ the call against a known secret.`,
3361
+ parameters: [
3362
+ {
3363
+ name: 'orderID',
3364
+ in: 'query',
3365
+ required: true,
3366
+ schema: { type: 'string' },
3367
+ description: 'The same order id that was generated by the API when creating the link to the payment page.',
3368
+ },
3369
+ {
3370
+ name: 'PAYID',
3371
+ in: 'query',
3372
+ required: true,
3373
+ schema: { type: 'string' },
3374
+ description: 'A unique id generated by Ingenico for this payment.',
3375
+ },
3376
+ {
3377
+ name: 'STATUS',
3378
+ in: 'query',
3379
+ required: true,
3380
+ schema: { type: 'integer' },
3381
+ description: 'The new status of the payment.',
3382
+ },
3383
+ {
3384
+ name: 'NCERROR',
3385
+ in: 'query',
3386
+ required: true,
3387
+ schema: { type: 'integer' },
3388
+ description: 'If the new status is an error this will be the exact error. If there is no error it will be 0.',
3389
+ },
3390
+ {
3391
+ name: 'SHASIGN',
3392
+ in: 'query',
3393
+ required: true,
3394
+ schema: { type: 'string' },
3395
+ description: 'A digest of the entire query string that the API will use to verify that the caller is Ingenico.',
3396
+ },
3397
+ ],
3398
+ responses: {
3399
+ ' 200': {
3400
+ description: 'The data in the URL query parameters has been verified and accepted.',
3401
+ content: { 'text/plain': { schema: { type: 'string', enum: ['ok'] } } },
3402
+ },
3403
+ ' 400': {
3404
+ description: 'There is invalid data in the URL query parameters',
3405
+ content: { 'text/plain': { schema: { type: 'string', description: 'a description of the invalid query parameters' } } },
3406
+ },
3407
+ ' 401': {
3408
+ description: 'The signing digest is invalid',
3409
+ content: { 'text/plain': { schema: { type: 'string', enum: ['the signing digest is invalid'] } } },
3410
+ },
3411
+ },
3412
+ },
3413
+ },
3414
+ '/i/{shortId}': {
3415
+ get: {
3416
+ tags: ['Redirects'],
3417
+ summary: 'To Ingenico payment page',
3418
+ description: `
3419
+ The URLs of the payment pages at Ingenico are very long because they include many parameters in the query string.
3420
+
3421
+ To allow sharing the link to the payment page via methods that are limited in content length, each sale has a \`payment.shortId\` field
3422
+ that can be used with this endpoint to redirect to the actual payment page at Ingenico.
3423
+
3424
+ The endpoint does not require any authorization, anyone who knows the \`shortId\` can get redirected to the payment page.`,
3425
+ parameters: [
3426
+ {
3427
+ name: 'shortId',
3428
+ in: 'path',
3429
+ required: true,
3430
+ schema: { type: 'string' },
3431
+ description: `The \`payment.shortId\` field of the sale`,
3432
+ },
3433
+ ],
3434
+ responses: {
3435
+ ' 302': {
3436
+ description: 'A redirection to the payment page at Ingenico.',
3437
+ headers: {
3438
+ Location: {
3439
+ description: 'The URL of the payment page.',
3440
+ schema: { type: 'string', format: 'uri' },
3441
+ },
3442
+ },
3443
+ },
3444
+ ' 404': {
3445
+ description: `There is no sale with the provided \`shortId\``,
3446
+ content: { 'text/plain': { schema: { type: 'string', enum: ['not found'] } } },
3447
+ },
3448
+ },
3449
+ },
3450
+ },
3310
3451
  };
3311
3452
 
3312
3453
  module.exports = openApiSpec;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gls_spain/gps-common",
3
- "version": "33.0.9",
3
+ "version": "34.0.0",
4
4
  "description": "Errors, schemas and documentation for the Parcel Shops project",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -40,7 +40,10 @@ const sale = () => ({
40
40
  status: {
41
41
  type: 'object',
42
42
  properties: {
43
- code: { type: 'string', enum: ['pending', 'paid', 'failed'] },
43
+ code: {
44
+ type: 'string',
45
+ enum: ['invalidOrIncomplete', 'cancelledByCustomer', 'authorizationRefused', 'paymentRequested', 'paymentDeleted', 'refund'],
46
+ },
44
47
  },
45
48
  required: ['code'],
46
49
  additionalProperties: false,
@@ -88,6 +91,30 @@ const sale = () => ({
88
91
  required: ['name', 'nif', 'address', 'emails', 'phones', 'fiscal'],
89
92
  additionalProperties: false,
90
93
  },
94
+ payment: {
95
+ type: 'object',
96
+ properties: {
97
+ statusHistory: {
98
+ type: 'array',
99
+ items: {
100
+ type: 'object',
101
+ properties: {
102
+ at: datetime(),
103
+ status: { type: 'integer' },
104
+ error: { type: 'integer' },
105
+ },
106
+ required: ['at', 'status', 'error'],
107
+ additionalProperties: false,
108
+ },
109
+ },
110
+ orderId: { type: 'string' },
111
+ payId: { type: 'string', description: 'only available after payment' },
112
+ fullUrl: { type: 'string' },
113
+ shortId: { type: 'string' },
114
+ },
115
+ required: ['statusHistory', 'orderId', 'fullUrl', 'shortId'],
116
+ additionalProperties: false,
117
+ },
91
118
  },
92
119
  required: [
93
120
  '_id',
@@ -102,6 +129,7 @@ const sale = () => ({
102
129
  'settings',
103
130
  'destination',
104
131
  'sender',
132
+ 'payment',
105
133
  ],
106
134
  additionalProperties: false,
107
135
  });