@commercetools/checkout-payments-processor-sdk 0.0.6
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/CHANGELOG.md +15 -0
- package/README.md +42 -0
- package/biome.json +38 -0
- package/package.json +48 -0
- package/src/api/context/request-context.helper.test.ts +98 -0
- package/src/api/context/request-context.helper.ts +89 -0
- package/src/api/context/request-context.provider.ts +27 -0
- package/src/api/context/types/request-context.type.ts +18 -0
- package/src/api/handlers/payment-components.handler.test.ts +378 -0
- package/src/api/handlers/payment-components.handler.ts +80 -0
- package/src/api/handlers/payment-intents.handler.test.ts +475 -0
- package/src/api/handlers/payment-intents.handler.ts +169 -0
- package/src/api/handlers/status.handler.test.ts +551 -0
- package/src/api/handlers/status.handler.ts +216 -0
- package/src/api/handlers/transaction.handler.ts +86 -0
- package/src/api/handlers/types/handler.type.ts +49 -0
- package/src/api/hooks/authorize.hook.test.ts +62 -0
- package/src/api/hooks/authorize.hook.ts +51 -0
- package/src/api/hooks/jwt-auth.hook.test.ts +54 -0
- package/src/api/hooks/jwt-auth.hook.ts +56 -0
- package/src/api/hooks/oauth2-auth.hook.test.ts +173 -0
- package/src/api/hooks/oauth2-auth.hook.ts +46 -0
- package/src/api/hooks/session-header-auth.hook.ts +47 -0
- package/src/api/hooks/session-query-param-auth.hook.ts +46 -0
- package/src/api/hooks/types/hook.type.ts +12 -0
- package/src/api/index.ts +11 -0
- package/src/api/types.ts +3 -0
- package/src/commercetools/api/base-api.ts +28 -0
- package/src/commercetools/api/cart-api.test.ts +95 -0
- package/src/commercetools/api/cart-api.ts +55 -0
- package/src/commercetools/api/custom-type-api.ts +39 -0
- package/src/commercetools/api/order-api.ts +22 -0
- package/src/commercetools/api/payment-api.ts +64 -0
- package/src/commercetools/api/payment-method-api.ts +118 -0
- package/src/commercetools/api/root-api.ts +109 -0
- package/src/commercetools/errors/ct-api.error.ts +27 -0
- package/src/commercetools/helpers/currency.converter.test.ts +121 -0
- package/src/commercetools/helpers/currency.converter.test_data.json +2379 -0
- package/src/commercetools/helpers/currency.converter.ts +102 -0
- package/src/commercetools/helpers/taxrate.converter.test.ts +48 -0
- package/src/commercetools/helpers/taxrate.converter.ts +39 -0
- package/src/commercetools/index.ts +22 -0
- package/src/commercetools/services/ct-cart.service.test.ts +1616 -0
- package/src/commercetools/services/ct-cart.service.ts +316 -0
- package/src/commercetools/services/ct-custom-type.service.ts +62 -0
- package/src/commercetools/services/ct-order.service.test.ts +136 -0
- package/src/commercetools/services/ct-order.service.ts +47 -0
- package/src/commercetools/services/ct-payment-method.service.test.ts +878 -0
- package/src/commercetools/services/ct-payment-method.service.ts +223 -0
- package/src/commercetools/services/ct-payment.service.test.ts +1123 -0
- package/src/commercetools/services/ct-payment.service.ts +574 -0
- package/src/commercetools/types/api.type.ts +162 -0
- package/src/commercetools/types/cart.type.ts +83 -0
- package/src/commercetools/types/custom-type.type.ts +21 -0
- package/src/commercetools/types/order.type.ts +19 -0
- package/src/commercetools/types/payment-method.type.ts +130 -0
- package/src/commercetools/types/payment.type.ts +74 -0
- package/src/commercetools/types/predefined-custom-types.type.ts +240 -0
- package/src/commercetools/types.ts +7 -0
- package/src/errorx/errorx.ts +625 -0
- package/src/errorx/index.ts +1 -0
- package/src/errorx/types.ts +5 -0
- package/src/fetch/decorators/base.decorator.ts +13 -0
- package/src/fetch/decorators/monitoring.decorator.ts +41 -0
- package/src/fetch/fetch.test.ts +57 -0
- package/src/fetch/index.ts +3 -0
- package/src/fetch/types/fetch.type.ts +11 -0
- package/src/fetch/types.ts +1 -0
- package/src/index.ts +15 -0
- package/src/logger/commercetools-logger.ts +69 -0
- package/src/logger/index.ts +1 -0
- package/src/logger/types/logger.type.ts +6 -0
- package/src/logger/types.ts +1 -0
- package/src/mocks/auth.mock.ts +6 -0
- package/src/mocks/cart.mock.ts +239 -0
- package/src/mocks/ct-api-error.mock.ts +23 -0
- package/src/mocks/index.ts +4 -0
- package/src/mocks/payment.mock.ts +35 -0
- package/src/payment-processor.ts +317 -0
- package/src/security/authn/authns.ts +219 -0
- package/src/security/authn/bearer-utils.test.ts +35 -0
- package/src/security/authn/bearer-utils.ts +28 -0
- package/src/security/authn/jwt-authn-manager.ts +69 -0
- package/src/security/authn/oauth2-authn-manager.ts +105 -0
- package/src/security/authn/session-header-authn-manager.ts +58 -0
- package/src/security/authn/session-query-param-authn-manager.ts +53 -0
- package/src/security/authn/types/authn.type.ts +50 -0
- package/src/security/authz/authorization-manager.ts +39 -0
- package/src/security/authz/types/authz.type.ts +13 -0
- package/src/security/index.ts +13 -0
- package/src/security/services/authorization.service.ts +54 -0
- package/src/security/services/jwt.service.test.ts +27 -0
- package/src/security/services/jwt.service.ts +45 -0
- package/src/security/services/oauth2.service.ts +60 -0
- package/src/security/services/session.service.ts +141 -0
- package/src/security/services/types/authorization.type.ts +10 -0
- package/src/security/services/types/jwt.type.ts +3 -0
- package/src/security/services/types/oauth2.type.ts +15 -0
- package/src/security/services/types/session.type.ts +38 -0
- package/src/security/types.ts +6 -0
- package/tsconfig.json +28 -0
- package/tsconfig.prod.json +9 -0
- package/typedoc.json +6 -0
- package/vitest.config.ts +15 -0
- package/wiki/getting-started.md +13 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type TokenInfo = {
|
|
2
|
+
active: boolean;
|
|
3
|
+
scope: string;
|
|
4
|
+
exp: number;
|
|
5
|
+
client_id: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export interface Oauth2Service {
|
|
9
|
+
introspectToken(opts: {
|
|
10
|
+
url: string;
|
|
11
|
+
clientId: string;
|
|
12
|
+
clientSecret: string;
|
|
13
|
+
token: string;
|
|
14
|
+
}): Promise<TokenInfo>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Money } from '@commercetools/platform-sdk';
|
|
2
|
+
|
|
3
|
+
export type Session = {
|
|
4
|
+
id: string;
|
|
5
|
+
version: number;
|
|
6
|
+
createdAt: string;
|
|
7
|
+
lastModifiedAt: string;
|
|
8
|
+
state: 'ACTIVE' | 'EXPIRED';
|
|
9
|
+
activeCart?: {
|
|
10
|
+
cartRef: {
|
|
11
|
+
id: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
customer?: {
|
|
15
|
+
customerRef: {
|
|
16
|
+
externalId?: string;
|
|
17
|
+
id?: string;
|
|
18
|
+
key?: string;
|
|
19
|
+
};
|
|
20
|
+
anonymousId?: string;
|
|
21
|
+
};
|
|
22
|
+
metadata?: {
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export interface SessionService {
|
|
28
|
+
verifySession(sessionId: string): Promise<Session>;
|
|
29
|
+
getCartFromSession(session: Session): string;
|
|
30
|
+
getAllowedPaymentMethodsFromSession(session: Session): string[];
|
|
31
|
+
getProcessorUrlFromSession(session: Session): string;
|
|
32
|
+
getPaymentInterfaceFromSession(session: Session): string | undefined;
|
|
33
|
+
getCheckoutTransactionItemIdFromSession(session: Session): string | undefined;
|
|
34
|
+
getMerchantReturnUrlFromSession(session: Session): string | undefined;
|
|
35
|
+
getFutureOrderNumberFromSession(session: Session): string | undefined;
|
|
36
|
+
getGiftCardPlannedAmountFromSession(session: Session): Money | undefined;
|
|
37
|
+
getCorrelationIdFromSession(session: Session): string | undefined;
|
|
38
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from '@/security/authn/types/authn.type.js';
|
|
2
|
+
export * from '@/security/authz/types/authz.type.js';
|
|
3
|
+
export * from '@/security/services/types/authorization.type.js';
|
|
4
|
+
export * from '@/security/services/types/jwt.type.js';
|
|
5
|
+
export * from '@/security/services/types/oauth2.type.js';
|
|
6
|
+
export * from '@/security/services/types/session.type.js';
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@tsconfig/node24/tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"types": ["vitest/globals"],
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"rootDir": "./src",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationMap": true,
|
|
9
|
+
"paths": {
|
|
10
|
+
"@/*": ["./src/*"],
|
|
11
|
+
"@errorx": ["./src/errorx/index.js"],
|
|
12
|
+
"@errorx-types": ["./src/errorx/types.js"],
|
|
13
|
+
"@logger": ["./src/logger/index.js"],
|
|
14
|
+
"@logger-types": ["./src/logger/types.js"],
|
|
15
|
+
"@security": ["./src/security/index.js"],
|
|
16
|
+
"@security-types": ["./src/security/types.js"],
|
|
17
|
+
"@api": ["./src/api/index.js"],
|
|
18
|
+
"@api-types": ["./src/api/types.js"],
|
|
19
|
+
"@commercetools": ["./src/commercetools/index.js"],
|
|
20
|
+
"@commercetools-types": ["./src/commercetools/types.js"],
|
|
21
|
+
"@fetch": ["./src/fetch/index.js"],
|
|
22
|
+
"@fetch-types": ["./src/fetch/types.js"],
|
|
23
|
+
"@mocks": ["./src/mocks/index.js"]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"exclude": ["src/**/*.[test|spec|mock].ts"],
|
|
27
|
+
"include": ["src/**/*.ts"]
|
|
28
|
+
}
|
package/typedoc.json
ADDED
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import tsconfigPaths from "vite-tsconfig-paths";
|
|
2
|
+
import { defineConfig } from "vitest/config";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
plugins: [tsconfigPaths()],
|
|
6
|
+
test: {
|
|
7
|
+
globals: true,
|
|
8
|
+
coverage: {
|
|
9
|
+
provider: "istanbul", // or 'v8'
|
|
10
|
+
reporter: ["text", "json-summary"],
|
|
11
|
+
exclude: ["./generated-doc/**/*", "./dist/**/*", "./src/**/*.test.ts", "./src/**/*.spec.ts"],
|
|
12
|
+
},
|
|
13
|
+
include: ["./src/**/*.test.ts", "./src/**/*.spec.ts"],
|
|
14
|
+
},
|
|
15
|
+
});
|