@gls_spain/gps-common 33.0.8 → 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.
- package/.idea/workspace.xml +43 -40
- package/CHANGELOG.md +19 -0
- package/errors/SaleDoesNotExistError.js +11 -0
- package/errors/index.js +3 -0
- package/open-api-spec/index.js +157 -6
- package/package.json +1 -1
- package/schemas/definitions/sales.js +29 -1
package/.idea/workspace.xml
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<project version="4">
|
|
3
3
|
<component name="ChangeListManager">
|
|
4
|
-
<list default="true" id="c2833e40-3178-44f3-9bc5-203849985c7f" name="Default Changelist" comment=""
|
|
4
|
+
<list default="true" id="c2833e40-3178-44f3-9bc5-203849985c7f" name="Default Changelist" comment="">
|
|
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" />
|
|
7
|
+
</list>
|
|
5
8
|
<option name="SHOW_DIALOG" value="false" />
|
|
6
9
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
7
10
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
@@ -41,7 +44,7 @@
|
|
|
41
44
|
<property name="WebServerToolWindowFactoryState" value="false" />
|
|
42
45
|
<property name="javascript.nodejs.core.library.configured.version" value="12.13.0" />
|
|
43
46
|
<property name="javascript.nodejs.core.library.typings.version" value="12.12.53" />
|
|
44
|
-
<property name="last_opened_file_path" value="$PROJECT_DIR
|
|
47
|
+
<property name="last_opened_file_path" value="$PROJECT_DIR$/errors" />
|
|
45
48
|
<property name="node.js.detected.package.eslint" value="true" />
|
|
46
49
|
<property name="node.js.detected.package.standard" value="true" />
|
|
47
50
|
<property name="node.js.path.for.package.eslint" value="project" />
|
|
@@ -58,13 +61,6 @@
|
|
|
58
61
|
<property name="ts.external.directory.path" value="$APPLICATION_HOME_DIR$/plugins/JavaScriptLanguage/jsLanguageServicesImpl/external" />
|
|
59
62
|
</component>
|
|
60
63
|
<component name="RecentsManager">
|
|
61
|
-
<key name="MoveFile.RECENT_KEYS">
|
|
62
|
-
<recent name="$PROJECT_DIR$/open-api" />
|
|
63
|
-
<recent name="$PROJECT_DIR$" />
|
|
64
|
-
<recent name="$PROJECT_DIR$/schemas" />
|
|
65
|
-
<recent name="$PROJECT_DIR$/open-api-spec" />
|
|
66
|
-
<recent name="$PROJECT_DIR$/errors" />
|
|
67
|
-
</key>
|
|
68
64
|
<key name="CopyFile.RECENT_KEYS">
|
|
69
65
|
<recent name="$PROJECT_DIR$/errors" />
|
|
70
66
|
<recent name="$PROJECT_DIR$/schemas/definitions" />
|
|
@@ -72,39 +68,43 @@
|
|
|
72
68
|
<recent name="$PROJECT_DIR$/schemas" />
|
|
73
69
|
<recent name="$PROJECT_DIR$/lib/scripts" />
|
|
74
70
|
</key>
|
|
71
|
+
<key name="MoveFile.RECENT_KEYS">
|
|
72
|
+
<recent name="$PROJECT_DIR$/open-api" />
|
|
73
|
+
<recent name="$PROJECT_DIR$" />
|
|
74
|
+
<recent name="$PROJECT_DIR$/schemas" />
|
|
75
|
+
<recent name="$PROJECT_DIR$/open-api-spec" />
|
|
76
|
+
<recent name="$PROJECT_DIR$/errors" />
|
|
77
|
+
</key>
|
|
75
78
|
</component>
|
|
76
79
|
<component name="RunManager" selected="JavaScript Debug.documentation.html (1)">
|
|
77
|
-
<configuration name="
|
|
78
|
-
<node-interpreter value="project" />
|
|
79
|
-
<node-options value="" />
|
|
80
|
-
<jest-package value="$PROJECT_DIR$/node_modules/jest" />
|
|
81
|
-
<working-dir value="$PROJECT_DIR$" />
|
|
82
|
-
<envs />
|
|
83
|
-
<scope-kind value="SUITE" />
|
|
84
|
-
<test-file value="$PROJECT_DIR$/index.test.js" />
|
|
85
|
-
<test-names>
|
|
86
|
-
<test-name value="#errors" />
|
|
87
|
-
</test-names>
|
|
80
|
+
<configuration name="documentation.html (1)" type="JavascriptDebugType" temporary="true" nameIsGenerated="true" uri="http://localhost:63342/gps-common/build/documentation/documentation.html" useBuiltInWebServerPort="true">
|
|
88
81
|
<method v="2" />
|
|
89
82
|
</configuration>
|
|
90
|
-
<configuration name="
|
|
83
|
+
<configuration name="build-documentation" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
|
|
84
|
+
<package-json value="$PROJECT_DIR$/package.json" />
|
|
85
|
+
<command value="run" />
|
|
86
|
+
<scripts>
|
|
87
|
+
<script value="build-documentation" />
|
|
88
|
+
</scripts>
|
|
91
89
|
<node-interpreter value="project" />
|
|
92
|
-
<node-options value="" />
|
|
93
|
-
<jest-package value="$PROJECT_DIR$/node_modules/jest" />
|
|
94
|
-
<working-dir value="$PROJECT_DIR$" />
|
|
95
90
|
<envs />
|
|
96
|
-
<scope-kind value="TEST_FILE" />
|
|
97
|
-
<test-file value="$PROJECT_DIR$/index.test.js" />
|
|
98
91
|
<method v="2" />
|
|
99
92
|
</configuration>
|
|
100
|
-
<configuration name="
|
|
93
|
+
<configuration name="commit" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
|
|
94
|
+
<package-json value="$PROJECT_DIR$/package.json" />
|
|
95
|
+
<command value="run" />
|
|
96
|
+
<scripts>
|
|
97
|
+
<script value="commit" />
|
|
98
|
+
</scripts>
|
|
99
|
+
<node-interpreter value="project" />
|
|
100
|
+
<envs />
|
|
101
101
|
<method v="2" />
|
|
102
102
|
</configuration>
|
|
103
|
-
<configuration name="
|
|
103
|
+
<configuration name="semantic-release" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
|
|
104
104
|
<package-json value="$PROJECT_DIR$/package.json" />
|
|
105
105
|
<command value="run" />
|
|
106
106
|
<scripts>
|
|
107
|
-
<script value="
|
|
107
|
+
<script value="semantic-release" />
|
|
108
108
|
</scripts>
|
|
109
109
|
<node-interpreter value="project" />
|
|
110
110
|
<envs />
|
|
@@ -122,11 +122,11 @@
|
|
|
122
122
|
</configuration>
|
|
123
123
|
<recent_temporary>
|
|
124
124
|
<list>
|
|
125
|
-
<item itemvalue="JavaScript Debug.documentation.html (1)" />
|
|
126
125
|
<item itemvalue="npm.build-documentation" />
|
|
126
|
+
<item itemvalue="JavaScript Debug.documentation.html (1)" />
|
|
127
|
+
<item itemvalue="npm.semantic-release" />
|
|
128
|
+
<item itemvalue="npm.commit" />
|
|
127
129
|
<item itemvalue="npm.test" />
|
|
128
|
-
<item itemvalue="Jest.index.test.js" />
|
|
129
|
-
<item itemvalue="Jest.#errors" />
|
|
130
130
|
</list>
|
|
131
131
|
</recent_temporary>
|
|
132
132
|
</component>
|
|
@@ -588,6 +588,9 @@
|
|
|
588
588
|
<workItem from="1595865087442" duration="564000" />
|
|
589
589
|
<workItem from="1595914052000" duration="4102000" />
|
|
590
590
|
<workItem from="1595939490548" duration="3433000" />
|
|
591
|
+
<workItem from="1595961689372" duration="1814000" />
|
|
592
|
+
<workItem from="1595999862116" duration="11371000" />
|
|
593
|
+
<workItem from="1596052438845" duration="2652000" />
|
|
591
594
|
</task>
|
|
592
595
|
<servers />
|
|
593
596
|
</component>
|
|
@@ -630,22 +633,22 @@
|
|
|
630
633
|
<screen x="0" y="23" width="2048" height="1129" />
|
|
631
634
|
</state>
|
|
632
635
|
<state x="762" y="341" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.23.2048.1129@0.23.2048.1129" timestamp="1595577705727" />
|
|
633
|
-
<state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="
|
|
636
|
+
<state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1596055279837">
|
|
634
637
|
<screen x="0" y="23" width="2048" height="1129" />
|
|
635
638
|
</state>
|
|
636
|
-
<state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="
|
|
637
|
-
<state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="
|
|
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">
|
|
638
641
|
<screen x="0" y="23" width="2048" height="1129" />
|
|
639
642
|
</state>
|
|
640
|
-
<state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="
|
|
641
|
-
<state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="
|
|
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">
|
|
642
645
|
<screen x="0" y="23" width="2048" height="1129" />
|
|
643
646
|
</state>
|
|
644
|
-
<state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="
|
|
645
|
-
<state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="
|
|
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">
|
|
646
649
|
<screen x="0" y="23" width="2048" height="1129" />
|
|
647
650
|
</state>
|
|
648
|
-
<state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="
|
|
651
|
+
<state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1596055279837" />
|
|
649
652
|
<state x="689" y="276" width="670" height="676" key="search.everywhere.popup" timestamp="1595579270021">
|
|
650
653
|
<screen x="0" y="23" width="2048" height="1129" />
|
|
651
654
|
</state>
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
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
|
+
|
|
13
|
+
## [33.0.9](https://github.com/GLS-Spain/gps-common/compare/v33.0.8...v33.0.9) (2020-07-28)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* add sale does not exist error when creating an expedition with a shop and a sale ([2c7f9b1](https://github.com/GLS-Spain/gps-common/commit/2c7f9b1db39b9f68c8100b119cef80eccdf10f76))
|
|
19
|
+
|
|
1
20
|
## [33.0.8](https://github.com/GLS-Spain/gps-common/compare/v33.0.7...v33.0.8) (2020-07-28)
|
|
2
21
|
|
|
3
22
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const { DatabaseError } = require('@gls_spain/mongodb');
|
|
2
|
+
|
|
3
|
+
class SaleDoesNotExistError extends DatabaseError {
|
|
4
|
+
constructor(message = 'Sale does not exist.') {
|
|
5
|
+
// noinspection JSCheckFunctionSignatures
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'SaleDoesNotExistError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = SaleDoesNotExistError;
|
package/errors/index.js
CHANGED
|
@@ -27,6 +27,7 @@ const RepresentativeCannotBeDeletedError = require('./RepresentativeCannotBeDele
|
|
|
27
27
|
const ZoneDoesNotExistError = require('./ZoneDoesNotExistError');
|
|
28
28
|
const ZoneAlreadyExistsError = require('./ZoneAlreadyExistsError');
|
|
29
29
|
const ZoneCannotBeDeletedError = require('./ZoneCannotBeDeletedError');
|
|
30
|
+
const SaleDoesNotExistError = require('./SaleDoesNotExistError');
|
|
30
31
|
const SaleAlreadyExistsError = require('./SaleAlreadyExistsError');
|
|
31
32
|
const InconsistentSalesSettingsError = require('./InconsistentSalesSettingsError');
|
|
32
33
|
const InvalidSaleDestinationError = require('./InvalidSaleDestinationError');
|
|
@@ -61,6 +62,7 @@ const errorsNames = {
|
|
|
61
62
|
ZoneDoesNotExistError: 'ZoneDoesNotExistError',
|
|
62
63
|
ZoneAlreadyExistsError: 'ZoneAlreadyExistsError',
|
|
63
64
|
ZoneCannotBeDeletedError: 'ZoneCannotBeDeletedError',
|
|
65
|
+
SaleDoesNotExistError: 'SaleDoesNotExistError',
|
|
64
66
|
SaleAlreadyExistsError: 'SaleAlreadyExistsError',
|
|
65
67
|
InconsistentSalesSettingsError: 'InconsistentSalesSettingsError',
|
|
66
68
|
InvalidSaleDestinationError: 'InvalidSaleDestinationError',
|
|
@@ -96,6 +98,7 @@ module.exports = {
|
|
|
96
98
|
ZoneDoesNotExistError,
|
|
97
99
|
ZoneAlreadyExistsError,
|
|
98
100
|
ZoneCannotBeDeletedError,
|
|
101
|
+
SaleDoesNotExistError,
|
|
99
102
|
SaleAlreadyExistsError,
|
|
100
103
|
InconsistentSalesSettingsError,
|
|
101
104
|
InvalidSaleDestinationError,
|
package/open-api-spec/index.js
CHANGED
|
@@ -38,6 +38,7 @@ const {
|
|
|
38
38
|
ZoneDoesNotExistError,
|
|
39
39
|
ZoneAlreadyExistsError,
|
|
40
40
|
ZoneCannotBeDeletedError,
|
|
41
|
+
SaleDoesNotExistError,
|
|
41
42
|
SaleAlreadyExistsError,
|
|
42
43
|
InconsistentSalesSettingsError,
|
|
43
44
|
InvalidSaleDestinationError,
|
|
@@ -224,8 +225,8 @@ openApiSpec['x-tagGroups'] = [
|
|
|
224
225
|
'Expeditions expiration',
|
|
225
226
|
'GLS Spain integration',
|
|
226
227
|
'GLS International integration',
|
|
227
|
-
'GLS SMS integration',
|
|
228
228
|
'Ingenico integration',
|
|
229
|
+
'GLS SMS integration',
|
|
229
230
|
],
|
|
230
231
|
},
|
|
231
232
|
{
|
|
@@ -246,6 +247,8 @@ openApiSpec['x-tagGroups'] = [
|
|
|
246
247
|
'Sales',
|
|
247
248
|
'Historic records',
|
|
248
249
|
'Integrations',
|
|
250
|
+
'Callbacks',
|
|
251
|
+
'Redirects',
|
|
249
252
|
],
|
|
250
253
|
},
|
|
251
254
|
];
|
|
@@ -514,11 +517,21 @@ under the \`glsInternationalExport\` name. Its \`networks\` field lists the netw
|
|
|
514
517
|
to the international API. All other networks are ignored.`,
|
|
515
518
|
},
|
|
516
519
|
{
|
|
517
|
-
name: '
|
|
518
|
-
description: `
|
|
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.`,
|
|
519
532
|
},
|
|
520
533
|
{
|
|
521
|
-
name: '
|
|
534
|
+
name: 'GLS SMS integration', // todo
|
|
522
535
|
description: `TODO`,
|
|
523
536
|
},
|
|
524
537
|
{
|
|
@@ -747,12 +760,12 @@ records. Since they are part of their expedition historic records, PODs do not h
|
|
|
747
760
|
<SchemaDefinition schemaRef="#/components/schemas/pod" />`,
|
|
748
761
|
},
|
|
749
762
|
{
|
|
750
|
-
name: 'Sales',
|
|
763
|
+
name: 'Sales',
|
|
751
764
|
description: `Create and find sales.
|
|
752
765
|
|
|
753
766
|
Customers can go to a parcel shop at any time and pay to have a package sent to an allowed destination.
|
|
754
767
|
|
|
755
|
-
The allowed destinations and the price of the service can be found in the [
|
|
768
|
+
The allowed destinations and the price of the service can be found in the [defaults object](#tag/Config/paths/~1config~1defaults~1get/get).
|
|
756
769
|
|
|
757
770
|
The process for a sale is the following:
|
|
758
771
|
|
|
@@ -761,6 +774,22 @@ The process for a sale is the following:
|
|
|
761
774
|
- If Ingenico responds that the customer has paid the API will use the GLS Spain integration to notify GLS of the new sale.
|
|
762
775
|
- GLS Spain will then create a pickup expedition associated to the sale which will be picked up by a driver.
|
|
763
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
|
+
|
|
764
793
|
## Sale schema
|
|
765
794
|
|
|
766
795
|
<SchemaDefinition schemaRef="#/components/schemas/sale" />`,
|
|
@@ -793,6 +822,19 @@ of each record.
|
|
|
793
822
|
|
|
794
823
|
<SchemaDefinition schemaRef="#/components/schemas/integration" />`,
|
|
795
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
|
+
},
|
|
796
838
|
];
|
|
797
839
|
|
|
798
840
|
const headers = {
|
|
@@ -857,6 +899,7 @@ const errors = {
|
|
|
857
899
|
zoneDoesNotExist: new ZoneDoesNotExistError(),
|
|
858
900
|
zoneAlreadyExists: new ZoneAlreadyExistsError(),
|
|
859
901
|
zoneCannotBeDeleted: new ZoneCannotBeDeletedError(),
|
|
902
|
+
saleDoesNotExist: new SaleDoesNotExistError(),
|
|
860
903
|
saleAlreadyExists: new SaleAlreadyExistsError(),
|
|
861
904
|
inconsistentSalesSettings: new InconsistentSalesSettingsError(),
|
|
862
905
|
invalidSaleDestination: new InvalidSaleDestinationError(),
|
|
@@ -1007,6 +1050,10 @@ const responses = {
|
|
|
1007
1050
|
description: 'The zone cannot be deleted.',
|
|
1008
1051
|
content: { 'application/json': { schema: specificHttpError(errors.zoneCannotBeDeleted) } },
|
|
1009
1052
|
},
|
|
1053
|
+
saleDoesNotExist: {
|
|
1054
|
+
description: 'The sale does not exist.',
|
|
1055
|
+
content: { 'application/json': { schema: specificHttpError(errors.saleDoesNotExist) } },
|
|
1056
|
+
},
|
|
1010
1057
|
saleAlreadyExists: {
|
|
1011
1058
|
description: 'The sale already exists.',
|
|
1012
1059
|
content: { 'application/json': { schema: specificHttpError(errors.saleAlreadyExists) } },
|
|
@@ -2547,6 +2594,9 @@ An expedition can be associated on creation to either a shop or a network:
|
|
|
2547
2594
|
If the provided shop does not exist the API will return a \`500 ShopDoesNotExistError\`, if it is not enabled it will return a
|
|
2548
2595
|
\`500 ShopNotEnabledError\`, and if it is readonly it will return a \`500 ShopCannotBeUpdatedError\`.
|
|
2549
2596
|
|
|
2597
|
+
When providing a shop one can also provide a sale if the expedition is created because of it. If the provided sale does not
|
|
2598
|
+
exist the API will return a \`500 SaleDoesNotExistError\`.
|
|
2599
|
+
|
|
2550
2600
|
If the provided network does not exist the API will return a \`500 NetworkDoesNotExistError\`.
|
|
2551
2601
|
|
|
2552
2602
|
The \`status.code\` of a new expedition cannot be specified and it will always be \`incoming\`.
|
|
@@ -2575,6 +2625,7 @@ ${securitySchemes.superAdminRole}`,
|
|
|
2575
2625
|
' 500 ': responses.shopNotEnabled,
|
|
2576
2626
|
' 500 ': responses.shopCannotBeUpdated,
|
|
2577
2627
|
' 500 ': responses.networkDoesNotExist,
|
|
2628
|
+
' 500 ': responses.saleDoesNotExist,
|
|
2578
2629
|
},
|
|
2579
2630
|
},
|
|
2580
2631
|
},
|
|
@@ -3297,6 +3348,106 @@ ${securitySchemes.superAdminRole}`,
|
|
|
3297
3348
|
},
|
|
3298
3349
|
},
|
|
3299
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
|
+
},
|
|
3300
3451
|
};
|
|
3301
3452
|
|
|
3302
3453
|
module.exports = openApiSpec;
|
package/package.json
CHANGED
|
@@ -40,7 +40,10 @@ const sale = () => ({
|
|
|
40
40
|
status: {
|
|
41
41
|
type: 'object',
|
|
42
42
|
properties: {
|
|
43
|
-
code: {
|
|
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
|
});
|