Ir para o conteúdo

Synchronizes transactions and closes the current batch


This method must be called to perform batch close and batch submission.

A batch is a set of transactions used to group multiple payments and reversals. The batch is opened when the first transaction is made, this transaction will receive the batch number to which it is associated. When closing a batch, the terminal searches for all transactions associated with the batch to be closed and generates the report to send to the host and for printing. Only one batch is opened at a time in the terminal. When closed, the next transaction will open a new batch, incrementing the previous batch number. When errors occur and transactions remain pending, it is not possible to close the batch.

Methods

Signature Description
void closeBatchV2(SettlementRequest settlementRequest, PaymentCallbackV2 paymentCallback) Synchronizes transactions and closes the current batch.

Parameters

Name Type Mandatory Description
request SettlementRequest Yes Data transfer object that will contain the information of the batch close request. Note that not all parameters are required.
callback PaymentCallbackV2 Yes Interface that will be executed for success or error notifications of the batch close process.

Detail Parameters request (SettlementRequest)

Name Type Mandatory Description
ApplicationInfo.credentials Credentials Yes Credentials of the application that is requesting the operation, as registered at PayStore. Basically, it's about the application ID and the access token.
ApplicationInfo.softwareVersion String Yes Version of the application that is requesting payment.
printMerchantReceipt Boolean No Indicates whether the establishment voucher should be printed or not.

(Available from version(.aar) v3.1.4.0)

callback (SettlementCallbackV2)

Name Type Mandatory Description
onSuccess Method for notification on success.
Settlement.Receipt.merchantVia String Yes Returns a receipt from the acquirer with the batch closing information.
Settlement.BatchNumber String Yes Lot number.
acquirerResponseCode String Yes Host response code.
terminalId String Yes Terminal ID
acquirerAdditionalMessage String No Message sent in EPS reply field 63, to be printed or displayed at the end of the transactional flow. The payments application remains responsible for displaying or verifying the content present in this field on the screen, but must also send the received amount to the integrated application so that it can apply its business rules based on the content of this field.
batchClosureDate Date No Batch closing date and time.
hasMultiMerchant boolean No Indicates whether the multimerchant is enabled (true) or disabled (false).
batchReports List<BatchReport> No List of transactions by acquirers.
totalReportInfos List<BatchReportInfo> No List with total payment data.
onError Method for notification in case of failure.
ErrorData.paymentsResponseCode String Yes Response code for the error that occurred. See Response_Code
ErrorData.acquirerResponseCode String No Response code for the occurred 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 reason for 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 EPS reply field 63, to be printed or displayed at the end of the transactional flow. The payments application remains responsible for displaying or verifying the content present in this field on the screen, but must also send the received amount to the integrated application so that it can apply its business rules based on the content of this field.
ErrorDataV2.errorMessage String No Descriptive message of the reason for the non-authorization. This field is unique to the error message.

BatchReport

Name Type Description
productName String Product Name.
BatchReportTransaction.transactionReportInfo List<BatchReportInfo> List with organization of transactions.
BatchReportTransaction.parcelReportInfo List<BatchReportInfo> List with grouping of transactions by installment.
batchReportsMultiMerchant List<BatchReportMultiMerchant> List grouped by merchants.

BatchReportTransaction

Name Type Description
transactionReportInfo List<BatchReportInfo> List with organization of transactions.
parcelReportInfo List<BatchReportInfo> List with grouping of transactions by installment.

BatchReportInfo

Name Type Description (Transaction) Description (Parcel)
item String Transaction type (0 - Sale; 1 - Devolution; 2 - Annulament; 3 - Withdraw; 4 - Annulament of Withdraw). Number of installments.
quantity Integer Número de transacciones por tipo de transacción. Number of transactions of the same installment.
value BigDecimal Suma de los valores del tipo de transacción. Sum of the values ​​of the same parcel.

BatchReportMultiMerchant

Name Type Description
groupCode String Merchant group code.
groupName String Name of the merchant group.
BatchReportTransaction.transactionReportInfo List<BatchReportInfo> Lista com agrupamento das transações.
BatchReportTransaction.parcelReportInfo List<BatchReportInfo> Lista com agrupamento das transações por parcela.

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");

        SettlementRequest settlementRequest = new SettlementRequest();
        settlementRequest.setApplicationInfo(appInfo);
        settlementRequest.setPrintMerchantReceipt(true);

        try {
            paymentClient.closeBatchV2(settlementRequest, this);
        } catch (ClientException e) {
            Log.e(TAG, "Error while closing batch.", e);
        }
    }

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

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