Expose payment processor error from PaymentProcessor.pay
authorJon Goldberg <jon@megaphonetech.com>
Mon, 7 Mar 2022 20:04:08 +0000 (15:04 -0500)
committerJon Goldberg <jon@megaphonetech.com>
Mon, 7 Mar 2022 20:04:08 +0000 (15:04 -0500)
api/v3/PaymentProcessor.php

index 06587f00ca3120f50e4067ed510eda1c3544a814..803f38dce4e4509854108d6b1801f562c4e33e21 100644 (file)
@@ -123,7 +123,8 @@ function civicrm_api3_payment_processor_pay($params) {
     if (empty($code)) {
       $code = 'EXTERNAL_FAILURE';
     }
-    throw new API_Exception('Payment failed', $code, $errorData, $e);
+    $message = $e->getMessage() ?? 'Payment Failed';
+    throw new API_Exception($message, $code, $errorData, $e);
   }
   return civicrm_api3_create_success(array($result), $params);
 }