feat(payment): configure named gateway providers

This commit is contained in:
Clintchiz committed 2026-08-28 09:49:53 +05:30
1 parent c578bc0f92
commit 95c291db64
5 files changed
+162 -5

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
import { expect, test } from "bun:test";
import { memoryPaymentStore } from "../src/store.ts";
import { paymentOptionsFromConfig } from "../src/config.ts";
test("configuration creates any number of named provider gateways", () => {
const options = paymentOptionsFromConfig(
{
default: "india",
environment: "test",
gateways: {
india: {
provider: "razorpay",
keyId: "rzp_test",
keySecret: "secret",
webhookSecret: "razorpay-hook",
},
global: {
provider: "stripe",
secretKey: "sk_test",
publishableKey: "pk_test",
webhookSecret: "stripe-hook",
},
disabled: false,
},
},
memoryPaymentStore(),
);
expect(options.default).toBe("india");
expect(options.adapters.map((adapter) => adapter.id)).toEqual(["india", "global"]);
expect(options.webhookSecrets).toEqual({ india: "razorpay-hook", global: "stripe-hook" });
});
test("configuration rejects a disabled or missing default gateway", () => {
expect(() =>
paymentOptionsFromConfig(
{ default: "missing", gateways: { sandbox: { provider: "sandbox" } } },
memoryPaymentStore(),
),
).toThrow("default gateway 'missing' is not enabled or configured");
});