A lightweight, fully-featured, modular, typescript-compatible javascript library for PayMongo.
npm install paymongo.js # or yarn add paymongo.js
import PaymongoClient from "paymongo.js";
export const client = PaymongoClient("sk_key");
To use this feature, install with
npm install paymongo.js@next # or yarn add paymongo.js@next
-
Create a Link
const link = await client.link.create({ amount: 10000, description: "Test payment link", });
-
Retrieve a Link
const link = await client.link.retrieve("some_link_id");
-
Retrieve from Reference number
const link = await client.link.retrieveFromRef("some_ref_id");
-
Archive a Link
const link = await client.link.archive("some_link_id");
-
Unarchive a Link
const link = await client.link.unarchive("some_link_id");
See PaymentMethod Resource reference.
-
const createResponse = await client.method.create({ details: { cardNumber: "4343434343434345", expMonth: 3, expYear: 2023, cvc: "321", }, type: "card", // card | paymaya });
-
const retrieveResponse = await client.method.retrieve("some_method_id");
See PaymentIntent Resource reference.
-
const createResponse = await client.intent.create({ amount: 10000, metadata: { order_id: "some_order_id", }, });
-
const retrieveResponse = await client.intent.retrieve({ intentId: "some_intent_id", });
-
const attachResponse = await client.intent.attach({ intentId: "some_intent_id", methodId: "some_method_id", });
See Source Resource reference.
-
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", }, });
-
const retrieveResponse = await client.source.retrieve("some_source_id");
See Payment Resource reference.
-
const p = await client.payment.create({ amount: 10000, source: { id: "some_source_id", type: "source", }, });
-
const p = await client.payment.list();
-
const p = await client.payment.retrieve("some_payment_id");
See Webhook Resource reference.
-
const webhook = await client.webhook.create({ events: ["payment.failed", "payment.paid", "source.chargeable"], url: "https://example.com/webhook", });
-
const webhook = await client.webhook.update({ webhookId: "some_webhook_id", events: ["payment.failed"], });
-
const webhooks = await client.webhook.list();
-
const webhook = await client.webhook.retrieve("some_webhook_id");
-
const webhook = await client.webhook.enable("some_webhook_id");
-
const webhook = await client.webhook.disable("some_webhook_id");
See CONTRIBUTING.md
Like the project? would appreciate a coffee β
Clone the repository:
git clone https://github.com/princejoogie/paymongo.js.git
cd paymongo.js
npm start # or yarn start
This builds to /dist
and runs the project in watch mode so any edits you save inside src
causes a rebuild to /dist
.
To do a one-off build, use npm run build
or yarn build
.
To run tests, use npm test
or yarn test
.
Code quality is set up for you with prettier
, husky
, and lint-staged
. Adjust the respective fields in package.json
accordingly.
Jest tests are set up to run with npm test
or yarn test
.
size-limit
is set up to calculate the real cost of your library with npm run size
and visualize the bundle with npm run analyze
.
This library uses Rollup as a bundler and generates multiple rollup configs for various module formats and build settings. See Optimizations for details.
tsconfig.json
is set up to interpret dom
and esnext
types, as well as react
for jsx
. Adjust according to your needs.
Two actions are added by default:
main
which installs deps w/ cache, lints, tests, and builds on all pushes against a Node and OS matrixsize
which comments cost comparison of your library on every pull request usingsize-limit
Please see the main tsdx
optimizations docs. In particular, know that you can take advantage of development-only optimizations:
// ./types/index.d.ts
declare var __DEV__: boolean;
// inside your code...
if (__DEV__) {
console.log("foo");
}
You can also choose to install and use invariant and warning functions.
CJS, ESModules, and UMD module formats are supported.
The appropriate paths are configured in package.json
and dist/index.js
accordingly. Please report if any issues are found.
We recommend using np.
Made by Prince Carlo Juguilon together with these awesome Contributors.