Showing
6 changed files
with
66 additions
and
8 deletions
| @@ -12,14 +12,14 @@ if (flutterRoot == null) { | @@ -12,14 +12,14 @@ if (flutterRoot == null) { | ||
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | -def flutterVersionCode = "392" | 15 | +def flutterVersionCode = "393" |
| 16 | if (flutterVersionCode == null) { | 16 | if (flutterVersionCode == null) { |
| 17 | - flutterVersionCode = '392' | 17 | + flutterVersionCode = '393' |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | -def flutterVersionName = "3.9.2" | 20 | +def flutterVersionName = "3.9.3" |
| 21 | if (flutterVersionName == null) { | 21 | if (flutterVersionName == null) { |
| 22 | - flutterVersionName = '3.9.2' | 22 | + flutterVersionName = '3.9.3' |
| 23 | } | 23 | } |
| 24 | apply plugin: 'com.android.application' | 24 | apply plugin: 'com.android.application' |
| 25 | apply plugin: 'kotlin-android' | 25 | apply plugin: 'kotlin-android' |
| @@ -134,7 +134,7 @@ class HttpUrl { | @@ -134,7 +134,7 @@ class HttpUrl { | ||
| 134 | "?service=App.Customer.GetTableFillUpDate"; // 根据指定日期,返回当前商家包间类型置满情况的日期 | 134 | "?service=App.Customer.GetTableFillUpDate"; // 根据指定日期,返回当前商家包间类型置满情况的日期 |
| 135 | 135 | ||
| 136 | static const String app_pay_sub = | 136 | static const String app_pay_sub = |
| 137 | - "?service=App.Pay.AppPaySub"; // 根据指定日期,返回当前商家包间类型置满情况的日期 | 137 | + "?service=App.Pay.AppPaySub"; // 微信支付 |
| 138 | 138 | ||
| 139 | static const String get_table_class_by_id = | 139 | static const String get_table_class_by_id = |
| 140 | "?service=App.Seller.GetTableClassById"; // 获取包间分类 | 140 | "?service=App.Seller.GetTableClassById"; // 获取包间分类 |
| 1 | +import 'dart:convert'; | ||
| 2 | + | ||
| 1 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
| 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 4 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 3 | import 'package:one_key/models/sms_info.dart'; | 5 | import 'package:one_key/models/sms_info.dart'; |
| @@ -13,6 +15,7 @@ import 'package:one_key/widgets/system_app_bar.dart'; | @@ -13,6 +15,7 @@ import 'package:one_key/widgets/system_app_bar.dart'; | ||
| 13 | import 'package:one_key/widgets/v_empty_view.dart'; | 15 | import 'package:one_key/widgets/v_empty_view.dart'; |
| 14 | import 'package:provider/provider.dart'; | 16 | import 'package:provider/provider.dart'; |
| 15 | import 'package:fluwx/fluwx.dart' as fluwx; | 17 | import 'package:fluwx/fluwx.dart' as fluwx; |
| 18 | +import 'package:crypto/crypto.dart'; | ||
| 16 | 19 | ||
| 17 | class SmsRechargePage extends StatefulWidget { | 20 | class SmsRechargePage extends StatefulWidget { |
| 18 | final SmsInfoData infoData; | 21 | final SmsInfoData infoData; |
| @@ -169,6 +172,26 @@ class _SmsRechargePageState extends State<SmsRechargePage> { | @@ -169,6 +172,26 @@ class _SmsRechargePageState extends State<SmsRechargePage> { | ||
| 169 | context, params); | 172 | context, params); |
| 170 | if (success) { | 173 | if (success) { |
| 171 | print(rechargeModel.sunModel.package.substring(10)); | 174 | print(rechargeModel.sunModel.package.substring(10)); |
| 175 | + Map<String, String> str = { | ||
| 176 | + 'appid': rechargeModel.sunModel.appId, | ||
| 177 | + 'partnerid': '1489405762', | ||
| 178 | + 'prepayid': | ||
| 179 | + rechargeModel.sunModel.package.substring(10), | ||
| 180 | + 'timestamp': rechargeModel.sunModel.timeStamp, | ||
| 181 | + 'noncestr': rechargeModel.sunModel.nonceStr, | ||
| 182 | + 'package': 'Sign=WXPay', | ||
| 183 | + // 'signtype': rechargeModel.sunModel.signType | ||
| 184 | + }; | ||
| 185 | + | ||
| 186 | + // String str = | ||
| 187 | + // '${rechargeModel.sunModel.appId}\n${rechargeModel.sunModel.timeStamp}\n${rechargeModel.sunModel.nonceStr}\n${rechargeModel.sunModel.package.substring(10)}\n'; | ||
| 188 | + String sign = Utils.keySort(str); | ||
| 189 | + | ||
| 190 | + // var content = utf8.encode(signtemp); | ||
| 191 | + // String sign = base64Encode(content); | ||
| 192 | + print(sign); | ||
| 193 | + print(rechargeModel.sunModel.paySign); | ||
| 194 | + | ||
| 172 | //掉起微信支付 | 195 | //掉起微信支付 |
| 173 | fluwx | 196 | fluwx |
| 174 | .payWithWeChat( | 197 | .payWithWeChat( |
| @@ -182,14 +205,18 @@ class _SmsRechargePageState extends State<SmsRechargePage> { | @@ -182,14 +205,18 @@ class _SmsRechargePageState extends State<SmsRechargePage> { | ||
| 182 | nonceStr: rechargeModel.sunModel.nonceStr, | 205 | nonceStr: rechargeModel.sunModel.nonceStr, |
| 183 | timeStamp: int.parse( | 206 | timeStamp: int.parse( |
| 184 | rechargeModel.sunModel.timeStamp), | 207 | rechargeModel.sunModel.timeStamp), |
| 185 | - // sign: rechargeModel.sunModel.paySign, | ||
| 186 | - sign: 'MD5') | 208 | + // sign: sign |
| 209 | + sign: sign, | ||
| 210 | + // signType: rechargeModel.sunModel.signType | ||
| 211 | + // signType: rechargeModel.sunModel.signType) | ||
| 212 | + ) | ||
| 187 | .then((data) { | 213 | .then((data) { |
| 188 | print("---》$data"); | 214 | print("---》$data"); |
| 189 | }).catchError((error) { | 215 | }).catchError((error) { |
| 190 | print(error.toString()); | 216 | print(error.toString()); |
| 191 | }); | 217 | }); |
| 192 | } else { | 218 | } else { |
| 219 | + print('fffff'); | ||
| 193 | //给用户提示错误 | 220 | //给用户提示错误 |
| 194 | } | 221 | } |
| 195 | }, | 222 | }, |
| @@ -23,6 +23,8 @@ import 'package:package_info/package_info.dart'; | @@ -23,6 +23,8 @@ import 'package:package_info/package_info.dart'; | ||
| 23 | import 'package:permission_handler/permission_handler.dart'; | 23 | import 'package:permission_handler/permission_handler.dart'; |
| 24 | import 'package:provider/provider.dart'; | 24 | import 'package:provider/provider.dart'; |
| 25 | import 'package:url_launcher/url_launcher.dart'; | 25 | import 'package:url_launcher/url_launcher.dart'; |
| 26 | +import 'package:crypto/crypto.dart'; | ||
| 27 | +import 'dart:convert'; | ||
| 26 | import 'package:webview_flutter/webview_flutter.dart'; | 28 | import 'package:webview_flutter/webview_flutter.dart'; |
| 27 | 29 | ||
| 28 | import '../app.dart'; | 30 | import '../app.dart'; |
| @@ -30,6 +32,34 @@ import '../app.dart'; | @@ -30,6 +32,34 @@ import '../app.dart'; | ||
| 30 | typedef BookTimeSetCallback = void Function(bool needChange); | 32 | typedef BookTimeSetCallback = void Function(bool needChange); |
| 31 | 33 | ||
| 32 | class Utils { | 34 | class Utils { |
| 35 | + //请求参数按key按ASCII排序key1=value1&key2=value2&...&keyN=valueN | ||
| 36 | + static String keySort(Map<String, String> oldParamsMap) { | ||
| 37 | + List attrKeys = oldParamsMap.keys.toList(); | ||
| 38 | + attrKeys.sort(); //排序 ASCII 字符顺序进行排序 | ||
| 39 | + var str = ''; | ||
| 40 | + for (var i = 0; i < oldParamsMap.length; i++) { | ||
| 41 | + if (i == oldParamsMap.length - 1) { | ||
| 42 | + str += "${attrKeys[i]}=${oldParamsMap[attrKeys[i]]}"; | ||
| 43 | + } else { | ||
| 44 | + str += "${attrKeys[i]}=${oldParamsMap[attrKeys[i]]}&"; | ||
| 45 | + } | ||
| 46 | + } | ||
| 47 | + print(str); | ||
| 48 | + String stringSignTemp = | ||
| 49 | + str + "&key=3F59D13EB7681868B96A50902296BCE6"; //注:key为商户平台设置的密钥key | ||
| 50 | + | ||
| 51 | + var key = utf8.encode('3F59D13EB7681868B96A50902296BCE6'); | ||
| 52 | + var hmacSha256 = Hmac(sha256, key); // HMAC-SHA256 | ||
| 53 | + var bytes = utf8.encode(stringSignTemp); | ||
| 54 | + var digest = hmacSha256.convert(bytes); | ||
| 55 | + | ||
| 56 | + print("HMAC digest as bytes: ${digest.bytes}"); | ||
| 57 | + print("HMAC digest as hex string: $digest"); | ||
| 58 | + | ||
| 59 | + return '$digest'.toUpperCase(); | ||
| 60 | + //注:HMAC-SHA256签名方式,部分语言的hmac方法生成结果二进制结果,需要调对应函数转化为十六进制字符串 | ||
| 61 | + } | ||
| 62 | + | ||
| 33 | // 验证是否为数字 | 63 | // 验证是否为数字 |
| 34 | static bool isNumber(String str) { | 64 | static bool isNumber(String str) { |
| 35 | final reg = RegExp(r'^-?[0-9]+'); | 65 | final reg = RegExp(r'^-?[0-9]+'); |
| @@ -268,7 +268,7 @@ packages: | @@ -268,7 +268,7 @@ packages: | ||
| 268 | source: hosted | 268 | source: hosted |
| 269 | version: "0.3.3+1" | 269 | version: "0.3.3+1" |
| 270 | crypto: | 270 | crypto: |
| 271 | - dependency: transitive | 271 | + dependency: "direct main" |
| 272 | description: | 272 | description: |
| 273 | name: crypto | 273 | name: crypto |
| 274 | url: "https://pub.flutter-io.cn" | 274 | url: "https://pub.flutter-io.cn" |
-
Please register or login to post a comment