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

@sunnypay/react-native

v1.0.0

Published

Official React Native SDK for Sunny Payments - Accept Mobile payments, cards, crypto, BNPL and more

Readme

Installation

npm install @sunnypayments/react-native
# or
yarn add @sunnypayments/react-native

Requirements

  • React Native 0.64.0 or higher
  • React 17.0.0 or higher

Quick Start

Option 1: Direct Usage

import { SunnyClient } from '@sunnypayments/react-native';

const sunny = new SunnyClient('sk_live_your_api_key');

// M-Pesa STK Push
const result = await sunny.mobileMoney.mpesaSTKPush({
  phoneNumber: '254712345678',
  amount: 1000,
  accountReference: 'ORDER-001',
});

console.log(result.checkout_request_id);

Option 2: Using React Hooks (Recommended)

import { SunnyProvider, useSunny } from '@sunnypayments/react-native';

// App.tsx - Wrap your app
function App() {
  return (
    <SunnyProvider apiKey="sk_live_xxx">
      <PaymentScreen />
    </SunnyProvider>
  );
}

// PaymentScreen.tsx - Use the hook
function PaymentScreen() {
  const sunny = useSunny();
  
  const handlePayment = async () => {
    const result = await sunny.mobileMoney.mpesaSTKPush({
      phoneNumber: '254712345678',
      amount: 1000,
      accountReference: 'ORDER-001',
    });
    console.log(result);
  };
  
  return <Button title="Pay with M-Pesa" onPress={handlePayment} />;
}

Features

All 12 Sunny Payments resources are supported:

| Resource | Description | |----------|-------------| | payments | Create, capture, refund payments | | customers | Manage customer profiles | | refunds | Process refunds | | webhooks | Register endpoints | | bills | Airtime, data, electricity payments | | crypto | BTC, ETH, USDT, USDC payments | | mobileMoney | M-Pesa, MTN MoMo, Airtel Money | | invoices | Create and manage invoices | | qrCodes | Static and dynamic QR payments | | virtualAccounts | Virtual bank account numbers | | bnpl | Buy Now Pay Later | | ussd | USSD application management |

Usage Examples

Purchase Airtime

const tx = await sunny.bills.purchaseAirtime({
  phoneNumber: '+254712345678',
  amount: 100,
  network: 'safaricom',
});

Accept Crypto Payments

// Get rates
const rates = await sunny.crypto.getRates();
console.log(`BTC: $${rates.BTC}`);

// Create payment address
const address = await sunny.crypto.createAddress('BTC', 10000);
console.log(`Send ${address.amount_crypto} BTC to: ${address.address}`);

BNPL (Buy Now Pay Later)

// Check eligibility
const eligibility = await sunny.bnpl.checkEligibility('cus_123', 50000);

if (eligibility.eligible) {
  const plan = await sunny.bnpl.create({
    customer: 'cus_123',
    amount: 30000,
    installments: 3,
  });
  console.log(`Monthly payment: ${plan.installment_amount}`);
}

Create Invoice

const invoice = await sunny.invoices.create({
  customer: 'cus_123',
  items: [
    { description: 'Widget', quantity: 2, unit_price: 500, amount: 1000 },
  ],
});
await sunny.invoices.send(invoice.id);

Error Handling

import { 
  AuthenticationError, 
  ValidationError, 
  RateLimitError,
  ApiError,
  NetworkError 
} from '@sunnypayments/react-native';

try {
  const result = await sunny.payments.create(params);
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.log('Invalid API key');
  } else if (error instanceof ValidationError) {
    console.log(`Validation error: ${error.message}`);
  } else if (error instanceof RateLimitError) {
    console.log(`Rate limited, retry after ${error.retryAfter} seconds`);
  } else if (error instanceof ApiError) {
    console.log(`API error [${error.statusCode}]: ${error.message}`);
  } else if (error instanceof NetworkError) {
    console.log('Network error - check connection');
  }
}

TypeScript Support

Full TypeScript support is included. All types are exported:

import type { 
  Payment, 
  Customer,
  STKPushParams,
  STKPushResult,
  // ... all types
} from '@sunnypayments/react-native';

Configuration

const sunny = new SunnyClient('sk_live_xxx', {
  baseUrl: 'https://api.sunnypay.co.ke/v1',
  timeout: 30000,
  maxRetries: 3,
});

React Native Compatibility

| Platform | Status | |----------|--------| | iOS | ✅ Fully supported | | Android | ✅ Fully supported | | Expo | ✅ Fully supported | | Web (react-native-web) | ✅ Fully supported |

Resources

License

MIT License - see LICENSE for details.