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
{
///
/// 移动支付服务地址列表
///
public ConcurrentDictionary PayServiceList { get; set; }
///
/// 初始化移动支付通道信息
///
///
///
///
public bool MobilePayServiceInit(string serviceIP, string[] servicePort)
{
if (PayServiceList == null)
{
PayServiceList = new ConcurrentDictionary();
}
for (int i = 0; i < servicePort.Count(); i++)
{
//初始化支付服务接口列表,本地使用传入端口信息即可
GetMobilePayOperators(serviceIP, servicePort[i], "888888", "042002");
}
return true;
}
///
/// 获取移动支付通道信息
///
///
///
///
///
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 移动支付提供商
///
/// 移动支付提供商
///
public enum MobilePayOperators
{
///
/// 富友
///
[Description("富友")]
fuiou = 1001,
///
/// 众码付
///
[Description("众码付")]
zhongmapay = 1002,
///
/// 威付通
///
[Description("威付通")]
swiftpass = 1003,
///
/// 付付
///
[Description("付付")]
ffdzpay = 1004,
///
/// 客无忧
///
[Description("客无忧")]
kwypay = 1005,
///
/// 通联支付
///
[Description("通联支付")]
allinpay = 1006,
///
/// 银联支付
///
[Description("银联支付")]
unionpay = 1007,
///
/// 南京银行
///
[Description("南京银行")]
irichpay = 1008,
///
/// 建设银行
///
[Description("建设银行")]
ccbpay =1009,
///
/// 贵州农信
///
[Description("贵州农信")]
gznxpay = 1010,
///
/// 工商银行
///
[Description("工商银行")]
icbcpay = 1011,
///
/// 重庆嗨客
///
[Description("重庆嗨客")]
uphicoo = 1012
}
#endregion
}
}