C# 中ICanPay的使用
1: 支付宝的使用
services.AddICanPay(a =>
{
var gateways = new Gateways();
gateways.Add(new AlipayGateway(new Merchant
{
AppId = "2018021002174688",
NotifyUrl = "http://apitest.maimaiba.shop/payment/alipaynotify",
ReturnUrl = "http://localhost:38823/Notify",
AlipayPublicKey = "",
Privatekey = @"",
})
{
GatewayUrl = "https://openapi.alipay.com/",
//GatewayUrl = "https://openapi.alipaydev.com/",
//GatewayUrl = "https://openapi.alipay.com/gateway.do",
});
gateways.Add(new WechatpayGateway(new ICanPay.Wechatpay.Merchant()
{
AppId = "wx2428e34e0e7dc6ef",
MchId = "1233410002",
Key = "e10adc3849ba56abbe56e056f20f883e",
AppSecret = "51c56b886b5be869567dd389b3e5d1d6",
SslCertPath = "Certs/apiclient_cert.p12",
SslCertPassword = "1233410002",
NotifyUrl = "http://localhost:38823/Notify"
}));
return gateways;
});
1: 沙箱测试:
GatewayUrl = GatewayUrl = "https://openapi.alipaydev.com/"
gateways.Add(new AlipayGateway(new Merchant
{
AppId = "2016081600256163",
NotifyUrl = "http://localhost:38823/Notify",
ReturnUrl = "http://localhost:38823/Notify",
AlipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsW6+mN2E3Oji2DPjSKuYgRzK6MlH9q6W0iM0Yk3R0qbpp5wSesSXqudr2K25gIBOTCchiIbXO7GXt/zEdnhnC32eOaTnonDsnuBWIp+q7LoVx/gvKIX5LTHistCvGli8VW4EDGsu2jAyQXyMPgPrIz+/NzgQIDAQAB",
Privatekey = "MIIEpAIBAAKCAQEAyC43UbsE5XZ2Pmqg1YgzeCqAMk4HOH8fYHslseeSgKxyDjybjqM0yjGIJry1FRmVvLnY7v8jURgwr7d/pDCSRdoHa6zaxuSzg0OlieNmujae34YZ54PmFxULZW0BHSdzmx3OIYK2GarRECkds531ZzpbLdRXqsxQf5G26JZLIFxmNuh/VjBjJ6Hic1WOFT+FCYyi8om+LkPn3jELeA7LPLXzFqzzxx0vo4yiAePrsX5WucWxf+Y8rZoDhRIy/cPtQECXi9SiAWOJe/82JqjVjfpowf3QN7UJHsA82RBloAS4lvvDGJA7a+8DDlqpqPer8cS41Dv5r39iqtJUybDqoQIDAQABAoIBAHi39kBhiihe8hvd7bQX+QIEj17G02/sqZ1jZm4M+rqCRB31ytGP9qvghvzlXEanMTeo0/v8/O1Qqzusa1s2t19MhqEWkrDTBraoOtIWwsKVYeXmVwTY9A8Db+XwgHV2by8iIEbxLqP38S/Pu8uv/GgONyJCJcQohnsIAsfsqs2OGggz+PplZaXJfUkPomWkRdHM9ZWWDLrCIlmRSHLmhHEtFJaXD083kqo437qra58Amw/n+2gH57utbAQ9V3YQFjD8zW511prC+mB6N/WUlaLstkxswGJ16obEJfQ0r8wYHx14ep6UKGyi3YXlMHcteI8gz+uFx4RuVV9EotdXagECgYEA7AEz9oPFYlW1H15fvQQ0n+viyQXcj6TVVOSnf6X5MRC8MYmBHTbHA8+59bSAfanO/l7muwQQro+6TlUVMyaviLvjlwpxV/sACXC6jCiO06IqreIbXdlJ41RBw2op0Ss5gM5pBRLUS58V+HP7GBWKrnrofofXtAq6zZ8txok4EQKBgQCXrTeGMs7ECfehLz64qZtPkiQbNwupg938Z40Qru/G1GR9u0kmN7ibTyYauI6NNVHGEZa373EBEkacfN+kkkLQMs1tj5Zrlw+iITm+ad/irpXQZS/NHCcrg6h82vu0LcgiKnHKlmW6K5ne0w4LqmsmRCm7JdJjt9WlapAs0ticiw==",
})
2: 正式上线:
GatewayUrl = GatewayUrl = GatewayUrl = "https://openapi.alipay.com/"
gateways.Add(new AlipayGateway(new Merchant
{
AppId = "201**********88",
NotifyUrl = "http://******************/alipaynotify",
ReturnUrl = "http://**********/Notify",
AlipayPublicKey = "",
Privatekey = @"",
})
其中: NotifyUrl为支付宝通知应用的地址
ReturnUrl为回调地址
AlipayPublicKey为支付宝公钥,而不是应用公钥
PrivateKey:是由工具生成的,工具介绍与下载地址:https://docs.open.alipay.com/291/106097/,
把生成的商户公钥改成线上创建应用的应用公钥, 私钥要自己保存
参考链接: https://www.cnblogs.com/varorbc/p/7890331.html