PayStore Additional Fields Query¶
PayStore uses a powerful resource to pass parameters registered in the Server to be used by the terminals, without having to change the Startup message. This brings enormous flexibility for creating new features in apps.
Additional Fields (also called Parameters) are information that can be registered in the PayStore Portal, and can be configured for all merchants and facilitator terminals, for a specific group of merchants, for a merchant (affects all terminals of that merchant) or to a specific terminal. This information can be read by an application through Providers.
The ConfigurationStoreContract class is responsible for providing this information. Below is an example of its implementation:
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import br.com.phoebus.android.payments.api.provider.ConfigurationStoreContract;
public class ConfigController {
private Context context;
public ConfigController(Context context) {
this.context = context;
}
public String getProperty(String key) {
Uri.Builder uriBuilder = ConfigurationStoreContract.getUriBuilder();
uriBuilder.appendQueryParameter(ConfigurationStoreContract.column.KEY, key);
ContentResolver resolver = this.context.getContentResolver();
String value = null;
try (Cursor query = resolver.query(uriBuilder.build(), null, null, null, null)) {
if (query != null && query.moveToFirst()) {
value = query.getString(query.getColumnIndex(ConfigurationStoreContract.column.VALUE));
}
}
return value;
}
}
To use this class, just use the key previously defined in the Additional Fields as a parameter, as shown below:
ConfigController config = new ConfigController(mContext);
String conteudoCampoAdicional = config.getProperty("sua_chave");