Refunding Transactions
A transaction can be refunded if its status is settled or settling. If the transaction has not yet begun settlement, it should be voided instead of refunded.
Full Refund
If you do not specify an amount to refund, the entire transaction amount will be refunded.
Result<Transaction> result = gateway.transaction().refund("a_transaction_id");
result.isSuccess();
// true
Transaction refund = result.getTarget();
refund.getType();
// Transaction.Type.CREDIT
refund.getRefundedTransactionId();
// original transaction Id
Transaction transaction = gateway.transaction().find("a_transaction_id");
transaction.getRefundId();
// Id of refund associated to the transaction
Partial Refund
If you only want to refund a portion of the transaction, you can specify the amount to refund. We also support multiple partial refunds. You can continue to refund a transaction as many times as you like so long as the sum of the refund amounts is less than the amount of the initial transaction. If you have already partially refunded a transaction, performing another refund without specifying the balance it will create a refund for the remaining non-refunded amount of the transaction.
Result<Transaction> result = gateway.transaction().refund(
"a_transaction_id",
new BigDecimal("50.00")
);
result.isSuccess();
// true
Transaction refund = result.getTarget();
refund.getType();
// Transaction.Type.CREDIT
refund.getAmount();
// 50.00
Result<Transaction> result = gateway.transaction().refund(
"a_transaction_id",
new BigDecimal("10.00")
);
result.isSuccess();
// true
Transaction refund = result.getTarget();
refund.getType();
// Transaction.Type.CREDIT
refund.getAmount();
// 10.00
Validations
- Transaction status must be settled or settling.
- Refund amount cannot be greater than remaining non-refunded amount of the original transaction.
- Transaction cannot be refunded again after being completely refunded.