Example: Use C#.NET to teach you how to develop WeChat public account (19) -- use WeChat payment to transfer money to WeChat fans change account

There are many ways for official accounts to pay WeChat users. The most commonly used ones are sending red envelopes and transferring money to change accounts. The previous article explained in detail the process of using red envelopes, from the configuration in the official account to the configuration of WeChat payment. , and then to the specific class implementation.

This article mainly explains the transfer to change. The specific class has been given in the previous article, so only the demo code is given.

1. Demonstration results

 

 

2. Demo source code

Front-end source code:

<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeFile="AccountTest.aspx.cs" Inherits="Jjlm.AccountTest" %>

<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<head id="Head1" runat="server">
    <title>微信支付转账到零钱测试</title>

</head>

<body style="background:#fff;">
<center>
<div style="width:95%;">
 <form id="form1" runat="server">
    </br>
	openid*:<asp:TextBox runat="server" id="tbxOpenid" Width="60%" Visible="true"></asp:TextBox></br></br>
	转账金额*:<asp:TextBox runat="server" id="tbxNum" Width="60%"></asp:TextBox></br></br>
	转账备注*:<asp:TextBox runat="server" id="tbxRemark" Width="60%"></asp:TextBox></br></br>
	商户名称:<asp:TextBox runat="server" id="tbxShanghu" Width="60%"></asp:TextBox></br></br>
	转账描述:<asp:TextBox runat="server" id="tbxZhufu" Width="60%"></asp:TextBox></br></br>
	转账事由:<asp:TextBox runat="server" id="tbxReason" Width="60%"></asp:TextBox></br></br>
	<div style="margin-top: 10px;text-align: center;">
		<asp:Button ID="btnSendCommission" Runat="server" OnClick="Send" width="15%" Text="微信支付转账到零钱"></asp:Button>
	</div>	

	<asp:Label runat="server" id="lbresult" Visible="true"/>

</form>
</div>
</center>

</body>
</html>

Backend source code:

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Data.SqlClient;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Xml;
using System.Text;
using System.Net;
using System.Drawing;
using System.Drawing.Imaging;
using QinMing.Config;
using QinMing.WeixinPayPayment;

namespace Jjlm
{
	public partial class AccountTest : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if (!IsPostBack)
			{

			}
		}

		protected void Send(object sender, EventArgs e)
		{
			Random r = new Random();
			string ran1 = r.Next(1000, 9999).ToString();
			string out_trade_no = QinMingConfig.Weixin_MchId + DateTime.Now.ToString("yyyyMMddHHmmss") + ran1;
			
			QinMingWeixinPayPayment.TransferAccountOne(tbxShanghu.Text, tbxZhufu.Text, tbxOpenid.Text, tbxNum.Text, tbxReason.Text, tbxRemark.Text, out_trade_no);
			lbresult.Text = "微信支付已转账,请注意查收";
		}
	}
}

The demo code is very simple, so I won't explain it.

Guess you like

Origin blog.csdn.net/daobaqin/article/details/125156130