pay_unit_sdk 3.1.13 pay_unit_sdk: ^3.1.13 copied to clipboard
Library flutter of the most complete payment aggregator of Cameroon, pay integrate ORANGE, MTN, PAYPAL and EXPRESS UNION in some click in your Flutter application
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:pay_unit_sdk/pay_unit_sdk.dart';
void main() {
runApp(App());
}
class App extends StatelessWidget {
@override
Widget build(BuildContext context) => MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Home(),
),
);
}
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
@override
initState() {
super.initState();
}
// Generate random transaction Id
getRandomId() {
//initialize the Date of the day
var now = DateTime.now();
var rng = Random();
//specify the format of the date
var formatter = DateFormat('yyyyMMddHms');
String formattedDate = "${formatter.format(now)}${rng.nextInt(100000)}";
return formattedDate;
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey,
appBar: AppBar(
elevation: 1,
backgroundColor: Colors.white,
title: const Text(
"Pay unit demo",
style: TextStyle(color: Colors.black),
),
centerTitle: true,
),
body: Center(
child: Padding(
padding: EdgeInsets.only(left: 30, right: 30),
child: PayUnitButton(
isTerminalPayment: false,
hasConnexion: true,
apiUser: "xxxxxxxxxxxxxxxxxxxxxxx",
apiPassword: "xxxxxx-xxxxxxx-xxxxxx-xxxxxx",
apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
transactionId: getRandomId(),
mode: 'live', // test or live
transactionCallBackUrl: "",
notiFyUrl: "",
transactionAmount: "Enter the Amount here",
currency: "XAF",
buttonTextColor: Colors.black,
productName: "Vapor max sniper edition",
color: Colors.white,
actionAfterProccess: (transactionId, transactionStatus) {
print("Transaction id is : $transactionId and transaction status : $transactionStatus");
if (transactionStatus != "FAILED") {
// Do this if the transaction succeeds
} else {
// Do this if the transaction fails
}
},
),
),
));
}
}