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

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;

/**
 * PayerMax支付 isv参数定义
 *
 * @author zx
 *
 * @date 2022/9/20 14:16
 */
@Data
public class PmpayIsvParams extends IsvParams {

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

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

    /** 服务商应用AppId */
    private String appId;

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

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

    @Override
    public String deSenData() {
        PmpayIsvParams isvParams = this;
        if (StringUtils.isNotBlank(this.privateKey)) {
            isvParams.setPrivateKey(StringKit.autoDesensitization(this.privateKey));
        }
        if (StringUtils.isNotBlank(this.publicKey)) {
            isvParams.setPublicKey(StringKit.autoDesensitization(this.publicKey));
        }
        return ((JSONObject) JSON.toJSON(isvParams)).toJSONString();
    }
}
