Handling API Responses

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

Validating API Signatures

//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

//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

//PHP
if($response['responseCode'] != 0 && $response['responseCode'] != 65802) {
    //Handle error
}

Last updated