Ir para o conteúdo

Version 2


reprintV2()

This method is an update of the reprint() method, used to perform reprinting and/or sharing (email) of the client’s way about any authorized payment. Now, in addition to printing, the method allows you to present on screen the same printed proof of trade and customer. As the original receipt has already been printed, the reprint of the receipt will have a black stripe. If the payment has been successfully reversed, the receipt becomes the chargeback, in the case when trying to reprint the proof of purchase, will be presented the proof of chargeback, in this way, if you try to reprint the transaction reprint with paymentId of the purchase or chargeback, the proof presented or printed shall be that of chargeback.

Parameters

Name Type Mandatory Description
request ReprintReceiptRequestV2 Yes Data transfer object that will contain the payment request information. Note that not all parameters are mandatory.
callback PaymentCallback Yes Interface that will be executed for notifications of success or error of the payment process.

Detail of the Parameters

request (ReprintReceiptRequestV2)

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.
paymentId String Yes PaymenId returned in the callback of the payment or chargeback of the transaction made. Serves to identify the transaction being reprinted.
previewMerchantReceipt Boolean Not Indicates whether the preview screen of the receipt of the establishment will be presented with a black stripe and reprint indication. The default value is true, which means that the voucher will be displayed if the field is not sent.
previewCustomerReceipt Boolean Not Indicates whether the preview screen of the customer’s receipt will be presented with a black stripe and reprint indication. The default value is true, which means that the customer’s receipt will be displayed if it is not sent.
printMerchantReceipt Boolean Not Indicates whether the establishment receipt should be printed or not. The default value is true, so the receipt will be printed if it is not sent.
printCustomerReceipt Boolean Not Indicates whether the customer’s receipt should be printed or not. The default value is true, so the receipt will be printed if it is not sent.

Expected behavior when filling in the paymentId:

Searches for payments by the paymentId informed.

Result: Returns the payment or chargeback for the informed paymentId. If the paymentId of the payment has been successful, the paymentId of the purchase will be presented on screen and for printing the proof of chargeback.

Expected behavior when filling in the following parameters:

If value is true

Result: Displays the proof of purchase or chargeback on a screen.

If value is true

Result: Displays the customer’s proof of purchase or chargeback.

If value is true

Result: Proof of purchase or trade chargeback will be printed

If value is true

Result: Proof of purchase or customer chargeback will be printed

callback (PaymentCallback)

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.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 No 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.
Example of reprint flow
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

import br.com.phoebus.android.payments.api.ErrorData;
import br.com.phoebus.android.payments.api.PaymentClient;
import br.com.phoebus.android.payments.api.PrintReceiptRequest;
import br.com.phoebus.android.payments.api.client.Client;
import br.com.phoebus.android.payments.api.exception.ClientException;
import br.com.phoebus.payments.demo.utils.AlertUtils;
import br.com.phoebus.payments.demo.utils.CredentialsUtils;
import br.com.phoebus.payments.demo.utils.Helper;

public void printReceipt(View view) {
        if (!isDataValid()) return;

        PaymentClient mPaymentClient = new PaymentClient();

        ReprintReceiptRequestV2 reprintReceiptRequestV2 = new ReprintReceiptRequestV2();

        try {
            reprintReceiptRequestV2.setApplicationInfo(CredentialsUtils.getMyAppInfo(this.getPackageManager(), this.getPackageName()));
            reprintReceiptRequestV2.setPaymentId(paymentTransactionIdEdt.getText().toString());
            reprintReceiptRequestV2.setPrintCustomerReceipt(chbReceiptCustomer.isChecked());
            reprintReceiptRequestV2.setPrintMerchantReceipt(chbReceiptMerchant.isChecked());
            reprintReceiptRequestV2.setPreviewCustomerReceipt(previewReceiptCustomer.isChecked());
            reprintReceiptRequestV2.setPreviewMerchantReceipt(previewReceiptMerchant.isChecked());

        } catch (PackageManager.NameNotFoundException e) {
            showSnackBar(getString(R.string.requestFailed) +": " + e.getMessage());
            return;
        }

        mPaymentClient.bind(this, new Client.OnConnectionCallback() {
            @Override
            public void onConnected() {
                try {
                    mPaymentClient.reprintV2(reprintReceiptRequestV2, new PaymentClient.PaymentCallback<Void>() {
                        @Override
                        public void onSuccess(Void aVoid) {
                            Log.d("PayStore App Demo", "Reprint has finished successfully!");
                        }

                        @Override
                        public void onError(ErrorData errorData) {
                            if (errorData != null && !TextUtils.isEmpty(errorData.getResponseMessage())) {
                                AlertUtils.showSnackBar(findViewById(android.R.id.content), errorData.getResponseMessage());
                            }
                            Log.e("PayStore App Demo", "Reprint has finished wrongfully!");
                        }
                    });
                } catch (ClientException e) {
                    if (!TextUtils.isEmpty(e.getMessage())) {
                        AlertUtils.showSnackBar(findViewById(android.R.id.content), e.getMessage());
                    }
                }
            }

            @Override
            public void onDisconnected(boolean b) {
                Log.d("PayStore App Demo", "Reprint disconnected!");
            }
        });
    }