1.1.2 • Published 2 years ago

paymongo.js v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

paymongo.js

CI CJS ESM License

A lightweight, fully-featured, modular, typescript-compatible javascript library for Paymongo.

Installation

NPM

npm install paymongo.js # or yarn add paymongo.js

Usage

import PaymongoClient from "paymongo.js";
export const client = PaymongoClient("sk_key");

Payment Methods

See PaymentMethod Resource reference.

  • Create a Method

    const createResponse = await client.createPaymentMethod({
      details: {
        card_number: "4343434343434345",
        exp_month: 3,
        exp_year: 2023,
        cvc: "321",
      },
      type: "card",
    });
  • Retrieve a Method

    const retrieveResponse = await client.retrievePaymentMethod({
      methodId: "some_method_id",
    });

Payment Intents

See PaymentIntent Resource reference.

  • Create a Intent

    const createResponse = await client.createPaymentIntent({
      amount: 10000,
      metadata: {
        order_id: "some_order_id",
      },
    });
  • Retrieve a PaymentIntent

    const retrieveResponse = await client.retrievePaymentIntent({
      intentId: "some_intent_id",
    });
  • Attach to PaymentIntent

    const attachResponse = await client.attachPaymentIntent({
      intentId: "some_intent_id",
      methodId: "some_method_id",
    });

Payment Webhooks

See Webhook Resource

  • Create a Webhook

    const webhook = await client.createWebhook({
      events: ["payment.failed", "payment.paid", "source.chargeable"],
      url: "https://example.com/webhook",
    });
  • Update a Webhook

    const webhook = await client.updateWebhook({
      webhookId: "some_webhook_id",
      events: ["payment.failed"],
    });
  • List all Webhooks

    const webhooks = await client.listWebhooks();
  • Retrieve a Webhook

    const webhook = await client.retrieveWebhook("some_webhook_id");
  • Enable a Webhook

    const webhook = await client.enableWebhook("some_webhook_id");
  • Disable a Webhook

    const webhook = await client.disableWebhook("some_webhook_id");

Contributing

todo


Running your own instance

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.

Configuration

Code quality is set up for you with prettier, husky, and lint-staged. Adjust the respective fields in package.json accordingly.

Jest

Jest tests are set up to run with npm test or yarn test.

Bundle Analysis

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.

Rollup

This library uses Rollup as a bundler and generates multiple rollup configs for various module formats and build settings. See Optimizations for details.

TypeScript

tsconfig.json is set up to interpret dom and esnext types, as well as react for jsx. Adjust according to your needs.

Continuous Integration

GitHub Actions

Two actions are added by default:

  • main which installs deps w/ cache, lints, tests, and builds on all pushes against a Node and OS matrix
  • size which comments cost comparison of your library on every pull request using size-limit

Optimizations

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.

Module Formats

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.

Publishing to NPM

We recommend using np.


Prince Carlo Juguilon

1.2.1-0

2 years ago

1.2.0-0

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.1.2-1

2 years ago

0.1.2-0

2 years ago

0.1.1-0

2 years ago