Sunny Payments Flutter SDK

Official Flutter SDK for Sunny Payments. Accept Mobile-money, cards, crypto, and more.

pub package Flutter License: MIT

Installation

dependencies:
  sunny_payments: ^1.0.0

Quick Start

import 'package:sunny_payments/sunny_payments.dart';

final sunny = Sunny(apiKey: 'sk_live_your_api_key');

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

// Check status
final status = await sunny.mobileMoney.mpesaStatus(result['checkoutRequestId']);

Features

Mobile Money (M-Pesa, MTN, Airtel)

// M-Pesa STK Push
await sunny.mobileMoney.mpesaStkPush(phoneNumber: '254...', amount: 1000);

// M-Pesa B2C (payouts)
await sunny.mobileMoney.mpesaB2C(phoneNumber: '254...', amount: 500);

// MTN MoMo
await sunny.mobileMoney.mtnCollect(phoneNumber: '+256...', amount: 5000);

// Airtel Money
await sunny.mobileMoney.airtelCollect(phoneNumber: '254...', amount: 1000);

Card Payments

final payment = await sunny.payments.create(
  amount: 5000,
  currency: 'KES',
  email: 'customer@example.com',
);

Crypto Payments

final address = await sunny.crypto.createAddress(
  cryptocurrency: 'USDT',
  amount: 10000,
);

QR Codes

final qr = await sunny.qrCodes.create(
  type: 'dynamic',
  amount: 500,
);

Bills (Airtime, Data, Electricity)

await sunny.bills.purchaseAirtime(phoneNumber: '254...', amount: 100);
await sunny.bills.purchaseElectricity(meterNumber: '12345', amount: 500);

Invoices

final invoice = await sunny.invoices.create(
  customerEmail: 'customer@example.com',
  amount: 10000,
  currency: 'KES',
);
await sunny.invoices.send(invoice['id']);

Virtual Accounts

final account = await sunny.virtualAccounts.create(
  customerEmail: 'customer@example.com',
);

BNPL (Buy Now Pay Later)

final eligible = await sunny.bnpl.checkEligibility(
  customerId: 'cus_123',
  amount: 50000,
);

Error Handling

try {
  await sunny.mobileMoney.mpesaStkPush(...);
} on SunnyException catch (e) {
  print('Error [${e.code}]: ${e.message}');
}

License

MIT License

Libraries

sunny_payments
Sunny Payments Flutter SDK