nravepay 1.1.0 copy "nravepay: ^1.1.0" to clipboard
nravepay: ^1.1.0 copied to clipboard

outdated

Nravepay is a package that makes accepting card payments in a flutter project easier using Flutterwave.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:nravepay/nravepay.dart';

import 'keys.dart';

void main() {
  NRavePayRepository.setup(Setup(
    publicKey: PaymentKeys.publicKey,
    encryptionKey: PaymentKeys.encryptionKey,
    secKey: PaymentKeys.secretKey,
    staging: true,
    version: Version.v3,
    allowSaveCard: true,
  ));
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.purple,
      ),
      home: MyHomePage(title: 'NRavePay Example'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  Future<void> _startPayment() async {
    var initializer = PayInitializer(
        amount: 45,
        email: 'email@email.com',
        txRef: 'TXREF-${DateTime.now().microsecondsSinceEpoch}',
        narration: 'New payment',
        country: 'NG',
        currency: 'NGN',
        firstname: 'Nelson',
        lastname: 'Eze',
        phoneNumber: '09092343432',
        onComplete: (result) {
          if (result.status == HttpStatus.success) {
            if (result.card != null) {
              print(result.card.toMap());
              //  saveCard(card);
            }
          }
          print(result.message);
        });
    return PayManager().prompt(context: context, initializer: initializer);
  }

  List<BankCard> cards = [
    BankCard(
        id: '1234567',
        token: "flw-t1nf-5eab9b1fbfbab5806f676a88ef9630c2-m03k",
        last4digits: "4246",
        expiry: "09/32",
        first6digits: "418742",
        issuer: "Visa",
        type: "VISA"),
    BankCard(
        id: "1622103329220332_2643",
        token: "flw-t1nf-2c09dac5ab2da4c472c75da603da2e42-m03k",
        last4digits: "2643",
        expiry: "09/32",
        country: "UNITED KINGDOM GB",
        first6digits: "455605",
        issuer: "CREDIT",
        type: "VISA")
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'Accept payments in Flutter using Flutterwave',
            ),
            Container(
              margin: const EdgeInsets.all(18.0),
              width: 200,
              child: ElevatedButton(
                child: Text('Pay #450'),
                onPressed: _startPayment,
              ),
            ),
            Container(
              margin: const EdgeInsets.all(18.0),
              width: 200,
              child: ElevatedButton(
                child: Text('Pay With Saved Card #450'),
                onPressed: () {
                  NRavePayRepository.instance
                      .updateCards(cards, "1622103329220332_2643");
                  return _startPayment();
                },
              ),
            ),
          ],
        ),
      ),
    );
  }
}
7
likes
0
pub points
42%
popularity

Publisher

verified publishernelsoneze.com

Nravepay is a package that makes accepting card payments in a flutter project easier using Flutterwave.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

async, cupertino_icons, dio, equatable, flutter, flutter_svg, get_it, intl, tripledes_nullsafety, webview_flutter

More

Packages that depend on nravepay