Alipay+ DocsAlipay+ Docs

ConfigProxy

Call the ConfigProxy SPI to remotely manage SDK configurations.

Method Signature

copy
public interface ConfigProxy {
    /**
     * Get config from cloud
     *
     * @param key          Key of the config
     * @param defaultValue Default value of config
     * @return Config data
     */
    @Nullable
    String getConfig(String key, @Nullable String defaultValue);

    /**
     * Get the boolean config data from cloud
     *
     * @param key          Key of the config
     * @param defaultValue Default value
     * @return Config data
     */
    boolean getConfigBoolean(String key, boolean defaultValue);

    /**
     * Get the JSONObject config
     *
     * @param key Key of the config
     * @return Config data, can be null
     */
    @Nullable
    JSONObject getConfigJSONObject(String key);

    /**
     * Get the JSONArray config
     *
     * @param key Key of the config
     * @return Config data, can be null
     */
    @Nullable
    JSONArray getConfigJSONArray(String key);
}

Request parameters

Item

Type

Parameters

Description

String getConfig(String key, @Nullable String defaultValue)

Function

String key

String defaultValue

Returns the configuration value associated with the specified key as a string.

boolean getConfigBoolean(String key, boolean defaultValue)

Function

String key

boolean defaultValue

Returns the configuration value associated with the specified key as a Boolean.

JSONObject getConfigJSONObject(String key)

Function

String key

Returns the configuration value associated with the specified key as a JSON object.

JSONArray getConfigJSONArray(String key)

Function

String key

Returns the configuration value associated with the specified key as a JSON array.

Response parameters

Item

Type

Description

String getConfig(String key, @Nullable String defaultValue)

String

Configuration data

boolean getConfigBoolean(String key, boolean defaultValue)

boolean

Boolean configuration data

JSONObject getConfigJSONObject(String key)

JSONObject

JSONObject configuration data

JSONArray getConfigJSONArray(String key)

JSONArray

JSONArray configuration data

More information

For detailed SDK configurations, see Environment configurations.

Sample

copy
public class NFCConfigProxyImpl implements ConfigProxy {

    @Nullable
    @Override
    public String getConfig(String s, @Nullable String s1) {
        if (s.equals("nfc_issue_config")) {
            return "{    \n" +
                    "            \"applyTokenTimes\": 25,\n" +
                    "            \"applyTokenInterval\": 2000,\n" +
                    "            \"activateTimes\": 7,\n" +
                    "            \"activateInterval\": 1000,\n" +
                    "            \"sessionTimes\": 7,\n" +
                    "            \"sessionInterval\": 1500\n" +
                    "        }";
        } else if (s.equals("nfc_transaction_config")) {
            return "{\n" +
                    "    \"isSupportTransit\": false,\n" +
                    "    \"asyncAmountLimitSwitch\": false,\n" +
                    "    \"canQueryAmountLimit\": false,\n" +
                    "    \"regionTBC\": [\"0344\"],\n" +
                    "  }";
        }
        return null;
    }

    @Override
    public boolean getConfigBoolean(String s, boolean b) {
        return false;
    }

    @Nullable
    @Override
    public JSONObject getConfigJSONObject(String s) {
        return null;
    }

    @Nullable
    @Override
    public JSONArray getConfigJSONArray(String s) {
        return null;
    }
}