@open-mercato/gateway-autopay 0.0.0-stage → 0.10.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/.turbo/turbo-build.log +2 -0
- package/build.mjs +7 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +7 -0
- package/dist/modules/gateway_autopay/acl.js +20 -0
- package/dist/modules/gateway_autopay/acl.js.map +7 -0
- package/dist/modules/gateway_autopay/api/launch/route.js +93 -0
- package/dist/modules/gateway_autopay/api/launch/route.js.map +7 -0
- package/dist/modules/gateway_autopay/api/return/route.js +98 -0
- package/dist/modules/gateway_autopay/api/return/route.js.map +7 -0
- package/dist/modules/gateway_autopay/cli.js +86 -0
- package/dist/modules/gateway_autopay/cli.js.map +7 -0
- package/dist/modules/gateway_autopay/di.js +35 -0
- package/dist/modules/gateway_autopay/di.js.map +7 -0
- package/dist/modules/gateway_autopay/index.js +9 -0
- package/dist/modules/gateway_autopay/index.js.map +7 -0
- package/dist/modules/gateway_autopay/integration.js +65 -0
- package/dist/modules/gateway_autopay/integration.js.map +7 -0
- package/dist/modules/gateway_autopay/lib/adapters/v1.js +206 -0
- package/dist/modules/gateway_autopay/lib/adapters/v1.js.map +7 -0
- package/dist/modules/gateway_autopay/lib/autopay-client.js +241 -0
- package/dist/modules/gateway_autopay/lib/autopay-client.js.map +7 -0
- package/dist/modules/gateway_autopay/lib/error-reporting.js +11 -0
- package/dist/modules/gateway_autopay/lib/error-reporting.js.map +7 -0
- package/dist/modules/gateway_autopay/lib/hash.js +10 -0
- package/dist/modules/gateway_autopay/lib/hash.js.map +7 -0
- package/dist/modules/gateway_autopay/lib/health.js +95 -0
- package/dist/modules/gateway_autopay/lib/health.js.map +7 -0
- package/dist/modules/gateway_autopay/lib/launch.js +138 -0
- package/dist/modules/gateway_autopay/lib/launch.js.map +7 -0
- package/dist/modules/gateway_autopay/lib/preset.js +76 -0
- package/dist/modules/gateway_autopay/lib/preset.js.map +7 -0
- package/dist/modules/gateway_autopay/lib/public-route.js +69 -0
- package/dist/modules/gateway_autopay/lib/public-route.js.map +7 -0
- package/dist/modules/gateway_autopay/lib/return-bridge.js +23 -0
- package/dist/modules/gateway_autopay/lib/return-bridge.js.map +7 -0
- package/dist/modules/gateway_autopay/lib/status-map.js +87 -0
- package/dist/modules/gateway_autopay/lib/status-map.js.map +7 -0
- package/dist/modules/gateway_autopay/setup.js +32 -0
- package/dist/modules/gateway_autopay/setup.js.map +7 -0
- package/jest.config.cjs +33 -0
- package/package.json +91 -3
- package/src/index.ts +1 -0
- package/src/modules/gateway_autopay/__tests__/__fixtures__/legacyStatusInterpretation.ts +8 -0
- package/src/modules/gateway_autopay/__tests__/acl-dependencies.test.ts +77 -0
- package/src/modules/gateway_autopay/__tests__/adapter.test.ts +345 -0
- package/src/modules/gateway_autopay/__tests__/autopay-client.test.ts +93 -0
- package/src/modules/gateway_autopay/__tests__/cli.test.ts +51 -0
- package/src/modules/gateway_autopay/__tests__/di.test.ts +36 -0
- package/src/modules/gateway_autopay/__tests__/exact-amounts.test.ts +49 -0
- package/src/modules/gateway_autopay/__tests__/gateway-service.boundary.test.ts +494 -0
- package/src/modules/gateway_autopay/__tests__/hash.test.ts +37 -0
- package/src/modules/gateway_autopay/__tests__/health.test.ts +120 -0
- package/src/modules/gateway_autopay/__tests__/launch.test.ts +161 -0
- package/src/modules/gateway_autopay/__tests__/preset.test.ts +108 -0
- package/src/modules/gateway_autopay/__tests__/return-bridge.test.ts +62 -0
- package/src/modules/gateway_autopay/__tests__/routes.test.ts +327 -0
- package/src/modules/gateway_autopay/__tests__/status-interpretation-backward-compat.test.ts +29 -0
- package/src/modules/gateway_autopay/__tests__/status-map.test.ts +80 -0
- package/src/modules/gateway_autopay/__tests__/support/autopay-xml.ts +80 -0
- package/src/modules/gateway_autopay/acl.ts +16 -0
- package/src/modules/gateway_autopay/api/launch/route.ts +99 -0
- package/src/modules/gateway_autopay/api/return/route.ts +106 -0
- package/src/modules/gateway_autopay/cli.ts +104 -0
- package/src/modules/gateway_autopay/di.ts +35 -0
- package/src/modules/gateway_autopay/i18n/de.json +33 -0
- package/src/modules/gateway_autopay/i18n/en.json +33 -0
- package/src/modules/gateway_autopay/i18n/es.json +33 -0
- package/src/modules/gateway_autopay/i18n/ko.json +33 -0
- package/src/modules/gateway_autopay/i18n/pl.json +33 -0
- package/src/modules/gateway_autopay/index.ts +5 -0
- package/src/modules/gateway_autopay/integration.ts +61 -0
- package/src/modules/gateway_autopay/lib/adapters/v1.ts +279 -0
- package/src/modules/gateway_autopay/lib/autopay-client.ts +395 -0
- package/src/modules/gateway_autopay/lib/error-reporting.ts +16 -0
- package/src/modules/gateway_autopay/lib/hash.ts +24 -0
- package/src/modules/gateway_autopay/lib/health.ts +105 -0
- package/src/modules/gateway_autopay/lib/launch.ts +163 -0
- package/src/modules/gateway_autopay/lib/preset.ts +126 -0
- package/src/modules/gateway_autopay/lib/public-route.ts +85 -0
- package/src/modules/gateway_autopay/lib/return-bridge.ts +34 -0
- package/src/modules/gateway_autopay/lib/status-map.ts +148 -0
- package/src/modules/gateway_autopay/setup.ts +32 -0
- package/tsconfig.json +9 -0
- package/watch.mjs +7 -0
- package/README.md +0 -3
package/build.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { dirname } from 'node:path'
|
|
2
|
+
import { fileURLToPath } from 'node:url'
|
|
3
|
+
import { buildPackage } from '../../scripts/build-package.mjs'
|
|
4
|
+
|
|
5
|
+
const packageDir = dirname(fileURLToPath(import.meta.url))
|
|
6
|
+
|
|
7
|
+
await buildPackage(packageDir, { name: 'gateway-autopay' })
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const features = [
|
|
2
|
+
{
|
|
3
|
+
id: "gateway_autopay.view",
|
|
4
|
+
title: "View Autopay gateway configuration",
|
|
5
|
+
module: "gateway_autopay",
|
|
6
|
+
dependsOn: ["payment_gateways.view"]
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
id: "gateway_autopay.configure",
|
|
10
|
+
title: "Configure Autopay gateway settings",
|
|
11
|
+
module: "gateway_autopay",
|
|
12
|
+
dependsOn: ["gateway_autopay.view", "payment_gateways.manage"]
|
|
13
|
+
}
|
|
14
|
+
];
|
|
15
|
+
var acl_default = features;
|
|
16
|
+
export {
|
|
17
|
+
acl_default as default,
|
|
18
|
+
features
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=acl.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/modules/gateway_autopay/acl.ts"],
|
|
4
|
+
"sourcesContent": ["export const features = [\n {\n id: 'gateway_autopay.view',\n title: 'View Autopay gateway configuration',\n module: 'gateway_autopay',\n dependsOn: ['payment_gateways.view'],\n },\n {\n id: 'gateway_autopay.configure',\n title: 'Configure Autopay gateway settings',\n module: 'gateway_autopay',\n dependsOn: ['gateway_autopay.view', 'payment_gateways.manage'],\n },\n]\n\nexport default features\n"],
|
|
5
|
+
"mappings": "AAAO,MAAM,WAAW;AAAA,EACtB;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW,CAAC,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW,CAAC,wBAAwB,yBAAyB;AAAA,EAC/D;AACF;AAEA,IAAO,cAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { createRequestContainer } from "@open-mercato/shared/lib/di/container";
|
|
2
|
+
import { resolveTranslations } from "@open-mercato/shared/lib/i18n/server";
|
|
3
|
+
import { resolveApiHost } from "../../lib/autopay-client.js";
|
|
4
|
+
import { reportAutopayError } from "../../lib/error-reporting.js";
|
|
5
|
+
import {
|
|
6
|
+
isWellFormedLaunchToken,
|
|
7
|
+
isWellFormedOrderId,
|
|
8
|
+
LAUNCH_PAGE_CONTENT_SECURITY_POLICY,
|
|
9
|
+
launchGrantMatches,
|
|
10
|
+
readFormPost,
|
|
11
|
+
renderLaunchPage
|
|
12
|
+
} from "../../lib/launch.js";
|
|
13
|
+
import {
|
|
14
|
+
findAutopayCandidates,
|
|
15
|
+
htmlResponse,
|
|
16
|
+
limitPublicRequest,
|
|
17
|
+
messageResponse,
|
|
18
|
+
readTransactionMetadata
|
|
19
|
+
} from "../../lib/public-route.js";
|
|
20
|
+
const metadata = {
|
|
21
|
+
path: "/gateway_autopay/launch",
|
|
22
|
+
GET: { requireAuth: false }
|
|
23
|
+
};
|
|
24
|
+
async function GET(req) {
|
|
25
|
+
const { t } = await resolveTranslations();
|
|
26
|
+
const unavailable = (status) => messageResponse(
|
|
27
|
+
{
|
|
28
|
+
title: t("gateway_autopay.launch.unavailableTitle", "Payment link unavailable"),
|
|
29
|
+
message: t(
|
|
30
|
+
"gateway_autopay.launch.unavailable",
|
|
31
|
+
"This payment link is invalid, has expired, or the payment is no longer pending. Go back to the shop and start the payment again."
|
|
32
|
+
)
|
|
33
|
+
},
|
|
34
|
+
status
|
|
35
|
+
);
|
|
36
|
+
const container = await createRequestContainer();
|
|
37
|
+
const limited = await limitPublicRequest(container, req, "launch");
|
|
38
|
+
if (limited) return limited;
|
|
39
|
+
const params = new URL(req.url).searchParams;
|
|
40
|
+
const orderId = params.get("o") ?? "";
|
|
41
|
+
const token = params.get("t") ?? "";
|
|
42
|
+
if (!isWellFormedOrderId(orderId) || !isWellFormedLaunchToken(token)) return unavailable(404);
|
|
43
|
+
try {
|
|
44
|
+
const em = container.resolve("em");
|
|
45
|
+
const candidates = await findAutopayCandidates(em, orderId);
|
|
46
|
+
const matches = candidates.filter((candidate) => launchGrantMatches(readTransactionMetadata(candidate).launch, token));
|
|
47
|
+
if (matches.length !== 1) return unavailable(404);
|
|
48
|
+
const [transaction] = matches;
|
|
49
|
+
if (transaction.unifiedStatus !== "pending") return unavailable(404);
|
|
50
|
+
const form = readFormPost(readTransactionMetadata(transaction).formPost);
|
|
51
|
+
if (!form) return unavailable(404);
|
|
52
|
+
resolveApiHost(form.url);
|
|
53
|
+
return htmlResponse(
|
|
54
|
+
renderLaunchPage(form, {
|
|
55
|
+
title: t("gateway_autopay.launch.title", "Redirecting to Autopay"),
|
|
56
|
+
message: t(
|
|
57
|
+
"gateway_autopay.launch.redirecting",
|
|
58
|
+
"Redirecting you to Autopay to complete the payment. If nothing happens, use the button below."
|
|
59
|
+
),
|
|
60
|
+
continueLabel: t("gateway_autopay.launch.continue", "Continue to Autopay")
|
|
61
|
+
}),
|
|
62
|
+
200,
|
|
63
|
+
LAUNCH_PAGE_CONTENT_SECURITY_POLICY
|
|
64
|
+
);
|
|
65
|
+
} catch (error) {
|
|
66
|
+
reportAutopayError(error, "gateway_autopay.launch_failed");
|
|
67
|
+
return unavailable(500);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const openApi = {
|
|
71
|
+
tags: ["Autopay"],
|
|
72
|
+
summary: "Start an Autopay payment",
|
|
73
|
+
methods: {
|
|
74
|
+
GET: {
|
|
75
|
+
summary: "Render the page that forwards the payer to Autopay with a signed POST",
|
|
76
|
+
tags: ["Autopay"],
|
|
77
|
+
responses: [
|
|
78
|
+
{ status: 200, description: "HTML page that submits the signed payment form to Autopay" },
|
|
79
|
+
{ status: 404, description: "The link is invalid, expired or the payment is no longer pending" },
|
|
80
|
+
{ status: 429, description: "Too many requests" },
|
|
81
|
+
{ status: 500, description: "The payment could not be started" }
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var route_default = GET;
|
|
87
|
+
export {
|
|
88
|
+
GET,
|
|
89
|
+
route_default as default,
|
|
90
|
+
metadata,
|
|
91
|
+
openApi
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/gateway_autopay/api/launch/route.ts"],
|
|
4
|
+
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport { resolveApiHost } from '../../lib/autopay-client'\nimport { reportAutopayError } from '../../lib/error-reporting'\nimport {\n isWellFormedLaunchToken,\n isWellFormedOrderId,\n LAUNCH_PAGE_CONTENT_SECURITY_POLICY,\n launchGrantMatches,\n readFormPost,\n renderLaunchPage,\n} from '../../lib/launch'\nimport {\n findAutopayCandidates,\n htmlResponse,\n limitPublicRequest,\n messageResponse,\n readTransactionMetadata,\n} from '../../lib/public-route'\n\nexport const metadata = {\n path: '/gateway_autopay/launch',\n GET: { requireAuth: false },\n}\n\nexport async function GET(req: Request) {\n const { t } = await resolveTranslations()\n const unavailable = (status: number) => messageResponse(\n {\n title: t('gateway_autopay.launch.unavailableTitle', 'Payment link unavailable'),\n message: t(\n 'gateway_autopay.launch.unavailable',\n 'This payment link is invalid, has expired, or the payment is no longer pending. Go back to the shop and start the payment again.',\n ),\n },\n status,\n )\n\n const container = await createRequestContainer()\n const limited = await limitPublicRequest(container, req, 'launch')\n if (limited) return limited\n\n const params = new URL(req.url).searchParams\n const orderId = params.get('o') ?? ''\n const token = params.get('t') ?? ''\n if (!isWellFormedOrderId(orderId) || !isWellFormedLaunchToken(token)) return unavailable(404)\n\n try {\n const em = container.resolve('em') as EntityManager\n const candidates = await findAutopayCandidates(em, orderId)\n const matches = candidates.filter((candidate) => (\n launchGrantMatches(readTransactionMetadata(candidate).launch, token)\n ))\n if (matches.length !== 1) return unavailable(404)\n\n const [transaction] = matches\n if (transaction.unifiedStatus !== 'pending') return unavailable(404)\n\n const form = readFormPost(readTransactionMetadata(transaction).formPost)\n if (!form) return unavailable(404)\n resolveApiHost(form.url)\n\n return htmlResponse(\n renderLaunchPage(form, {\n title: t('gateway_autopay.launch.title', 'Redirecting to Autopay'),\n message: t(\n 'gateway_autopay.launch.redirecting',\n 'Redirecting you to Autopay to complete the payment. If nothing happens, use the button below.',\n ),\n continueLabel: t('gateway_autopay.launch.continue', 'Continue to Autopay'),\n }),\n 200,\n LAUNCH_PAGE_CONTENT_SECURITY_POLICY,\n )\n } catch (error) {\n reportAutopayError(error, 'gateway_autopay.launch_failed')\n return unavailable(500)\n }\n}\n\nexport const openApi = {\n tags: ['Autopay'],\n summary: 'Start an Autopay payment',\n methods: {\n GET: {\n summary: 'Render the page that forwards the payer to Autopay with a signed POST',\n tags: ['Autopay'],\n responses: [\n { status: 200, description: 'HTML page that submits the signed payment form to Autopay' },\n { status: 404, description: 'The link is invalid, expired or the payment is no longer pending' },\n { status: 429, description: 'Too many requests' },\n { status: 500, description: 'The payment could not be started' },\n ],\n },\n },\n}\n\nexport default GET\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,WAAW;AAAA,EACtB,MAAM;AAAA,EACN,KAAK,EAAE,aAAa,MAAM;AAC5B;AAEA,eAAsB,IAAI,KAAc;AACtC,QAAM,EAAE,EAAE,IAAI,MAAM,oBAAoB;AACxC,QAAM,cAAc,CAAC,WAAmB;AAAA,IACtC;AAAA,MACE,OAAO,EAAE,2CAA2C,0BAA0B;AAAA,MAC9E,SAAS;AAAA,QACP;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,EACF;AAEA,QAAM,YAAY,MAAM,uBAAuB;AAC/C,QAAM,UAAU,MAAM,mBAAmB,WAAW,KAAK,QAAQ;AACjE,MAAI,QAAS,QAAO;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,EAAE,QAAQ,KAAK,aAAa,oBAAoB;AAAA,QAChD,EAAE,QAAQ,KAAK,aAAa,mCAAmC;AAAA,MACjE;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { createRequestContainer } from "@open-mercato/shared/lib/di/container";
|
|
2
|
+
import { resolveTranslations } from "@open-mercato/shared/lib/i18n/server";
|
|
3
|
+
import { reportAutopayError } from "../../lib/error-reporting.js";
|
|
4
|
+
import { isWellFormedOrderId, pickReturnTarget, readReturnTargets } from "../../lib/launch.js";
|
|
5
|
+
import {
|
|
6
|
+
findAutopayCandidates,
|
|
7
|
+
limitPublicRequest,
|
|
8
|
+
messageResponse,
|
|
9
|
+
readTransactionMetadata,
|
|
10
|
+
redirectResponse
|
|
11
|
+
} from "../../lib/public-route.js";
|
|
12
|
+
import { isValidReturnSignature, readReturnQuery } from "../../lib/return-bridge.js";
|
|
13
|
+
const INTEGRATION_ID = "gateway_autopay";
|
|
14
|
+
const metadata = {
|
|
15
|
+
path: "/gateway_autopay/return",
|
|
16
|
+
GET: { requireAuth: false }
|
|
17
|
+
};
|
|
18
|
+
async function GET(req) {
|
|
19
|
+
const { t } = await resolveTranslations();
|
|
20
|
+
const unavailable = (status) => messageResponse(
|
|
21
|
+
{
|
|
22
|
+
title: t("gateway_autopay.return.unavailableTitle", "Payment return not recognized"),
|
|
23
|
+
message: t(
|
|
24
|
+
"gateway_autopay.return.unavailable",
|
|
25
|
+
"We could not match this return to a payment. Go back to the shop to check the payment status."
|
|
26
|
+
)
|
|
27
|
+
},
|
|
28
|
+
status
|
|
29
|
+
);
|
|
30
|
+
const container = await createRequestContainer();
|
|
31
|
+
const limited = await limitPublicRequest(container, req, "return");
|
|
32
|
+
if (limited) return limited;
|
|
33
|
+
const query = readReturnQuery(new URL(req.url).searchParams);
|
|
34
|
+
if (!query || !isWellFormedOrderId(query.orderId)) return unavailable(400);
|
|
35
|
+
try {
|
|
36
|
+
const em = container.resolve("em");
|
|
37
|
+
const credentialsService = container.resolve("integrationCredentialsService");
|
|
38
|
+
const candidates = await findAutopayCandidates(em, query.orderId);
|
|
39
|
+
const verified = [];
|
|
40
|
+
for (const candidate of candidates) {
|
|
41
|
+
const credentials = await credentialsService.resolve(INTEGRATION_ID, {
|
|
42
|
+
organizationId: candidate.organizationId,
|
|
43
|
+
tenantId: candidate.tenantId
|
|
44
|
+
});
|
|
45
|
+
if (credentials && isValidReturnSignature(credentials, query)) verified.push(candidate);
|
|
46
|
+
}
|
|
47
|
+
if (verified.length !== 1) return unavailable(400);
|
|
48
|
+
const [transaction] = verified;
|
|
49
|
+
let status = transaction.unifiedStatus;
|
|
50
|
+
try {
|
|
51
|
+
const service = container.resolve("paymentGatewayService");
|
|
52
|
+
const canonical = await service.getPaymentStatus(transaction.id, {
|
|
53
|
+
organizationId: transaction.organizationId,
|
|
54
|
+
tenantId: transaction.tenantId
|
|
55
|
+
});
|
|
56
|
+
status = canonical.status;
|
|
57
|
+
} catch (error) {
|
|
58
|
+
reportAutopayError(error, "gateway_autopay.return_failed");
|
|
59
|
+
}
|
|
60
|
+
const target = pickReturnTarget(status, readReturnTargets(readTransactionMetadata(transaction).returnTargets));
|
|
61
|
+
if (target) return redirectResponse(target);
|
|
62
|
+
return messageResponse(
|
|
63
|
+
{
|
|
64
|
+
title: t("gateway_autopay.return.doneTitle", "Payment status updated"),
|
|
65
|
+
message: t("gateway_autopay.return.done", "You can close this window and return to the shop.")
|
|
66
|
+
},
|
|
67
|
+
200
|
|
68
|
+
);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
reportAutopayError(error, "gateway_autopay.return_failed");
|
|
71
|
+
return unavailable(500);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const openApi = {
|
|
75
|
+
tags: ["Autopay"],
|
|
76
|
+
summary: "Autopay payer return",
|
|
77
|
+
methods: {
|
|
78
|
+
GET: {
|
|
79
|
+
summary: "Verify the signed return from Autopay, refresh the payment status and send the payer back to the shop",
|
|
80
|
+
tags: ["Autopay"],
|
|
81
|
+
responses: [
|
|
82
|
+
{ status: 200, description: "Status refreshed; no shop return address was stored for this payment" },
|
|
83
|
+
{ status: 302, description: "Redirect to the shop success or cancel page" },
|
|
84
|
+
{ status: 400, description: "The return could not be matched to exactly one payment" },
|
|
85
|
+
{ status: 429, description: "Too many requests" },
|
|
86
|
+
{ status: 500, description: "The return could not be processed" }
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
var route_default = GET;
|
|
92
|
+
export {
|
|
93
|
+
GET,
|
|
94
|
+
route_default as default,
|
|
95
|
+
metadata,
|
|
96
|
+
openApi
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/gateway_autopay/api/return/route.ts"],
|
|
4
|
+
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport type { UnifiedPaymentStatus } from '@open-mercato/shared/modules/payment_gateways/types'\nimport type { CredentialsService } from '@open-mercato/core/modules/integrations/lib/credentials-service'\nimport type { PaymentGatewayService } from '@open-mercato/core/modules/payment_gateways/lib/gateway-service'\nimport { reportAutopayError } from '../../lib/error-reporting'\nimport { isWellFormedOrderId, pickReturnTarget, readReturnTargets } from '../../lib/launch'\nimport {\n findAutopayCandidates,\n limitPublicRequest,\n messageResponse,\n readTransactionMetadata,\n redirectResponse,\n} from '../../lib/public-route'\nimport { isValidReturnSignature, readReturnQuery } from '../../lib/return-bridge'\n\nconst INTEGRATION_ID = 'gateway_autopay'\n\nexport const metadata = {\n path: '/gateway_autopay/return',\n GET: { requireAuth: false },\n}\n\nexport async function GET(req: Request) {\n const { t } = await resolveTranslations()\n const unavailable = (status: number) => messageResponse(\n {\n title: t('gateway_autopay.return.unavailableTitle', 'Payment return not recognized'),\n message: t(\n 'gateway_autopay.return.unavailable',\n 'We could not match this return to a payment. Go back to the shop to check the payment status.',\n ),\n },\n status,\n )\n\n const container = await createRequestContainer()\n const limited = await limitPublicRequest(container, req, 'return')\n if (limited) return limited\n\n const query = readReturnQuery(new URL(req.url).searchParams)\n if (!query || !isWellFormedOrderId(query.orderId)) return unavailable(400)\n\n try {\n const em = container.resolve('em') as EntityManager\n const credentialsService = container.resolve('integrationCredentialsService') as CredentialsService\n const candidates = await findAutopayCandidates(em, query.orderId)\n\n const verified = []\n for (const candidate of candidates) {\n const credentials = await credentialsService.resolve(INTEGRATION_ID, {\n organizationId: candidate.organizationId,\n tenantId: candidate.tenantId,\n })\n if (credentials && isValidReturnSignature(credentials, query)) verified.push(candidate)\n }\n if (verified.length !== 1) return unavailable(400)\n\n const [transaction] = verified\n let status = transaction.unifiedStatus as UnifiedPaymentStatus\n try {\n const service = container.resolve('paymentGatewayService') as PaymentGatewayService\n const canonical = await service.getPaymentStatus(transaction.id, {\n organizationId: transaction.organizationId,\n tenantId: transaction.tenantId,\n })\n status = canonical.status\n } catch (error) {\n reportAutopayError(error, 'gateway_autopay.return_failed')\n }\n\n const target = pickReturnTarget(status, readReturnTargets(readTransactionMetadata(transaction).returnTargets))\n if (target) return redirectResponse(target)\n return messageResponse(\n {\n title: t('gateway_autopay.return.doneTitle', 'Payment status updated'),\n message: t('gateway_autopay.return.done', 'You can close this window and return to the shop.'),\n },\n 200,\n )\n } catch (error) {\n reportAutopayError(error, 'gateway_autopay.return_failed')\n return unavailable(500)\n }\n}\n\nexport const openApi = {\n tags: ['Autopay'],\n summary: 'Autopay payer return',\n methods: {\n GET: {\n summary: 'Verify the signed return from Autopay, refresh the payment status and send the payer back to the shop',\n tags: ['Autopay'],\n responses: [\n { status: 200, description: 'Status refreshed; no shop return address was stored for this payment' },\n { status: 302, description: 'Redirect to the shop success or cancel page' },\n { status: 400, description: 'The return could not be matched to exactly one payment' },\n { status: 429, description: 'Too many requests' },\n { status: 500, description: 'The return could not be processed' },\n ],\n },\n },\n}\n\nexport default GET\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AAIpC,SAAS,0BAA0B;AACnC,SAAS,qBAAqB,kBAAkB,yBAAyB;AACzE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB,uBAAuB;AAExD,MAAM,iBAAiB;AAEhB,MAAM,WAAW;AAAA,EACtB,MAAM;AAAA,EACN,KAAK,EAAE,aAAa,MAAM;AAC5B;AAEA,eAAsB,IAAI,KAAc;AACtC,QAAM,EAAE,EAAE,IAAI,MAAM,oBAAoB;AACxC,QAAM,cAAc,CAAC,WAAmB;AAAA,IACtC;AAAA,MACE,OAAO,EAAE,2CAA2C,+BAA+B;AAAA,MACnF,SAAS;AAAA,QACP;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,EACF;AAEA,QAAM,YAAY,MAAM,uBAAuB;AAC/C,QAAM,UAAU,MAAM,mBAAmB,WAAW,KAAK,QAAQ;AACjE,MAAI,QAAS,QAAO;AAEpB,QAAM,QAAQ,gBAAgB,IAAI,IAAI,IAAI,GAAG,EAAE,YAAY;AAC3D,MAAI,CAAC,SAAS,CAAC,oBAAoB,MAAM,OAAO,EAAG,QAAO,YAAY,GAAG;AAEzE,MAAI;AACF,UAAM,KAAK,UAAU,QAAQ,IAAI;AACjC,UAAM,qBAAqB,UAAU,QAAQ,+BAA+B;AAC5E,UAAM,aAAa,MAAM,sBAAsB,IAAI,MAAM,OAAO;AAEhE,UAAM,WAAW,CAAC;AAClB,eAAW,aAAa,YAAY;AAClC,YAAM,cAAc,MAAM,mBAAmB,QAAQ,gBAAgB;AAAA,QACnE,gBAAgB,UAAU;AAAA,QAC1B,U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AACF;AAEA,IAAO,gBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { parseModuleCliOptions } from "@open-mercato/shared/lib/cli/parseModuleCliOptions";
|
|
2
|
+
import { createRequestContainer } from "@open-mercato/shared/lib/di/container";
|
|
3
|
+
import { parseBooleanToken } from "@open-mercato/shared/lib/boolean";
|
|
4
|
+
import { reportAutopayError } from "./lib/error-reporting.js";
|
|
5
|
+
import { applyAutopayEnvPreset, readAutopayEnvPreset } from "./lib/preset.js";
|
|
6
|
+
function resolveForceFlag(rawForce) {
|
|
7
|
+
if (rawForce === void 0) return void 0;
|
|
8
|
+
if (typeof rawForce === "boolean") return rawForce;
|
|
9
|
+
return parseBooleanToken(rawForce) ?? void 0;
|
|
10
|
+
}
|
|
11
|
+
function parseArgs(args) {
|
|
12
|
+
return parseModuleCliOptions(args);
|
|
13
|
+
}
|
|
14
|
+
function printHelp() {
|
|
15
|
+
console.log("Usage: yarn mercato gateway_autopay configure-from-env --tenant <tenantId> --org <organizationId> [--force]");
|
|
16
|
+
console.log("");
|
|
17
|
+
console.log("Required env vars:");
|
|
18
|
+
console.log(" OM_INTEGRATION_AUTOPAY_SERVICE_ID");
|
|
19
|
+
console.log(" OM_INTEGRATION_AUTOPAY_SHARED_KEY");
|
|
20
|
+
console.log(" OM_INTEGRATION_AUTOPAY_GATEWAY_URL");
|
|
21
|
+
console.log("");
|
|
22
|
+
console.log("Optional env vars:");
|
|
23
|
+
console.log(" OM_INTEGRATION_AUTOPAY_HASH_ALGORITHM (sha256 default, or sha512)");
|
|
24
|
+
console.log(" OM_INTEGRATION_AUTOPAY_ENABLED");
|
|
25
|
+
console.log(" OM_INTEGRATION_AUTOPAY_FORCE_PRECONFIGURE");
|
|
26
|
+
}
|
|
27
|
+
const configureFromEnvCommand = {
|
|
28
|
+
command: "configure-from-env",
|
|
29
|
+
async run(rest) {
|
|
30
|
+
const args = parseArgs(rest);
|
|
31
|
+
const tenantId = String(args.tenantId ?? args.tenant ?? "");
|
|
32
|
+
const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? "");
|
|
33
|
+
const force = resolveForceFlag(args.force);
|
|
34
|
+
if (!tenantId || !organizationId) {
|
|
35
|
+
printHelp();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const preset = readAutopayEnvPreset();
|
|
39
|
+
if (!preset) {
|
|
40
|
+
console.error("[gateway_autopay] No Autopay env preset was found.");
|
|
41
|
+
printHelp();
|
|
42
|
+
process.exitCode = 1;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const container = await createRequestContainer();
|
|
46
|
+
try {
|
|
47
|
+
const credentialsService = container.resolve("integrationCredentialsService");
|
|
48
|
+
const integrationStateService = container.resolve("integrationStateService");
|
|
49
|
+
const integrationLogService = container.resolve("integrationLogService");
|
|
50
|
+
const result = await applyAutopayEnvPreset({
|
|
51
|
+
credentialsService,
|
|
52
|
+
integrationStateService,
|
|
53
|
+
integrationLogService,
|
|
54
|
+
scope: { tenantId, organizationId },
|
|
55
|
+
force
|
|
56
|
+
});
|
|
57
|
+
if (result.status === "skipped") {
|
|
58
|
+
console.log(`[gateway_autopay] Skipped: ${result.reason}`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
console.log(`[gateway_autopay] Autopay credentials were configured from env. enabled=${String(result.enabled)}`);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
const message = error instanceof Error ? error.message : "Unknown Autopay preset error";
|
|
64
|
+
console.error(`[gateway_autopay] ${message}`);
|
|
65
|
+
reportAutopayError(error, "gateway_autopay.cli_configure_failed");
|
|
66
|
+
process.exitCode = 1;
|
|
67
|
+
} finally {
|
|
68
|
+
const disposable = container;
|
|
69
|
+
if (typeof disposable.dispose === "function") {
|
|
70
|
+
await disposable.dispose();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const helpCommand = {
|
|
76
|
+
command: "help",
|
|
77
|
+
async run() {
|
|
78
|
+
printHelp();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
var cli_default = [configureFromEnvCommand, helpCommand];
|
|
82
|
+
export {
|
|
83
|
+
cli_default as default,
|
|
84
|
+
resolveForceFlag
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/modules/gateway_autopay/cli.ts"],
|
|
4
|
+
"sourcesContent": ["import { parseModuleCliOptions } from '@open-mercato/shared/lib/cli/parseModuleCliOptions'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport type { ModuleCli } from '@open-mercato/shared/modules/registry'\nimport type { CredentialsService } from '@open-mercato/core/modules/integrations/lib/credentials-service'\nimport type { IntegrationLogService } from '@open-mercato/core/modules/integrations/lib/log-service'\nimport type { IntegrationStateService } from '@open-mercato/core/modules/integrations/lib/state-service'\nimport { parseBooleanToken } from '@open-mercato/shared/lib/boolean'\nimport { reportAutopayError } from './lib/error-reporting'\nimport { applyAutopayEnvPreset, readAutopayEnvPreset } from './lib/preset'\n\n/**\n * `undefined` (flag never passed) must stay `undefined`, not coerce to\n * `false` \u2014 `applyAutopayEnvPreset` does `params.force ?? preset.force`, so a\n * coerced `false` here would silently override\n * `OM_INTEGRATION_AUTOPAY_FORCE_PRECONFIGURE=true` from the env preset every\n * time the CLI is run without an explicit `--force` flag.\n */\nexport function resolveForceFlag(rawForce: string | boolean | undefined): boolean | undefined {\n if (rawForce === undefined) return undefined\n if (typeof rawForce === 'boolean') return rawForce\n return parseBooleanToken(rawForce) ?? undefined\n}\n\nfunction parseArgs(args: string[]): Record<string, string | boolean> {\n return parseModuleCliOptions(args)\n}\n\nfunction printHelp(): void {\n console.log('Usage: yarn mercato gateway_autopay configure-from-env --tenant <tenantId> --org <organizationId> [--force]')\n console.log('')\n console.log('Required env vars:')\n console.log(' OM_INTEGRATION_AUTOPAY_SERVICE_ID')\n console.log(' OM_INTEGRATION_AUTOPAY_SHARED_KEY')\n console.log(' OM_INTEGRATION_AUTOPAY_GATEWAY_URL')\n console.log('')\n console.log('Optional env vars:')\n console.log(' OM_INTEGRATION_AUTOPAY_HASH_ALGORITHM (sha256 default, or sha512)')\n console.log(' OM_INTEGRATION_AUTOPAY_ENABLED')\n console.log(' OM_INTEGRATION_AUTOPAY_FORCE_PRECONFIGURE')\n}\n\nconst configureFromEnvCommand: ModuleCli = {\n command: 'configure-from-env',\n async run(rest) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? '')\n const force = resolveForceFlag(args.force)\n\n if (!tenantId || !organizationId) {\n printHelp()\n return\n }\n\n const preset = readAutopayEnvPreset()\n if (!preset) {\n console.error('[gateway_autopay] No Autopay env preset was found.')\n printHelp()\n process.exitCode = 1\n return\n }\n\n const container = await createRequestContainer()\n try {\n const credentialsService = container.resolve('integrationCredentialsService') as CredentialsService\n const integrationStateService = container.resolve('integrationStateService') as IntegrationStateService\n const integrationLogService = container.resolve('integrationLogService') as IntegrationLogService\n\n const result = await applyAutopayEnvPreset({\n credentialsService,\n integrationStateService,\n integrationLogService,\n scope: { tenantId, organizationId },\n force,\n })\n\n if (result.status === 'skipped') {\n console.log(`[gateway_autopay] Skipped: ${result.reason}`)\n return\n }\n\n console.log(`[gateway_autopay] Autopay credentials were configured from env. enabled=${String(result.enabled)}`)\n } catch (error) {\n const message = error instanceof Error ? error.message : 'Unknown Autopay preset error'\n console.error(`[gateway_autopay] ${message}`)\n reportAutopayError(error, 'gateway_autopay.cli_configure_failed')\n process.exitCode = 1\n } finally {\n const disposable = container as unknown as { dispose?: () => Promise<void> }\n if (typeof disposable.dispose === 'function') {\n await disposable.dispose()\n }\n }\n },\n}\n\nconst helpCommand: ModuleCli = {\n command: 'help',\n async run() {\n printHelp()\n },\n}\n\nexport default [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M,0BAA0B,UAAU,QAAQ,yBAAyB;AAC3E,YAAM,wBAAwB,UAAU,QAAQ,uBAAuB;AAEvE,YAAM,SAAS,MAAM,sBAAsB;AAAA,QACzC;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO,EAAE,UAAU,eAAe;AAAA,QAClC;AAAA,MACF,CAAC;AAED,UAAI,OAAO,WAAW,WAAW;AAC/B,gBAAQ,IAAI,8BAA8B,OAAO,MAAM,EAAE;AACzD;AAAA,MACF;AAEA,cAAQ,IAAI,2EAA2E,OAAO,OAAO,OAAO,CAAC,EAAE;AAAA,IACjH,SAAS,OAAO;AACd,YAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU;AACzD,cAAQ,MAAM,qBAAqB,OAAO,EAAE;AAC5C,yBAAmB,OAAO,sCAAsC;AAChE,cAAQ,WAAW;AAAA,IACrB,UAAE;AACA,YAAM,aAAa;AACnB,UAAI,OAAO,WAAW,YAAY,YAAY;AAC5C,cAAM,WAAW,QAAQ;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AACF;AAEA,MAAM,cAAyB;AAAA,EAC7B,SAAS;AAAA,EACT,MAAM,MAAM;AACV,cAAU;AAAA,EACZ;AACF;AAEA,IAAO,cAAQ,CAAC,yBAAyB,WAAW;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { asValue } from "awilix";
|
|
2
|
+
import {
|
|
3
|
+
registerGatewayAdapter,
|
|
4
|
+
registerPaymentGatewayDescriptor
|
|
5
|
+
} from "@open-mercato/shared/modules/payment_gateways/types";
|
|
6
|
+
import { autopayHealthCheck } from "./lib/health.js";
|
|
7
|
+
import { autopayAdapterV1 } from "./lib/adapters/v1.js";
|
|
8
|
+
function register(container) {
|
|
9
|
+
registerGatewayAdapter(autopayAdapterV1, { version: "v1" });
|
|
10
|
+
registerPaymentGatewayDescriptor({
|
|
11
|
+
providerKey: "autopay",
|
|
12
|
+
label: "Autopay",
|
|
13
|
+
requiresPayerFields: ["email"],
|
|
14
|
+
sessionConfig: {
|
|
15
|
+
supportedCurrencies: ["PLN"],
|
|
16
|
+
defaultRendererKey: "autopay.hosted_redirect",
|
|
17
|
+
renderers: [
|
|
18
|
+
{
|
|
19
|
+
key: "autopay.hosted_redirect",
|
|
20
|
+
label: "Autopay Hosted Redirect",
|
|
21
|
+
type: "redirect",
|
|
22
|
+
description: "Redirects the payer to Autopay's hosted payment page (bank transfer, BLIK, cards).",
|
|
23
|
+
supportedPaymentTypes: "*"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
container.register({
|
|
29
|
+
autopayHealthCheck: asValue(autopayHealthCheck)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
register
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=di.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/modules/gateway_autopay/di.ts"],
|
|
4
|
+
"sourcesContent": ["import { asValue } from 'awilix'\nimport type { AppContainer } from '@open-mercato/shared/lib/di/container'\nimport {\n registerGatewayAdapter,\n registerPaymentGatewayDescriptor,\n} from '@open-mercato/shared/modules/payment_gateways/types'\nimport { autopayHealthCheck } from './lib/health'\nimport { autopayAdapterV1 } from './lib/adapters/v1'\n\nexport function register(container: AppContainer) {\n registerGatewayAdapter(autopayAdapterV1, { version: 'v1' })\n\n registerPaymentGatewayDescriptor({\n providerKey: 'autopay',\n label: 'Autopay',\n requiresPayerFields: ['email'],\n sessionConfig: {\n supportedCurrencies: ['PLN'],\n defaultRendererKey: 'autopay.hosted_redirect',\n renderers: [\n {\n key: 'autopay.hosted_redirect',\n label: 'Autopay Hosted Redirect',\n type: 'redirect',\n description: 'Redirects the payer to Autopay\\'s hosted payment page (bank transfer, BLIK, cards).',\n supportedPaymentTypes: '*',\n },\n ],\n },\n })\n\n container.register({\n autopayHealthCheck: asValue(autopayHealthCheck),\n })\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,eAAe;AAExB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AAE1B,SAAS,SAAS,WAAyB;AAChD,yBAAuB,kBAAkB,EAAE,SAAS,KAAK,CAAC;AAE1D,mCAAiC;AAAA,IAC/B,aAAa;AAAA,IACb,OAAO;AAAA,IACP,qBAAqB,CAAC,OAAO;AAAA,IAC7B,eAAe;AAAA,MACb,qBAAqB,CAAC,KAAK;AAAA,MAC3B,oBAAoB;AAAA,MACpB,WAAW;AAAA,QACT;AAAA,UACE,KAAK;AAAA,UACL,OAAO;AAAA,UACP,MAAM;AAAA,UACN,aAAa;AAAA,UACb,uBAAuB;AAAA,QACzB;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AAED,YAAU,SAAS;AAAA,IACjB,oBAAoB,QAAQ,kBAAkB;AAAA,EAChD,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/modules/gateway_autopay/index.ts"],
|
|
4
|
+
"sourcesContent": ["export const metadata = {\n id: 'gateway_autopay',\n title: 'Autopay Payment Gateway',\n description: 'Accept hosted PLN payments (bank transfers, BLIK, cards) via Autopay Online.',\n}\n"],
|
|
5
|
+
"mappings": "AAAO,MAAM,WAAW;AAAA,EACtB,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,aAAa;AACf;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const integration = {
|
|
2
|
+
id: "gateway_autopay",
|
|
3
|
+
title: "Autopay",
|
|
4
|
+
description: "Accept hosted PLN payments (bank transfers, BLIK, cards) via Autopay Online.",
|
|
5
|
+
category: "payment",
|
|
6
|
+
hub: "payment_gateways",
|
|
7
|
+
providerKey: "autopay",
|
|
8
|
+
icon: "autopay",
|
|
9
|
+
docsUrl: "https://developers.autopay.pl/online/dokumentacja-v1-1",
|
|
10
|
+
package: "@open-mercato/gateway-autopay",
|
|
11
|
+
version: "1.0.0",
|
|
12
|
+
author: "Open Mercato Team",
|
|
13
|
+
company: "Open Mercato",
|
|
14
|
+
license: "MIT",
|
|
15
|
+
tags: ["pln", "blik", "bank-transfer", "poland", "hosted-redirect"],
|
|
16
|
+
credentials: {
|
|
17
|
+
fields: [
|
|
18
|
+
{
|
|
19
|
+
key: "serviceId",
|
|
20
|
+
label: "Service ID",
|
|
21
|
+
type: "text",
|
|
22
|
+
required: true,
|
|
23
|
+
placeholder: "2",
|
|
24
|
+
helpText: 'Register your own Partner Service at https://portal.autopay.eu/ to get this. The sandbox worked-example value "2" only verifies the hash math, never a real session.'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
key: "sharedKey",
|
|
28
|
+
label: "Shared Key",
|
|
29
|
+
type: "secret",
|
|
30
|
+
required: true,
|
|
31
|
+
helpText: 'Issued alongside the Service ID at https://portal.autopay.eu/. Used to sign and verify every message (plain concatenated hash, not HMAC). The sandbox worked-example value "2test2" only verifies the hash math, never a real session.'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
key: "hashAlgorithm",
|
|
35
|
+
label: "Hash Algorithm",
|
|
36
|
+
type: "select",
|
|
37
|
+
required: false,
|
|
38
|
+
options: [
|
|
39
|
+
{ value: "sha256", label: "SHA-256 (default)" },
|
|
40
|
+
{ value: "sha512", label: "SHA-512" }
|
|
41
|
+
],
|
|
42
|
+
helpText: "Fixed per Service during Autopay onboarding; defaults to SHA-256 if not specified there."
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
key: "gatewayUrl",
|
|
46
|
+
label: "Payment Initiation URL",
|
|
47
|
+
type: "url",
|
|
48
|
+
required: true,
|
|
49
|
+
placeholder: "https://testpay.autopay.eu/<path-issued-at-onboarding>",
|
|
50
|
+
helpText: "The exact hosted-session URL Autopay issues per Partner Service when you register at https://portal.autopay.eu/. Never guess this value \u2014 it is specific to your own registration, not a fixed public path. The host must be https://testpay.autopay.eu (sandbox) or https://pay.autopay.eu (production); the status/cancel/refund API host is derived from this URL."
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
healthCheck: { service: "autopayHealthCheck" }
|
|
55
|
+
};
|
|
56
|
+
const integrations = [integration];
|
|
57
|
+
const bundles = [];
|
|
58
|
+
const bundle = void 0;
|
|
59
|
+
export {
|
|
60
|
+
bundle,
|
|
61
|
+
bundles,
|
|
62
|
+
integration,
|
|
63
|
+
integrations
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=integration.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/modules/gateway_autopay/integration.ts"],
|
|
4
|
+
"sourcesContent": ["import type { IntegrationBundle, IntegrationDefinition } from '@open-mercato/shared/modules/integrations/types'\n\nexport const integration: IntegrationDefinition = {\n id: 'gateway_autopay',\n title: 'Autopay',\n description: 'Accept hosted PLN payments (bank transfers, BLIK, cards) via Autopay Online.',\n category: 'payment',\n hub: 'payment_gateways',\n providerKey: 'autopay',\n icon: 'autopay',\n docsUrl: 'https://developers.autopay.pl/online/dokumentacja-v1-1',\n package: '@open-mercato/gateway-autopay',\n version: '1.0.0',\n author: 'Open Mercato Team',\n company: 'Open Mercato',\n license: 'MIT',\n tags: ['pln', 'blik', 'bank-transfer', 'poland', 'hosted-redirect'],\n credentials: {\n fields: [\n {\n key: 'serviceId',\n label: 'Service ID',\n type: 'text',\n required: true,\n placeholder: '2',\n helpText: 'Register your own Partner Service at https://portal.autopay.eu/ to get this. The sandbox worked-example value \"2\" only verifies the hash math, never a real session.',\n },\n {\n key: 'sharedKey',\n label: 'Shared Key',\n type: 'secret',\n required: true,\n helpText: 'Issued alongside the Service ID at https://portal.autopay.eu/. Used to sign and verify every message (plain concatenated hash, not HMAC). The sandbox worked-example value \"2test2\" only verifies the hash math, never a real session.',\n },\n {\n key: 'hashAlgorithm',\n label: 'Hash Algorithm',\n type: 'select',\n required: false,\n options: [\n { value: 'sha256', label: 'SHA-256 (default)' },\n { value: 'sha512', label: 'SHA-512' },\n ],\n helpText: 'Fixed per Service during Autopay onboarding; defaults to SHA-256 if not specified there.',\n },\n {\n key: 'gatewayUrl',\n label: 'Payment Initiation URL',\n type: 'url',\n required: true,\n placeholder: 'https://testpay.autopay.eu/<path-issued-at-onboarding>',\n helpText: 'The exact hosted-session URL Autopay issues per Partner Service when you register at https://portal.autopay.eu/. Never guess this value \u2014 it is specific to your own registration, not a fixed public path. The host must be https://testpay.autopay.eu (sandbox) or https://pay.autopay.eu (production); the status/cancel/refund API host is derived from this URL.',\n },\n ],\n },\n healthCheck: { service: 'autopayHealthCheck' },\n}\n\nexport const integrations: IntegrationDefinition[] = [integration]\nexport const bundles: IntegrationBundle[] = []\nexport const bundle: IntegrationBundle | undefined = undefined\n"],
|
|
5
|
+
"mappings": "AAEO,MAAM,cAAqC;AAAA,EAChD,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,aAAa;AAAA,EACb,UAAU;AAAA,EACV,KAAK;AAAA,EACL,aAAa;AAAA,EACb,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM,CAAC,OAAO,QAAQ,iBAAiB,UAAU,iBAAiB;AAAA,EAClE,aAAa;AAAA,IACX,QAAQ;AAAA,MACN;AAAA,QACE,KAAK;AAAA,QACL,OAAO;AAAA,QACP,MAAM;AAAA,QACN,UAAU;AAAA,QACV,aAAa;AAAA,QACb,UAAU;AAAA,MACZ;AAAA,MACA;AAAA,QACE,KAAK;AAAA,QACL,OAAO;AAAA,QACP,MAAM;AAAA,QACN,UAAU;AAAA,QACV,UAAU;AAAA,MACZ;AAAA,MACA;AAAA,QACE,KAAK;AAAA,QACL,OAAO;AAAA,QACP,MAAM;AAAA,QACN,UAAU;AAAA,QACV,SAAS;AAAA,UACP,EAAE,OAAO,UAAU,OAAO,oBAAoB;AAAA,UAC9C,EAAE,OAAO,UAAU,OAAO,UAAU;AAAA,QACtC;AAAA,QACA,UAAU;AAAA,MACZ;AAAA,MACA;AAAA,QACE,KAAK;AAAA,QACL,OAAO;AAAA,QACP,MAAM;AAAA,QACN,UAAU;AAAA,QACV,aAAa;AAAA,QACb,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAAA,EACA,aAAa,EAAE,SAAS,qBAAqB;AAC/C;AAEO,MAAM,eAAwC,CAAC,WAAW;AAC1D,MAAM,UAA+B,CAAC;AACtC,MAAM,SAAwC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|