package com.jeequan.jeepay.core.model.params.hmpay;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.annotate.ChannelMchId;
import com.jeequan.jeepay.core.constants.ChannelMchIdTypeEnum;
import com.jeequan.jeepay.core.model.params.IsvParams;
import com.jeequan.jeepay.core.utils.StringKit;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/**
 * 杉德[河马] 服务商配置
 *
 * @author xiaoyu
 *
 * @date 2022/3/8 14:45
 */
@Data
public class HmpayIsvParams extends IsvParams {

    /** 是否沙箱环境 */
    private Byte sandbox;

    /** 服务商ID */
    @ChannelMchId(type = ChannelMchIdTypeEnum.ISV_NO)
    private String appId;

    /** 支付产品编号 */
    private String productCode;

    /** 服务商私钥 */
    private String privateKey;

    /** 平台公钥 */
    private String publicKey;

    /** 微信开户意愿地址 */
    private String wxUrl;

    /** 支付宝商家认证地址 */
    private String aliUrl;

    @Override
    public String deSenData() {

        HmpayIsvParams isvParams = this;
        if (StringUtils.isNotBlank(this.privateKey)) {
            isvParams.setPrivateKey(StringKit.str2Star(this.privateKey, 4, 4, 6));
        }
        if (StringUtils.isNotBlank(this.publicKey)) {
            isvParams.setPublicKey(StringKit.str2Star(this.publicKey, 6, 6, 6));
        }
        return ((JSONObject) JSON.toJSON(isvParams)).toJSONString();
    }

}
