fly hai 1 ano
pai
achega
68f8818962
Modificáronse 2 ficheiros con 30 adicións e 4 borrados
  1. 4 2
      Common/AlipayCommon.cs
  2. 26 2
      Service/PaymentService.cs

+ 4 - 2
Common/AlipayCommon.cs

@@ -39,7 +39,7 @@ namespace WingPaymentService.Common
         /// <param name="totalAmount"></param>
         /// <param name="recordCode"></param>
         /// <returns></returns>
-        public (string, string) AlipayPagePay(string subject, double totalAmount, string recordCode)
+        public (string, string) AlipayPagePay(string subject, double totalAmount, string recordCode, string payReturnUrl)
         {
             try
             {
@@ -69,6 +69,7 @@ namespace WingPaymentService.Common
                 request.SetNotifyUrl(_notifyUrl);
                 request.SetProdCode("FAST_INSTANT_TRADE_PAY");
                 request.SetBizModel(model);
+                request.SetReturnUrl(payReturnUrl);
                 // 3. 发起请求并处理响应
                 Aop.Api.Response.AlipayTradePagePayResponse response = client.SdkExecute(request);
                 if (!response.IsError)
@@ -106,7 +107,7 @@ namespace WingPaymentService.Common
         /// <param name="totalAmount"></param>
         /// <param name="recordCode"></param>
         /// <returns></returns>
-        public (string, string) AlipayWapPay(string subject, double totalAmount, string recordCode)
+        public (string, string) AlipayWapPay(string subject, double totalAmount, string recordCode, string payReturnUrl)
         {
             try
             {
@@ -136,6 +137,7 @@ namespace WingPaymentService.Common
                 request.SetNotifyUrl(_notifyUrl);
                 request.SetProdCode("QUICK_WAP_WAY");
                 request.SetBizModel(model);
+                request.SetReturnUrl(payReturnUrl);
                 // 3. 发起请求并处理响应
                 Aop.Api.Response.AlipayTradeWapPayResponse response = client.SdkExecute(request);
                 if (!response.IsError)

+ 26 - 2
Service/PaymentService.cs

@@ -26,6 +26,10 @@ namespace WingPaymentService.Service
     {
         private string _alipayShortBaseUrl => EnvironmentConfigManager.GetParammeter<StringParameter>("Alipay", "PayShortBaseUrl").Value;
         private string _wechatShortBaseUrl => EnvironmentConfigManager.GetParammeter<StringParameter>("WeChat", "PayShortBaseUrl").Value;
+        private string _alipayPayReturnUrl => EnvironmentConfigManager.GetParammeter<StringParameter>("Alipay", "PayReturnUrl").Value;
+        private string _wechatPayReturnUrl => EnvironmentConfigManager.GetParammeter<StringParameter>("WeChat", "PayReturnUrl").Value;
+        private bool _alipayPayEnable => EnvironmentConfigManager.GetParammeter<BoolParameter>("Alipay", "Enable").Value;
+        private bool _wechatPayEnable => EnvironmentConfigManager.GetParammeter<BoolParameter>("WeChat", "Enable").Value;
         private IEducationService _educationService;
         private IAuthenticationService _authenticationService;
         private IPaymentDBService _paymentDBService;
@@ -113,7 +117,7 @@ namespace WingPaymentService.Service
                     {
                         case PayTypeEnum.Alipay_PAGE:
                             _recordRelation.AddOrUpdate(recordCode, request.OrderCode, (a,b)=> { return request.OrderCode; });
-                            payContent = _alipayCommon.AlipayPagePay(orderInfo.OrderTitle, orderInfo.OrderAmount, recordCode);
+                            payContent = _alipayCommon.AlipayPagePay(orderInfo.OrderTitle, orderInfo.OrderAmount, recordCode, _alipayPayReturnUrl);
                             payUrlRequest.PaymentOrderCode = request.OrderCode;
                             payUrlRequest.PayLink = payContent.payUrl;
                             payUrlRequest.PayShortLink = string.Format(_alipayShortBaseUrl, payUrlRequest.PaymentOrderCode);
@@ -125,7 +129,7 @@ namespace WingPaymentService.Service
                             break;
                         case PayTypeEnum.Alipay_WAP:
                             _recordRelation.AddOrUpdate(recordCode, request.OrderCode, (a,b)=> { return request.OrderCode; });
-                            payContent = _alipayCommon.AlipayWapPay(orderInfo.OrderTitle, orderInfo.OrderAmount, recordCode);
+                            payContent = _alipayCommon.AlipayWapPay(orderInfo.OrderTitle, orderInfo.OrderAmount, recordCode, _alipayPayReturnUrl);
                             payUrlRequest.PaymentOrderCode = request.OrderCode;
                             payUrlRequest.PayLink = payContent.payUrl;
                             payUrlRequest.PayShortLink = string.Format(_alipayShortBaseUrl, payUrlRequest.PaymentOrderCode);
@@ -205,6 +209,26 @@ namespace WingPaymentService.Service
             }
         }
 
+        /// <summary>
+        /// 获取可支付列表
+        /// </summary>
+        /// <returns></returns>
+        public Task<PayableTypeDTO> GetPayableTypes()
+        {
+            var payTypes = new List<string>();
+            if(_alipayPayEnable)
+            {
+                payTypes.Add("alipay");
+            }
+            if(_wechatPayEnable)
+            {
+                payTypes.Add("wechat");
+            }
+            var result = new PayableTypeDTO();
+            result.PayTypes = payTypes;
+            return result;
+        }
+
         /// <summary>
         /// 支付宝回调
         /// </summary>