发布:2020/4/26 11:45:22作者:管理员 来源:本站 浏览次数:1147
//支付宝
根据官网接口参数传即可
// private static string appId="XXX";//appid private static string privateKeyPem="XXX";//私钥 private static string AlipublicKey="XXX";//公钥 public static string AliRefundMoney(string out_trade_no, int refund_amount) { string out_request_no = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss:ffff"); IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", appId, privateKeyPem, "json", "1.0", "RSA2", AlipublicKey, "UTF-8", false); AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); request.BizContent = "{" + "\"out_trade_no\":\"" + out_trade_no + "\"," + "\"trade_no\":\"\"," + "\"refund_amount\":" + refund_amount / 100 + "," + //同一笔需要多次退款时候需要 "\"out_request_no\":\"" + out_request_no + "\"" + ///每次需要不一样 不然不会退款成功(可以用退款表中的id或者时分秒) "}"; AlipayTradeRefundResponse response = client.Execute(request); // this.body = response.Body; return response.Body; }
//微信
特别注意:微信退款时需要证书,微信公众平台下载证书并点击安装到相应的服务器或者本地计算机上即可
服务器和本地测试的证书引入有差别
//未引入证书或引入错误会提示连接被关闭
1 X509Certificate2 cer = new X509Certificate2("D:/apiclient_cert.p12", 商户号, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);//线上发布需要添加的 2 // X509Certificate cer = new X509Certificate("D:/apiclient_cert.p12", 商户号);//线下发布需要添加的
© Copyright 2014 - 2024 柏港建站平台 ejk5.com. 渝ICP备16000791号-4