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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-native-cashonrails

v0.1.3

Published

A react native library for seamless payment integration with Cashonrails.

Downloads

7

Readme

Cashonrails

Cashonrails is a lightweight React Native library that provides easy-to-integrate components and hooks for embedding a secure and customizable checkout or access code process into your application.


🚀 Installation

Use npm or yarn to add Cashonrails to your project:

npm install react-native-cashonrails
# or
yarn add react-native-cashonrails

🧩 Basic Usage

1. Wrap Your App with CashonrailsProvider

To enable context-based features (e.g., modals, configuration sharing), you must wrap your app with CashonrailsProvider.

import React from 'react';
import { CashonrailsProvider } from 'react-native-cashonrails';

const App = () => (
  <CashonrailsProvider>
    {/* Your components go here */}
  </CashonrailsProvider>
);

export default App;

2. Checkout Using CheckoutButton

The CheckoutButton component renders a styled button that opens the secure checkout modal when clicked.

import React from 'react';
import { CheckoutButton } from 'react-native-cashonrails';

const App = () => {
  const config = {
    api_key: 'your-api-key',
    amount: 1000,
    currency: 'USD',
    customer: {
      email: '[email protected]',
      first_name: 'John',
      last_name: 'Doe',
      phone: '1234567890',
    },
    onComplete: (data) => console.log('Payment complete:', data),
    onCancel: (data) => console.log('Payment cancelled:', data),
  };

  return <CheckoutButton config={config} />;
};

export default App;

3. Trigger Checkout Directly with Checkout

The Checkout component opens the modal automatically when rendered.

import React from 'react';
import { Checkout } from 'react-native-cashonrails';

const App = () => {
  const config = {
    api_key: 'your-api-key',
    amount: 1000,
    currency: 'USD',
    customer: {
      email: '[email protected]',
      first_name: 'John',
      last_name: 'Doe',
      phone: '1234567890',
    },
    onComplete: (data) => console.log('Payment complete:', data),
    onCancel: (data) => console.log('Payment cancelled:', data),
  };

  return <Checkout config={config} />;
};

export default App;

4. Use Access Code Flow via UseAccessCode

This component renders a modal-based WebView for handling access code-based flows.

import React from 'react';
import { UseAccessCode } from 'react-native-cashonrails';

const App = () => {
  const config = {
    access_code: 'your-access-code',
    onComplete: (data) => console.log('Access code success:', data),
    onCancel: (data) => console.log('Access code cancelled:', data),
  };

  return <UseAccessCode config={config} />;
};

export default App;

📘 API Reference

CheckoutButton

| Prop | Type | Default | Description | |---------------|-------------------|------------------------------------------|------------------------------------------| | config | CheckoutConfig | Required | Checkout configuration object | | buttonText | string | 'Checkout Securely' | Button label | | style | React.CSSProperties | undefined | Custom style for the button container | | textStyle | React.CSSProperties | undefined | Custom style for the button text | | disabled | boolean | false | Disables the button | | loadingText | string | 'Processing...' | Text displayed when loading | | showHeader | boolean | true | Display header text above button | | headerText | string | 'Secure payment powered by Cashonrails'| Header text | | headerStyle | React.CSSProperties | undefined | Custom style for the header |


Checkout

| Prop | Type | Default | Description | |------------|------------------|-------------|----------------------------------------| | config | CheckoutConfig | Required| Triggers checkout modal on render |


UseAccessCode

| Prop | Type | Default | Description | |------------|-----------------------|-------------|----------------------------------------| | config | UseAccessCodeConfig | Required| Triggers access code modal on render |


📦 Types

CheckoutConfig

type CheckoutConfig = {
  api_key: string;
  amount: number;
  currency: string;
  customer: {
    email: string;
    first_name: string;
    last_name: string;
    phone: string;
  };
  callback_url?: string;
  onComplete?: (data: Response) => void;
  onCancel?: (data: Response) => void;
  debug?: boolean;
};

UseAccessCodeConfig

type UseAccessCodeConfig = {
  access_code: string;
  callback_url?: string;
  onComplete?: (data: Response) => void;
  onCancel?: (data: Response) => void;
  debug?: boolean;
};

Response

type Response = {
  status: string;
  reference: string;
  transaction_date?: string;
  [key: string]: any;
};

CashonrailsContextType

type CashonrailsContextType = {
  openCheckout: (config: CheckoutConfig) => void;
  openAccessCode: (config: UseAccessCodeConfig) => void;
  subscribeToModalClose: (callback: () => void) => () => void;
  isDebug: boolean;
  setIsDebug: (value: boolean) => void;
};

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.