From 8af73c75a23fe42f89528274121f2f063519fa2b Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" <mjw@mjwconsult.co.uk> Date: Thu, 19 Sep 2019 16:13:14 +0100 Subject: [PATCH] Friendly error message when no amount specified on the form --- CRM/Stripe/AJAX.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CRM/Stripe/AJAX.php b/CRM/Stripe/AJAX.php index 4bcce974..7cf07a75 100644 --- a/CRM/Stripe/AJAX.php +++ b/CRM/Stripe/AJAX.php @@ -3,6 +3,8 @@ * https://civicrm.org/licensing */ +use CRM_Stripe_ExtensionUtil as E; + /** * Class CRM_Stripe_AJAX */ @@ -39,7 +41,10 @@ class CRM_Stripe_AJAX { public static function confirmPayment() { $paymentMethodID = CRM_Utils_Request::retrieveValue('payment_method_id', 'String'); $paymentIntentID = CRM_Utils_Request::retrieveValue('payment_intent_id', 'String'); - $amount = CRM_Utils_Request::retrieveValue('amount', 'Money', NULL, TRUE); + $amount = CRM_Utils_Request::retrieveValue('amount', 'Money'); + if (empty($amount)) { + CRM_Utils_JSON::output(['error' => ['message' => E::ts('No amount specified for payment!')]]); + } $currency = CRM_Utils_Request::retrieveValue('currency', 'String', CRM_Core_Config::singleton()->defaultCurrency); $processorID = CRM_Utils_Request::retrieveValue('id', 'Integer', NULL, TRUE); $processor = new CRM_Core_Payment_Stripe('', civicrm_api3('PaymentProcessor', 'getsingle', ['id' => $processorID])); -- GitLab