bundle_rave_pay 0.3.1 bundle_rave_pay: ^0.3.1 copied to clipboard
Bundle App Rave plugin
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": "1500",
"cvv": "470",
"cardExpiry": "10/22",
"cardNumber": "5399838383838381",
"saveCard": "true",
"country": "NG",
"currencyCode": "NGN",
"email": "hashilekky@gmail.com",
"firstName": "Oluwaleke",
"lastName": "Fakorede",
"transactionReference": _randomString(12),
"isLive": "false",
"publicKey": "",
"encryptionKey": "",
"secretKey": "",
"narration": "How are you doing?",
"paymentMethod": "card",
};
result = await BundleRavePay.initializePayment(cardBody);
if (result != null && result['status'] == 'success') {
print(result);
} else {
print("NOT JSON");
}
} 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(),
)
),
),
);
}
}