// import 'package:fluwx/fluwx.dart' as fluwx; // import 'package:flutter_alipay/flutter_alipay.dart'; // import 'package:stripe_payment/stripe_payment.dart'; class PayService { PayService._(); /// 发起微信支付 Future createWechatPayment({ required String productId, String? source, }) async { return sendPostRequest( '/v1/payment/wechatpay/', (resp) { return WechatPaymentCreatedResponse.fromJson(resp.data); }, formData: { 'product_id': productId, 'source': source, }, ); } void wechatPay() async { bool isInstalled = await fluwx.isWeChatAppInstalled(); if (isInstalled) { fluwx .pay(fluwx.PayInfo( appId: 'your_app_id', partnerId: 'your_partner_id', prepayId: 'your_prepay_id', packageValue: 'Sign=WXPay', nonceStr: 'your_nonce_str', timeStamp: 'your_timestamp', sign: 'your_sign', )) .then((response) { // 处理支付结果 }); } else { // alert('未安装微信'); } } void alipay() async { String orderString = 'your_order_string'; // 从服务器获取 var result = await FlutterAlipay.pay(orderString); } void stripe() async { var token = await StripePayment.paymentRequestWithCardForm( CardFormPaymentRequest()); // 发送 token 到服务器进行支付处理 } }