123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.IO;
- using System.Linq;
- using System.Web;
- namespace Central.Control.WebApi.Config
- {
- /// <summary>
- ///
- /// </summary>
- public class AliPayConfig
- {
- /// <summary>
- /// 支付宝公钥
- /// </summary>
- public static string alipay_public_key = ConfigurationManager.AppSettings["alipay_public_key"].ToString();
- /// <summary>
- /// 开发者私钥
- /// </summary>
- public static string merchant_private_key = ConfigurationManager.AppSettings["alipay_merchant_private_key"].ToString();
- /// <summary>
- /// 开发者公钥
- /// </summary>
- public static string merchant_public_key = ConfigurationManager.AppSettings["alipay_merchant_public_key"].ToString();
- /// <summary>
- /// 应用ID
- /// </summary>
- public static string appId = ConfigurationManager.AppSettings["alipay_appId"].ToString();
- /// <summary>
- /// 合作伙伴ID:partnerID
- /// </summary>
- public static string pid = ConfigurationManager.AppSettings["alipay_partnerId"].ToString();
- /// <summary>
- /// 支付宝网关
- /// </summary>
- 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";
- /// <summary>
- /// 公钥文件类型转换成纯文本类型
- /// </summary>
- /// <returns>过滤后的字符串类型公钥</returns>
- 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;
- }
- /// <summary>
- /// 私钥文件类型转换成纯文本类型
- /// </summary>
- /// <returns>过滤后的字符串类型私钥</returns>
- 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;
- }
- }
- }
|