1. 程式人生 > >微信公眾號支付回撥頁面處理asp.net

微信公眾號支付回撥頁面處理asp.net

1.在商家微信商戶通中配置回撥url
2.在提交訂單時傳入的回撥頁面中獲取支付成功後或支付失敗後的引數,對訂單進行處理
public partial class gzpayCallback : System.Web.UI.Page, IHttpHandler
{
protected void Page_Load(object sender, EventArgs e)
{
//接收維修支付通知頁面
Stream s = Request.InputStream;
byte[] b = new byte[s.Length];
s.Read(b, 0, (int)s.Length);
string result = System.Text.Encoding.UTF8.GetString(b);
if (GetXMLInnerText(result, “return_code”) == “SUCCESS”) {
//這裡沒有驗證簽名
string orderId = GetXMLInnerText(result, “out_trade_no”);
string appid = GetXMLInnerText(result, “appid”);
string bank_type = GetXMLInnerText(result, “bank_type”);
// string cash_fee = GetXMLInnerText(result, “cash_fee”);
string fee_type = GetXMLInnerText(result, “fee_type”);
string mch_id = GetXMLInnerText(result, “mch_id”);
string openid = GetXMLInnerText(result, “openid”);
string total_fee = GetXMLInnerText(result, “total_fee”);
string transaction_id = GetXMLInnerText(result, “transaction_id”);
string time_end = GetXMLInnerText(result, “time_end”);
/// 對獲取到支付成功的訂單進行處理
……
///
//告訴微信收到支付成功果

                    Response.Write("<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>");
                }
                s.Flush();
                s.Close();
                s.Dispose();