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

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 zx
 * 
 * @date 2023/5/22 18:02
 */
@Data
public class SxfpayIsvParams extends IsvParams {

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

    /** 天阙平台机构号 **/
    @ChannelMchId(type = ChannelMchIdTypeEnum.ISV_NO)
    private String orgId;

    /** privateKey 私钥 **/
    private String privateKey;

    /** publicKey 随行付公钥 **/
    private String publicKey;

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

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

    @Override
    public String deSenData() {

        SxfpayIsvParams 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();
    }

}
