164 lines
5.3 KiB
C#
164 lines
5.3 KiB
C#
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace MobilePayCheck
|
|
{
|
|
public class MobilePayInit
|
|
{
|
|
/// <summary>
|
|
/// 移动支付服务地址列表
|
|
/// </summary>
|
|
public ConcurrentDictionary<MobilePayOperators, string> PayServiceList { get; set; }
|
|
|
|
/// <summary>
|
|
/// 初始化移动支付通道信息
|
|
/// </summary>
|
|
/// <param name="serviceIP"></param>
|
|
/// <param name="servicePort"></param>
|
|
/// <returns></returns>
|
|
public bool MobilePayServiceInit(string serviceIP, string[] servicePort)
|
|
{
|
|
if (PayServiceList == null)
|
|
{
|
|
PayServiceList = new ConcurrentDictionary<MobilePayOperators, string>();
|
|
}
|
|
for (int i = 0; i < servicePort.Count(); i++)
|
|
{
|
|
//初始化支付服务接口列表,本地使用传入端口信息即可
|
|
GetMobilePayOperators(serviceIP, servicePort[i], "888888", "042002");
|
|
}
|
|
return true;
|
|
}
|
|
/// <summary>
|
|
/// 获取移动支付通道信息
|
|
/// </summary>
|
|
/// <param name="servierIp"></param>
|
|
/// <param name="servicePort"></param>
|
|
/// <param name="serverPartCode"></param>
|
|
/// <param name="shopCode"></param>
|
|
private void GetMobilePayOperators(string servierIp, string servicePort, string serverPartCode, string shopCode)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(servicePort))
|
|
{
|
|
string retString = "";
|
|
try
|
|
{
|
|
string _strServiceURL = string.Format("http://{0}:{1}/service.asmx", servierIp, servicePort);
|
|
if (!PayServiceList.Values.Contains(_strServiceURL))
|
|
{
|
|
System.Collections.Hashtable hashtable = new System.Collections.Hashtable
|
|
{
|
|
{ "serverPartCode", serverPartCode },
|
|
{ "shopCode", shopCode }
|
|
};
|
|
retString = SoapWSHelper.QuerySoapWebServiceString(_strServiceURL, "GetMerchant", hashtable);
|
|
if (retString.Trim() != "")
|
|
{
|
|
JObject _JObject = JObject.Parse(retString);
|
|
string TradeOn = _JObject["trade_no"].ToString();
|
|
string TradeNum = _JObject["trade_num"].ToString();
|
|
string ResultDesc = _JObject["result_desc"].ToString();
|
|
string ResultCode = _JObject["result_code"].ToString();
|
|
|
|
if (Enum.TryParse(ResultDesc, out MobilePayOperators _MobilePayOperators))
|
|
{
|
|
PayServiceList.AddOrUpdate(_MobilePayOperators, _strServiceURL, (operators, serviceURL) => _strServiceURL);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteSendLog($"通道{servicePort}信息初始化失败:" + ex.Message);
|
|
}
|
|
}
|
|
}
|
|
|
|
#region 移动支付提供商
|
|
/// <summary>
|
|
/// 移动支付提供商
|
|
/// </summary>
|
|
public enum MobilePayOperators
|
|
{
|
|
/// <summary>
|
|
/// 富友
|
|
/// </summary>
|
|
[Description("富友")]
|
|
fuiou = 1001,
|
|
|
|
/// <summary>
|
|
/// 众码付
|
|
/// </summary>
|
|
[Description("众码付")]
|
|
zhongmapay = 1002,
|
|
|
|
/// <summary>
|
|
/// 威付通
|
|
/// </summary>
|
|
[Description("威付通")]
|
|
swiftpass = 1003,
|
|
|
|
/// <summary>
|
|
/// 付付
|
|
/// </summary>
|
|
[Description("付付")]
|
|
ffdzpay = 1004,
|
|
|
|
/// <summary>
|
|
/// 客无忧
|
|
/// </summary>
|
|
[Description("客无忧")]
|
|
kwypay = 1005,
|
|
|
|
/// <summary>
|
|
/// 通联支付
|
|
/// </summary>
|
|
[Description("通联支付")]
|
|
allinpay = 1006,
|
|
|
|
/// <summary>
|
|
/// 银联支付
|
|
/// </summary>
|
|
[Description("银联支付")]
|
|
unionpay = 1007,
|
|
|
|
/// <summary>
|
|
/// 南京银行
|
|
/// </summary>
|
|
[Description("南京银行")]
|
|
irichpay = 1008,
|
|
|
|
/// <summary>
|
|
/// 建设银行
|
|
/// </summary>
|
|
[Description("建设银行")]
|
|
ccbpay =1009,
|
|
|
|
/// <summary>
|
|
/// 贵州农信
|
|
/// </summary>
|
|
[Description("贵州农信")]
|
|
gznxpay = 1010,
|
|
|
|
/// <summary>
|
|
/// 工商银行
|
|
/// </summary>
|
|
[Description("工商银行")]
|
|
icbcpay = 1011,
|
|
|
|
/// <summary>
|
|
/// 重庆嗨客
|
|
/// </summary>
|
|
[Description("重庆嗨客")]
|
|
uphicoo = 1012
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|