예제 #1
0
        /// <summary>
        /// 现在新的快捷需要上传name 开户人 cert_id 证件号  cert_type 证件类型 1 身份证
        /// </summary>
        /// <param name="type"></param>
        /// <param name="channel"></param>
        /// <param name="order"></param>
        /// <param name="amount"></param>
        /// <param name="ip"></param>
        /// <param name="Ua"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <param name="remark"></param>
        /// <param name="resultUrl"></param>
        /// <param name="no"></param>
        /// <param name="name"></param>
        /// <param name="cert_id"></param>
        /// <param name="cert_type"></param>
        /// <returns></returns>
        public string Chargeexpress(ushort type, ushort channel, string order, decimal amount, string ip, string Ua, string subject, string body, string remark, string resultUrl, string no, string name, string cert_id, int cert_type, string mobile)
        {
            try
            {
                var request = new ChinaRailway.Payment.Models.Charge.ChargeBankEasy(channel, ChinaRailway.Payment.Models.Charge.BankAccountType.DebitCard, no)
                {
                    //Type = type,
                    //Channel = channel,
                    Order    = order,
                    Currency = 1,
                    Amount   = amount,
                    Client   = new ChinaRailway.Payment.Models.Charge.ChargeClient()
                    {
                        Ip = ip,
                        Ua = Ua
                    },
                    Product = new ChinaRailway.Payment.Models.Charge.ChargeProduct()
                    {
                        Subject = subject,
                        Body    = body,
                    },
                    Time      = Smartunicom.DateTimeHelper.LocalDateTimeToUnixTimeStamp(DateTime.Now),
                    Timeout   = 60 * 10,
                    Remark    = remark,
                    ResultUrl = resultUrl,
                    name      = name,
                    cert_id   = cert_id,
                    cert_type = cert_type,
                    mobile    = mobile
                };
                ChargeBankEasyResult response;
                var result = ChinaRailwayApp.GetInstance(AppId, PrivateKey, gateway_url).Charge.ChargeBankEasy(request, out response); // 调用接口生成订单

                if (result.IsSuccess)
                {
                    if (response.Credential.Type == 2)
                    {
                        return(string.Format("{0}|{1}|{2}", "true", 2, response.Credential.Content));
                    }
                    else
                    {
                        return(string.Format("{0}|{1}|{2}", "true", 1, response.Credential.Content));
                        //return string.Format("{0}|{1}|{2}", "true", 1, string.Format(slf_payurl, response.Transaction));//response.Credential.Content
                    }
                    //return string.Format("{0}|{1}", "true", response.Credential.Content);
                }
                else
                {
                    return(string.Format("{0}|{1}", "false", result.Message));
                }
            }
            catch (Exception exp)
            {
                return(string.Format("{0}|{1}", "false", exp.Message));
            }
        }
예제 #2
0
        public int CheckSignature(Dictionary <string, string> header, string request_content, string request_header_signature, string request_header_event, out decimal money, out string orderid, out string outorderid, out string remark)
        {
            money      = 0;
            orderid    = string.Empty;
            outorderid = string.Empty;
            remark     = string.Empty;
            if (!ChinaRailwayApp.GetInstance(AppId, PrivateKey, gateway_url).WebHook.CheckSignature(header, request_content, request_header_signature))
            {
                return(500);
            }

            int id = 0;

            switch (request_header_event)
            {
            case EventNames.Charge_Succeeded:     // 支付成功通知
            {
                var result = ChinaRailwayApp.GetInstance(AppId, PrivateKey, gateway_url).Serializer.Deserialize <ChargeSucceeded>(request_content);
                if (result.Status != 1)
                {
                    return(500);
                }

                //todo: 获取到订单信息 转由商户系统处理
                // 注意金额变动时的并发问题
                money      = result.Amount;
                orderid    = result.Order;
                outorderid = result.Transaction;
                remark     = result.Remark;
            }
                return(204);

            case EventNames.Pay_Succeeded:     // 代付 - 成功通知
            {
                var result = ChinaRailwayApp.GetInstance(AppId, PrivateKey, gateway_url).Serializer.Deserialize <PaySucceeded>(request_content);
                if (result.Status != 1)
                {
                    return(500);
                }

                //todo: 获取到订单信息 转由商户系统处理
                // 注意金额变动时的并发问题
                money      = result.Amount;
                orderid    = result.Order;
                outorderid = result.Transaction;
                remark     = result.Remark;
            }
                return(204);

            default:
            {
                return(404);
            }
            }
        }
예제 #3
0
        /// <summary>
        /// 20171201增加手机H5专用通道
        /// </summary>
        /// <param name="type"></param>
        /// <param name="channel"></param>
        /// <param name="order"></param>
        /// <param name="amount"></param>
        /// <param name="ip"></param>
        /// <param name="Ua"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <param name="remark"></param>
        /// <returns></returns>
        public string ChargeWeixinH5(ushort type, ushort channel, string order, decimal amount, string ip, string Ua, string subject, string body, string remark)
        {
            try
            {
                var request = new ChinaRailway.Payment.Models.Charge.ChargeWepayNative()
                {
                    Type     = type,
                    Channel  = channel,
                    Order    = order,
                    Currency = 1,
                    Amount   = amount,
                    Client   = new ChinaRailway.Payment.Models.Charge.ChargeClient()
                    {
                        Ip = ip,
                        Ua = Ua
                    },
                    Product = new ChinaRailway.Payment.Models.Charge.ChargeProduct()
                    {
                        Subject = subject,
                        Body    = body,
                    },
                    Time    = Smartunicom.DateTimeHelper.LocalDateTimeToUnixTimeStamp(DateTime.Now),
                    Timeout = 60 * 10,
                    Remark  = remark
                };

                ChargeWepayNativeResult response;
                var result = ChinaRailwayApp.GetInstance(AppId, PrivateKey, gateway_url).Charge.ChargeWepayNative(request, out response); // 调用接口生成订单

                if (result.IsSuccess)
                {
                    //if (response.Credential.Type == 2)
                    if (response.Credential.Type == 0)//手机微信H5专用通道
                    {
                        return(string.Format("{0}|{1}|{2}", "true", 2, response.Credential.Content));
                    }
                    else
                    {
                        return(string.Format("{0}|{1}|{2}", "true", 1, string.Format(slf_payurl, response.Transaction)));//response.Credential.Content
                    }
                }
                else
                {
                    return(string.Format("{0}|{1}", "false", result.Message));
                }
            }
            catch (Exception exp)
            {
                return(string.Format("{0}|{1}", "false", exp.Message));
            }
        }