Overview | API Call | API Response

Cancel Transaction

 

The ‘Cancel Transaction’ feature is exactly what it sounds like: You send an api call with the request to cancel the transaction and helloPay responses with the confirmation or if it didn’t work with some information why it didn’t work.


API Call

 

This command cancels the transaction of the associated purchase id. You got the purchase id in the response for creating a transaction.

$response = $helloPay->cancelTransaction($purchaseId);

API Response

If cancelling the transaction was successful the $response variable will be true. You can decide for yourself how you want to handle this confirmation, one simple solution is to just echo “Transaction has been cancelled successfully!” If cancelling the transaction didn’t work you can use the getLastMessage() function, which shows the message, which is the error message.

if ($response) {
  echo "Transaction has been cancelled successfully!";
} else {
  echo $helloPay->getLastMessage();
}