基础库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

49 lines
1.4 KiB

  1. import 'dart:async';
  2. import 'package:zhiying_comm/zhiying_comm.dart';
  3. import 'package:fluwx/fluwx.dart' as fluwx;
  4. ////微信支付简单封装
  5. class WxPayUtil {
  6. static StreamSubscription subscription;
  7. ////调用此方法
  8. static toPay(Map<String, dynamic> params,Function (bool) callback) async {
  9. subscription = fluwx.weChatResponseEventHandler.listen((res) {
  10. if (res is fluwx.WeChatPaymentResponse) {
  11. subscription.cancel();
  12. callback(res.isSuccessful);
  13. }
  14. });
  15. print(params);
  16. await payWithWeChat(
  17. appId: params['appid'].toString(),
  18. partnerId: params['partnerid'].toString(),
  19. prepayId: params['prepayid'].toString(),
  20. packageValue: params['package'].toString(),
  21. nonceStr: params['noncestr'].toString(),
  22. timeStamp: int.tryParse(params['timestamp']),
  23. sign: params['sign'],
  24. );
  25. // var payInfo = SyPayInfo();
  26. // payInfo.appid = params['appid'];
  27. // payInfo.noncestr = params['noncestr'];
  28. // payInfo.package = params['package'];
  29. // payInfo.partnerid = params['partnerid'];
  30. // payInfo.sign = params['sign'];
  31. // payInfo.timestamp = params['timestamp'];
  32. // payInfo.prepayid = params['prepayid'];
  33. // print("发起微信支付");
  34. // SyPayResult result = await SyFlutterWechat.pay(payInfo);
  35. //
  36. // if (result == SyPayResult.success) {
  37. // return true;
  38. // } else {
  39. // return false;
  40. // }
  41. }
  42. }