Commit 2705211a authored by rubofvil's avatar rubofvil
Browse files

Adapt new standar, replace 'array()' by '[]' and replace...

Adapt new standar, replace 'array()' by '[]' and replace 'CRM_Core_Error::debug_log_message' by 'Civi::log()->debug'
parent bc5b1397
......@@ -84,7 +84,7 @@ class CRM_Core_Payment_Redsys extends CRM_Core_Payment {
*/
public function checkConfig() {
$config = CRM_Core_Config::singleton();
$error = array();
$error = [];
if (empty($this->_paymentProcessor["user_name"])) {
$error[] = E::ts("Merchant Code is not set in the Redsys Payment Processor settings.");
......@@ -213,15 +213,15 @@ class CRM_Core_Payment_Redsys extends CRM_Core_Payment {
}
elseif (isset($params["financial_type_id"]) && $params["financial_type_id"] > 0) {
try {
$financial_type = civicrm_api3('FinancialType', 'getsingle', array(
$financial_type = civicrm_api3('FinancialType', 'getsingle', [
'sequential' => 1,
'id' => $params["financial_type_id"],
));
]);
$description = $financial_type["name"];
}
catch (CiviCRM_API3_Exception $e) {
$error = $e->getMessage();
CRM_Core_Error::debug_log_message("Redsys-missing parameter financial type: " . $error);
Civi::log()->debug("Redsys-missing parameter financial type: " . $error);
}
}
......@@ -259,16 +259,16 @@ class CRM_Core_Payment_Redsys extends CRM_Core_Payment {
}
public function handlePaymentNotification() {
$input = $ids = $objects = array();
$input = $ids = $objects = [];
$ipn = new CRM_Core_Payment_RedsysIPN();
// Load vars in $input, &ids.
$ipn->getInput($input, $ids);
CRM_Core_Error::debug_log_message("Redsys IPN Response: Parameteres received \n input: " . print_r($input, TRUE) . "\n ids: " . print_r($ids, TRUE));
Civi::log()->debug("Redsys IPN Response: Parameteres received \n input: " . print_r($input, TRUE) . "\n ids: " . print_r($ids, TRUE));
$paymentProcessorID = $this->_paymentProcessor['id'];
if (!$ipn->validateData($this->_paymentProcessor, $input, $ids, $objects, TRUE, $paymentProcessorID)) {
CRM_Core_Error::debug_log_message("Redsys Validation failed");
Civi::log()->debug("Redsys Validation failed");
return FALSE;
}
......
......@@ -11,7 +11,7 @@ class CRM_Core_Payment_RedsysIPN extends CRM_Core_Payment_BaseIPN {
parent::__construct();
$this->_redsysAPI = new RedsysAPI();
$this->_errors = array(
$this->_errors = [
"101" => "Tarjeta caducada",
"102" => "Tarjeta en excepción transitoria o bajo sospecha de fraude",
"106" => "Intentos de PIN excedidos",
......@@ -47,7 +47,7 @@ class CRM_Core_Payment_RedsysIPN extends CRM_Core_Payment_BaseIPN {
"9997" => "Se está procesando otra transacción en SIS con la misma tarjeta",
"9998" => "Operación en proceso de solicitud de datos de tarjeta",
"9999" => "Operación que ha sido redirigida al emisor a autenticar",
);
];
}
public function single(&$input, &$ids, &$objects, $recur = FALSE, $first = FALSE) {
......@@ -55,7 +55,7 @@ class CRM_Core_Payment_RedsysIPN extends CRM_Core_Payment_BaseIPN {
if (!$recur) {
if (str_replace(",", "", $contribution->total_amount) != str_replace(",", "", $input['amount'])) {
CRM_Core_Error::debug_log_message("Amount values dont match between database and IPN request");
Civi::log()->debug("Amount values dont match between database and IPN request");
echo "Failure: Amount values dont match between database and IPN request<p>";
return FALSE;
}
......@@ -70,32 +70,32 @@ class CRM_Core_Payment_RedsysIPN extends CRM_Core_Payment_BaseIPN {
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));
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));
try {
civicrm_api3('contribution', 'create', array('id' => $input['contributionID'], 'contribution_status_id' => 'Cancelled', 'cancel_reason' => $input['reasonCode'], 'cancel_date' => date('Y-m-d')));
civicrm_api3('contribution', 'create', ['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());
Civi::log()->debug("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));
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));
try {
civicrm_api3('contribution', 'completetransaction', array('id' => $input['contributionID'], 'trxn_id' => $input["trxn_id"]));
civicrm_api3('contribution', 'completetransaction', ['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());
Civi::log()->debug("Redsys IPN Error Updating contribution: " . $e->getMessage());
}
}
return TRUE;
}
public function getInput(&$input, &$ids) {
$input = array(
$input = [
// GET Parameters.
'module' => self::retrieve('md', 'String', 'GET', TRUE),
'component' => self::retrieve('md', 'String', 'GET', TRUE),
......@@ -112,7 +112,7 @@ class CRM_Core_Payment_RedsysIPN extends CRM_Core_Payment_BaseIPN {
'Ds_SignatureVersion' => self::retrieve('Ds_SignatureVersion', 'String', 'POST', TRUE),
'Ds_MerchantParameters' => self::retrieve('Ds_MerchantParameters', 'String', 'POST', TRUE),
'Ds_Signature' => self::retrieve('Ds_Signature', 'String', 'POST', TRUE),
);
];
$decodecResponseJson = $this->_redsysAPI->decodeMerchantParameters($input["Ds_MerchantParameters"]);
$decodecResponse = json_decode($decodecResponseJson);
$input['Ds_MerchantCode'] = $decodecResponse->Ds_MerchantCode;
......@@ -122,10 +122,10 @@ class CRM_Core_Payment_RedsysIPN extends CRM_Core_Payment_BaseIPN {
$input['amount'] = number_format(($decodecResponse->Ds_Amount / 100), 2);
$input['trxn_id'] = $decodecResponse->Ds_AuthorisationCode;
$ids = array(
$ids = [
'contribution' => $input['contributionID'],
'contact' => $input['contactID'],
);
];
if ($input['module'] == "event") {
$ids['event'] = $input['eventID'];
$ids['participant'] = $input['participantID'];
......@@ -141,12 +141,12 @@ class CRM_Core_Payment_RedsysIPN extends CRM_Core_Payment_BaseIPN {
$signatureNotif = $this->_redsysAPI->createMerchantSignatureNotif($paymentProcessor["password"], $input["Ds_MerchantParameters"]);
if ($input['Ds_MerchantCode'] != $paymentProcessor["user_name"]) {
CRM_Core_Error::debug_log_message("Redsys Response param Ds_MerchantCode incorrect");
Civi::log()->debug("Redsys Response param Ds_MerchantCode incorrect");
return FALSE;
}
if ($signatureNotif !== $input['Ds_Signature']) {
CRM_Core_Error::debug_log_message("Redsys signature doesn't match");
Civi::log()->debug("Redsys signature doesn't match");
return FALSE;
}
......@@ -157,7 +157,7 @@ class CRM_Core_Payment_RedsysIPN extends CRM_Core_Payment_BaseIPN {
static $store = NULL;
$value = CRM_Utils_Request::retrieve($name, $type, $store, FALSE, NULL, $location);
if ($abort && $value === NULL) {
CRM_Core_Error::debug_log_message("Could not find an entry for $name in $location");
Civi::log()->debug("Could not find an entry for $name in $location");
echo "Failure: Missing Parameter<p>";
exit();
}
......
......@@ -7,28 +7,28 @@ class CRM_Redsys_Form_Settings extends CRM_Core_Form {
public function buildQuickForm() {
$this->add('checkbox', 'ipn_http', 'Use http for IPN Callback');
$this->add('text', 'merchant_terminal', 'Merchant Terminal', array('size' => 5));
$this->add('text', 'merchant_terminal', 'Merchant Terminal', ['size' => 5]);
$paymentProcessors = $this->getPaymentProcessors();
foreach ($paymentProcessors as $paymentProcessor) {
$settingCode = 'merchant_terminal_' . $paymentProcessor["id"];
$settingTitle = $paymentProcessor["name"] . " (" .
($paymentProcessor["is_test"] == 0 ? "Live" : "Test") . ")";
$this->add('text', $settingCode, $settingTitle, array('size' => 5));
$this->add('text', $settingCode, $settingTitle, ['size' => 5]);
}
$this->addButtons(array(
array(
$this->addButtons([
[
'type' => 'submit',
'name' => E::ts('Submit'),
'isDefault' => TRUE,
),
));
],
]);
parent::buildQuickForm();
}
public function setDefaultValues() {
$defaults = array();
$defaults = [];
$redsys_settings = CRM_Core_BAO_Setting::getItem("Redsys Settings", 'redsys_settings');
if (!empty($redsys_settings)) {
$defaults = $redsys_settings;
......@@ -48,21 +48,21 @@ class CRM_Redsys_Form_Settings extends CRM_Core_Form {
}
CRM_Core_BAO_Setting::setItem($redsys_settings, "Redsys Settings", 'redsys_settings');
CRM_Core_Session::setStatus(E::ts('Redsys Settings Saved', array('domain' => 'com.ixiam.payment.redsys')), 'Configuration Updated', 'success');
CRM_Core_Session::setStatus(E::ts('Redsys Settings Saved', ['domain' => 'com.ixiam.payment.redsys']), 'Configuration Updated', 'success');
parent::postProcess();
}
public function getPaymentProcessors() {
// Get the Redsys payment processor type.
$redsysName = array('name' => 'Redsys');
$redsysName = ['name' => 'Redsys'];
$paymentProcessorType = civicrm_api3('PaymentProcessorType', 'getsingle', $redsysName);
// Get the payment processors of Redsys type.
$redsysType = array(
$redsysType = [
'payment_processor_type_id' => $paymentProcessorType['id'],
'is_active' => 1,
);
];
$paymentProcessors = civicrm_api3('PaymentProcessor', 'get', $redsysType);
return $paymentProcessors["values"];
......
......@@ -21,15 +21,15 @@ class CRM_Redsys_Upgrader extends CRM_Redsys_Upgrader_Base {
$query = "SELECT id FROM `civicrm_navigation` WHERE name = 'CiviContribute'";
$dao = CRM_Core_DAO::executeQuery($query);
if ($dao->fetch()) {
$menu_params = array(
'label' => E::ts('Redsys Settings', array('domain' => 'com.ixiam.payment.redsys')),
$menu_params = [
'label' => E::ts('Redsys Settings', ['domain' => 'com.ixiam.payment.redsys']),
'url' => 'civicrm/redsys/settings',
'permission' => array('administer OfflinePay'),
'permission' => ['administer OfflinePay'],
'permission_operator' => 'AND',
'has_separator' => '1',
'is_active' => '1',
'parent_id' => $dao->id,
);
];
$parent = CRM_Core_BAO_Navigation::add($menu_params);
// Also reset navigation.
......
......@@ -63,7 +63,7 @@ class CRM_Redsys_Upgrader_Base {
$instance->ctx = array_shift($args);
$instance->queue = $instance->ctx->queue;
$method = array_shift($args);
return call_user_func_array(array($instance, $method), $args);
return call_user_func_array([$instance, $method], $args);
}
public function __construct($extensionName, $extensionDir) {
......@@ -120,7 +120,7 @@ class CRM_Redsys_Upgrader_Base {
* provides syntatic sugar for queueing several tasks that
* run different queries
*/
public function executeSql($query, $params = array()) {
public function executeSql($query, $params = []) {
// FIXME verify that we raise an exception on error
CRM_Core_DAO::executeQuery($query, $params);
return TRUE;
......@@ -139,11 +139,11 @@ class CRM_Redsys_Upgrader_Base {
$args = func_get_args();
$title = array_shift($args);
$task = new CRM_Queue_Task(
array(get_class($this), '_queueAdapter'),
[get_class($this), '_queueAdapter'],
$args,
$title
);
return $this->queue->createItem($task, array('weight' => -1));
return $this->queue->createItem($task, ['weight' => -1]);
}
// ******** Revision-tracking helpers ********
......@@ -176,23 +176,23 @@ class CRM_Redsys_Upgrader_Base {
$currentRevision = $this->getCurrentRevision();
foreach ($this->getRevisions() as $revision) {
if ($revision > $currentRevision) {
$title = E::ts('Upgrade %1 to revision %2', array(
$title = E::ts('Upgrade %1 to revision %2', [
1 => $this->extensionName,
2 => $revision,
));
]);
// note: don't use addTask() because it sets weight=-1
$task = new CRM_Queue_Task(
array(get_class($this), '_queueAdapter'),
array('upgrade_' . $revision),
[get_class($this), '_queueAdapter'],
['upgrade_' . $revision],
$title
);
$this->queue->createItem($task);
$task = new CRM_Queue_Task(
array(get_class($this), '_queueAdapter'),
array('setCurrentRevision', $revision),
[get_class($this), '_queueAdapter'],
['setCurrentRevision', $revision],
$title
);
$this->queue->createItem($task);
......@@ -207,7 +207,7 @@ class CRM_Redsys_Upgrader_Base {
*/
public function getRevisions() {
if (!is_array($this->revisions)) {
$this->revisions = array();
$this->revisions = [];
$clazz = new ReflectionClass(get_class($this));
$methods = $clazz->getMethods();
......@@ -255,7 +255,7 @@ class CRM_Redsys_Upgrader_Base {
$this->executeCustomDataFileByAbsPath($file);
}
}
if (is_callable(array($this, 'install'))) {
if (is_callable([$this, 'install'])) {
$this->install();
}
$revisions = $this->getRevisions();
......@@ -265,7 +265,7 @@ class CRM_Redsys_Upgrader_Base {
}
public function onUninstall() {
if (is_callable(array($this, 'uninstall'))) {
if (is_callable([$this, 'uninstall'])) {
$this->uninstall();
}
$files = glob($this->extensionDir . '/sql/*_uninstall.sql');
......@@ -279,14 +279,14 @@ class CRM_Redsys_Upgrader_Base {
public function onEnable() {
// stub for possible future use
if (is_callable(array($this, 'enable'))) {
if (is_callable([$this, 'enable'])) {
$this->enable();
}
}
public function onDisable() {
// stub for possible future use
if (is_callable(array($this, 'disable'))) {
if (is_callable([$this, 'disable'])) {
$this->disable();
}
}
......@@ -294,7 +294,7 @@ class CRM_Redsys_Upgrader_Base {
public function onUpgrade($op, CRM_Queue_Queue $queue = NULL) {
switch ($op) {
case 'check':
return array($this->hasPendingRevisions());
return [$this->hasPendingRevisions()];
case 'enqueue':
return $this->enqueuePendingRevisions($queue);
......
......@@ -25,7 +25,7 @@ class RedsysAPI {
/******
*
* Array de DatosEntrada ******/
public $vars_pay = array();
public $vars_pay = [];
/******
*
......
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