package com.fzm.mall.pay.util;//package com.fzm.mall.server.admin.pay.util;
//
//import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
//import com.wechat.pay.contrib.apache.httpclient.auth.AutoUpdateCertificatesVerifier;
//import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
//import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials;
//import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator;
//import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
//import org.apache.http.impl.client.CloseableHttpClient;
//import org.junit.After;
//import org.junit.Before;
//
//import java.io.ByteArrayInputStream;
//import java.io.IOException;
//import java.security.PrivateKey;
//
///**
// * @author wangp
// * @date 2021/3/19 18:20
// * @description
// * @since JDK 1.8
// */
//public class WechatPayUtil {
//
//    public static CloseableHttpClient httpClient;
//
//    @Before
//    public void setup() throws IOException {
//        // 加载商户私钥（privateKey：私钥字符串）
//        PrivateKey merchantPrivateKey = PemUtil.loadPrivateKey(new ByteArrayInputStream(privateKey.getBytes("utf-8")));
//
//        // 加载平台证书（mchId：商户号,mchSerialNo：商户证书序列号,apiV3Key：V3秘钥）
//        AutoUpdateCertificatesVerifier verifier = new AutoUpdateCertificatesVerifier(new WechatPay2Credentials(mchId,
//                new PrivateKeySigner(mchSerialNo, merchantPrivateKey)), apiV3Key.getBytes("utf-8"));
//
//        // 初始化httpClient
//        httpClient = WechatPayHttpClientBuilder.create().withMerchant(mchId, mchSerialNo, merchantPrivateKey)
//                .withValidator(new WechatPay2Validator(verifier)).build();
//    }
//
//    @After
//    public void after() throws IOException {
//        httpClient.close();
//    }
//
//
//}
