财付通信用卡 外卡支付

财付通提示工商信用卡还款成功:服务一线:0571-28066155
二线:0571-28896159

1.请求支付:

业务受理:投诉、退货、退款、认证、差评、提现、账户疑问、解绑资金等义务。

控制器:

[网购规则第一章]

图片 1图片 2

第一条:
为促进开放、透明、分享、责任的新商业文明,保障用户合法权益,维护网购正常经营秩序,根据《网购宣言》及《交易服务协议》、《网购服务协议》,制定本规则。
第二条:
凡在任何购物网的消费者,尊守规章是对用户增加基本义务或限制基本权利的条款。
第三条:
网购规则,是对购物用户增加基本义务或限制基本权利的条款。官方发布的其他管理内容(包括但不限于规则、规范、类目管理标准、行业标准等)中提及的网购规则包括支付规则。
第四条: 违规行为的认定与处理,应基于管理人员认定的事实并严格依规执行。
消费者在适用规则上一律平等。
第五条:
用户应遵守国家法律、行政法规、部门规章等规范性文件。对任何涉嫌违反国家法律、行政法规、部门规章等规范性文件的行为,本规则已有规定的,适用本规则;本规则尚无规定的,管理人有权酌情处理,但对用户的处理不免除其应尽的法律责任。
用户在网上的任何网购行为,应同时遵守与购物网站及其关联公司所签订的各项协议。
公司有权随时变更本规则并在网站上予以公告。若用户不同意相关变更,应立即停止使用本公司的相关服务或产品。工作人员有权对用户行为及应适用的规则进行单方认定,并据此处理。

public ActionResult Index(decimal amount, string submitType, string relationCode, int? couponId = 0)
        {
            var model = new TenpayModel();
            amount = Math.Round((amount * 0.035M) + amount, 2);
            if (amount < 1)
            {
                model.ErrorMsg = "The amount cannot be less than 1USD.";
                return View(model);
            }
            if (amount > 2000)
            {
                model.ErrorMsg = "The amount cannot be less than 2000USD.";
                return View(model);
            }
            string relationId;
            relationId = submitType == "AddMoney" ? CurrentUserId.ToString() : relationCode;

            model.IsSend = false;

            RelationTypeEnum relationType = (RelationTypeEnum)Enum.Parse(typeof(RelationTypeEnum), submitType);

            var ourPaymentNumber = AddMoneyDataService.GetOrderId();    //我们的交易号

            model.Request = TenpayManager.CreateTenPayRequest(amount, relationId, CurrentUserId.ToString(), ourPaymentNumber, LanguageType.En);

            model.sign = TenpayManager.createRequestSign(model.Request);

            var TenpayBegin = AddMoneyDataService.TenpayAddMoney(CurrentUserId, amount, ourPaymentNumber, relationType,
                relationId, model.ToJson(), LanguageType.En); //begin

            if (TenpayBegin)
            {
                model.IsSend = true;
            }
            else
            {
                model.ErrorMsg = "System Error";
            }

            YOYBuyComLogDataService.Log("提交TenPay充值信息", LogType.TenpaySend, CurrentUserId, null, model.ToJson());
            return View(model);
        }

[网购规则第二章]
 
第六条:
淘宝,包括淘宝网,一淘网,天猫,京东商城,米奇网,团购,等等的一切购物网站;
第七条: 用户,指具有完全民事行为能力的网购各项服务的使用者。
第八条:
会员,指与站内签订《买卖条例》和《网购服务协议》并完成注册流程的用户。一个会员可以拥有多个账户,每个账户对应唯一的会员名。
第九条: 买家,指在网站浏览或购买商品的用户。
第十条: 卖家,指在网站上发布商品的会员,网上卖家也称为“商家”。
第十一条: 拍下,指买家在网上点击并确认购买的行为。
第十二条:
订单,指买家向单一商家同一时间拍下单款或多款商品的合约。订单中针对任一款商品的内容构成独立的交易。
第十三条: 绑定,指会员账户与支付宝账户一一对应。
第十四条:
商品发布数量,指商家在网站上出售中及在线上仓库中商品款数的总和。
第十五条:
退货运费险,指保险公司为投保该险种的站内会员支付单次退货运费。
第十六条: 分销商品,指公司分销平台分销商从其供应商获取并出售的商品。
第十七条:
节点处理,指当会员违规扣分累计达到一定分值时而被执行处理的过程。
第十八条:
店铺装修区,指店铺招牌、宝贝分类、公告栏、促销区、广告牌等店铺相关模块。
第十九条:
成交,指买家在网站上拍下商品并成功付款到支付宝。货到付款交易中买家拍下商品即视为成交。
第二十条: 下架,指将出售中的商品转移至线上仓库。
第二十一条: 包邮,指商家对所售商品承担大陆地区首次发货的运费。

View Code

[网购规则第三章]

view:

第二十二条:
自买家拍下或商家最后修改交易条件之时起三天内,买家未付款的,交易关闭,特殊商品除外。
第二十三条:
买家自付款之时起即可申请退款。自买家申请退款之时起两天内商家仍未点击发货的,管理员通知支付宝退款给买家。
第二十四条:
自商家在站内确认发货之时起,买家未在以下时限内确认收货且未申请退款的,站内的工作人员通知支付宝打款给商家:
(一) 自动发货商品一天内;
(二) 虚拟商品三天内;
(三) 快递、EMS及不需要物流的商品十天内,特殊商品除外;
(四) 平邮商品三十天内,特殊商品除外。
第二十五条: 买家申请退款后,依以下情况分别处理:
(一)
商家拒绝退款的,买家有权修改退款协议、要求工作人员介入或确认收货。买家在商家拒绝退款后七天内未操作的,退款流程关闭,交易正常进行;
(二)
商家同意退款或在以下时间内未操作的,且不要求买家退货的,管理员通知支付宝退款给买家:
1、 带有“电”标识的订单的超时时间为三天;
2、 未带有“电”标识的订单的超时时间为五天。
(三)
商家同意退款或在本条第{二}项第1、2目所述超时时间内未操作的,且要求买家退货的,则按以下情形处理:
1、 买家未在七天内点击退货的,退款流程关闭,交易正常进行;
2、 买家在七天内点击退货,且商家确认收货的,淘宝退款给买家;
3、
买家在七天内点击退货,通过快递退货十天内、平邮退货三十天内,商家未确认收货的,管理员通知支付宝退款给买家;
4、
买家在七天内点击退货,通过快递退货十天内、平邮退货三十天内,商家拒绝退款的,在以下情形下,工作人员将主动介入处理。

图片 3图片 4

                                             《以上条例条规最终解释权由本公司所有》

@if (Model.IsSend)
{
    <div class="floR status">
        <h2 class="clear ove mar10 font18 parbor">Credit Card - Online Payment</h2>
        <div class="clear ove mar40">
            Processing…
        </div>
    </div>
    <script type="text/javascript" language="javascript">
        $(document).ready(function () {
            $("#tenpayForm").submit();
        });
    </script>
    if (Model != null && Model.Request != null)
    {
        using (Html.BeginForm(null, null, FormMethod.Post, new { action = Model.Request.gateUrl, target = "_self", id = "tenpayForm", name = "tenpayForm", style = "display:none;" }))
        {
            <input type="text" id="attach" name="attach" value="@Model.Request.attach" />
            <input type="text" id="body" name="body" value="@Model.Request.body" />
            <input type="text" id="fee_type" name="fee_type" value="@Model.Request.fee_type"/>
            <input type="text" id="input_charset" name="input_charset" value="@Model.Request.input_charset" />
            <input type="text" id="language" name="language" value="@Model.Request.language" />
            <input type="text" id="notify_url" name="notify_url" value="@Model.Request.notify_url" />
            <input type="text" id="out_trade_no" name="out_trade_no" value="@Model.Request.out_trade_no" />
            <input type="text" id="partner" name="partner" value="@Model.Request.partner" />
            <input type="text" id="project_type" name="project_type" value="@Model.Request.project_type" />
            <input type="text" id="return_url" name="return_url" value="@Model.Request.return_url" />
            <input type="text" id="spbill_create_ip" name="spbill_create_ip" value="@Model.Request.spbill_create_ip" />
            <input type="text" id="total_fee" name="total_fee" value="@Model.Request.total_fee" />
            @*<input type="text" id="key" name="key" value="@Model.Request.key" />*@
            <input type="text" id="sign" name="sign" value="@Model.sign" />
        }
    }
}
else
{
    <div class="floR status">
        <h2 class="clear ove mar10 font18 parbor">Tenpay - Online Payment</h2>
        <div class="clear ove mar40">
            Error: @Model.ErrorMsg
        </div>
    </div>
}

View Code

用到的方法:

图片 5图片 6

public static class TenpayManager
    {
        //生成实体类
        public static PayRequest CreateTenPayRequest(decimal amount, string ticketId, string userId, string ourPaymentNumber, LanguageType lan)
        {
            var result = new PayRequest();
            result.gateUrl = ConfigurationManager.AppSettings["TenpayPostUrl"];//请求地址
            result.key = ConfigurationManager.AppSettings["TenpayKey"];//密钥
            result.partner = ConfigurationManager.AppSettings["TenpayPartner"];//商户号
            result.return_url = ConfigurationManager.AppSettings["TenpayReturn_url"];//同步
            result.notify_url = ConfigurationManager.AppSettings["TenpayNotify_url"];//异步
            //语种
            switch (lan)
            {
                case LanguageType.En:
                    result.language = "EN";
                    result.body = "YOYBUY  Deposit";//商品描述!
                    break;
                case LanguageType.Cn:
                    result.language = "CN";
                    result.body = "YOYBUY 充值";//商品描述!
                    break;
                case LanguageType.Ru:
                    result.language = "RU";
                    result.body = "YOYBUY депозит";//商品描述!
                    break;
                case LanguageType.Es:
                    result.language = "SP";
                    result.body = " YOYBUY  Depositar";//商品描述!
                    break;
                default:
                    result.language = "EN";
                    result.body = "YOYBUY  Deposit";//商品描述!
                    break;
            }
            result.project_type = 1; //外卡
            result.spbill_create_ip = HttpContext.Current.Request.UserHostAddress; //客户机ip
            //result.spbill_create_ip = "124.207.35.178"; //客户机ip
            result.fee_type = "USD"; //币种
            result.total_fee = Convert.ToInt32(amount * 100).ToString();//钱
            result.out_trade_no = ourPaymentNumber; //商家订单号
            result.input_charset = "UTF-8";//编码
            var whiteUser = UserLimitedDataService.CheckUserIsInUserGroup(int.Parse(userId));
            result.attach = whiteUser ? "is_white_user=1" : "is_white_user=0";
            return result;
        }
        //第一次请求支付
        public static string createRequestSign(PayRequest Request)
        {
            var parameters = new Hashtable();
            parameters.Add("attach", Request.attach);
            parameters.Add("body", Request.body);
            parameters.Add("input_charset", Request.input_charset);
            parameters.Add("notify_url", Request.notify_url);
            parameters.Add("return_url", Request.return_url);
            parameters.Add("partner", Request.partner);
            parameters.Add("out_trade_no", Request.out_trade_no);
            parameters.Add("total_fee", Request.total_fee);
            parameters.Add("fee_type", Request.fee_type);
            parameters.Add("spbill_create_ip", Request.spbill_create_ip);
            parameters.Add("project_type", Request.project_type);
            parameters.Add("language", Request.language);
            return createSign(parameters);
        }
        //第一次相应参数
        public static Hashtable getResponseParameters(NameValueCollection collection)
        {
            var parameters = new Hashtable();
            //添加相应参数
            foreach (string k in collection)
            {
                string v = (string)collection[k];
                if (!string.IsNullOrEmpty(k))
                {
                    parameters.Add(k, v);
                }
            }
            return parameters;
        }
        //根据相应参数生成实体
        public static PayResponse getResponseModel(Hashtable parameters)
        {
            var response = new PayResponse();
            response.Sign = parameters["sign"]?.ToString() ?? "";
            response.notify_id = parameters["notify_id"]?.ToString() ?? "";
            return response;
        }
        //通知查询 第二次请求
        public static string Call(string notify_id)
        {
            var url = ConfigurationManager.AppSettings["TenpaySearchUrl"];//通知请求地址;
            var partner = ConfigurationManager.AppSettings["TenpayPartner"]; //商户号
            var parameters = new Hashtable();
            parameters.Add("input_charset", "UTF-8");
            parameters.Add("partner", partner);
            parameters.Add("notify_id", notify_id);
            var sign = createSign(parameters);
            parameters.Add("sign", sign);
            var content = getCallUrl(url, parameters);

            string[] sArray = Regex.Split(content, "\\?");
            HttpWebRequest hp = (HttpWebRequest)WebRequest.Create(sArray[0]);
            hp.Timeout = 5000;
            var encoding = System.Text.Encoding.GetEncoding("UTF-8");
            string postData = "";
            if (sArray.Length >= 2)
            {
                postData = sArray[1];
            }
            if (postData != null)
            {
                byte[] data = encoding.GetBytes(postData);
                hp.Method = "POST";
                hp.ContentType = "application/x-www-form-urlencoded";
                hp.ContentLength = data.Length;
                var ws = hp.GetRequestStream();
                // 发送数据
                ws.Write(data, 0, data.Length);
                ws.Close();
            }
            var wr = (HttpWebResponse)hp.GetResponse();
            var sr = new StreamReader(wr.GetResponseStream(), encoding);
            var responseData = sr.ReadToEnd();
            sr.Close();
            wr.Close();
            return responseData;
        }

        //获取查询通知路径
        public static string getCallUrl(string url, Hashtable parameters)
        {
            var sb = new StringBuilder();
            ArrayList keys = new ArrayList(parameters.Keys);
            keys.Sort();
            foreach (string k in keys)
            {
                var v = parameters[k].ToString();
                if (null != v && "key".CompareTo(k) != 0)
                {
                    sb.Append(k + "=" + HttpUtility.UrlEncode(v, Encoding.GetEncoding("UTF-8")) + "&");
                }
            }
            if (sb.Length > 0)
            {
                sb.Remove(sb.Length - 1, 1);
            }
            return url + "?" + sb.ToString();
        }

        //解析第二次获取xml
        public static Hashtable getCallBackParameters(string xml)
        {
            var parameters = new Hashtable();

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xml);
            XmlNode root = xmlDoc.SelectSingleNode("root");
            XmlNodeList xnl = root.ChildNodes;

            foreach (XmlNode xnf in xnl)
            {
                parameters.Add(xnf.Name, xnf.InnerXml);
            }
            return parameters;
        }

        public static CallBack getCallBackModel(Hashtable parameters)
        {
            var call = new CallBack();
            call.Sign = parameters["sign"]?.ToString() ?? "";
            call.out_trade_no = parameters["out_trade_no"]?.ToString() ?? "";
            call.transaction_id = parameters["transaction_id"]?.ToString() ?? "";
            if (!string.IsNullOrEmpty(parameters["total_fee"].ToString()))
            {
                call.total_fee= Convert.ToDecimal(parameters["total_fee"].ToString()) / 100;
            }
            call.trade_state = parameters["trade_state"]?.ToString() ?? "";
            call.trade_mode = parameters["trade_mode"]?.ToString() ?? "";
            call.retcode = parameters["retcode"]?.ToString() ?? "";
            return call;
        }

        //生成sign
        public static string createSign(Hashtable parameters)
        {
            var key = ConfigurationManager.AppSettings["TenpayKey"];//密钥
            StringBuilder sb = new StringBuilder();
            ArrayList akeys = new ArrayList(parameters.Keys);
            akeys.Sort();
            foreach (string k in akeys)
            {
                string v = parameters[k].ToString();
                if (null != v && "".CompareTo(v) != 0
                    && "sign".CompareTo(k) != 0 && "key".CompareTo(k) != 0)
                {
                    sb.Append(k + "=" + v + "&");
                }
            }
            sb.Append("key=" + key);
            string sign = Encryption.MD5(sb.ToString(), 32).ToUpper();
            return sign;
        }


    }

View Code

图片 7图片 8

    public class CallBack
    {
        public string Sign { get; set; }
        public string out_trade_no { get; set; }
        public string transaction_id { get; set; }
        public decimal total_fee { get; set; }
        public string trade_state { get; set; }
        public string trade_mode { get; set; }
        public string retcode { get; set; }
    }

CallBack.cs

图片 9图片 10

    public class PayResponse
    {
        //签名
        public string Sign { get; set; }

        //相应id
        public string notify_id { get; set; }
    }

PayResponse.cs

图片 11图片 12

public class PayRequest
    {
        //编码
        public string input_charset { get; set; }
        //白名单 1是 0否 附加项
        public string attach { get; set; }
        //商品描述
        public string body { get; set; }
        //同步url
        public string return_url { get; set; }
        //异步url
        public string notify_url { get; set; }
        //商户号
        public string partner { get; set; }
        //商家订单号
        public string out_trade_no { get; set; }
        //商品金额
        public string total_fee { get; set; }
        //币种
        public string fee_type { get; set; }
        //用户ip
        public string spbill_create_ip { get; set; }
        //业务类型
        public int project_type { get; set; }
        //语种
        public string language { get; set; }
        // 密钥
        public string key { get; set; }
        // 请求地址
        public string gateUrl { get; set; }
    }

PayResult.cs

2.响应支付同步和异步的,自动补单机制,每5分钟左右会一直异步请求,直到返回success为止。

图片 13图片 14

public ActionResult returnurl()
        {
            var collection = Request.HttpMethod == "POST" ? Request.Form : Request.QueryString;
            var responseParameters = TenpayManager.getResponseParameters(collection);
            var responseModel = TenpayManager.getResponseModel(responseParameters);
            var responseSign = TenpayManager.createSign(responseParameters);
            if (responseModel.Sign.Equals(responseSign))
            {
                //通知查询
                var xml = TenpayManager.Call(responseModel.notify_id);
                var callBackParameters = TenpayManager.getCallBackParameters(xml);
                var callBackSign = TenpayManager.createSign(callBackParameters);
                var callBackModel = TenpayManager.getCallBackModel(callBackParameters);

                if (callBackModel.Sign.Equals(callBackSign))
                {
                    //我们的交易号
                    var out_trade_no = callBackModel.out_trade_no;
                    //财付通交易号
                    var transaction_id = callBackModel.transaction_id;
                    //金额,以分为单位
                    var amount = callBackModel.total_fee;
                    //支付结果
                    var trade_state = callBackModel.trade_state;
                    //交易模式,1即时到帐 2中介担保
                    var trade_mode = callBackModel.trade_mode;
                    var retcode = callBackModel.retcode;

                    if (retcode == "0" || trade_mode == "1" || trade_state == "1")
                    {
                        var successModel = new SuccessModel();
                        successModel.TradeNo = transaction_id;
                        successModel.Amount = amount > 0 ? amount : 0;

                        var failModel = new FailModel();
                        failModel.TradeNo = transaction_id;

                        var result = AddMoneyDataService.TenpayPayFinished(transaction_id, out_trade_no, amount, true, callBackModel.ToJson());


                        switch (result.Status)
                        {
                            case CommonEnum.DataExisted:
                                switch (result.Data.Language)
                                {
                                    case LanguageType.En:
                                        switch (result.Data.RelationType)
                                        {
                                            case RelationTypeEnum.AddMoney: //充值
                                                return View("/Views/Tenpay/Success.cshtml", successModel);
                                            case RelationTypeEnum.DirectOrderPay: //直购支付成功
                                            case RelationTypeEnum.DirectOrderOncePay:
                                                return Redirect("http://order.yoybuy.com/en/orderv5/orderlist");
                                            case RelationTypeEnum.PurchasingOrderOncePay: //代购订单支付成功
                                            case RelationTypeEnum.PurchasingOrderPay:
                                                return Redirect("http://shoppingcart.yoybuy.com/en/Purchase/paySuccessful?goodsBelongsType=order&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/en/order?ot=pp&pt=alipay&tid=" + result.Data.RelationCode);
                                            case RelationTypeEnum.PurchasingWaybillOncePay: //代购运单补款成功
                                                return Redirect("http://shoppingcart.yoybuy.com/en/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/en/myparcels");
                                            case RelationTypeEnum.PurchasingWaybillPay: //代购运单支付成功
                                                return Redirect("http://shoppingcart.yoybuy.com/en/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/en/myparcels");
                                            case RelationTypeEnum.ForwardingWaybillOncePay: //转运运单支付成功
                                            case RelationTypeEnum.ForwardingWaybillPay:
                                                return Redirect("http://shoppingcart.yoybuy.com/en/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/en/myforwardingparcels");
                                            default:
                                                return View("/Views/Tenpay/Fail.cshtml", failModel);
                                        }
                                    case LanguageType.Cn:
                                        switch (result.Data.RelationType)
                                        {
                                            case RelationTypeEnum.AddMoney: //充值
                                                return View("/Areas/Cn/Views/Tenpay/Success.cshtml", successModel);
                                            case RelationTypeEnum.DirectOrderPay: //直购支付成功
                                            case RelationTypeEnum.DirectOrderOncePay:
                                                return Redirect("http://order.yoybuy.com/cn/orderv5/orderlist");
                                            case RelationTypeEnum.PurchasingOrderOncePay: //代购订单支付成功
                                            case RelationTypeEnum.PurchasingOrderPay:
                                                return Redirect("http://shoppingcart.yoybuy.com/cn/Purchase/paySuccessful?goodsBelongsType=order&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/cn/order?ot=pp&pt=alipay&tid=" + result.Data.RelationCode);
                                            case RelationTypeEnum.PurchasingWaybillOncePay: //代购运单补款成功
                                                return Redirect("http://shoppingcart.yoybuy.com/cn/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/cn/myparcels");
                                            case RelationTypeEnum.PurchasingWaybillPay: //代购运单支付成功
                                                return Redirect("http://shoppingcart.yoybuy.com/cn/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/cn/myparcels");
                                            case RelationTypeEnum.ForwardingWaybillOncePay: //转运运单支付成功
                                            case RelationTypeEnum.ForwardingWaybillPay:
                                                return Redirect("http://shoppingcart.yoybuy.com/cn/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/cn/myforwardingparcels");
                                            default:
                                                return View("/Areas/Cn/Views/Tenpay/Fail.cshtml", failModel);
                                        }
                                    case LanguageType.Es:
                                        switch (result.Data.RelationType)
                                        {
                                            case RelationTypeEnum.AddMoney: //充值
                                                return View("/Areas/Es/Views/Tenpay/Success.cshtml", successModel);
                                            case RelationTypeEnum.DirectOrderPay: //直购支付成功
                                            case RelationTypeEnum.DirectOrderOncePay:
                                                return Redirect("http://order.yoybuy.com/es/orderv5/orderlist");
                                            case RelationTypeEnum.PurchasingOrderOncePay: //代购订单支付成功
                                            case RelationTypeEnum.PurchasingOrderPay:
                                                return Redirect("http://shoppingcart.yoybuy.com/es/Purchase/paySuccessful?goodsBelongsType=order&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/es/order?ot=pp&pt=alipay&tid=" + result.Data.RelationCode);
                                            case RelationTypeEnum.PurchasingWaybillOncePay: //代购运单补款成功
                                                return Redirect("http://shoppingcart.yoybuy.com/es/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/es/myparcels");
                                            case RelationTypeEnum.PurchasingWaybillPay: //代购运单支付成功
                                                return Redirect("http://shoppingcart.yoybuy.com/es/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/es/myparcels");
                                            case RelationTypeEnum.ForwardingWaybillOncePay: //转运运单支付成功
                                            case RelationTypeEnum.ForwardingWaybillPay:
                                                return Redirect("http://shoppingcart.yoybuy.com/es/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/es/myforwardingparcels");
                                            default:
                                                return View("/Areas/Es/Views/Tenpay/Fail.cshtml", failModel);
                                        }
                                    case LanguageType.Ru:
                                        switch (result.Data.RelationType)
                                        {
                                            case RelationTypeEnum.AddMoney: //充值
                                                return View("/Areas/Ru/Views/Tenpay/Success.cshtml", successModel);
                                            case RelationTypeEnum.DirectOrderPay: //直购支付成功
                                            case RelationTypeEnum.DirectOrderOncePay:
                                                return Redirect("http://order.yoybuy.com/ru/orderv5/orderlist");
                                            case RelationTypeEnum.PurchasingOrderOncePay: //代购订单支付成功
                                            case RelationTypeEnum.PurchasingOrderPay:
                                                return Redirect("http://shoppingcart.yoybuy.com/ru/Purchase/paySuccessful?goodsBelongsType=order&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/ru/order?ot=pp&pt=alipay&tid=" + result.Data.RelationCode);
                                            case RelationTypeEnum.PurchasingWaybillOncePay: //代购运单补款成功
                                                return Redirect("http://shoppingcart.yoybuy.com/ru/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/ru/myparcels");
                                            case RelationTypeEnum.PurchasingWaybillPay: //代购运单支付成功
                                                return Redirect("http://shoppingcart.yoybuy.com/ru/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/ru/myparcels");
                                            case RelationTypeEnum.ForwardingWaybillOncePay: //转运运单支付成功
                                            case RelationTypeEnum.ForwardingWaybillPay:
                                                return Redirect("http://shoppingcart.yoybuy.com/ru/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/ru/myforwardingparcels");
                                            default:
                                                return View("/Areas/Ru/Views/Tenpay/Fail.cshtml", failModel);
                                        }
                                    default:
                                        switch (result.Data.RelationType)
                                        {
                                            case RelationTypeEnum.AddMoney: //充值
                                                return View("/Views/Tenpay/Success.cshtml", successModel);
                                            case RelationTypeEnum.DirectOrderPay: //直购支付成功
                                            case RelationTypeEnum.DirectOrderOncePay:
                                                return Redirect("http://order.yoybuy.com/en/orderv5/orderlist");
                                            case RelationTypeEnum.PurchasingOrderOncePay: //代购订单支付成功
                                            case RelationTypeEnum.PurchasingOrderPay:
                                                return Redirect("http://shoppingcart.yoybuy.com/en/Purchase/paySuccessful?goodsBelongsType=order&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/en/order?ot=pp&pt=alipay&tid=" + result.Data.RelationCode);
                                            case RelationTypeEnum.PurchasingWaybillOncePay: //代购运单补款成功
                                                return Redirect("http://shoppingcart.yoybuy.com/en/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/en/myparcels");
                                            case RelationTypeEnum.PurchasingWaybillPay: //代购运单支付成功
                                                return Redirect("http://shoppingcart.yoybuy.com/en/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/en/myparcels");
                                            case RelationTypeEnum.ForwardingWaybillOncePay: //转运运单支付成功
                                            case RelationTypeEnum.ForwardingWaybillPay:
                                                return Redirect("http://shoppingcart.yoybuy.com/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + result.Data.RelationCode + "&returnUrl=http://order.yoybuy.com/en/myforwardingparcels");
                                            default:
                                                return View("/Views/Tenpay/Fail.cshtml", failModel);
                                        }

                                }
                            case CommonEnum.Success:
                                #region 更新相关订单、运单的状态

                                var relationType = result.Data.RelationType;
                                var relationCode = result.Data.RelationCode;
                                var userId = result.Data.UserId;
                                switch (relationType)
                                {
                                    case RelationTypeEnum.AddMoney:
                                        break;
                                    case RelationTypeEnum.PurchasingOrderPay: //代购订单支付成功
                                        var res = GoodsDataService.PaySucessWebOrder(relationCode, userId, PaymentTypeEnum.CreditCard.ToString());
                                        #region  代购订单支付 添加日志
                                        if (res == CreateProcureListStatus.Success)
                                        {
                                            YOYBuyComLogDataService.Log("使用CreditCard代购订单支付成功[ReturnData],订单号:" + relationCode, LogType.AlipayNotify, null, null,
                                                res.ToJson());
                                        }
                                        else
                                        {
                                            YOYBuyComLogDataService.Log("使用CreditCard代购订单支付失败[ReturnData],订单号:" + relationCode, LogType.AlipayNotify, null, null,
                                                res.ToJson());
                                        }
                                        #endregion
                                        break;
                                    case RelationTypeEnum.PurchasingOrderOncePay: //代购订单补款成功
                                        var returnState = OrderDataService.RefundForProcure(int.Parse(relationCode), userId);
                                        #region 代购订单补款 添加日志
                                        if (returnState == 0)
                                        {
                                            YOYBuyComLogDataService.Log("使用CreditCard代购订单补款成功[ReturnData],订单号:" + relationCode, LogType.AlipayNotify, null, null, null);
                                        }
                                        else
                                        {
                                            YOYBuyComLogDataService.Log("使用CreditCard代购订单补款失败[ReturnData],订单号:" + relationCode, LogType.AlipayNotify, null, null, returnState.ToString());
                                        }
                                        #endregion
                                        break;
                                    case RelationTypeEnum.PurchasingWaybillPay: //代购运单支付成功
                                        var backState = OrderDataService.PaySuccessWaybill(relationCode, userId, PaymentTypeEnum.CreditCard.ToString());
                                        #region  代购运单支付 添加日志
                                        if (backState.Status == CreateOrderStatus.Success)
                                        {
                                            YOYBuyComLogDataService.Log("使用CreditCard代购运单支付成功[ReturnData],运单号:" + relationCode, LogType.AlipayNotify, null, null, backState.ToJson());
                                        }
                                        else
                                        {
                                            YOYBuyComLogDataService.Log("使用CreditCard代购运单支付失败[ReturnData],运单号:" + relationCode, LogType.AlipayNotify, null, null, backState.ToJson());
                                        }

                                        #endregion
                                        break;
                                    case RelationTypeEnum.PurchasingWaybillOncePay: //代购运单补款支付成功
                                        var payRebackState = OrderDataService.PaySecondFeight20120823(relationCode, userId);
                                        #region  代购运单补款支付 添加日志
                                        if (payRebackState == 1)
                                        {
                                            YOYBuyComLogDataService.Log("使用CreditCard代购运单补款成功[ReturnData],运单号:" + relationCode, LogType.AlipayNotify, null, null, null);
                                        }
                                        else
                                        {
                                            YOYBuyComLogDataService.Log("使用CreditCard代购运单补款失败[ReturnData],运单号:" + relationCode, LogType.AlipayNotify, null, null, null);
                                        }
                                        #endregion
                                        break;
                                    case RelationTypeEnum.ForwardingWaybillPay: //转运运单支付成功
                                        var forwardingWaybillPay = OrderDataService.PaySuccessWaybill(relationCode, userId, PaymentTypeEnum.CreditCard.ToString());
                                        #region 转运运单支付 添加日志
                                        if (forwardingWaybillPay.Status == CreateOrderStatus.Success)
                                        {
                                            YOYBuyComLogDataService.Log("使用CreditCard转运运单支付成功[ReturnData],运单号:" + relationCode, LogType.AlipayNotify, null, null, forwardingWaybillPay.ToJson());
                                        }
                                        else
                                        {
                                            YOYBuyComLogDataService.Log("使用CreditCard转运运单支付失败[ReturnData],运单号:" + relationCode, LogType.AlipayNotify, null, null, forwardingWaybillPay.ToJson());
                                        }
                                        #endregion
                                        break;
                                    case RelationTypeEnum.ForwardingWaybillOncePay: //转运运单补款成功
                                        var forwardingWaybillOncePay = OrderDataService.PaySecondFeight20120823(relationCode, userId);
                                        #region 转运运单补款 添加日志
                                        if (forwardingWaybillOncePay == 1)
                                        {
                                            YOYBuyComLogDataService.Log("使用CreditCard转运运单补款成功[ReturnData],运单号:" + relationCode, LogType.AlipayNotify, null, null, null);
                                        }
                                        else
                                        {
                                            YOYBuyComLogDataService.Log("使用CreditCard转运运单补款失败[ReturnData],运单号:" + relationCode, LogType.AlipayNotify, null, null, null);
                                        }
                                        #endregion
                                        break;
                                    default:
                                        YOYBuyComLogDataService.Log("接收CreditCard异常[ReturnData]支付失败,单号:" + relationCode, LogType.AlipayNotify, null, null, null);
                                        break;
                                }

                                #endregion

                                switch (result.Data.Language)
                                {
                                    case LanguageType.En:
                                        switch (relationType)
                                        {
                                            case RelationTypeEnum.AddMoney: //充值
                                                return View("/Views/Tenpay/Success.cshtml", successModel);
                                            case RelationTypeEnum.DirectOrderPay: //直购支付成功
                                            case RelationTypeEnum.DirectOrderOncePay:
                                                return Redirect("http://order.yoybuy.com/en/orderv5/orderlist");
                                            case RelationTypeEnum.PurchasingOrderOncePay: //代购订单支付成功
                                            case RelationTypeEnum.PurchasingOrderPay:
                                                YOYBuyComLogDataService.Log("Tenpay代购订单支付", LogType.Info, userId, null, "http://order.yoybuy.com/en/order/?ot=pp&pt=alipay&tid=" + relationCode);
                                                return Redirect("http://shoppingcart.yoybuy.com/en/Purchase/paySuccessful?goodsBelongsType=order&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/en/order?ot=pp&pt=alipay&tid=" + relationCode);
                                            case RelationTypeEnum.PurchasingWaybillOncePay: //代购运单补款成功
                                                return Redirect("http://shoppingcart.yoybuy.com/en/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/en/myparcels");
                                            case RelationTypeEnum.PurchasingWaybillPay: //代购运单支付成功
                                                return Redirect("http://shoppingcart.yoybuy.com/en/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/en/myparcels");
                                            case RelationTypeEnum.ForwardingWaybillOncePay: //转运运单支付成功
                                            case RelationTypeEnum.ForwardingWaybillPay:
                                                return Redirect("http://shoppingcart.yoybuy.com/en/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/en/myforwardingparcels");
                                            default:
                                                return View("/Views/Tenpay/Fail.cshtml", failModel);
                                        }
                                    case LanguageType.Cn:
                                        switch (relationType)
                                        {
                                            case RelationTypeEnum.AddMoney: //充值
                                                return View("/Areas/Cn/Views/Tenpay/Success.cshtml", successModel);
                                            case RelationTypeEnum.DirectOrderPay: //直购支付成功
                                            case RelationTypeEnum.DirectOrderOncePay:
                                                return Redirect("http://order.yoybuy.com/cn/orderv5/orderlist");
                                            case RelationTypeEnum.PurchasingOrderOncePay: //代购订单支付成功
                                            case RelationTypeEnum.PurchasingOrderPay:
                                                YOYBuyComLogDataService.Log("Tenpay代购订单支付", LogType.Info, userId, null, "http://order.yoybuy.com/cn/order/?ot=pp&pt=alipay&tid=" + relationCode);
                                                return Redirect("http://shoppingcart.yoybuy.com/cn/Purchase/paySuccessful?goodsBelongsType=order&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/cn/order?ot=pp&pt=alipay&tid=" + relationCode);
                                            case RelationTypeEnum.PurchasingWaybillOncePay: //代购运单补款成功
                                                return Redirect("http://shoppingcart.yoybuy.com/cn/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/cn/myparcels");
                                            case RelationTypeEnum.PurchasingWaybillPay: //代购运单支付成功
                                                return Redirect("http://shoppingcart.yoybuy.com/cn/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/cn/myparcels");
                                            case RelationTypeEnum.ForwardingWaybillOncePay: //转运运单支付成功
                                            case RelationTypeEnum.ForwardingWaybillPay:
                                                return Redirect("http://shoppingcart.yoybuy.com/cn/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/cn/myforwardingparcels");
                                            default:
                                                return View("/Areas/Cn/Views/Tenpay/Fail.cshtml", failModel);
                                        }
                                    case LanguageType.Es:
                                        switch (relationType)
                                        {
                                            case RelationTypeEnum.AddMoney: //充值
                                                return View("/Areas/Es/Views/Tenpay/Success.cshtml", successModel);
                                            case RelationTypeEnum.DirectOrderPay: //直购支付成功
                                            case RelationTypeEnum.DirectOrderOncePay:
                                                return Redirect("http://order.yoybuy.com/es/orderv5/orderlist");
                                            case RelationTypeEnum.PurchasingOrderOncePay: //代购订单支付成功
                                            case RelationTypeEnum.PurchasingOrderPay:
                                                YOYBuyComLogDataService.Log("Tenpay代购订单支付", LogType.Info, userId, null, "http://order.yoybuy.com/es/order/?ot=pp&pt=alipay&tid=" + relationCode);
                                                return Redirect("http://shoppingcart.yoybuy.com/es/Purchase/paySuccessful?goodsBelongsType=order&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/es/order?ot=pp&pt=alipay&tid=" + relationCode);
                                            case RelationTypeEnum.PurchasingWaybillOncePay: //代购运单补款成功
                                                return Redirect("http://shoppingcart.yoybuy.com/es/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/es/myparcels");
                                            case RelationTypeEnum.PurchasingWaybillPay: //代购运单支付成功
                                                return Redirect("http://shoppingcart.yoybuy.com/es/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/es/myparcels");
                                            case RelationTypeEnum.ForwardingWaybillOncePay: //转运运单支付成功
                                            case RelationTypeEnum.ForwardingWaybillPay:
                                                return Redirect("http://shoppingcart.yoybuy.com/es/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/es/myforwardingparcels");
                                            default:
                                                return View("/Areas/Es/Views/Tenpay/Fail.cshtml", failModel);
                                        }
                                    case LanguageType.Ru:
                                        switch (relationType)
                                        {
                                            case RelationTypeEnum.AddMoney: //充值
                                                return View("/Areas/Ru/Views/Tenpay/Success.cshtml", successModel);
                                            case RelationTypeEnum.DirectOrderPay: //直购支付成功
                                            case RelationTypeEnum.DirectOrderOncePay:
                                                return Redirect("http://order.yoybuy.com/ru/orderv5/orderlist");
                                            case RelationTypeEnum.PurchasingOrderOncePay: //代购订单支付成功
                                            case RelationTypeEnum.PurchasingOrderPay:
                                                YOYBuyComLogDataService.Log("Tenpay代购订单支付", LogType.Info, userId, null, "http://order.yoybuy.com/ru/order/?ot=pp&pt=alipay&tid=" + relationCode);
                                                return Redirect("http://shoppingcart.yoybuy.com/ru/Purchase/paySuccessful?goodsBelongsType=order&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/ru/order?ot=pp&pt=alipay&tid=" + relationCode);
                                            case RelationTypeEnum.PurchasingWaybillOncePay: //代购运单补款成功
                                                return Redirect("http://shoppingcart.yoybuy.com/ru/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/ru/myparcels");
                                            case RelationTypeEnum.PurchasingWaybillPay: //代购运单支付成功
                                                return Redirect("http://shoppingcart.yoybuy.com/ru/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/ru/myparcels");
                                            case RelationTypeEnum.ForwardingWaybillOncePay: //转运运单支付成功
                                            case RelationTypeEnum.ForwardingWaybillPay:
                                                return Redirect("http://shoppingcart.yoybuy.com/ru/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/ru/myforwardingparcels");
                                            default:
                                                return View("/Areas/Ru/Views/Tenpay/Fail.cshtml", failModel);
                                        }
                                    default:
                                        switch (relationType)
                                        {
                                            case RelationTypeEnum.AddMoney: //充值
                                                return View("/Views/Tenpay/Success.cshtml", successModel);
                                            case RelationTypeEnum.DirectOrderPay: //直购支付成功
                                            case RelationTypeEnum.DirectOrderOncePay:
                                                return Redirect("http://order.yoybuy.com/en/orderv5/orderlist");
                                            case RelationTypeEnum.PurchasingOrderOncePay: //代购订单支付成功
                                            case RelationTypeEnum.PurchasingOrderPay:
                                                YOYBuyComLogDataService.Log("Tenpay代购订单支付", LogType.Info, userId, null, "http://order.yoybuy.com/en/order/?ot=pp&pt=alipay&tid=" + relationCode);
                                                return Redirect("http://shoppingcart.yoybuy.com/en/Purchase/paySuccessful?goodsBelongsType=order&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/en/order?ot=pp&pt=alipay&tid=" + relationCode);
                                            case RelationTypeEnum.PurchasingWaybillOncePay: //代购运单补款成功
                                                return Redirect("http://shoppingcart.yoybuy.com/en/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/en/myparcels");
                                            case RelationTypeEnum.PurchasingWaybillPay: //代购运单支付成功
                                                return Redirect("http://shoppingcart.yoybuy.com/en/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/en/myparcels");
                                            case RelationTypeEnum.ForwardingWaybillOncePay: //转运运单支付成功
                                            case RelationTypeEnum.ForwardingWaybillPay:
                                                return Redirect("http://shoppingcart.yoybuy.com/Purchase/paySuccessful?goodsBelongsType=waybill&totleAmount=" + amount + "&tracking=" + relationCode + "&returnUrl=http://order.yoybuy.com/en/myforwardingparcels");
                                            default:
                                                return View("/Views/Tenpay/Fail.cshtml", failModel);
                                        }
                                }
                            case CommonEnum.Failed:
                                switch (result.Data.Language)
                                {
                                    case LanguageType.En:
                                        return View("/Views/Tenpay/Fail.cshtml", failModel);

                                    case LanguageType.Cn:
                                        return View("/Areas/Cn/Views/Tenpay/Fail.cshtml", failModel);

                                    case LanguageType.Es:
                                        return View("/Areas/Es/Views/Tenpay/Fail.cshtml", failModel);

                                    case LanguageType.Ru:
                                        return View("/Areas/Ru/Views/Tenpay/Fail.cshtml", failModel);

                                    default:
                                        return View("/Views/Tenpay/Fail.cshtml", failModel);
                                }
                            default:
                                switch (result.Data.Language)
                                {
                                    case LanguageType.En:
                                        return View("/Views/Tenpay/Fail.cshtml", failModel);

                                    case LanguageType.Cn:
                                        return View("/Areas/Cn/Views/Tenpay/Fail.cshtml", failModel);

                                    case LanguageType.Es:
                                        return View("/Areas/Es/Views/Tenpay/Fail.cshtml", failModel);

                                    case LanguageType.Ru:
                                        return View("/Areas/Ru/Views/Tenpay/Fail.cshtml", failModel);

                                    default:
                                        return View("/Views/Tenpay/Fail.cshtml", failModel);
                                }
                        }
                    }
                    else
                    {
                        var failModel = new FailModel();
                        failModel.TradeNo = "";
                        var result = AddMoneyDataService.TenpayPayFinished(transaction_id, out_trade_no, amount, false, callBackModel.ToJson());
                        YOYBuyComLogDataService.Log("接收TenPay信息", LogType.TenpaySend, CurrentUserId, null, "第三方支付失败");
                        return View("/Views/Tenpay/Fail.cshtml", failModel);
                    }
                }
                else
                {
                    var failModel = new FailModel();
                    failModel.TradeNo = "";
                    YOYBuyComLogDataService.Log("接收TenPay信息", LogType.TenpaySend, CurrentUserId, null, "签名认证失败");
                    return View("/Views/Tenpay/Fail.cshtml", failModel);
                    //非空 错误原因
                    //var retmsg = parameters["retmsg"].ToString();
                }
            }
            else
            {
                var failModel = new FailModel();
                failModel.TradeNo = "";
                YOYBuyComLogDataService.Log("接收TenPay信息", LogType.TenpaySend, CurrentUserId, null, "签名认证失败");
                return View("/Views/Tenpay/Fail.cshtml", failModel);
            }
        }

returnurl

图片 15图片 16

public ActionResult notifyurl()
        {
            var collection = Request.HttpMethod == "POST" ? Request.Form : Request.QueryString;
            var responseParameters = TenpayManager.getResponseParameters(collection);
            var responseModel = TenpayManager.getResponseModel(responseParameters);
            var responseSign = TenpayManager.createSign(responseParameters);
            if (responseModel.Sign.Equals(responseSign))
            {
                //通知查询
                var xml = TenpayManager.Call(responseModel.notify_id);
                var callBackParameters = TenpayManager.getCallBackParameters(xml);
                var callBackSign = TenpayManager.createSign(callBackParameters);
                var callBackModel = TenpayManager.getCallBackModel(callBackParameters);

                if (callBackModel.Sign.Equals(callBackSign))
                {
                    //我们的交易号
                    var out_trade_no = callBackModel.out_trade_no;
                    //财付通交易号
                    var transaction_id = callBackModel.transaction_id;
                    //金额,以分为单位
                    var amount = callBackModel.total_fee;
                    //支付结果
                    var trade_state = callBackModel.trade_state;
                    //交易模式,1即时到帐 2中介担保
                    var trade_mode = callBackModel.trade_mode;
                    var retcode = callBackModel.retcode;

                    if (retcode == "0" || trade_mode == "1" || trade_state == "1")
                    {
                        var successModel = new SuccessModel();
                        successModel.TradeNo = transaction_id;
                        successModel.Amount = amount > 0 ? amount : 0;

                        var failModel = new FailModel();
                        failModel.TradeNo = transaction_id;

                        var result = AddMoneyDataService.TenpayPayFinished(transaction_id, out_trade_no, amount, true,
                            callBackModel.ToJson());


                        switch (result.Status)
                        {
                            case CommonEnum.DataExisted:
                                YOYBuyComLogDataService.Log("接收TenPay信息", LogType.TenpaySend, CurrentUserId, null,
                                    "付款成功");
                                return Content("Success");
                            case CommonEnum.Success:

                                var relationType = result.Data.RelationType;
                                var relationCode = result.Data.RelationCode;
                                var userId = result.Data.UserId;
                                #region 更新相关订单、运单的状态

                                switch (relationType)
                                {
                                    case RelationTypeEnum.AddMoney:
                                        break;
                                    case RelationTypeEnum.PurchasingOrderPay: //代购订单支付成功
                                        var res = GoodsDataService.PaySucessWebOrder(relationCode, userId,
                                            PaymentTypeEnum.CreditCard.ToString());

                                        #region  代购订单支付 添加日志

                                        if (res == CreateProcureListStatus.Success)
                                        {
                                            YOYBuyComLogDataService.Log(
                                                "使用CreditCard代购订单支付成功[ReturnData],订单号:" + relationCode,
                                                LogType.AlipayNotify, null, null,
                                                res.ToJson());
                                        }
                                        else
                                        {
                                            YOYBuyComLogDataService.Log(
                                                "使用CreditCard代购订单支付失败[ReturnData],订单号:" + relationCode,
                                                LogType.AlipayNotify, null, null,
                                                res.ToJson());
                                        }

                                        #endregion

                                        break;
                                    case RelationTypeEnum.PurchasingOrderOncePay: //代购订单补款成功
                                        var returnState = OrderDataService.RefundForProcure(int.Parse(relationCode),
                                            userId);

                                        #region 代购订单补款 添加日志

                                        if (returnState == 0)
                                        {
                                            YOYBuyComLogDataService.Log(
                                                "使用CreditCard代购订单补款成功[ReturnData],订单号:" + relationCode,
                                                LogType.AlipayNotify, null, null, null);
                                        }
                                        else
                                        {
                                            YOYBuyComLogDataService.Log(
                                                "使用CreditCard代购订单补款失败[ReturnData],订单号:" + relationCode,
                                                LogType.AlipayNotify, null, null, returnState.ToString());
                                        }

                                        #endregion

                                        break;
                                    case RelationTypeEnum.PurchasingWaybillPay: //代购运单支付成功
                                        var backState = OrderDataService.PaySuccessWaybill(relationCode, userId,
                                            PaymentTypeEnum.CreditCard.ToString());

                                        #region  代购运单支付 添加日志

                                        if (backState.Status == CreateOrderStatus.Success)
                                        {
                                            YOYBuyComLogDataService.Log(
                                                "使用CreditCard代购运单支付成功[ReturnData],运单号:" + relationCode,
                                                LogType.AlipayNotify, null, null, backState.ToJson());
                                        }
                                        else
                                        {
                                            YOYBuyComLogDataService.Log(
                                                "使用CreditCard代购运单支付失败[ReturnData],运单号:" + relationCode,
                                                LogType.AlipayNotify, null, null, backState.ToJson());
                                        }

                                        #endregion

                                        break;
                                    case RelationTypeEnum.PurchasingWaybillOncePay: //代购运单补款支付成功
                                        var payRebackState = OrderDataService.PaySecondFeight20120823(relationCode,
                                            userId);

                                        #region  代购运单补款支付 添加日志

                                        if (payRebackState == 1)
                                        {
                                            YOYBuyComLogDataService.Log(
                                                "使用CreditCard代购运单补款成功[ReturnData],运单号:" + relationCode,
                                                LogType.AlipayNotify, null, null, null);
                                        }
                                        else
                                        {
                                            YOYBuyComLogDataService.Log(
                                                "使用CreditCard代购运单补款失败[ReturnData],运单号:" + relationCode,
                                                LogType.AlipayNotify, null, null, null);
                                        }

                                        #endregion

                                        break;
                                    case RelationTypeEnum.ForwardingWaybillPay: //转运运单支付成功
                                        var forwardingWaybillPay = OrderDataService.PaySuccessWaybill(relationCode,
                                            userId, PaymentTypeEnum.CreditCard.ToString());

                                        #region 转运运单支付 添加日志

                                        if (forwardingWaybillPay.Status == CreateOrderStatus.Success)
                                        {
                                            YOYBuyComLogDataService.Log(
                                                "使用CreditCard转运运单支付成功[ReturnData],运单号:" + relationCode,
                                                LogType.AlipayNotify, null, null, forwardingWaybillPay.ToJson());
                                        }
                                        else
                                        {
                                            YOYBuyComLogDataService.Log(
                                                "使用CreditCard转运运单支付失败[ReturnData],运单号:" + relationCode,
                                                LogType.AlipayNotify, null, null, forwardingWaybillPay.ToJson());
                                        }

                                        #endregion

                                        break;
                                    case RelationTypeEnum.ForwardingWaybillOncePay: //转运运单补款成功
                                        var forwardingWaybillOncePay =
                                            OrderDataService.PaySecondFeight20120823(relationCode, userId);

                                        #region 转运运单补款 添加日志

                                        if (forwardingWaybillOncePay == 1)
                                        {
                                            YOYBuyComLogDataService.Log(
                                                "使用CreditCard转运运单补款成功[ReturnData],运单号:" + relationCode,
                                                LogType.AlipayNotify, null, null, null);
                                        }
                                        else
                                        {
                                            YOYBuyComLogDataService.Log(
                                                "使用CreditCard转运运单补款失败[ReturnData],运单号:" + relationCode,
                                                LogType.AlipayNotify, null, null, null);
                                        }

                                        #endregion

                                        break;
                                    default:
                                        YOYBuyComLogDataService.Log(
                                            "接收CreditCard异常[ReturnData]支付失败,单号:" + relationCode, LogType.AlipayNotify,
                                            null, null, null);
                                        break;
                                }

                                #endregion

                                YOYBuyComLogDataService.Log("接收TenPay信息", LogType.TenpaySend, CurrentUserId, null,
                                    "付款成功");
                                return Content("Success");
                            case CommonEnum.Failed:
                                YOYBuyComLogDataService.Log("接收TenPay信息", LogType.TenpaySend, CurrentUserId, null,
                                    "付款失败");
                                return Content("Failed");
                            default:
                                YOYBuyComLogDataService.Log("接收TenPay信息", LogType.TenpaySend, CurrentUserId, null,
                                    "付款失败");
                                return Content("Failed");
                        }
                    }
                    else
                    {
                        var result = AddMoneyDataService.TenpayPayFinished(transaction_id, out_trade_no, amount, false, callBackModel.ToJson());
                        YOYBuyComLogDataService.Log("接收TenPay信息", LogType.TenpaySend, CurrentUserId, null, "第三方支付失败");
                        return Content("Failed");
                    }
                }
                else
                {
                    YOYBuyComLogDataService.Log("接收TenPay信息", LogType.TenpaySend, CurrentUserId, null, "签名认证失败");
                    return Content("Failed");
                }
            }
            else
            {
                //签名认证失败
                YOYBuyComLogDataService.Log("接收TenPay信息", LogType.TenpaySend, CurrentUserId, null, "签名认证失败");
            }
            return Content("");
        }

notifyurl

3.web.config

图片 17图片 18

    <!--Tenpay在线充值开始-->
    <!--Tenpay提交地址-->
    <add key="TenpayPostUrl" value="https://payment.tenpay.com/cgi-bin/icard/icard_pay_gate.cgi" />
    <!--Tenpay商户号-->
    <add key="TenpayPartner" value="111111111" />
    <!--Tenpay密钥-->
    <add key="TenpayKey" value="asdasdasdasd" />
    <!--Tenpay同步回调-->
    <add key="TenpayReturn_url" value="https://account.yoybuy.com/en/returnurl" />
    <!--Tenpay异步回调-->
    <add key="TenpayNotify_url" value="https://account.yoybuy.com/en/notifyurl" />
    <!--<add key="TenpayNotify_url" value="http://114.215.130.252/en/notifyurl" />-->
    <!--Tenpay请求通知地址-->
    <add key="TenpaySearchUrl" value="https://payment.tenpay.com/cgi-bin/icard/icard_verifynotifyid.cgi" />
    <!--Tenpay在线充值结束-->

View Code

 

相关文章