winform微信支付
时间: 2023-08-26 13:04:36 浏览: 107
WinForm微信支付可以通过生成订单展示二维码的方式实现。你可以使用轮询的方式检查支付结果,直到支付成功为止。在WinForm中,你可以创建一个线程来进行轮询查询,查询订单支付状态。可以参考以下代码实现查询功能:
private void Query()
{
Thread thread = new Thread(LoopQuery);
thread.IsBackground = true;
thread.Start();
}
private void LoopQuery(object msg)
{
int i = 0;
WxPayData Querydata = new WxPayData();
Querydata.SetValue("out_trade_no", textBox_id.Text);
for (i = 0; i < 3; i++)
{
Thread.Sleep(5000); //每隔5s查询一次
WxPayData result = WxPayApi.OrderQuery(Querydata, 6);
var code = result.GetValue("return_code").ToString();
if (code == "SUCCESS")
{
var state = result.GetValue("trade_state").ToString();
if (state == "SUCCESS")
break;
}
}
if (i >= 3)
MessageBox.Show("还未成功付款哦");
else
MessageBox.Show("成功付款");
}
请确保在代码中引用了相关的第三方库和配置文件,并进行适当的配置。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Winfrom实现微信扫码支付功能](https://blog.csdn.net/qq_33182090/article/details/122928665)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [c# WinForm--微信Native支付](https://blog.csdn.net/qq_36834256/article/details/102941795)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文