Starts initialization process with PayStore and Acquirer¶
This method must be called to initialize the terminal with Paystore and the acquirer(s) installed.
Upon initialization, the terminal first registers with Paystore, either by sending the token or by joining the portal. It then receives the initialization parameters, such as which acquirers are configured, urls for communicating with the acquirers, enabled products, etc. After this step, the terminal initializes with the acquirers enabled, at this point it receives specific configurations for each acquirer, such as AID tables, products, bins and configurations related to the transactional flow.
Methods¶
| Signature | Description |
|---|---|
void startInitialization(String activityAction, PaymentCallback paymentCallback) |
Starts the initialization process with Paystore and Acquirer. |
void startInitialization(InitializationRequest initializationRequest, PaymentCallback paymentCallback) |
Starts the initialization process with Paystore and Acquirer, using InitializationRequest. |
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
activityAction |
String |
Yes | Action of the external application's activity that must be called after initialization is complete. |
callback |
PaymentCallback |
Yes | Interface that will be executed for success or error notifications. |
initializationRequest |
InitializationRequest |
Yes | Data transfer object that will contain the initialization request information. |
paymentCallback |
PaymentCallback |
Yes | Interface that will be executed for success or error notifications. |
Parameter details
callback
| Name | Type | Mandatory | Description |
|---|---|---|---|
onSuccess |
Method for notification on success | ||
onError |
Method for notification in case of error. | ||
ErrorData.paymentsResponseCode |
String |
Yes | Response code for the error that occurred. See Response Codes |
ErrorData.responseMessage |
String |
Yes | Descriptive message of the reason for the non-authorization. If the transaction was denied by the acquirer, it will contain the message returned by the acquirer. |
request (InitializationRequest)
| Name | Type | Mandatory | Description |
|---|---|---|---|
activityAction |
String |
No | Action of the external application that must be called after initialization is complete. |
installToken |
String |
No | Installation Token for terminal accreditation at Paystore. This parameter will only be considered on the first startup of the terminal. |
Example¶
public class MyActivity extends Activity implements PaymentClient.PaymentCallback {
private PaymentClient paymentClient;
private String action = "br.com.phoebus.payments.demo.ACTION_INITIALIZE";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_payment);
paymentClient = new PaymentClientImpl();
}
@Override
protected void onResume() {
super.onResume();
paymentClient.bind(this);
}
@Override
protected void onDestroy() {
try {
paymentClient.unbind(this);
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
super.onDestroy();
}
public void doExecute(){
InitializationRequest request = new InitializationRequest();
request.setInstallToken("1a2b3cdef");
request.setActivityAction("123456abcde");
ApplicationInfo appInfo = new ApplicationInfo();
appInfo.setCredentials(new Credentials("demo-app", "TOKEN-KEY-DEMO"));
appInfo.setSoftwareVersion("1.0.0.0");
try {
paymentClient.startInitialization(request, this);
} catch (ClientException e) {
Log.e(TAG, "Error while initialization.", e);
}
}
@Override
public void onError(ErrorData errorData) {
Log.e(TAG, "Error: " + errorData.getResponseMessage());
}
@Override
public void onSuccess(Object data) {
Log.i(TAG, "Success!");
}
}