thrownewCRM_Core_Exception('Failure: Could not find contribution record for '.(int)$contribution->id,NULL,['context'=>"Could not find contribution record: {$contribution->id} in IPN request: ".print_r($input,TRUE)]);
}
// make sure contact exists and is valid
// use the contact id from the contribution record as the id in the IPN may not be valid anymore.
$contact=newCRM_Contact_BAO_Contact();
$contact->id=$contribution->contact_id;
$contact->find(TRUE);
if($contact->id!=$ids['contact']){
// If the ids do not match then it is possible the contact id in the IPN has been merged into another contact which is why we use the contact_id from the contribution
CRM_Core_Error::debug_log_message("Contact ID in IPN {$ids['contact']} not found but contact_id found in contribution {$contribution->contact_id} used instead");
echo"WARNING: Could not find contact record: {$ids['contact']}<p>";