Unverified Commit c97c8a58 authored by sluc23's avatar sluc23 Committed by GitHub
Browse files

Merge pull request #31 from ixiam/dev-replaceCompleteTransaction

Replace completeTransaction method by api
parents cbb81327 707727bd
......@@ -67,20 +67,31 @@ class CRM_Core_Payment_RedsysIPN extends CRM_Core_Payment_BaseIPN {
if (array_key_exists($error, $this->_errors)) {
$input['reasonCode'] = $this->_errors[$error];
}
else {
$input['reasonCode'] = $error;
}
CRM_Core_Error::debug_log_message("Redsys IPN Response: About to cancel contr \n input: " . print_r($input, TRUE) . "\n ids: " . print_r($ids, TRUE) . "\n objects: " . print_r($objects, TRUE));
return $this->cancelled($objects, $transaction, $input);
}
// Check if contribution is already completed, if so we ignore this ipn.
if ($contribution->contribution_status_id == 1) {
$transaction->commit();
CRM_Core_Error::debug_log_message("returning since contribution has already been handled");
echo "Success: Contribution has already been handled<p>";
try {
civicrm_api3('contribution', 'create', array('id' => $input['contributionID'], 'contribution_status_id' => 'Cancelled', 'cancel_reason' => $input['reasonCode'], 'cancel_date' => date('Y-m-d')));
}
catch (CiviCRM_API3_Exception $e) {
if($e->getMessage()) {
CRM_Core_Error::debug_log_message("Redsys IPN Error Updating contribution: " . $e->getMessage());
}
}
return TRUE;
}
CRM_Core_Error::debug_log_message("Redsys IPN Response: About complete trans \n input: " . print_r($input, TRUE) . "\n ids: " . print_r($ids, TRUE) . "\n objects: " . print_r($objects, TRUE));
return $this->completeTransaction($input, $ids, $objects, $transaction, $recur);
try {
civicrm_api3('contribution', 'completetransaction', array('id' => $input['contributionID'], 'trxn_id' => $input["trxn_id"]));
}
catch (CiviCRM_API3_Exception $e) {
if (!stristr($e->getMessage(), 'Contribution already completed')) {
CRM_Core_Error::debug_log_message("Redsys IPN Error Updating contribution: " . $e->getMessage());
}
}
return TRUE;
}
function getInput(&$input, &$ids) {
......
......@@ -88,6 +88,10 @@ After installing and activating the extension, you'll need to configure your pay
Version 1.9 works with CiviCRM 4.6 / 4.7 / 5.x (until 5.3.0).
Version 2.0 works with CiviCRM 5.3.0 or newer versions.
### Error Log
To search if is failing in some cases, search in ConfigLog from civicrm the workd "Redsys IPN Error"
## License ##
Redsys Payment Processor for CiviCRM. Copyright (C) 2013 - 2018 Amnesty International (originally developed by Ixiam http://www.ixiam.com).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment