imepay_merchant_sdk 0.0.1-alpha.1 imepay_merchant_sdk: ^0.0.1-alpha.1 copied to clipboard
A new Flutter package.
import 'dart:async';
import 'dart:convert';
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:imepay_merchant_sdk/constants/app_constants.dart';
import 'package:imepay_merchant_sdk/start_sdk.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
BuildType selectedValue = BuildType.STAGE;
TextEditingController merchantCodeController =
TextEditingController(text: "CHIYA");
TextEditingController merchantNameController =
TextEditingController(text: "Test Merchant");
TextEditingController merchantUrlController = TextEditingController(
text: "https://stg.imepay.com.np:7979/api/sdk/recordTransaction");
TextEditingController amountController = TextEditingController(text: "100");
TextEditingController refIdController =
TextEditingController(text: "JSHJDSHJ8");
TextEditingController moduleController = TextEditingController(text: "Chiya");
TextEditingController userController = TextEditingController(text: "chiya");
TextEditingController customerController =
TextEditingController(text: "Ashok Shrestha");
TextEditingController passwordController =
TextEditingController(text: "pasal");
TextEditingController deliveryUrlController = TextEditingController(
text: "http://172.20.22.11:1717/api/sdk/deliveryService");
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
controller: merchantCodeController,
decoration: const InputDecoration(
border: OutlineInputBorder(), labelText: 'Merchant Code'),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
controller: merchantNameController,
decoration: const InputDecoration(
border: OutlineInputBorder(), labelText: 'Merchant Name'),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
controller: merchantUrlController,
decoration: const InputDecoration(
border: OutlineInputBorder(), labelText: 'Merchant URL'),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
controller: amountController,
decoration: const InputDecoration(
border: OutlineInputBorder(), labelText: 'Amount'),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
controller: refIdController,
decoration: const InputDecoration(
border: OutlineInputBorder(), labelText: 'Reference ID'),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
controller: moduleController,
decoration: const InputDecoration(
border: OutlineInputBorder(), labelText: 'Module Name'),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
controller: userController,
decoration: const InputDecoration(
border: OutlineInputBorder(), labelText: 'Username'),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
controller: customerController,
decoration: const InputDecoration(
border: OutlineInputBorder(), labelText: 'Customer Name'),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
controller: passwordController,
decoration: const InputDecoration(
border: OutlineInputBorder(), labelText: 'Password'),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
controller: deliveryUrlController,
decoration: const InputDecoration(
border: OutlineInputBorder(), labelText: 'Delivery URL'),
),
),
ListTile(
title: const Text('Stage'),
leading: Radio<BuildType>(
value: BuildType.STAGE,
groupValue: selectedValue,
onChanged: (BuildType? value) {
setState(() {
selectedValue = value!;
});
},
),
),
ListTile(
title: const Text('Live'),
leading: Radio<BuildType>(
value: BuildType.LIVE,
groupValue: selectedValue,
onChanged: (BuildType? value) {
setState(() {
selectedValue = value!;
});
},
),
),
InkWell(
onTap: () async {
Random random = new Random();
random.nextInt(15);
var result = await StartSdk.callSdk(context,
merchantCode: merchantCodeController.text,
merchantName: merchantNameController.text,
merchantUrl: merchantUrlController.text,
amount: amountController.text,
refId: refIdController.text,
module: moduleController.text,
user: userController.text,
customerName: customerController.text,
password: passwordController.text,
deliveryUrl: deliveryUrlController.text,
buildType: selectedValue,
logo: "assets/images/logo.png");
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(content: Text(json.encode(result)));
},
);
},
child: Container(
padding: EdgeInsets.all(10),
color: Colors.red.shade800,
child: Text(
'Login',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontFamily: AppFont.Volte,
fontWeight: FontWeight.w700,
package: "imepay_merchant_sdk",
),
),
),
),
SizedBox(
height: 20,
)
],
),
),
),
);
}
}