|
@@ -1,22 +1,33 @@ |
|
|
|
|
|
import 'dart:async'; |
|
|
|
|
|
|
|
|
import 'package:zhiying_comm/zhiying_comm.dart'; |
|
|
import 'package:zhiying_comm/zhiying_comm.dart'; |
|
|
|
|
|
import 'package:fluwx/fluwx.dart' as fluwx; |
|
|
|
|
|
|
|
|
////微信支付简单封装 |
|
|
////微信支付简单封装 |
|
|
class WxPayUtil { |
|
|
class WxPayUtil { |
|
|
|
|
|
static StreamSubscription subscription; |
|
|
|
|
|
|
|
|
////调用此方法 |
|
|
////调用此方法 |
|
|
static Future<bool> toPay(Map<String, dynamic> params) async { |
|
|
|
|
|
|
|
|
static toPay(Map<String, dynamic> params,Function (bool) callback) async { |
|
|
|
|
|
|
|
|
|
|
|
subscription = fluwx.weChatResponseEventHandler.listen((res) { |
|
|
|
|
|
if (res is fluwx.WeChatPaymentResponse) { |
|
|
|
|
|
subscription.cancel(); |
|
|
|
|
|
callback(res.isSuccessful); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
print(params); |
|
|
print(params); |
|
|
var result = await payWithWeChat( |
|
|
|
|
|
|
|
|
await payWithWeChat( |
|
|
appId: params['appid'].toString(), |
|
|
appId: params['appid'].toString(), |
|
|
partnerId: params['partnerid'].toString(), |
|
|
partnerId: params['partnerid'].toString(), |
|
|
prepayId: params['prepayid'].toString(), |
|
|
prepayId: params['prepayid'].toString(), |
|
|
packageValue: params['package'].toString(), |
|
|
packageValue: params['package'].toString(), |
|
|
nonceStr: params['noncestr'].toString(), |
|
|
nonceStr: params['noncestr'].toString(), |
|
|
timeStamp:int.tryParse(params['timestamp']), |
|
|
|
|
|
|
|
|
timeStamp: int.tryParse(params['timestamp']), |
|
|
sign: params['sign'], |
|
|
sign: params['sign'], |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
print(result); |
|
|
|
|
|
return result; |
|
|
|
|
|
// var payInfo = SyPayInfo(); |
|
|
// var payInfo = SyPayInfo(); |
|
|
// payInfo.appid = params['appid']; |
|
|
// payInfo.appid = params['appid']; |
|
|
// payInfo.noncestr = params['noncestr']; |
|
|
// payInfo.noncestr = params['noncestr']; |
|
|