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

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

/**
 * 米花支付 isv参数定义
 *
 * @author yr
 *
 * @date 2022/9/20 14:16
 */
@Data
public class MbpayIsvParams extends IsvParams {

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

    /** 私钥 */
    private String privateKey;

    /** 公钥 */
    private String mbPublicKey;

    @Override
    public String deSenData() {
        MbpayIsvParams mchParams = this;
        if (StringUtils.isNotBlank(this.privateKey)) {
            mchParams.setPrivateKey(StringKit.autoDesensitization(this.privateKey));
        }
        if (StringUtils.isNotBlank(this.mbPublicKey)) {
            mchParams.setMbPublicKey(StringKit.autoDesensitization(this.mbPublicKey));
        }
        return ((JSONObject) JSON.toJSON(mchParams)).toJSONString();
    }
}
