API SDK Quickstart - Node.js
npm install malga
import express, { Request, Response } from "express"; import { Malga } from "malga"; const app = express(); const malga = new Malga({ apiKey: "17a64c8f-a387-4682-bdd8-d280493715e0", clientId: "d1d2b51a-0446-432a-b055-034518c2660e", options: { sandbox: true }, }); app.post("/", (request: Request, response: Response) => { try { const data = await malga.charges.create({ merchantId: "8cfef0d1-73af-4bdb-b6c4-09ad3fbfc7f1", amount: 100, paymentMethod: { type: "credit", installments: 1, card: { holderName: "João da Silva", number: "5453881028277600", cvv: "170", expirationDate: "10/2030", }, }, }); response.json(data); } catch (error) { response.status(400).json(error); } }); app.listen(3000, () => { console.log("Server running on http://localhost:3000"); });
Was this page helpful?