Refunds with myPOS Smart SDK

Just like processing a payment, issuing a refund using the myPOS Smart SDK is simple and flexible. You can initiate refunds with various options such as receipt preferences, MOTO support, and gift card refunds.

Step 1: Build & Perform the Refund

Use the MyPOSRefund builder to define your refund request.

MyPOSRefund refund = MyPOSRefund.builder()
    // Mandatory parameters
    .refundAmount(1.23)
    .currency(Currency.EUR)
    .foreignTransactionId(UUID.randomUUID().toString()) // Unique external reference

    // Optional parameters
    .printMerchantReceipt(MyPOSUtil.RECEIPT_ON)
    .printCustomerReceipt(MyPOSUtil.RECEIPT_ON)
    .build();

Special Transaction Types

refund.setMotoTransaction(true);         // For MOTO refunds
refund.setGiftCardTransaction(true);     // For gift card refunds

Initiate the Refund

MyPOSAPI.openRefundActivity(MainActivity.this, refund, 2);

The number 2 is used here as a request code to identify the refund transaction in onActivityResult.

Step 2: Handle the Refund Result

Process the result in your activity's onActivityResult method:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // The same request code as when calling MyPOSAPI.openRefundActivity
    if (requestCode == 2) {
        // The transaction was processed, handle the response
        if (resultCode == RESULT_OK) {
            // Something went wrong in the Payment core app and the result couldn't be returned properly
            if (data == null) {
                Toast.makeText(this, "Transaction cancelled", Toast.LENGTH_SHORT).show();
                return;
            }
            int transactionResult = data.getIntExtra("status", TransactionProcessingResult.TRANSACTION_FAILED);

            Toast.makeText(this, "Refund transaction has completed. Result: " + transactionResult, Toast.LENGTH_SHORT).show();

            // TODO: handle each transaction response accordingly
            if (transactionResult == TransactionProcessingResult.TRANSACTION_SUCCESS) {
                // Transaction is successful
            }
        } else {
            // The user cancelled the transaction
            Toast.makeText(this, "Transaction cancelled", Toast.LENGTH_SHORT).show();
        }
    }
}

Tip: Always verify the transaction result using TRANSACTION_SUCCESS, and make use of unique foreignTransactionId values for reliable tracking.