找传奇、传世资源到传世资源站!

微信当面付(c#源码)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

from clipboardusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using WxPayAPI;using ThoughtWorks.QRCode.Codec;namespace Weixi{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } string out_trade_no = string.Empty; string money = string.Empty; private void sub() { System.Random random = new Random(); int iResult; iResult = random.Next(100000000, 999999999); NativePay nativePay = new NativePay(); out_trade_no = textBox1.Text; money = textBox2.Text; try { //生成扫码支付模式二url string url2 = nativePay.GetPayUrl(iResult.ToString(), out out_trade_no, ((Convert.ToSingle(money) * 100)).ToString("0")); Bitmap bmp = null; QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; qrCodeEncoder.QRCodeScale = 4; //int version = Convert.ToInt16(cboVersion.Text); qrCodeEncoder.QRCodeVersion = 7; qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; bmp = qrCodeEncoder.Encode(url2); pictureBox1.Image = bmp; } catch { MessageBox.Show("出错"); } } private void button1_Click(object sender, EventArgs e) { sub(); } private void button3_Click(object sender, EventArgs e) { textBox1.Text = ""; textBox2.Text = ""; } /// <summary> /// 查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { getWeixiOrder(out_trade_no); } //查询微信是否付款成功 private bool getWeixiOrder(string _out_trade_no) { if (string.IsNullOrEmpty(_out_trade_no)) { MessageBox.Show("微信订单号和商户订单号至少填写一个,微信订单号优先!"); return false; } //调用订单查询接口,如果内部出现异常则在页面上显示异常原因 try { string result = OrderQuery.Run("", out_trade_no);//调用订单查询业务逻辑 // .Text = result; textBox3.Text = result; if (result.Contains("trade_state=SUCCESS")) return true; return false; } catch (WxPayException ex) { MessageBox.Show(ex.ToString()); return false; } catch (Exception ex) { MessageBox.Show(ex.ToString()); return false; } } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复