pay method
void
pay({})
微信支付
partnerId
商户id
prepayId
预支付id(由后端调预支付API返回)
nonceStr
随机串(由后端返回)
timeStamp
时间戳(由后端返回)
sign
签名
successCall
微信成功回调,code:0-支付中;1-支付成功;
failCall
微信失败回调,errorCode:0-发送支付请求失败;1-支付失败;2-请升级微信客户端;3-未安装客户端;4-用户取消;
Implementation
void pay({
required String partnerId,
required String prepayId,
required String nonceStr,
required String timeStamp,
required String sign,
Function(int code, String prePayId)? successCall,
Function(int errorCode, String prePayId)? failCall,
}) {
_successCall = successCall;
_failCall = failCall;
CloudChannelManager.instance.send(_weChatPayMethodName, arguments: {
"appId": _appId,
"universalLink": _universalLink,
"partnerId": partnerId,
"prepayId": prepayId,
"nonceStr": nonceStr,
"timeStamp": timeStamp,
"sign": sign,
}).then((response) {
if (response == "sendSuccess" && successCall != null) {
successCall(0, "");
} else if (response == "sendFail" && failCall != null) {
failCall(0, "");
} else if (response == "notSupported" && failCall != null) {
failCall(2, "");
} else if (response == "notInstalled" && failCall != null) {
failCall(3, "");
}
});
}