Esempio n. 1
0
        /// <summary>
        /// 创建支付提交的表单
        /// </summary>
        /// <param name="orderInfo"></param>
        /// <returns></returns>
        public static string BuildWapRequestForm(PayOrderInfo orderInfo)
        {
            var data = new AllinpayData(AllinpayDataType.PayRequest);

            //页面跳转同步通知页面路径
            data.SetValue("pickupUrl", string.Format("http://{0}/Allinpay/OnlinePayReturn", AppConfig.Global.Domain));
            //服务器接受支付结果的后台地址
            data.SetValue("receiveUrl", string.Format("http://{0}/Allinpay/OnlinePayNotify", AppConfig.Global.Domain));
            //商户号
            data.SetValue("merchantId", AppConfig.Global.AllinpayMerchantId);
            //商户订单号
            data.SetValue("orderNo", orderInfo.OrderId.Trim());
            //商户订单金额
            data.SetValue("orderAmount", ((int)(Convert.ToDecimal(orderInfo.PaymentAmt) * 100)).ToString());
            //商户订单提交时间
            data.SetValue("orderDatetime", orderInfo.OrderTime);

            int diffMinutes = (int)((DateTime.ParseExact(orderInfo.OrderTime, "yyyyMMddHHmmss", new CultureInfo("zh-CN", true)).AddHours(24) - DateTime.Now).TotalMinutes);

            //订单过期时间
            data.SetValue("orderExpireDatetime", Math.Max(diffMinutes, 1).ToString()); //默认下单后的24小时
            //支付方式
            data.SetValue("payType", "0");                                             //接入手机网关时,该值填固定填0
            //发卡方代码
            data.SetValue("issuerId", "");                                             //payType为0时,issuerId必须为空
            //签名字符串
            data.SetValue("signMsg", AllinpayCore.RequestSign(data));
            //建立请求
            string formHtml = data.ToForm(AppConfig.Global.AllinpayWapServerUrl, "post");

            return(formHtml);
        }
Esempio n. 2
0
        /// <summary>
        /// 执行同步退款
        /// </summary>
        /// <param name="orderInfo">退款订单</param>
        /// <param name="resultInfo">退款结果记录</param>
        /// <returns></returns>
        public override ExecuteResult <RefundNotifyInfo> ExecuteSyncRefund(RefundOrderInfo orderInfo, RefundResultInfo resultInfo)
        {
            var result = new ExecuteResult <RefundNotifyInfo>();

            try
            {
                resultInfo.OrderId       = orderInfo.OrderId;
                resultInfo.RefundOrderId = orderInfo.RefundOrderId;
                resultInfo.RefundAmt     = Convert.ToDecimal(orderInfo.RefundAmt);
                //获取退款金额
                int refundAmt  = (int)(resultInfo.RefundAmt * 100);//通联退款金额的单位为“分”,所以要乘以100
                var refundData = new AllinpayData(AllinpayDataType.RefundRequest);
                //商户号
                refundData.SetValue("merchantId", AppConfig.Global.AllinpayMerchantId);
                //商户订单号
                refundData.SetValue("orderNo", orderInfo.OrderId);
                //退款金额
                refundData.SetValue("refundAmount", refundAmt.ToString());
                //商户订单提交时间
                refundData.SetValue("orderDatetime", orderInfo.OrderTime);
                //签名字符串
                refundData.SetValue("signMsg", AllinpayCore.RefundSign(refundData));

                var executeResult = AllinpayManager.RefundRequest(refundData);
                if (executeResult.Status != ResultStatus.Success)
                {
                    resultInfo.ExecuteResult = (int)ResultStatus.Failure;
                    resultInfo.ResultDesc    = "通联退款请求失败:" + executeResult.Message;
                    RefundResultDAL.Update(resultInfo);

                    result.Status  = ResultStatus.Error;
                    result.Message = resultInfo.ResultDesc;
                    return(result);
                }

                //退款成功,解析返回参数
                resultInfo.RefundNo      = "";
                resultInfo.ExecuteResult = (int)ResultStatus.Success;

                result.Data   = this.GetRefundNotifyInfo(resultInfo, orderInfo.TradeNo);
                result.Status = ResultStatus.Success;
            }
            catch (Exception ex)
            {
                resultInfo.ExecuteResult = (int)ResultStatus.Error;
                resultInfo.ResultDesc    = ex.Message;
                RefundResultDAL.Update(resultInfo);

                result.Status  = ResultStatus.Error;
                result.Message = ex.Message;
            }
            return(result);
        }