⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 receive.aspx.cs

📁 如果不使用IIS,请先运行 XSP.exe,待提示已侦听 8080端口后
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Reflection;
using DNNLite.DesktopModules.OnlinePay;
using Ader.TemplateEngine;

public partial class Receive : System.Web.UI.Page
{
    protected string v_oid;		// 订单号
    protected string v_pstatus;	// 支付状态码
    //20(支付成功,对使用实时银行卡进行扣款的订单);
    //30(支付失败,对使用实时银行卡进行扣款的订单);

    protected string v_pstring;	//支付状态描述
    protected string v_pmode;	//支付银行
    protected string v_amount;	//支付金额
    protected string v_moneytype;	//币种		
    protected string remark1;	// 备注1
    protected string remark2;	// 备注1
    protected string v_md5str;
    protected string status_msg;

    protected void Page_Load(object sender, EventArgs e)
    {


        Configuration cfg = ConfigurationManager.OpenExeConfiguration(Server.MapPath("~/web.config"));

        // MD5密钥要跟订单提交页相同,如Send.asp里的 key = "test" ,修改""号内 test 为您的密钥
        string key = cfg.AppSettings.Settings["chinabankmd5"].Value; //"test";	// 如果您还没有设置MD5密钥请登陆我们为您提供商户后台,地址:https://merchant3.chinabank.com.cn/
        // 登陆后在上面的导航栏里可能找到“B2C”,在二级导航栏里有“MD5密钥设置”
        // 建议您设置一个16位以上的密钥或更高,密钥最多64位,但设置16位已经足够了

        v_oid = Request["v_oid"];
        v_pstatus = Request["v_pstatus"];
        v_pstring = Request["v_pstring"];
        v_pmode = Request["v_pmode"];
        v_md5str = Request["v_md5str"];
        v_amount = Request["v_amount"];
        v_moneytype = Request["v_moneytype"];
        remark1 = Request["remark1"];
        remark2 = Request["remark2"];

        string str = v_oid + v_pstatus + v_amount + v_moneytype + key;

        str = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "md5").ToUpper();

        if (str == v_md5str)
        {

            if (v_pstatus.Equals("20"))
            {
                //支付成功
                //在这里商户可以写上自己的业务逻辑
                try
                {
                    ReceiveMoney.ProcessMoney(v_oid, decimal.Parse(v_amount), v_pstatus, "网银");
                    // 完全成功

                    TemplateManager tpl = TemplateManager.FromFile(
                        Server.MapPath("~/Templets/OnlinePay/支付完全成功.htm")
                        );
                    tpl.SetValue("orderid", v_oid);
                    tpl.SetValue("money", v_amount);

                    Response.Write(tpl.Process());
                    //Response.End();

                    //return;
                }
                catch (Exception ex)
                {
                    //付款成功,但是网站处理出错

                    TemplateManager tpl = TemplateManager.FromFile(
                        Server.MapPath("~/Templets/OnlinePay/支付成功处理失败.htm")
                        );
                    tpl.SetValue("orderid", v_oid);
                    tpl.SetValue("money", v_amount);
                    tpl.SetValue("msg", ex.Message);

                    Response.Write(tpl.Process());
                    //Response.End();

                }

            }
        }
        else
        {
            //付款不成功
            //Response.Write("校验失败,数据可疑");
            TemplateManager tpl = TemplateManager.FromFile(
                        Server.MapPath("~/Templets/OnlinePay/支付不成功.htm")
                        );
            tpl.SetValue("orderid", v_oid);
            tpl.SetValue("money", v_amount);
            tpl.SetValue("msg", "校验失败,数据可疑");

            Response.Write(tpl.Process());
            //Response.End();



        }

        Response.End();

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -