提交 4c3d3ee8 authored 作者: nelson1110's avatar nelson1110

pay demo

上级 48d8f948
......@@ -41,6 +41,10 @@ android {
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
debug {
signingConfig signingConfigs.debug
}
}
signingConfigs {
......
......@@ -9,7 +9,7 @@ import 'share_music.dart';
import 'share_web_page.dart';
import 'share_image_page.dart';
import 'share_text_image.dart';
import 'pay_page.dart';
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget {
......@@ -37,7 +37,9 @@ class _MyAppState extends State<MyApp> {
"shareMusic": (context) => ShareMusicPage(),
"shareVideo": (context) => ShareVideoPage(),
"sendAuth": (context) => SendAuthPage(),
"shareMiniProgram":(context) => ShareMiniProgramPage()
"shareMiniProgram":(context) => ShareMiniProgramPage(),
"pay":(context)=> PayPage(),
},
home: new Scaffold(
appBar: new AppBar(
......@@ -110,6 +112,14 @@ class ShareSelectorPage extends StatelessWidget {
},
child: const Text("send auth")),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: new OutlineButton(
onPressed: () {
Navigator.of(context).pushNamed("pay");
},
child: const Text("pay")),
),
],
),
);
......
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:fluwx/fluwx.dart';
import 'dart:io' as H;
class PayPage extends StatefulWidget {
@override
_PayPageState createState() => _PayPageState();
}
class _PayPageState extends State<PayPage> {
String _url = "https://wxpay.wxutil.com/pub_v2/app/app_pay.php";
Fluwx _fluwx;
String _result ="无";
@override
void initState() {
super.initState();
_fluwx = new Fluwx();
_fluwx.response.listen((data){
setState(() {
_result = data.toString();
});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("pay"),
),
body: Column(
children: <Widget>[
OutlineButton(onPressed: () async {
var h = H.HttpClient();
h.badCertificateCallback = (cert, String host, int port){
return true;
};
var request =await h.getUrl(Uri.parse(_url));
var response = await request.close();
var data = await response.transform(Utf8Decoder()).join();
Map<String,dynamic> result = json.decode(data);
print(result['appid']);
_fluwx.pay(
WeChatPayModel(
appId: result['appid'].toString(),
partnerId: result['partnerId'].toString(),
prepayId: result['prepayId'].toString(),
packageValue: result['packageValue'].toString(),
nonceStr: result['nonceStr'].toString(),
timeStamp: result['timeStamp'].toString(),
sign: result['sign'].toString(),
),
);
},
child: const Text("pay"),
),
const Text("响应结果;"),
Text(_result)
],
),
);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论