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

onramp-native-sdk

v1.0.363

Published

Onramp Native App

Readme

Onramp React Native SDK

A React Native SDK for seamless payment integration using WebView.


📦 How to Install

Run the following command to install the latest version of the SDK package:

npm install onramp-native-sdk

Required Peer Dependencies

Make sure the following libraries are installed in your project before using the SDK, as they are required peer dependencies:

npm install react-native-webview react-native-device-info
# or
yarn add react-native-webview react-native-device-info

Note: These libraries are not bundled with the SDK to prevent version conflicts. Please ensure you install compatible versions in your app.

How to Import

After installing the package, import it where needed:

import PaymentsWebView from 'onramp-native-sdk';

How to Use the SDK to Render the Widget

This is the view container that holds the PaymentsWebView widget:

return (
  <View style={styles.container}>
    <PaymentsWebView
      ref={paymentRef}
      token={token}
      type={projectType}
      appEnv={appEnvironment}
      onClose={handleClose}
      onSuccess={handleSuccess}
      onError={handleError}
    />
  </View>
);

Example Usage (App.tsx)

Implement the following logic and provide the required parameters: token, projectType, and appEnvironment.


import React, { useState, useRef, useEffect } from 'react';
import { View, Alert, AppState, Linking, StyleSheet } from 'react-native';
import PaymentsWebView from 'onramp-native-sdk';

const App = () => {
  const [isVisible, setIsVisible] = useState(false);
  const [token, setToken] = useState('');
  const paymentRef = useRef(null);

  const projectType = 'cli';
  const appEnvironment = 'production';

  // Handle app resume after external redirect (e.g., BankID)
  useEffect(() => {
    const handleAppStateChange = async (state) => {
      if (state === 'active') {
        const url = await Linking.getInitialURL();
        if (url?.includes('ridmpaymentsapp://')) {
          Alert.alert('Returned from BankID', url);
          setIsVisible(false);
        }
      }
    };

    const subscription = AppState.addEventListener('change', handleAppStateChange);
    return () => subscription.remove();
  }, []);

  // Set token (retrieve once from backend and inject into frontend)
  useEffect(() => {
    setToken('abc'); // Replace this with your actual backend-generated token
  }, []);

  // Event handlers
  const handleClose = () => {
    Alert.alert('Closed', 'Payment modal closed');
    setIsVisible(false);
  };

  const handleSuccess = () => {
    Alert.alert('Success');
    setIsVisible(false);
  };

  const handleError = () => {
    Alert.alert('Error');
    setIsVisible(false);
  };

  return (
    <View style={styles.container}>
      <PaymentsWebView
        ref={paymentRef}
        token={token}
        type={projectType}
        appEnv={appEnvironment}
        onClose={handleClose}
        onSuccess={handleSuccess}
        onError={handleError}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

export default App;

Get Token API (Server-to-Server Only)

Important: This API must be called from your backend only. Do NOT integrate this endpoint directly into your frontend.

Endpoint:


POST {{your-url}}/backend/api/sdk/v1/token

Headers:

Content-Type: application/json
api-key: {{apiKey}}

Example Response:

{
  "code": 200,
  "status": true,
  "message": "Success",
  "data": {
    "sua_token": "xyz"
  }
}

How to Run the Application

Getting Started

Ensure you have completed the setup steps above before running the app.

Step 1: Start Metro Server

Metro is the JavaScript bundler for React Native.

# Using npm
npm start

# OR using Yarn
yarn start

Step 2: Run on Android


# Using npm
npx react-native run-android
# OR
npm run android

# Using Yarn
yarn android

Step 2: Run on iOS

For iOS, install CocoaPods dependencies (run only on first setup or when native dependencies change):

bundle install
bundle exec pod install

Then run the app:


# Using npm
npx react-native run-ios
# OR
npm run ios

# Using Yarn
yarn ios

For help with CocoaPods, visit the CocoaPods Getting Started Guide.

Step 3: Modify Your App

Make changes in App.tsx. Your app will auto-refresh on save.

✅ Congratulations! 🎉 You've successfully integrated and run the Onramp React Native SDK! Happy coding! 🚀