feat: add gateway-neutral payment package
Quality / quality (ubuntu-latest) (push) Failing after 9m55s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
Clintchiz committed 2026-08-23 21:05:27 +05:30
1 parent a9670c2a1c
commit 98e0813061
23 files changed
+1902 -6

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
import type { PaymentGateway } from "./types.ts";
export interface GatewayContractReport {
ok: boolean;
issues: string[];
}
/** Structural half of the shared adapter suite, usable by third-party adapters in CI. */
export function verifyGatewayContract(adapter: PaymentGateway): GatewayContractReport {
const issues: string[] = [];
const capability = (name: string, declared: boolean, present: boolean) => {
if (declared !== present)
issues.push(
`${adapter.id}: capability '${name}' is ${declared ? "declared but not implemented" : "implemented but not declared"}`,
);
};
capability(
"authorizeThenCapture",
adapter.capabilities.authorizeThenCapture,
typeof adapter.capture === "function",
);
capability(
"storedMethods",
adapter.capabilities.storedMethods,
typeof adapter.listMethods === "function" &&
typeof adapter.attachMethod === "function" &&
typeof adapter.detachMethod === "function",
);
capability(
"customerVault",
adapter.capabilities.customerVault,
typeof adapter.createCustomer === "function",
);
if (!adapter.capabilities.hostedFields && !adapter.capabilities.hostedCheckout)
issues.push(`${adapter.id}: a hosted payment surface is required`);
if (!adapter.capabilities.webhookSignature)
issues.push(`${adapter.id}: signed webhooks are required`);
return { ok: issues.length === 0, issues };
}