A simple way to integrate/implement Payment Gateway in Flutter app — (Paystack).

TechWithSam — Payment Integration with flutter (Paystack).

Let’s get started

A simple way to integrate or implement Payment Gateway in flutter (Paystack).
TechWithSam — Paystack Keys
dependencies:
paystack_manager: ^1.0.4
RaisedButton(
onPressed: _processPayment, // this function will be declear later
child: Text(
"Pay N1,000",
),
),
void _processPayment() {
try {
PaystackPayManager(context: context)
..setSecretKey("{YOUR-SECRET-KEY-HERE}")
// Your company Image
..setCompanyAssetImage(Image(
image: NetworkImage(
"https://res.cloudinary.com/acctgen1/image/upload/v1612393902/TECH2-01_vw1fvg.png"),
))
..setAmount(100000) // you need to add two zeros at the end e.g 100000 = N1,000.00
// you can set your own unique transaction reference, here am using timestamp
..setReference(DateTime.now().millisecondsSinceEpoch.toString())
..setCurrency("NGN") // Set currency, the platform only has three currencies, when registering the
list of countries listed is the currency that is available for you to use
..setEmail("samuelbeebest@gmail.com") // user email address and information
..setFirstName("Samuel")
..setLastName("Adekunle")
..setMetadata(
{
"custom_fields": [
{
"value": "TechWithSam", // set this your company name
"display_name": "Payment_to",
"variable_name": "Payment_to"
}
]
},
)
..onSuccesful(_onPaymentSuccessful)
..onPending(_onPaymentPending)
..onFailed(_onPaymentFailed)
..onCancel(_onCancel)
..initialize();
} catch (error) {
print('Payment Error ==> $error');
}
}
void _onPaymentSuccessful(Transaction transaction) {
print('Transaction succesful');
print(
"Transaction message ==> ${transaction.message}, Ref ${transaction.refrenceNumber}");
}
void _onPaymentPending(Transaction transaction) {
print('Transaction Pending');
print("Transaction Ref ${transaction.refrenceNumber}");
}
void _onPaymentFailed(Transaction transaction) {
print('Transaction Failed');
print("Transaction message ==> ${transaction.message}");
}
void _onCancel(Transaction transaction) {
print('Transaction Cancelled');
}
Payment Integration screenshot — Paystack #techwithsam
Screentshot 2 — Techwithsam
A simple way to integrate or implement Payment Gateway in flutter (Paystack).

Hi, I run the YouTube channel called TechWithSam! I’m passionate about learning and teaching programming majorly Flutter for the moment.