Example Test Suite
Codeimport { SaligPay } from "saligpay-node"; describe("SaligPay SDK", () => { let saligPay: SaligPay; beforeAll(() => { saligPay = new SaligPay({ clientId: process.env.TEST_CLIENT_ID, clientSecret: process.env.TEST_CLIENT_SECRET, env: "sandbox", }); }); it("should authenticate successfully", async () => { const tokens = await saligPay.authenticate(); expect(tokens).toBeDefined(); expect(tokens.accessToken).toBeDefined(); expect(tokens.refreshToken).toBeDefined(); expect(tokens.expiresAt).toBeInstanceOf(Date); }); it("should create a checkout session", async () => { await saligPay.authenticate(); const checkout = await saligPay.checkout.create({ externalId: "test-order", amount: 10000, description: "Test payment", webhookUrl: "https://example.com/webhook", returnUrl: "https://example.com/success", contact: { name: "Test User", email: "test@example.com", }, }); expect(checkout).toBeDefined(); expect(checkout.id).toBeDefined(); expect(checkout.checkoutUrl).toBeDefined(); }); it("should handle webhook payloads", () => { const payload = { externalId: "test-order", amount: 10000, status: "COMPLETED", paymentMethod: { id: "pm-test", type: "gcash", }, }; const event = saligPay.webhooks.constructEvent(payload); expect(event.externalId).toBe("test-order"); expect(event.status).toBe("COMPLETED"); }); });
Last modified on
