@unchainedshop/api 2.6.1 → 2.7.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/lib/resolvers/mutations/orders/signPaymentProviderForCheckout.js +18 -8
- package/lib/resolvers/mutations/orders/signPaymentProviderForCheckout.js.map +1 -1
- package/lib/schema/index.js +2 -4
- package/lib/schema/index.js.map +1 -1
- package/lib/schema/mutation.js +1 -1
- package/package.json +9 -11
- package/src/resolvers/mutations/orders/signPaymentProviderForCheckout.ts +14 -6
- package/src/schema/index.ts +2 -4
- package/src/schema/mutation.ts +1 -1
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
2
|
import { PaymentProviderType } from '@unchainedshop/core-payment';
|
|
3
3
|
import { OrderPaymentStatus } from '@unchainedshop/types/orders.payments.js';
|
|
4
|
-
import {
|
|
4
|
+
import { OrderPaymentConfigurationError, OrderPaymentNotFoundError, OrderPaymentTypeError, OrderWrongPaymentStatusError, } from '../../../errors.js';
|
|
5
|
+
import { getOrderCart } from '../utils/getOrderCart.js';
|
|
5
6
|
export default async function signPaymentProviderForCheckout(root, params, context) {
|
|
6
7
|
const { modules, userId } = context;
|
|
7
8
|
const { orderPaymentId, transactionContext } = params;
|
|
8
9
|
log(`mutation signPaymentProviderForCheckout ${orderPaymentId}`, {
|
|
9
10
|
userId,
|
|
10
11
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
let orderPayment;
|
|
13
|
+
if (orderPaymentId) {
|
|
14
|
+
orderPayment = await modules.orders.payments.findOrderPayment({
|
|
15
|
+
orderPaymentId,
|
|
16
|
+
});
|
|
17
|
+
if (!orderPayment)
|
|
18
|
+
throw new OrderPaymentNotFoundError({ orderPaymentId });
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const order = await getOrderCart({ user: context.user }, context);
|
|
22
|
+
orderPayment = await modules.orders.payments.findOrderPayment({
|
|
23
|
+
orderPaymentId: order.paymentId,
|
|
24
|
+
});
|
|
25
|
+
if (!orderPayment)
|
|
26
|
+
throw new OrderPaymentNotFoundError({ orderPaymentId });
|
|
27
|
+
}
|
|
18
28
|
const provider = await modules.payment.paymentProviders.findProvider({
|
|
19
29
|
paymentProviderId: orderPayment.paymentProviderId,
|
|
20
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signPaymentProviderForCheckout.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/orders/signPaymentProviderForCheckout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"signPaymentProviderForCheckout.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/orders/signPaymentProviderForCheckout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,EACzB,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,8BAA8B,CAC1D,IAAU,EACV,MAA2D,EAC3D,OAAgB;IAEhB,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACpC,MAAM,EAAE,cAAc,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAAC;IAEtD,GAAG,CA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;IACL,CAAC;IAED,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CACtD,QAAQ,CAAC,GAAG,EACZ;YACE,MAAM;YACN,YAAY;YACZ,kBAAkB;SACnB,EACD,OAAO,CACR,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,8BAA8B,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;AACH,CAAC"}
|
package/lib/schema/index.js
CHANGED
|
@@ -9,9 +9,7 @@ export const buildDefaultTypeDefs = ({ actions = [], events = [], workTypes = []
|
|
|
9
9
|
actions?.length && `extend enum RoleAction { ${actions.join(',')} }`,
|
|
10
10
|
events?.length && `extend enum EventType { ${events.join(',')} }`,
|
|
11
11
|
workTypes?.length && `extend enum WorkType { ${workTypes.join(',')} }`,
|
|
12
|
-
]
|
|
13
|
-
|
|
14
|
-
.join('\n');
|
|
15
|
-
return [...scalars, ...directives, ...types, ...inputTypes, ...query, ...mutation, dynamicTypeDefs];
|
|
12
|
+
].filter(Boolean);
|
|
13
|
+
return [...scalars, ...directives, ...types, ...inputTypes, ...query, ...mutation, ...dynamicTypeDefs];
|
|
16
14
|
};
|
|
17
15
|
//# sourceMappingURL=index.js.map
|
package/lib/schema/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,QAAQ,MAAM,eAAe,CAAC;AAErC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAE,OAAO,GAA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C,CAAC;AACzG,CAAC,CAAC"}
|
package/lib/schema/mutation.js
CHANGED
|
@@ -901,7 +901,7 @@ export default [
|
|
|
901
901
|
"""
|
|
902
902
|
Sign a generic order payment
|
|
903
903
|
"""
|
|
904
|
-
signPaymentProviderForCheckout(orderPaymentId: ID
|
|
904
|
+
signPaymentProviderForCheckout(orderPaymentId: ID, transactionContext: JSON): String!
|
|
905
905
|
|
|
906
906
|
prepareProductMediaUpload(mediaName: String!, productId: ID!): MediaUploadTicket!
|
|
907
907
|
prepareAssortmentMediaUpload(mediaName: String!, assortmentId: ID!): MediaUploadTicket!
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"main": "lib/api-index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/api-index.js",
|
|
@@ -41,19 +41,18 @@
|
|
|
41
41
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@apollo/server": "^4.10.0",
|
|
44
|
-
"cookie": "^0.6.0"
|
|
45
|
-
"graphql": "^16.6.0"
|
|
44
|
+
"cookie": "^0.6.0"
|
|
46
45
|
},
|
|
47
46
|
"optionalDependencies": {
|
|
48
47
|
"express": "^4.18.2"
|
|
49
48
|
},
|
|
50
49
|
"dependencies": {
|
|
51
50
|
"@metamask/eth-sig-util": "^7.0.1",
|
|
52
|
-
"@unchainedshop/core": "^2.
|
|
53
|
-
"@unchainedshop/events": "^2.
|
|
54
|
-
"@unchainedshop/logger": "^2.
|
|
55
|
-
"@unchainedshop/roles": "^2.
|
|
56
|
-
"@unchainedshop/utils": "^2.
|
|
51
|
+
"@unchainedshop/core": "^2.7.0",
|
|
52
|
+
"@unchainedshop/events": "^2.7.0",
|
|
53
|
+
"@unchainedshop/logger": "^2.7.0",
|
|
54
|
+
"@unchainedshop/roles": "^2.7.0",
|
|
55
|
+
"@unchainedshop/utils": "^2.7.0",
|
|
57
56
|
"accounting": "0.4.1",
|
|
58
57
|
"dataloader": "^2.2.2",
|
|
59
58
|
"graphql-scalars": "^1.22.4",
|
|
@@ -65,10 +64,9 @@
|
|
|
65
64
|
"devDependencies": {
|
|
66
65
|
"@types/graphql-upload": "^16.0.7",
|
|
67
66
|
"@types/locale": "^0.1.4",
|
|
68
|
-
"@types/node": "^20.11.
|
|
69
|
-
"@unchainedshop/types": "^2.
|
|
67
|
+
"@types/node": "^20.11.17",
|
|
68
|
+
"@unchainedshop/types": "^2.7.0",
|
|
70
69
|
"express": "^4.18.2",
|
|
71
|
-
"graphql": "^16.8.1",
|
|
72
70
|
"jest": "^29.7.0",
|
|
73
71
|
"ts-jest": "^29.1.2",
|
|
74
72
|
"typescript": "^5.3.3"
|
|
@@ -3,12 +3,12 @@ import { Context, Root } from '@unchainedshop/types/api.js';
|
|
|
3
3
|
import { PaymentProviderType } from '@unchainedshop/core-payment';
|
|
4
4
|
import { OrderPaymentStatus } from '@unchainedshop/types/orders.payments.js';
|
|
5
5
|
import {
|
|
6
|
-
InvalidIdError,
|
|
7
6
|
OrderPaymentConfigurationError,
|
|
8
7
|
OrderPaymentNotFoundError,
|
|
9
8
|
OrderPaymentTypeError,
|
|
10
9
|
OrderWrongPaymentStatusError,
|
|
11
10
|
} from '../../../errors.js';
|
|
11
|
+
import { getOrderCart } from '../utils/getOrderCart.js';
|
|
12
12
|
|
|
13
13
|
export default async function signPaymentProviderForCheckout(
|
|
14
14
|
root: Root,
|
|
@@ -22,12 +22,20 @@ export default async function signPaymentProviderForCheckout(
|
|
|
22
22
|
userId,
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
let orderPayment;
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
if (orderPaymentId) {
|
|
28
|
+
orderPayment = await modules.orders.payments.findOrderPayment({
|
|
29
|
+
orderPaymentId,
|
|
30
|
+
});
|
|
31
|
+
if (!orderPayment) throw new OrderPaymentNotFoundError({ orderPaymentId });
|
|
32
|
+
} else {
|
|
33
|
+
const order = await getOrderCart({ user: context.user }, context);
|
|
34
|
+
orderPayment = await modules.orders.payments.findOrderPayment({
|
|
35
|
+
orderPaymentId: order.paymentId,
|
|
36
|
+
});
|
|
37
|
+
if (!orderPayment) throw new OrderPaymentNotFoundError({ orderPaymentId });
|
|
38
|
+
}
|
|
31
39
|
|
|
32
40
|
const provider = await modules.payment.paymentProviders.findProvider({
|
|
33
41
|
paymentProviderId: orderPayment.paymentProviderId,
|
package/src/schema/index.ts
CHANGED
|
@@ -10,9 +10,7 @@ export const buildDefaultTypeDefs = ({ actions = [], events = [], workTypes = []
|
|
|
10
10
|
actions?.length && `extend enum RoleAction { ${actions.join(',')} }`,
|
|
11
11
|
events?.length && `extend enum EventType { ${events.join(',')} }`,
|
|
12
12
|
workTypes?.length && `extend enum WorkType { ${workTypes.join(',')} }`,
|
|
13
|
-
]
|
|
14
|
-
.filter(Boolean)
|
|
15
|
-
.join('\n');
|
|
13
|
+
].filter(Boolean);
|
|
16
14
|
|
|
17
|
-
return [...scalars, ...directives, ...types, ...inputTypes, ...query, ...mutation, dynamicTypeDefs];
|
|
15
|
+
return [...scalars, ...directives, ...types, ...inputTypes, ...query, ...mutation, ...dynamicTypeDefs];
|
|
18
16
|
};
|
package/src/schema/mutation.ts
CHANGED
|
@@ -901,7 +901,7 @@ export default [
|
|
|
901
901
|
"""
|
|
902
902
|
Sign a generic order payment
|
|
903
903
|
"""
|
|
904
|
-
signPaymentProviderForCheckout(orderPaymentId: ID
|
|
904
|
+
signPaymentProviderForCheckout(orderPaymentId: ID, transactionContext: JSON): String!
|
|
905
905
|
|
|
906
906
|
prepareProductMediaUpload(mediaName: String!, productId: ID!): MediaUploadTicket!
|
|
907
907
|
prepareAssortmentMediaUpload(mediaName: String!, assortmentId: ID!): MediaUploadTicket!
|