Foloosi
Search…
Flutter SDK
A Flutter plugin for making payments via Foloosi Payment Gateway. Fully supports Android and iOS.
">
1
<div style="text-align: center">
2
<table>
3
<tr>
4
<td style="text-align: center">
5
<img src="https://raw.githubusercontent.com/FoloosiTech/foloosi_flutter_payment/master/sample.gif" width="400" />
6
td>
7
tr>
8
table>
9
div>
Copied!

Installation

In the dependencies: section of your pubspec.yaml, add the following line:
1
foloosi_flutter_payment: ^1.0.4
Copied!
Import in your project:
1
import 'package:foloosi_flutter_payment/foloosi_flutter_payment.dart';
Copied!

Basic Usage

[ RaisedButton( onPressed: _proceeedToPayment, child: new Text( "Proceed to Payment", ), ) ], ), ), ); } } ">
1
class MyHomePage extends StatefulWidget {
2
MyHomePage({Key key}) : super(key: key);
3
4
@override
5
_MyHomePageState createState() => _MyHomePageState();
6
}
7
8
class _MyHomePageState extends State<MyHomePage> {
9
bool proceedToPayment = false;
10
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
11
12
void _proceeedToPayment() {
13
setState(() {
14
proceedToPayment = true;
15
});
16
}
17
18
@override
19
Widget build(BuildContext context) {
20
return Scaffold(
21
key: _scaffoldKey,
22
appBar: proceedToPayment
23
? null
24
: AppBar(
25
title: Text('Foloosi Payment Flutter'),
26
),
27
body: proceedToPayment
28
? FoloosiPayment(
29
headerText: 'Foloosi Payment',
30
loaderText: "Processing Request",
31
merchantKey: 'YOUR_FOLOOSI_MERCHANT_KEY',
32
secretKey: 'YOUR_FOLOOSI_SECRET_KEY',
33
transactionAmount: 1,
34
currency: 'AED',
35
customerName: 'Omar Ali',
36
customerEmail: '[email protected]',
37
customerMobile: '+971000000000',
38
customerAddress: 'No 2, Test Street',
39
customerCity: 'Dubai',
40
billingState: 'Dubai',
41
billingPostalCode: '000000', // For UAE, pass postal code as 000000
42
billingCountry: 'ARE', // Three Digit ISO Country Code
43
onError: (value) {
44
print("Payment Error : $value");
45
setState(() {
46
proceedToPayment = false;
47
});
48
_scaffoldKey.currentState.showSnackBar(SnackBar(
49
content: Text(value.toString()),
50
duration: Duration(seconds: 3),
51
));
52
},
53
onSuccess: (transactionDetails) {
54
print("Payment Success : $transactionDetails");
55
print(
56
json.decode(transactionDetails)['data']['transaction_no']);
57
setState(() {
58
proceedToPayment = false;
59
});
60
_scaffoldKey.currentState.showSnackBar(SnackBar(
61
content: Text(
62
json.decode(transactionDetails)['status'].toString()),
63
duration: Duration(seconds: 3),
64
));
65
},
66
)
67
: Center(
68
child: Column(
69
mainAxisAlignment: MainAxisAlignment.center,
70
children: <Widget>[
71
RaisedButton(
72
onPressed: _proceeedToPayment,
73
child: new Text(
74
"Proceed to Payment",
75
),
76
)
77
],
78
),
79
),
80
);
81
}
82
}
Copied!

Sample Dart Program

[ RaisedButton( onPressed: _proceeedToPayment, child: new Text( "Proceed to Payment", ), ) ], ), ), ); } } ">
1
import 'dart:convert';
2
3
import 'package:flutter/material.dart';
4
import 'package:foloosi_flutter_payment/foloosi_flutter_payment.dart';
5
6
void main() {
7
runApp(MyApp());
8
}
9
10
class MyApp extends StatelessWidget {
11
@override
12
Widget build(BuildContext context) {
13
return MaterialApp(
14
title: 'Foloosi Payment Flutter',
15
debugShowCheckedModeBanner: false,
16
theme: ThemeData(
17
primarySwatch: Colors.blue,
18
visualDensity: VisualDensity.adaptivePlatformDensity,
19
),
20
home: MyHomePage(),
21
);
22
}
23
}
24
25
class MyHomePage extends StatefulWidget {
26
MyHomePage({Key key}) : super(key: key);
27
28
@override
29
_MyHomePageState createState() => _MyHomePageState();
30
}
31
32
class _MyHomePageState extends State<MyHomePage> {
33
bool proceedToPayment = false;
34
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
35
36
void _proceeedToPayment() {
37
setState(() {
38
proceedToPayment = true;
39
});
40
}
41
42
@override
43
Widget build(BuildContext context) {
44
return Scaffold(
45
key: _scaffoldKey,
46
appBar: proceedToPayment
47
? null
48
: AppBar(
49
title: Text('Foloosi Payment Flutter'),
50
),
51
body: proceedToPayment
52
? FoloosiPayment(
53
headerText: 'Foloosi Payment',
54
loaderText: "Processing Request",
55
merchantKey: 'YOUR_FOLOOSI_MERCHANT_KEY',
56
secretKey: 'YOUR_FOLOOSI_SECRET_KEY',
57
transactionAmount: 1,
58
currency: 'AED',
59
customerName: 'Omar Ali',
60
customerEmail: '[email protected]',
61
customerMobile: '+971000000000',
62
customerAddress: 'No 2, Test Street',
63
customerCity: 'Dubai',
64
billingState: 'Dubai',
65
billingPostalCode: '000000', // For UAE, pass postal code as 000000
66
billingCountry: 'ARE', // Three Digit ISO Country Code
67
onError: (value) {
68
print("Payment Error : $value");
69
setState(() {
70
proceedToPayment = false;
71
});
72
_scaffoldKey.currentState.showSnackBar(SnackBar(
73
content: Text(value.toString()),
74
duration: Duration(seconds: 3),
75
));
76
},
77
onSuccess: (transactionDetails) {
78
print("Payment Success : $transactionDetails");
79
print(
80
json.decode(transactionDetails)['data']['transaction_no']);
81
setState(() {
82
proceedToPayment = false;
83
});
84
_scaffoldKey.currentState.showSnackBar(SnackBar(
85
content: Text(
86
json.decode(transactionDetails)['status'].toString()),
87
duration: Duration(seconds: 3),
88
));
89
},
90
)
91
: Center(
92
child: Column(
93
mainAxisAlignment: MainAxisAlignment.center,
94
children: <Widget>[
95
RaisedButton(
96
onPressed: _proceeedToPayment,
97
child: new Text(
98
"Proceed to Payment",
99
),
100
)
101
],
102
),
103
),
104
);
105
}
106
}
Copied!
Note: If you're using the foloosi secret and merchant keys as a string in flutter, remember to escape the $ dollar signs although it is recommended to load these from your backend
1
merchantKey: 'YOUR_MERCHANT_KEY',
2
secretKey: 'YOUR_SECRET_KEY',
Copied!

Properties

Here is a list of properties available:
Name
Type
Required
Description
headerText
String
false
the title of the widget's appbar
onError
Function
true
function to run on payment error
onSuccess
Function
true
function to run on payment success
loaderText
String
false
text to display under the loader
merchantKey
String
true
your foloosi merchant key
secretKey
String
true
your foloosi secret key
referenceToken
String
false
the reference token - generates automatically if null
redirectUrl
String
false
the redirect url
transactionAmount
String
-
transaction amount - required if referenceToken is null
currency
String
-
transaction currency - required if referenceToken is null
customerName
String
false
customer name - auto render in payment popup if passed
customerEmail
String
false
customer email - auto render in payment popup if passed
customerMobile
String
false
customer mobile - auto render in payment popup if passed
customerAddress
String
false
customer address - auto render in payment popup if passed
customerCity
String
false
customer city - auto render in payment popup if passed
billingState
String
false
Billing State - auto render in payment popup if passed
billingPostalCode
String
false
Billing Postcode - auto render in payment popup if passed
billingCountry
String
false
Billing Country - auto render in payment popup if passed
paymentCancellationMsg
String
false
message returned when user cancels the payment
debugMode
bool
false
to enable or disable package logs

Developed by

Foloosi

License

Copyrights (c) 2021 Foloosi
Last modified 10mo ago