Perform a Refund


Refunding a payment requires that you have the transactionRef of the payment transaction. Check that you have initialized the SDK before attempting to perform a refund.

 

1. Show the card entry form

Create an Intent for the RefundActivity with the required 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);
	...
}

Note: Please make sure that you are using the correct Transaction Reference ID for the transaction that you want to be refunded.

 

2. Check the payment result

In your calling Activity, override the onActivityResult method to receive a transaction reference of the operation and the reference of the original transaction:

@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);
  }
 }
...
}