// Path: ymate-payment-wxpay/src/main/java/net/ymate/payment/wxpay/request/WxPaySandboxSignKey.java
// public class WxPaySandboxSignKey extends WxPayBaseRequest<WxPaySandboxSignKey.Response> {
// 
//     public WxPaySandboxSignKey(WxPayAccountMeta accountMeta) {
//         super(accountMeta);
//     }
// 
//     @Override
//     protected String __doGetRequestURL() {
//         return "https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey";
//     }
// 
//     @Override
//     protected Response __doParseResponse(IHttpResponse httpResponse) throws Exception {
//         return new Response(httpResponse.getContent());
//     }
// 
//     /**
//      * 获取验签环境密钥响应
//      */
//     public static class Response extends WxPayBaseResponse {
// 
//         private String signkey;
// 
//         public Response(String protocol) throws Exception {
//             super(protocol);
//             this.signkey = BlurObject.bind(this.getResponseParams().get("sandbox_signkey")).toStringValue();
//         }
// 
//         public String signkey() {
//             return signkey;
//         }
//     }
// }


import net.ymate.framework.commons.HttpClientHelper;
import net.ymate.payment.wxpay.request.WxPaySandboxSignKey;
import net.ymate.platform.core.util.RuntimeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import java.io.Serializable;
import java.net.URL;
/*
 * Copyright 2007-2017 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.ymate.payment.wxpay.base;



/**
 * @author 刘镇 (suninformation@163.com) on 17/6/15 下午1:24
 * @version 1.0
 */
public class WxPayAccountMeta implements Serializable {

    private static final Log _LOG = LogFactory.getLog(WxPayAccountMeta.class);

    /**
     * 公众帐号APP_ID
     */
    private String appId;

    /**
     * 商户号
     */
    private String mchId;

    /**
     * 商号密钥
     */
    private String mchKey;

    /**
     * 证书文件路径
     */
    private String certFilePath;

    /**
     * 是否开启沙箱测试模式, 默认值: false
     */
    private boolean sandboxEnabled;

    /**
     * 获取沙箱测试模式下的接口URL地址前缀, 默认值: sandboxnew
     */
    private String sandboxPrefix;

    private SSLConnectionSocketFactory connectionSocketFactory;

    /**
     * 异步通知URL
     */
    private String notifyUrl;

    public WxPayAccountMeta(String appId, String mchId, String mchKey, String notifyUrl) {
        this.appId = appId;
        this.mchId = mchId;
        this.mchKey = mchKey;
        this.notifyUrl = notifyUrl;
    }

    public WxPayAccountMeta(String appId, String mchId, String mchKey, String certFilePath, String notifyUrl) {
        this.appId = appId;
        this.mchId = mchId;
        this.mchKey = mchKey;
        this.certFilePath = certFilePath;
        this.notifyUrl = notifyUrl;
    }

    private void __doGetSandboxSignKeyIfNeed() {
        if (sandboxEnabled) {
            try {
// Path: ymate-payment-wxpay/src/main/java/net/ymate/payment/wxpay/request/WxPaySandboxSignKey.java
// public class WxPaySandboxSignKey extends WxPayBaseRequest<WxPaySandboxSignKey.Response> {
// 
//     public WxPaySandboxSignKey(WxPayAccountMeta accountMeta) {
//         super(accountMeta);
//     }
// 
//     @Override
//     protected String __doGetRequestURL() {
//         return "https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey";
//     }
// 
//     @Override
//     protected Response __doParseResponse(IHttpResponse httpResponse) throws Exception {
//         return new Response(httpResponse.getContent());
//     }
// 
//     /**
//      * 获取验签环境密钥响应
//      */
//     public static class Response extends WxPayBaseResponse {
// 
//         private String signkey;
// 
//         public Response(String protocol) throws Exception {
//             super(protocol);
//             this.signkey = BlurObject.bind(this.getResponseParams().get("sandbox_signkey")).toStringValue();
//         }
// 
//         public String signkey() {
//             return signkey;
//         }
//     }
// }


// Path: ymate-payment-wxpay/src/main/java/net/ymate/payment/wxpay/base/WxPayAccountMeta.java
import net.ymate.framework.commons.HttpClientHelper;
import net.ymate.payment.wxpay.request.WxPaySandboxSignKey;
import net.ymate.platform.core.util.RuntimeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import java.io.Serializable;
import java.net.URL;

/*
 * Copyright 2007-2017 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.ymate.payment.wxpay.base;



/**
 * @author 刘镇 (suninformation@163.com) on 17/6/15 下午1:24
 * @version 1.0
 */
public class WxPayAccountMeta implements Serializable {

    private static final Log _LOG = LogFactory.getLog(WxPayAccountMeta.class);

    /**
     * 公众帐号APP_ID
     */
    private String appId;

    /**
     * 商户号
     */
    private String mchId;

    /**
     * 商号密钥
     */
    private String mchKey;

    /**
     * 证书文件路径
     */
    private String certFilePath;

    /**
     * 是否开启沙箱测试模式, 默认值: false
     */
    private boolean sandboxEnabled;

    /**
     * 获取沙箱测试模式下的接口URL地址前缀, 默认值: sandboxnew
     */
    private String sandboxPrefix;

    private SSLConnectionSocketFactory connectionSocketFactory;

    /**
     * 异步通知URL
     */
    private String notifyUrl;

    public WxPayAccountMeta(String appId, String mchId, String mchKey, String notifyUrl) {
        this.appId = appId;
        this.mchId = mchId;
        this.mchKey = mchKey;
        this.notifyUrl = notifyUrl;
    }

    public WxPayAccountMeta(String appId, String mchId, String mchKey, String certFilePath, String notifyUrl) {
        this.appId = appId;
        this.mchId = mchId;
        this.mchKey = mchKey;
        this.certFilePath = certFilePath;
        this.notifyUrl = notifyUrl;
    }

    private void __doGetSandboxSignKeyIfNeed() {
        if (sandboxEnabled) {
            try {
                WxPaySandboxSignKey _request = new WxPaySandboxSignKey(this);