CRM-17256 Show / bounce on paypal express errors
authoreileen <emcnaughton@wikimedia.org>
Tue, 27 Oct 2015 07:43:42 +0000 (20:43 +1300)
committereileen <emcnaughton@wikimedia.org>
Tue, 27 Oct 2015 07:47:34 +0000 (20:47 +1300)
CRM/Core/Form.php
CRM/Core/Payment.php
CRM/Core/Payment/PayPalImpl.php

index d36c6f1ca3a4657d636d499202d586a8f21cd684..2f328fcf5953e67161dcb2a1d32d67e6b368e0b0 100644 (file)
@@ -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']);
index 2d20cef15c005b8e0994cfab08a6c737d74f45c0..d0667b038c8dcbb7b55ba6ef9bf43802bd0737d6 100644 (file)
@@ -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,
index d54614a1f2bd8ce4b9492214ff5050d1f04ecfa3..ef1e96319996655dc1473957cd255e03557a7688 100644 (file)
@@ -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,