zoukankan      html  css  js  c++  java
  • 微信支付退款证书服务器配置

    1.需要去pay.weixin.com 下载证书

    2.解压 安装apiclient_cert.p12

    3.选择本地计算机

    4.下一步下一步  密码默认为商户号

     

    5.存储位置选个人

     

    6.打开MMC.exe  或者运行中输入MMC      点击  文件→添加或删除管理单元 →证书   选择计算机账户 下一步 完成

    7.点击 个人 →证书 →  选择微信支付证书  右键 管理私钥  添加IIS账户权限

    7.在请求API是添加证书文件  

    var certname="您公司的名字";

    var certnotbefore="证书的有效期";//腾讯比较变态  有二维码支付证书 app支付证书  公众号支付证书  证书的名字且都一样 为了能够公用一个退款接口且成功调用退款   我在请求时传入了证书名字 和 证书有效期 来区分是哪个支付的退款

    HttpWebResponse webreponse;

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
    //系统必须已经导入cert指向的证书
    string url = "https://api.mch.weixin.qq.com/secapi/pay/refund";
    X509Store store = new X509Store("My", StoreLocation.LocalMachine);
    store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
    store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
    X509Certificate2 cert = null;
    if (certnotbefore != null)
    foreach (X509Certificate2 certinfo in store.Certificates.Find(X509FindType.FindBySubjectName, certname, false))
    {
    if (certinfo.NotAfter == certnotbefore)
    cert = certinfo;
    }
    else
    cert = store.Certificates.Find(X509FindType.FindBySubjectName, certname, false)[0];
    HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(url);
    webrequest.ContentType = "application/x-www-form-urlencoded";
    webrequest.ClientCertificates.Add(cert);
    webrequest.Method = "post";
    webrequest.KeepAlive = true;

     8.赶紧测试一下吧 

    发现退款可以用了  

  • 相关阅读:
    SQL SERVER导入Excel csv
    微信付款码扫码枪支付
    idftp
    不正常地定义参数对象。提供了不一致或不完整的信息
    sql 日志文件截断收缩
    sql server 新语法 收藏
    SQL SERVER 2019新功能
    SQL SERVER 死锁
    rad 10.2
    TXMLDocument 创建空值节点不要缩写
  • 原文地址:https://www.cnblogs.com/xiaoxiangpaou/p/9799527.html
Copyright © 2011-2022 走看看