How to Perform a Refund

To issue a refund for a completed payment, you must have the transaction reference of the original transaction. Also, ensure the myPOS SDK is properly initialized before attempting to perform a refund.

Start the Refund Flow

To begin the refund process, launch the RefundActivity with the necessary intent extras:

public void onRefundBtnClick(View view) {
	...
Intent intent = new Intent(this, RefundActivity.class);
intent.putExtra(MyPos.INTENT_EXTRA_TRANSACTION_REFERENCE, "transactionRef");
intent.putExtra(MyPos.INTENT_EXTRA_AMOUNT, 10.00);
if( !orderId.equalsIgnoreCase(""))
    intent.putExtra(MyPos.INTENT_EXTRA_ORDER_ID, orderId);
startActivityForResult(intent, MyPos.REQUEST_CODE_REFUND);
	...
}

Always use the correct Transaction Reference ID of the payment you're refunding. This ID is required to identify and reverse the transaction properly.

Handle the Refund Result

Once the refund process completes, handle the result in your onActivityResult() method:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if( resultCode == RESULT_OK  && requestCode == MyPos.REQUEST_CODE_REFUND){
    int status = data.getIntExtra(MyPos.INTENT_EXTRA_STATUS, MyPos.STATUS_INTERNAL_API_ERROR);
    if( status == MyPos.STATUS_SUCCESS) {
        float amount                = data.getFloatExtra(MyPos.INTENT_EXTRA_AMOUNT, 0.00f);
        String currency             = data.getStringExtra(MyPos.INTENT_EXTRA_CURRENCY);
        String transactionReference = data.getStringExtra(MyPos.INTENT_EXTRA_TRANSACTION_REFERENCE);
  }
 }
...
}