Fix payment validation for payment on confirm
authorlarssandergreen <lars@wildsight.ca>
Sun, 4 Jun 2023 16:15:54 +0000 (10:15 -0600)
committerlarssandergreen <lars@wildsight.ca>
Sun, 4 Jun 2023 16:15:54 +0000 (10:15 -0600)
CRM/Event/Form/Registration/Confirm.php
CRM/Event/Form/Registration/Register.php

index 303f406bce84e24cd83309ab158e46d0b6d80fc5..ecd6fc3b35ecd16f7abf0dc04b6b19fa51d731e9 100644 (file)
@@ -398,6 +398,15 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
       $errors['payment_processor_id'] = ts('Please select a Payment Method');
     }
 
+    if ($form->showPaymentOnConfirm) {
+      CRM_Core_Payment_Form::validatePaymentInstrument(
+        $fields['payment_processor_id'],
+        $fields,
+        $errors,
+        (!$form->_isBillingAddressRequiredForPayLater ? NULL : 'billing')
+      );
+    }
+
     return empty($errors) ? TRUE : $errors;
   }
 
index 3b35e681c019470d74d0319c34b15188eb0eb0d2..201d82c655c0199d47ac6441e130308746aa1209 100644 (file)
@@ -922,12 +922,15 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
       ) {
         return empty($errors) ? TRUE : $errors;
       }
-      CRM_Core_Payment_Form::validatePaymentInstrument(
-        $fields['payment_processor_id'],
-        $fields,
-        $errors,
-        (!$form->_isBillingAddressRequiredForPayLater ? NULL : 'billing')
-      );
+
+      if (!$form->showPaymentOnConfirm) {
+        CRM_Core_Payment_Form::validatePaymentInstrument(
+          $fields['payment_processor_id'],
+          $fields,
+          $errors,
+          (!$form->_isBillingAddressRequiredForPayLater ? NULL : 'billing')
+        );
+      }
     }
 
     return empty($errors) ? TRUE : $errors;