flulm_auth 1.0.6 flulm_auth: ^1.0.6 copied to clipboard
The version of the flutter SDK licensed by lemapay is currently only available for the Android system, to be added to the iOS system call.
import 'package:flulm_auth/flulm_auth.dart' as flulmAuth;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
//import 'package:flutter_stetho/flutter_stetho.dart';
void main() => runApp(MaterialApp(
home: MyApp(),
));
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _code = 'Unknown';
String _appId = "1911131949173836111";
bool _isInstalled = false;
@override
void initState() {
super.initState();
// Stetho.initialize();
flulmAuth.register(appId: _appId);
flulmAuth.responseFromAuth.listen((data) {
setState(() {
_code = data.code;
});
});
flulmAuth.responseFromPay.listen((data) {
setState(() {
_code = data.toString();
// print("支付回调======:" +
// data.errStr +
// ",errCode=" +
// data.errCode.toString());
});
});
flulmAuth.isLemaPayInstalled().then((value) => setState(() => _isInstalled = value));
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('授权支付Demo'),
),
body: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
children: [
Row(children: [Text("乐马支付App"), Spacer(), Text(_isInstalled ? "已安装" : "未安装")]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(onPressed: () => sendAuth(context), child: Text("授权")),
ElevatedButton(onPressed: () => sendPay(context), child: Text("支付")),
],
),
Text('callback code= $_code\n'),
],
),
),
);
}
void sendAuth(BuildContext context) async {
print("开始授权=》");
flulmAuth.sendAuth(
mContext: context,
openId: _appId,
supportScan: true,
scope: "login",
isTest: 2,
);
}
void sendPay(BuildContext context) async {
flulmAuth.sendPay(
mContext: context,
openId: _appId,
supportScan: true,
signData:
"{\"uid\":\"84eeb5d23c741ea9cda9f19eae5878f0\",\"rid\":\"ca3e7d7e6c96d4b5c00682f979b6aae9\",\"order_id\":\"2006181540184800879\",\"app_id\":\"1903091622305700195\",\"timestamp\":1592472665,\"nonce_str\":\"sWaYDxjXUInlZbSH\",\"subject\":\"签证办理-1本\",\"sign\":\"D0629DBF67B3FD50714AB973A8247F0C\"}",
isTest: 2,
);
}
}