实例:用C#.NET手把手教你做微信公众号开发(19)--使用微信支付转账到微信粉丝零钱账户

公众号给微信用户支付费用的方式有很多种,最常用的是发红包和转账到零钱账户,上一篇文章详细讲解了使用发红包的过程,从公众号内的配置,到微信支付的配置,再到具体的类实现。

本篇主要讲解转账到零钱,具体的类在上篇文章已经给出了,所以只给出演示代码。

一、演示结果

 

二、演示源码

前端源码:

<%@ 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>

后端源码:

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 = "微信支付已转账,请注意查收";
		}
	}
}

演示代码很简单,所以不做讲解啦。

猜你喜欢

转载自blog.csdn.net/daobaqin/article/details/125156130