// Solution: Use ensureAuthenticated()await saligPay.ensureAuthenticated();// This automatically refreshes expired tokensconst checkout = await saligpay.checkout.create(options);
Validation Errors
Problem:ValidationError: Amount must be greater than 0
Code
// Solution: Validate input before API callconst createCheckout = async (options: CreateCheckoutOptions) => { if (options.amount <= 0) { throw new Error("Amount must be greater than 0"); } if (!options.externalId) { throw new Error("External ID is required"); } return saligpay.checkout.create(options);};
Webhook Issues
Problem: Invalid JSON payload
Code
// Solution: Ensure raw body is passed to webhook handlerapp.use(express.raw({ type: "application/json" }));app.post("/webhooks/saligpay", async (req, res) => { await saligpay.webhooks.listen(req, res, handler);});
Environment Setup
Problem: Module not found or import errors
Code
// Solution: Ensure Node.js 18+ is installed// Check Node versionconsole.log(process.version); // Should be v18.x.x or higher
If using TypeScript, ensure tsconfig.json has correct module settings: