bundle_rave_pay 0.5.7

Flutter Android iOS

Bundle App Rave plugin

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:math';

import 'package:flutter/services.dart';
import 'package:bundle_rave_pay/bundle_rave_pay.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  var result;

  @override
  void initState() {
    super.initState();
    // initPlatformState();
  }

  String _randomString(int length) {
    var rand = new Random();
    var codeUnits = new List.generate(
        length,
            (index){
          return rand.nextInt(33)+89;
        }
    );

    return new String.fromCharCodes(codeUnits);
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      var cardBody = {
        "amount": "250",
        "cvv": "564",
        "cardExpiry": "09/22",
        "cardNumber": "5531886652142950",
        "saveCard": "true",
        "country": "NG",
        "currencyCode": "NGN",
        "email": "hashilekky@gmail.com",
        "firstName": "Oluwaleke",
        "lastName": "Fakorede",
        "transactionReference": _randomString(12),
        "isLive": "false",
        // Update keys before running app
        "publicKey": "FLWPUBK_TEST-85cf4d8da93192c75d63ca7978592de2-X",
        "encryptionKey": "FLWSECK_TEST24303b8618e7",
        "narration": "Bundle Wallet Technology Ltd",
        "paymentMethod": "card",
      };
      result = await BundleRavePay.initializePayment(cardBody);
      if (result != null && result['status'] == 'success') {
        print("PAYMENT RESPONSE JSON IS SUCCESSFUL");
        print(result);

      } else {
        print("NOT JSON");
        print(result);
      }
    } on PlatformException {
      print('Failed to get platform version.');
    }

    if (!mounted) return;

    setState(() {
      // _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: FlatButton(
              child: Text('Running on:'),
              onPressed: () => initPlatformState(),
            )
        ),
      ),
    );
  }
}
0
likes
80
pub points
59%
popularity

Bundle App Rave plugin

Homepage

Documentation

API reference

Uploaders

hashilekky@gmail.com
johnsonejezie@gmail.com

License

BSD (LICENSE)

Dependencies

flutter

More

Packages that depend on bundle_rave_pay