techprocess 0.0.1
techprocess: ^0.0.1 copied to clipboard
tech process payment gateway
example/lib/main.dart
import 'dart:async';
import 'dart:math';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:techprocess/techprocess.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 _platformVersion = 'Unknown';
String result = "";
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try {
platformVersion =
await Techprocess.platformVersion ?? 'Unknown platform version';
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_platformVersion = platformVersion;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
// child: Text('Running on: $_platformVersion\n'),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Running on: $_platformVersion\n'),
ElevatedButton(
child: const Text("Call TechProcess"),
onPressed: () => _startTransaction(),
),
Text(result),
],
)),
),
);
}
Future<void> _startTransaction() async {
dynamic techMerchantCode = "L95280";
dynamic transactionNo = Random.secure().nextInt(1 << 32).toString();
dynamic techTransactionReference = "ORD0001";
dynamic techTransactionType = "Sale";
dynamic techTransactionSubType = "Debit";
dynamic techCurrency = "INR";
dynamic amount = "1";
dynamic emailId = "panneer060@gmail.com";
dynamic mobileNo = "9994937001";
dynamic schemaCode = "Shri";
dynamic publicKey = "1234-6666-6789-56";
dynamic mode = "DC";
var sendMap = <String, dynamic>{
"techMerchantCode": techMerchantCode,
"transactionNo": transactionNo,
"techTransactionReference": techTransactionReference,
"techTransactionType": techTransactionType,
"techTransactionSubType": techTransactionSubType,
"techCurrency": techCurrency,
"amount": amount,
"emailId": emailId,
"mobileNo": mobileNo,
"schemaCode": schemaCode,
"publicKey": publicKey,
"mode": mode
};
debugPrint(sendMap.toString());
try {
var response = Techprocess.startTransaction(
techMerchantCode,
transactionNo,
techTransactionReference,
techTransactionType,
techTransactionSubType,
techCurrency,
amount,
emailId,
mobileNo,
schemaCode,
publicKey,
mode);
response.then((value) {
debugPrint(value.toString());
setState(() {
result = value.toString();
});
}).catchError((onError) {
if (onError is PlatformException) {
setState(() {
result = onError.message.toString() +
" \n " +
onError.details.toString();
});
} else {
setState(() {
result = onError.toString();
});
}
});
} catch (err) {
result = err.toString();
}
}
}