Ir para o conteúdo

Open Batch

[DEPRECATED] openBatch()


This method allows opening a batch with a specific number.

Methods

Signature Description
void openBatch(OpenBatchRequest request, PaymentCallback<OpenBatchResponse> paymentCallback) Opens the batch with a specific number.

Parameters

Name Type Mandatory Description
request OpenBatchRequest Yes Data transfer object that will contain the batch request information.
callback PaymentCallback Yes Interface that will be executed for success or error notifications during the batch opening process.

Detail Parameters request (OpenBatchRequest)

Name Type Mandatory Description
ApplicationInfo.credentials Credentials Yes Credentials of the application requesting the operation, as registered in PayStore. Essentially, it is the application's identification and the access token.
ApplicationInfo.softwareVersion String Yes Version of the application requesting the batch.
batchNumber long No Specific batch number.

callback (PaymentCallback)

Name Type Mandatory Description
onSuccess Method for notification in case of success.
OpenBatchResponse.batchNumber String Yes Returns the number of the opened batch.
onError Method for notification in case of failure.
ErrorData.paymentsResponseCode String Yes Response code for the error that occurred. See Vide Response Codes
ErrorData.acquirerResponseCode String No Response code for the error returned by the acquirer. Note that this error will only be returned if the transaction is not authorized by the acquirer.
ErrorData.responseMessage String Yes Descriptive message of the cause of the non-authorization. If the transaction was denied by the acquirer, it will contain the message returned by the acquirer.
ErrorData.acquirerAdditionalMessage String No Message sent in field 63 of EPS response, to be printed or displayed at the end of the transaction flow. The payment application is responsible for displaying this on the screen or verifying the content in this field, but it must also send the value received to the integrated application so it can apply its business rules based on this field's content.

Example

public class MyActivity extends Activity implements PaymentClient.PaymentCallback {

  private PaymentClient paymentClient;

  @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(){
    ApplicationInfo appInfo = new ApplicationInfo();
    appInfo.setCredentials(new Credentials("demo-app", "TOKEN-KEY-DEMO"));
    appInfo.setSoftwareVersion("1.0.0.0");

    OpenBatchRequest openBatchRequest = new OpenBatchRequest();
    printBatchReceiptRequest.setApplicationInfo(appInfo);
    printBatchReceiptRequest.setBatchNumber(999L);

    try {
      paymentClient.openBatch(openBatchRequest, this);
    } catch (ClientException e) {
      Log.e(TAG, "Error", e);
    }
  }

  @Override
  public void onError(ErrorData errorData) {
    Log.e(TAG, "Error: " + errorData.getResponseMessage());
  }

  @Override
  public void onSuccess(Object o) {
    Log.i(TAG, "Success!");
  }
}