Novac Payment Plugin

Official Flutter plugin for Novac Payment Gateway. Accept payments seamlessly in your Flutter apps with support for cards, bank transfers, and mobile money.

pub package License: MIT

Features

  • 💳 Accept card payments (Visa, Mastercard, Verve)
  • 🏦 Bank transfer payments
  • 📱 Mobile money support
  • 🎨 Customizable checkout UI
  • ✅ Payment verification
  • 🔒 Secure and PCI-DSS compliant

Installation

Add this to your pubspec.yaml:

dependencies:
  novac_payment_plugin: ^1.0.0

Then run:

flutter pub get

Platform Setup

iOS

Add the following to your ios/Runner/Info.plist to enable deep linking:

<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>yourappscheme</string>
    </array>
  </dict>
</array>

Minimum iOS version: 12.0

Android

Add the following to your android/app/src/main/AndroidManifest.xml:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="yourappscheme" />
</intent-filter>

Minimum SDK version: 21

Usage

1. Initialize the SDK

Initialize the plugin with your API key from the Novac Dashboard:

import 'package:novac_payment_plugin/novac_payment_plugin.dart';

await NovacPaymentPlugin.initialize(
  apiKey: 'your_api_key',
  primaryColor: '#007AFF',      // Optional: Customize theme
  backgroundColor: '#FFFFFF',   // Optional
  buttonTextColor: '#FFFFFF',   // Optional
);

2. Launch Checkout

Start a payment flow:

final result = await NovacPaymentPlugin.launchCheckout(
  amount: 5000,                 // Amount in smallest currency unit
  currency: 'NGN',
  redirectUrl: 'https://yourapp.com/payment-complete',
  customerData: CustomerData(
    email: '[email protected]',
    firstName: 'John',
    lastName: 'Doe',            // Optional
    phoneNumber: '+2348012345678', // Optional
  ),
  customizationData: CustomizationData(
    logoUrl: 'https://yourcompany.com/logo.png',
    paymentDescription: 'Payment for Order #12345',
    checkoutModalTitle: 'Complete Payment',
  ),
  transactionReference: 'unique-reference-123', // Optional: Auto-generated if not provided
);

// Handle the result
if (result.isSuccess) {
  print('Payment successful! Transaction ID: ${result.transactionId}');
} else if (result.isCancelled) {
  print('Payment cancelled by user');
} else {
  print('Payment failed: ${result.errorMessage}');
}

3. Verify Payment

Verify a payment status:

final verification = await NovacPaymentPlugin.verifyPayment('transaction-reference');

print('Status: ${verification.status}');
print('Amount: ${verification.amount}');
print('Currency: ${verification.currency}');

API Reference

NovacPaymentPlugin

Method Description
initialize() Initialize the SDK with your API key
launchCheckout() Launch the payment checkout flow
verifyPayment() Verify a payment transaction

CustomerData

Property Type Required Description
email String Yes Customer's email address
firstName String Yes Customer's first name
lastName String No Customer's last name
phoneNumber String No Customer's phone number

CustomizationData

Property Type Description
logoUrl String URL to your company logo
paymentDescription String Description shown on checkout
checkoutModalTitle String Title of the checkout modal

PaymentResult

Property Type Description
isSuccess bool Whether payment was successful
isCancelled bool Whether user cancelled the payment
transactionId String? Transaction ID if successful
transactionReference String? Transaction reference
errorMessage String? Error message if failed
errorCode String? Error code if failed

VerificationResult

Property Type Description
status String Payment status (success, pending, failed)
transactionReference String? Transaction reference
amount double? Transaction amount
currency String? Transaction currency
errorMessage String? Error message if verification failed

Testing

Use test API keys from your Novac dashboard for development:

// Use test key for development
await NovacPaymentPlugin.initialize(
  apiKey: 'nc_test_xxxxxxxxxxxx',
);

Test card numbers:

  • Success: 5555 5555 5555 4444
  • Failed: 1234 5678 9876 5432

OTP for testing

  • 123456

Error Handling

try {
  final result = await NovacPaymentPlugin.launchCheckout(...);
  
  if (result.isSuccess) {
    // Handle success
  } else if (result.isCancelled) {
    // Handle cancellation
  } else {
    // Handle failure
    print('Error: ${result.errorCode} - ${result.errorMessage}');
  }
} catch (e) {
  // Handle unexpected errors
  print('Unexpected error: $e');
}

Support

License

MIT License - see LICENSE for details.