예제 #1
0
        public static string MakeAliPayOrder(string companyId, AlipayTradeOrderModel model)
        {
            try
            {
                AliPayApiConfig config = AliPayApiConfigServices.QueryAliPayConfig(companyId);
                if (config == null)
                {
                    throw new MyException("获取支付宝配置失败");
                }

                string aliPayNotifyUrl           = string.Format("{0}/AliPayNotify", config.SystemDomain);
                AlipayTradeCreateRequest request = new AlipayTradeCreateRequest();
                request.BizContent = JsonHelper.GetJsonString(model);
                request.SetNotifyUrl(aliPayNotifyUrl);
                AlipayTradeCreateResponse response = GetDefaultAopClient(companyId).Execute(request);
                if (response.IsError)
                {
                    TxtLogServices.WriteTxtLogEx("AliPayApiServices", string.Format("统一下单失败1:{0}", response.Body));
                    return("");
                }
                return(response.TradeNo);
            }
            catch (Exception ex)
            {
                TxtLogServices.WriteTxtLogEx("AliPayApiServices", string.Format("统一下单失败2:{0}", ex.Message));
            }
            return("");
        }