feat(payment): configure named gateway providers
This commit is contained in:
1 parent
c578bc0f92
commit
95c291db64
5 files changed
+162
-5
No files matched your search
@@ -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");
|
||||
});
|
||||
Reference in new issue
Block a user