Ir para o conteúdo

Performs the unreferenced return process.


This method must be called to perform the unreferenced return.

From version 3.1.5.0

When a transaction is made, it could previously be confirmed by printing it (or via printReceipt), or by making a new transaction. Now, the reversal can also be confirmed by using the new autoConfirm parameter - indicating whether or not to confirm regardless of printing - or by using the new confirmReversePayment() method.

Methods

Signature Description
void refundPaymentV2(RefundRequestV2 settlementRequest, PaymentCallback paymentCallback) Performs the unreferenced return process.
void confirmReversePayment(String paymentId, PaymentCallback paymentCallback) Confirms an unreferenced return authorization made previously.
void cancelReversePayment(String paymentId, PaymentCallback paymentCallback) Undoes an unreferenced return request.

refundPaymentV2()

Parameters

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

Parameter details request (RefundRequestV2)

Name Type Mandatory Description
value BigDecimal No Return value not referenced. If it is not filled in (null), or if it is filled in with 0 (zero), the Payment App must request the amount from the operator. The value must be formatted with two decimal places.
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 No Version of the application that is requesting payment.
printMerchantReceipt Boolean No Indicates whether the establishment voucher should be printed or not. The default value is false, that is, the voucher is not printed.
printCustomerReceipt Boolean No Indicates whether the customer receipt should be printed or not. The default value is false, that is, the voucher is not printed.
productShortName String No When filled in, after reading the card and identifying the branded product, if it does not match the productShortName of the product in question, the terminal should display an error on the screen and terminate the transaction. Examples: VI=VISA, MC=MASTERCARD, AX=AMEX
appTransactionId String No Integrated transaction identifier for the software. The Identifier referred to is the one used in the application that originated the return request. It must not be repeated.
previewMerchantReceipt Boolean No Indicates whether the merchant voucher preview screen should be displayed after confirming the transaction. The default value is true, which means the voucher will be displayed.
previewCustomerReceipt Boolean No Indicates whether the customer voucher preview screen should be displayed after confirming the transaction. The default value is true, which means the voucher will be displayed.
autoConfirm (v3.1.5.0) Boolean No Indicates whether the transaction should be confirmed automatically.
Possible values:
1. null (default) : confirms automatically if the receipt is printed.
2. true : confirms automatically regardless of the printing rule.
3. false : does not confirm automatically, pending confirmation.
merchantGroupCode String If allowMultimerchant= true, groupCode is required Merchant group code.
originalReceiptNumber String No Voucher number of the original transaction to be refunded.
originalReceiptDate Date No Coupon date of the original transaction to be refunded.

callback (RefundCallback)

Name Type Mandatory Description
onSuccess Method for notification on success
Refund.acquirerId String Yes Acquirer ID.
Refund.refundId String Yes Return ID.
Refund.productShortName String Yes Corresponds to the productShortName corresponding to the transaction context's flag product.
Refund.batchNumber String Yes ID of the batch to which the transaction belongs.
Refund.nsuTerminal String Yes NSU generated by the terminal for the transaction. The rightmost 4 digits correspond to the Ticket Number. This NSU is informed by the terminal to PhAST in the “merchantTransactionId” parameter.
Refund.acquirerResponseCode String Yes Acquirer response code.
Refund.acquirerResponseDate Date Yes Date/time returned by the acquirer.
Refund.acquirerAuthorizationNumber String Yes Authorization number provided by the acquirer (it appears on the Cardholder's customer receipt).
Refund.Receipt.merchantVia String No Content of the voucher - copy of the establishment.
Refund.Receipt.clientVia String No Voucher content - customer's copy.
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 Yes Descriptive message of the cause of the error.

confirmReversePayment()

This method must be called to confirm an unreferenced return that the terminal has managed to fully process the authorization leg sent by the Authorizer.

This method should not be called for an unreferenced return that has already been confirmed, i.e. where the confirmReversePayment() method has already been executed.

This method should not be called for an unreferenced return that has already been undone, i.e. where the cancelReversePayment() method has already been executed.

This no method must be called for an unreferenced return that has been denied by the Authorizer, i.e. the transaction must have been authorized by the Authorizer.

Parameters

Name Type Mandatory Description
paymentId String Yes Identifier of the transaction to be confirmed. The Identifier referred to is the one used in the payment application.
callback 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.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.

cancelReversePayment()

This method must be called to undo a previously authorized unreferenced return. This transaction must not have been undone yet and must have been authorized (not denied) previously.

As stated in the description of reversePayment(), it is possible that there is no undo for the unreferenced return for a given acquirer. Thus, the cancelReversePayment() method may return a specific error stating that it is not possible to perform this operation (see Response Codes).

Parameters

Name Type Mandatory Description
paymentId String Yes Identifier of the transaction to be rolled back. The Identifier referred to is the one used in the payment application.
callback 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.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.

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

        RefundRequestV2 refundRequestV2 = new RefundRequestV2();
        refundRequestV2.setApplicationInfo(appInfo);
        refundRequestV2.setPrintMerchantReceipt(true);

        try {
            paymentClient.refundPaymentV2(refundRequestV2, this);
        } catch (ClientException e) {
            Log.e(TAG, "Error starting devolution", e);
        }
    }

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

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