Handling API Responses

This page assumes you have made a request to the BreathePay API and have a response object

Validating API Signatures

circle-exclamation
//PHP
//Use the createBreathePaySignature function we created earlier to verify the responses signature 
if(isset($response['signature'])) {
  $signature = $response['signature'];
  unset($response['signature']);
  
  if($signature !== $this->createBreathePaySignature($response, YOUR_MERCHANT_SECRET)) {
    //SIGNATURE INVALID, TRANSACTION IS COMPROMISED
  }
}

Successful Response

circle-check
//PHP
if($response['responseCode'] == 0) {
    //If it was a charge request, store these values for reconcilliation and refunds
    $txId = $response['transactionID'];
    $xref = $response['xref'];
}

Error Response

circle-exclamation

Last updated