Commit 51519355 authored by rubofvil's avatar rubofvil
Browse files

Add option to avoid save log with contributions info, avoid save critical info...

Add option to avoid save log with contributions info, avoid save critical info #42 !48
parent 1e0f7647
......@@ -61,6 +61,13 @@ class CRM_Core_Payment_RedsysIPN extends CRM_Core_Payment_BaseIPN {
}
}
$redsys_settings = CRM_Core_BAO_Setting::getItem("Redsys Settings", 'redsys_settings');
$masquerade_input = $input;
$fields_to_hide = ['Ds_MerchantParameters', 'Ds_Signature', 'Ds_Merchant_Identifier'];
foreach ($fields_to_hide as $field_to_hide) {
unset($masquerade_input[$field_to_hide]);
}
$transaction = new CRM_Core_Transaction();
if ($input['Ds_Response'] != self::REDSYS_RESPONSE_CODE_ACCEPTED) {
$error = self::trimAmount($input['Ds_Response']);
......@@ -70,7 +77,9 @@ class CRM_Core_Payment_RedsysIPN extends CRM_Core_Payment_BaseIPN {
else {
$input['reasonCode'] = $error;
}
Civi::log()->debug("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));
if ($redsys_settings['save_log'] == '1') {
Civi::log()->debug("Redsys IPN Response: About to cancel contr \n input: " . print_r($masquerade_input, TRUE) . "\n ids: " . print_r($ids, TRUE));
}
try {
civicrm_api3('contribution', 'create', ['id' => $input['contributionID'], 'contribution_status_id' => 'Cancelled', 'cancel_reason' => $input['reasonCode'], 'cancel_date' => date('Y-m-d')]);
}
......@@ -81,8 +90,9 @@ class CRM_Core_Payment_RedsysIPN extends CRM_Core_Payment_BaseIPN {
}
return TRUE;
}
Civi::log()->debug("Redsys IPN Response: About complete trans \n input: " . print_r($input, TRUE) . "\n ids: " . print_r($ids, TRUE) . "\n objects: " . print_r($objects, TRUE));
if ($redsys_settings['save_log'] == '1') {
Civi::log()->debug("Redsys IPN Response: About complete trans \n input: " . print_r($masquerade_input, TRUE) . "\n ids: " . print_r($ids, TRUE));
}
try {
civicrm_api3('contribution', 'completetransaction', ['id' => $input['contributionID'], 'trxn_id' => $input["trxn_id"]]);
}
......
......@@ -6,6 +6,7 @@ class CRM_Redsys_Form_Settings extends CRM_Core_Form {
public function buildQuickForm() {
$this->add('checkbox', 'ipn_http', 'Use http for IPN Callback');
$this->add('checkbox', 'save_log', 'Save log of all transactions');
$this->add('text', 'merchant_terminal', 'Merchant Terminal', ['size' => 5]);
$paymentProcessors = $this->getPaymentProcessors();
......@@ -38,6 +39,7 @@ class CRM_Redsys_Form_Settings extends CRM_Core_Form {
public function postProcess() {
$values = $this->exportValues();
$redsys_settings['ipn_http'] = $values['ipn_http'];
$redsys_settings['save_log'] = $values['save_log'];
$redsys_settings['merchant_terminal'] = $values['merchant_terminal'];
$paymentProcessors = $this->getPaymentProcessors();
......
......@@ -10,6 +10,16 @@
<span class="description">Redsys doesn't support ipn callbacks using SSL shared certificate in multiples websites with a single IP. In that case you must force to use http protocol in ipn callback url</span>
</td>
</tr>
<td width="20%">
{$form.save_log.label}
</td>
<td>
{$form.save_log.html}
<br>
<span class="description">Save the log of all transactions in ConfigAndLog</span>
</td>
</tr>
<td>
<tr class="crm-redsys-form-block-merchant_terminal">
<td width="20%">
{$form.merchant_terminal.label}
......
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