paymongo.js
An end-to-end typesafe library for PayMongo
Installation
bash
npm install paymongo.jsUsage
js
import { createPaymongoClient } from "paymongo.js";
const client = createPaymongoClient("sk_key");Payment Intent
See PaymentIntent Resource reference.
-
js
const res = await client.intent.create({ amount: 10000, payment_method_allowed: ["card", "gcash"], currency: "PHP", }); -
js
const res = client.intent.retrieve({ intentId: "some_intent_id", }); -
js
const res = await client.intent.attach({ intentId: "some_intent_id", intentId: "some_method_id", return_url: "https://example.com/success", });
Payment Method
See PaymentMethod Resource reference.
-
js
const res = await client.method.create({ type: "gcash", billing: { name: "John Doe", email: "john@email.com", phone: "+639999999999", address: { city: "Manila", line1: "line 1", line2: "line 2", state: "Metro Manila", country: "PH", postal_code: "1000", }, }, });jsconst res = await client.method.create({ type: "card", details: { card_number: "4242424242424242", exp_month: 12, exp_year: 2025, }, }); -
js
const retrieveResponse = await client.method.retrieve({ methodId: "some_method_id", });
Webhooks
See Webhook Resource reference.
-
js
const webhook = await client.webhook.create({ events: ["payment.failed", "payment.paid", "source.chargeable"], url: "https://example.com/webhook", }); -
js
const webhook = await client.webhook.update({ webhookId: "some_webhook_id", events: ["payment.failed"], }); -
js
const webhooks = await client.webhook.list(); -
js
const webhook = await client.webhook.retrieve("some_webhook_id"); -
js
const webhook = await client.webhook.enable("some_webhook_id"); -
js
const webhook = await client.webhook.disable("some_webhook_id");
Older APIs
The following API's are for older workflows, it is recommended that you use the Payment Intent workflow
Sources
See Source Resource reference.
-
js
const createResponse = await client.source.create({ type: "gcash", // gcash | grab_pay currency: "PHP", amount: 10000, redirect: { success: "https://example.com/payments/success", failed: "https://example.com/payments/error", }, }); -
js
const retrieveResponse = await client.source.retrieve("some_source_id");
Payments
See Payment Resource reference.
-
js
const p = await client.payment.create({ amount: 10000, source: { id: "some_source_id", type: "source", }, }); -
js
const p = await client.payment.list(); -
js
const p = await client.payment.retrieve("some_payment_id");
Contributing
See CONTRIBUTING.md
Like the project? would appreciate a coffee ☕
Contributor list
Made by Prince Carlo Juguilon together with these awesome Contributors.



