package com.ruoyi.app.omgpay;

/** Maps the App payment-method allowlist to one OMG hosted payment channel. */
public enum OmgPaymentMethod {
    CREDIT("Credit", true),
    APPLE_PAY("ApplePay", false);

    private final String choosePayment;
    private final boolean unionPayDisabled;

    OmgPaymentMethod(String choosePayment, boolean unionPayDisabled) {
        this.choosePayment = choosePayment;
        this.unionPayDisabled = unionPayDisabled;
    }

    public String getChoosePayment() {
        return choosePayment;
    }

    public boolean isUnionPayDisabled() {
        return unionPayDisabled;
    }

    public static OmgPaymentMethod require(String value) {
        try {
            return value == null ? invalid() : valueOf(value);
        } catch (IllegalArgumentException error) {
            return invalid();
        }
    }

    private static OmgPaymentMethod invalid() {
        throw new OmgPaymentBusinessException(OmgPaymentErrorCode.PAYMENT_METHOD_INVALID);
    }
}
