using System; using System.Collections.Generic; using System.Configuration; using System.IO; using System.Linq; using System.Web; namespace Central.Control.WebApi.Config { /// /// /// public class AliPayConfig { /// /// 支付宝公钥 /// public static string alipay_public_key = ConfigurationManager.AppSettings["alipay_public_key"].ToString(); /// /// 开发者私钥 /// public static string merchant_private_key = ConfigurationManager.AppSettings["alipay_merchant_private_key"].ToString(); /// /// 开发者公钥 /// public static string merchant_public_key = ConfigurationManager.AppSettings["alipay_merchant_public_key"].ToString(); /// /// 应用ID /// public static string appId = ConfigurationManager.AppSettings["alipay_appId"].ToString(); /// /// 合作伙伴ID:partnerID /// public static string pid = ConfigurationManager.AppSettings["alipay_partnerId"].ToString(); /// /// 支付宝网关 /// public static string serverUrl = ConfigurationManager.AppSettings["alipay_serverUrl"].ToString(); public static string mapiUrl = "https://mapi.alipay.com/gateway.do"; public static string monitorUrl = "http://mcloudmonitor.com/gateway.do"; //编码,无需修改 public static string charset = "utf-8"; //签名类型,支持RSA2(推荐!)、RSA //public static string sign_type = "RSA2"; public static string sign_type = "RSA2"; //版本号,无需修改 public static string version = "1.0"; /// /// 公钥文件类型转换成纯文本类型 /// /// 过滤后的字符串类型公钥 public static string getMerchantPublicKeyStr() { StreamReader sr = new StreamReader(merchant_public_key); string pubkey = sr.ReadToEnd(); sr.Close(); if (pubkey != null) { pubkey = pubkey.Replace("-----BEGIN PUBLIC KEY-----", ""); pubkey = pubkey.Replace("-----END PUBLIC KEY-----", ""); pubkey = pubkey.Replace("\r", ""); pubkey = pubkey.Replace("\n", ""); } return pubkey; } /// /// 私钥文件类型转换成纯文本类型 /// /// 过滤后的字符串类型私钥 public static string getMerchantPriveteKeyStr() { StreamReader sr = new StreamReader(merchant_private_key); string pubkey = sr.ReadToEnd(); sr.Close(); if (pubkey != null) { pubkey = pubkey.Replace("-----BEGIN PUBLIC KEY-----", ""); pubkey = pubkey.Replace("-----END PUBLIC KEY-----", ""); pubkey = pubkey.Replace("\r", ""); pubkey = pubkey.Replace("\n", ""); } return pubkey; } } }