From abfb35ee251d16a1faaf4202a8a712d82c89d411 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 27 Oct 2015 20:43:42 +1300 Subject: [PATCH] CRM-17256 Show / bounce on paypal express errors --- CRM/Core/Form.php | 3 +-- CRM/Core/Payment.php | 2 +- CRM/Core/Payment/PayPalImpl.php | 5 +++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index d36c6f1ca3..2f328fcf59 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -827,8 +827,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { } } catch (\Civi\Payment\Exception\PaymentProcessorException $e) { - CRM_Core_Error::displaySessionError($e->getMessage()); - CRM_Utils_System::redirect($params['cancelURL']); + CRM_Core_Error::statusBounce(ts('Payment approval failed with message :') . $e->getMessage(), $payment->getCancelUrl($params['qfKey'], CRM_Utils_Array::value('participant_id', $params))); } $this->set('pre_approval_parameters', $result['pre_approval_parameters']); diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index 2d20cef15c..d0667b038c 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -777,7 +777,7 @@ abstract class CRM_Core_Payment { * * @return string cancel url */ - protected function getCancelUrl($qfKey, $participantID) { + public function getCancelUrl($qfKey, $participantID) { if ($this->_component == 'event') { return CRM_Utils_System::url($this->getBaseReturnUrl(), array( 'reset' => 1, diff --git a/CRM/Core/Payment/PayPalImpl.php b/CRM/Core/Payment/PayPalImpl.php index d54614a1f2..ef1e963199 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -220,7 +220,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { $result = $this->invokeAPI($args); if (is_a($result, 'CRM_Core_Error')) { - return $result; + throw new PaymentProcessorException($result->message); } /* Success */ @@ -264,7 +264,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { $result = $this->invokeAPI($args); if (is_a($result, 'CRM_Core_Error')) { - return $result; + throw new PaymentProcessorException(CRM_Core_Error::getMessages($result)); } /* Success */ @@ -1017,6 +1017,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { if (strtolower($result['ack']) != 'success' && strtolower($result['ack']) != 'successwithwarning' ) { + throw new PaymentProcessorException("{$result['l_shortmessage0']} {$result['l_longmessage0']}"); $e = CRM_Core_Error::singleton(); $e->push($result['l_errorcode0'], 0, NULL, -- 2.25.1