Commit 93e0cb57 authored by sluc23's avatar sluc23
Browse files

Merge branch '2.x-dev-webform-civicrm-drupal-9' into 'master'

2.x dev webform civicrm drupal 9

See merge request !50
parents ccf94776 91897482
<?php
use CRM_Redsys_ExtensionUtil as E;
require_once 'includes/apiRedsys.php';
......@@ -24,7 +25,7 @@ class CRM_Core_Payment_Redsys extends CRM_Core_Payment {
static private $_singleton = NULL;
/**
* mode of operation: live or test
* Mode of operation: live or test.
*
* @var object
*/
......@@ -42,10 +43,12 @@ class CRM_Core_Payment_Redsys extends CRM_Core_Payment {
public $_processorName = NULL;
/**
* Constructor
* Constructor.
*
* @param string $mode the mode of operation: live or test
* @param int $paymentProcessor paymentProcessor id
* @param string $mode
* the mode of operation: live or test.
* @param int $paymentProcessor
* paymentProcessor id.
*
* @return void
*/
......@@ -56,14 +59,16 @@ class CRM_Core_Payment_Redsys extends CRM_Core_Payment {
}
/**
* Singleton function used to manage this object
* Singleton function used to manage this object.
*
* @param string $mode the mode of operation: live or test
* @param int $paymentProcessor paymentProcessor id
* @param string $mode
* the mode of operation: live or test.
* @param int $paymentProcessor
* paymentProcessor id.
*
* @return object
* @static
*
* @static
*/
public static function &singleton($mode, &$paymentProcessor) {
$processorName = $paymentProcessor["name"];
......@@ -74,13 +79,13 @@ class CRM_Core_Payment_Redsys extends CRM_Core_Payment {
}
/**
* This function checks to see if we have the right config values
* This function checks to see if we have the right config values.
*
* @return string the error message if any
*
* @public
*/
public function checkConfig() {
$config = CRM_Core_Config::singleton();
$error = [];
if (empty($this->_paymentProcessor["user_name"])) {
......@@ -102,7 +107,7 @@ class CRM_Core_Payment_Redsys extends CRM_Core_Payment {
* This function is not implemented, as long as this payment
* procesor is notify mode only.
*
* @param type $params
* @param mixed $params
*/
public function doDirectPayment(&$params) {
CRM_Core_Error::fatal(E::ts("This function is not implemented"));
......@@ -114,17 +119,22 @@ class CRM_Core_Payment_Redsys extends CRM_Core_Payment {
*/
public function doTransferCheckout(&$params, $component = 'contribute') {
$config = CRM_Core_Config::singleton();
if ($component != 'contribute' && $component != 'event') {
CRM_Core_Error::fatal(E::ts('Component is invalid'));
}
if (array_key_exists('webform_redirect_success', $params)) {
$returnURL = $params['webform_redirect_success'];
$cancelURL = $params['webform_redirect_cancel'];
$returnURL = $this->successUrl ?? $params['webform_redirect_success'];
$cancelURL = $this->cancelUrl ?? $params['webform_redirect_cancel'];
// Drupal Webform CiviCRM workflow.
if ($returnURL && $cancelURL) {
// Avoid issues with relative paths.
$config = CRM_Core_Config::singleton();
$returnURL = (strpos($returnURL, '/') === 0) ? $config->userFrameworkBaseURL . $returnURL : $returnURL;
$cancelURL = (strpos($cancelURL, '/') === 0) ? $config->userFrameworkBaseURL . $cancelURL : $cancelURL;
}
else {
// CiviCRM Core Workflow, Contribution Pages / Events
elseif (!$returnURL && !$cancelURL) {
$url = ($component == 'event') ? 'civicrm/event/register' : 'civicrm/contribute/transact';
$cancel = ($component == 'event') ? '_qf_Register_display' : '_qf_Main_display';
$returnURL = CRM_Utils_System::url($url,
......@@ -143,6 +153,9 @@ class CRM_Core_Payment_Redsys extends CRM_Core_Payment {
TRUE, NULL, FALSE
);
}
else {
throw new CRM_Core_Exception(E::ts("Redsys payment processor - Missing vars to launch full process of redirects."));
}
$merchantUrlParams = "contactID={$params['contactID']}&contributionID={$params['contributionID']}";
if ($component == 'event') {
......
......@@ -14,8 +14,8 @@
<author>iXiam Global Solutions</author>
<email>info@ixiam.com</email>
</maintainer>
<releaseDate>2021-10-14</releaseDate>
<version>2.4.1</version>
<releaseDate>2022-05-09</releaseDate>
<version>2.4.2</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.35</ver>
......
Supports Markdown
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