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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@astropay/payments-lib

v2.0.16

Published

Official AstroPay payments library for web and mobile.

Readme

AstroPay

AstroPay's official frontend library that allows you to easily embed customizable and secure payment components into your website or e-commerce platform. It supports seamless international transactions, theming, localization, and real-time payment processing — all with minimal setup.

NPM version NPM downloads

🚀 Quick Links

📋 Table of Contents

📦 Installation

Prerequisites

DOM Requirements

Before using the AstroPay Payment components, ensure your HTML document includes container elements where the components will be rendered. For example, to use the basic payment component, you need to have an element with id="payment-container" in your DOM:

<div id="payment-container"></div>

The library will render the payment interface inside this container element.

NPM

npm install @astropay/payments-lib

Yarn

yarn add @astropay/payments-lib

🚀 Basic Usage

Initialize the library with your API token and optional configuration:

import { AstroPayCore, AstroPayFullCheckout } from '@astropay/payments-lib';

// Initialize the library
AstroPayCore.init('app-id', {
  environment: 'production', // or 'sandbox'
  theme: 'light', // or 'dark'
  language: 'en', // or 'es', 'pt'
  currencyMode: 'iso', // or 'symbol'
  tracking: true // or false to disable tracking
});

// Use the payment component in your application
const paymentComponent = new AstroPayFullCheckout({
  amount: 100,
  currency: 'USD',
  country: 'BR',
  onSuccess: () => console.log('Payment successful'),
  onError: () => console.error('Payment failed')
});

// Render the component into a container element
const paymentElement = document.getElementById('payment-container');
paymentComponent.render(paymentElement);

// Later, when you want to clean up
// paymentComponent.destroy();

🧩 Components

AstroPayFullCheckout

The main component for rendering a payment interface.

Props

| Prop | Type | Required | Description | | --------------- | ---------- | -------- | ------------------------------------------------------------ | | amount | number | Yes | The payment amount | | currency | string | Yes | The currency code (e.g., 'USD') | | country | string | Yes | The country code (e.g., 'BR', 'US') | | showTitle | boolean | No | Whether to show the component title (defaults to true) | | showDescription | boolean | No | Whether to show the payment description (defaults to true) | | cardConfig | object | No | Configuration for card module. | | cardConfig.showPaymentSummary | boolean | No | Whether to display the summary of the payment (defaults to true) | | cardConfig.expirationDateFormat | MM/YYYY or MM/YY | No | Mask format for expiration date (defaults to MM/YY) | | onSuccess | () => void | No | Callback function called when payment is successful | | onError | () => void | No | Callback function called when payment fails |

Example

import { AstroPayFullCheckout } from '@astropay/payments-lib';

const fullCheckoutComponent = new AstroPayFullCheckout({
  amount: 100,
  currency: 'USD',
  country: 'US',
  // Optional props
  showTitle: true,
  showDescription: true,
  cardConfig: {
    showPaymentSummary: true,
    expirationDateFormat: 'MM/YY',
  },
  onSuccess: () => {
    console.log('Payment was successful');
    // Handle successful payment, e.g., redirect to success page
  },
  onError: () => {
    console.error('Payment failed');
    // Handle payment failure
  }
});

// Render the component into a container element
const container = document.getElementById('payment-container');
fullCheckoutComponent.render(container);

// Later, when you want to clean up (e.g., on page navigation)
// fullCheckoutComponent.destroy();

AstroPayPayment

A streamlined payment component focused on AstroPay's native payment method.

Props

| Prop | Type | Required | Description | | --------- | ---------- | -------- | --------------------------------------------------- | | amount | number | Yes | The payment amount | | currency | string | Yes | The currency code (e.g., 'USD') | | country | string | Yes | The country code (e.g., 'BR', 'US') | | onSuccess | () => void | No | Callback function called when payment is successful | | onError | () => void | No | Callback function called when payment fails |

Example

import { AstroPayPayment } from '@astropay/payments-lib';

const paymentComponent = new AstroPayPayment({
  amount: 100,
  currency: 'USD',
  country: 'BR',
  onSuccess: () => {
    console.log('Payment was successful');
    // Handle successful payment, e.g., redirect to success page
  },
  onError: () => {
    console.error('Payment failed');
    // Handle payment failure
  }
});

// Render the component into a container element
const container = document.getElementById('payment-container');
paymentComponent.render(container);

// Later, when you want to clean up (e.g., on page navigation)
// paymentComponent.destroy();

🎨 Styling & Theming

The library supports customizable theming through the initialization configuration.

Available Themes

The library comes with two built-in themes:

  • light (default)
  • dark

You can specify the theme during initialization:

AstroPayCore.init('app-id', {
  theme: 'dark',
  environment: 'production', // or 'sandbox'
  language: 'en',
  currencyMode: 'iso', // or 'symbol'
});

Custom Styling

You can customize the styling by providing a styles object in the initialization configuration:

AstroPayCore.init('app-id', {
  styles: {
    backgroundColor: '#FFFFFF',
    fontFamily: 'Arial, sans-serif',
    textColor: '#000000',
    primaryColor: '#FF5500',
    textPrimaryColor: '#333333',
    secondaryColor: '#00AAFF',
    textSecondaryColor: '#666666',
    width: 500,
    paddingWrapper: 20,
    borderRadiusWrapper: 8,
  },
});

Available Style Properties

| Property | Type | Description | | ------------------- | ------------- | ---------------------------------- | | backgroundColor | string | Background color | | fontFamily | string | Font family | | textColor | string | Text color | | primaryColor | string | Primary brand color | | textPrimaryColor | string | Primary text color | | secondaryColor | string | Secondary brand color | | textSecondaryColor | string | Secondary text color | | width | string/number | Component width in pixels | | paddingWrapper | string/number | Padding for component wrapper | | borderRadiusWrapper | string/number | Border radius for component wrapper| | ...otherProps | — | For additional styling options, see the full style API docs |

🌐 Internationalization

The library supports multiple languages through the i18next internationalization framework.

Available Languages

  • English (en) - Default
  • Spanish (es)
  • Portuguese (pt)

You can specify the language during initialization:

AstroPayCore.init('app-id', {
  language: 'es',
});