connect_ips_flutter 1.0.0+2 connect_ips_flutter: ^1.0.0+2 copied to clipboard
Unofficial plugin for integrating connect ips gateway via flutter
import 'dart:developer';
import 'package:connect_ips_flutter/connect_ips_flutter.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Connect IPS Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.redAccent,
),
useMaterial3: true,
),
home: const MyHomePage(title: 'Connect IPS demo'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({
super.key,
required this.title,
});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
// late ConnectIps connectIps;
// @override
// void initState() {
// super.initState();
// connectIps = ConnectIps(
// config: const CIPSConfig.stag(
// creditorPath: 'private_key.pem', // path of the .pem file
// merchantID: 007, // merchant ID provided by NCHL
// appID: 'MER-550-APP-1', // app ID provided by NCHL
// appName: 'APPNAME', // app name provided by NCHL
// transactionID:
// 'earthier_0015', // unique transaction ID for every transaction
// successUrl:
// 'https://dev.earthier.net/transaction/success', // your success url set for connect IPS after successful transaction
// failureUrl:
// 'https://dev.earthier.net/transaction/failure', // your failure url set by connect IPS afetr failure
// transactionAmount: 1000, // transaction amount in paisa
// ),
// onMessage: (
// connectIPS, {
// description,
// event,
// needsPaymentConfirmation,
// statusCode,
// }) {
// log(
// 'Description: $description, Status Code: $statusCode, Event: $event, NeedsPaymentConfirmation: $needsPaymentConfirmation',
// );
// connectIPS.close(context);
// },
// onPaymentResult: (paymentResult, connectIps) {
// log('result => $paymentResult');
// connectIps.close(context);
// },
// onReturn: ([payment]) {
// log('redirection after payment completion : $payment');
// },
// );
// }
final config = const CIPSConfig.stag(
creditorPath: 'private_key.pem',
merchantID: 007,
appID: 'MER-550-APP-1',
appName: 'APPNAME',
transactionID: 'TXN-007',
successUrl: 'https://example.com/success',
failureUrl: 'https://example.com/transaction/failure',
transactionAmount: 1000,
);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: ConnectIPSPaymentButton(
config: config,
onMessage: (
connectIPS, {
description,
event,
needsPaymentConfirmation,
statusCode,
}) {
log('message: $description, event: $event, statusCode: $statusCode ');
},
onPaymentResult: (paymentResult, connectIps) {
log('payment result => $paymentResult');
},
),
),
);
}
}