open_payment 3.0.0 open_payment: ^3.0.0 copied to clipboard
Flutter plugin which lets you seamlessly integrate OPEN Payment Gateway with your Flutter app and start collecting payments from your customers.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:open_payment/open_payment.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String accessToken = "c59bc560-c7ac-11eb-8009-bb514bcfec2b";
String paymentToken = "pt_35672B414C88e2B";
PaymentEnvironment environment = PaymentEnvironment.live;
String? result;
Future<void> onPaymentClick() async {
OpenPaymentPayload openPaymentPayload = OpenPaymentPayload(
accessToken: accessToken,
paymentToken: paymentToken,
environment: environment,
// logoUrl: "your-logo-url",
mainColor: "#83025c",
errorColor: "#ff0000");
await OpenPayment.initiatePayment(
openPaymentPayload: openPaymentPayload,
onTransactionComplete: (TransactionDetails transactionDetails) {
setState(() {
result = transactionDetails.status;
});
},
onError: (String error) {
setState(() {
result = error;
});
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Open Payment Demo'),
),
body: Text(result.toString()),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.add),
onPressed: onPaymentClick,
),
),
);
}
}