npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@littleapp/little-pay-api

v1.0.14

Published

An API library for interacting with the Little Pay API

Downloads

97

Readme

Quickstart

Welcome to the Little Pay API client library documentation. This library allows you to interact with the Little Pay API. It is built to be used in a browser environment. You can access the full documentation here.

Installation

You can install the client library using npm:

npm install @littlepay/little-pay-api

Usage

Initialize the client

To use the client library, you need to import it into your application and initialize it with your clientId, clientSecret and tokenId. You can then use the library to interact with the Little Pay API.

import { LittlePayClient } from "@littlepay/little-pay-api";

const client = new LittlePayClient({
  clientId: "81af9dffa51f6059",
  clientSecret: "f9oNskEf6kiOZk/GZiARPw==",
  tokenId: "9f252db9-dfbd-4af6-be88-24f1635c5de3",
});

Create a payment intent

You can use the client library to create a payment intent. This will return a payment intent object that you can use to process a payment.

const intent = await client.createIntent({
  amount: 1,
  callbackUrl: "https://example.com",
  currency: "KES",
  description: "Test payment",
  expiresAt: 1,
  key: new Date().getTime().toString(), //A unique alphanumeric string that you can use to identify the payment intent
  payload: {
    billingAddress: {
      firstName: "John",
      lastName: "Doe",
      address1: "1 Market St",
      locality: "Nairobi",
      administrativeArea: "Nairobi",
      postalCode: "00100",
      country: "Kenya",
      email: "[email protected]",
      phoneNumber: "254712345678",
    },
  },
  returnUrl: "https://example.com",
});

Process a payment

Option 1: Redirect the user to our hosted checkout page

You can redirect the user to our hosted checkout page to process the payment. You will receive the payment status and details on the callbackUrl you provided when creating the payment intent.

intent.redirectToCheckout();

Option 2: Process the payment using your own checkout page

You can use the payment intent object to process the payment using your own checkout page. You will receive the payment status and details on the callbackUrl you provided when creating the payment intent.

const paymentProcessor = client.createPaymentProcessor(
  {
    type: "CARDS",
    payment: {
      cc_number,
      cc_cvv,
      cc_exp,
      cc_name,
    },
  },
  intent.getReference()
);

await client.validateDetails(intent, paymentProcessor);

const response = await client.processPayment();

Handle the payment response

You can handle the payment response using the callbackUrl you provided when creating the payment intent. The response will contain the payment status and details.

app.post("/callback", (req, res) => {
  const { status, reference, currency, provider, amount, key } = req.body;
  // Handle the payment response
});