Merge remote-tracking branch 'upstream/4.6' into 4.6-master-2015-08-16-18-06-10
[civicrm-core.git] / CRM / Core / Payment / PayPalImpl.php
index 7a6f58e0381db703828c92303a2a49925ae5d15f..0af967fd7dac5d77898728de15a47b19bb9a74ab 100644 (file)
@@ -124,7 +124,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment {
    * Billing mode button is basically synonymous with paypal express  - this is probably a good example of 'odds & sods' code we
    * need to find a way for the payment processor to assign. A tricky aspect is that the payment processor may need to set the order
    *
-   * @param $form
+   * @param CRM_Core_Form $form
    */
   protected function addPaypalExpressCode(&$form) {
     if (empty($form->isBackOffice)) {
@@ -155,6 +155,21 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment {
     return TRUE;
   }
 
+  /**
+   * Default payment instrument validation.
+   *
+   * Implement the usual Luhn algorithm via a static function in the CRM_Core_Payment_Form if it's a credit card
+   * Not a static function, because I need to check for payment_type.
+   *
+   * @param array $values
+   * @param array $errors
+   */
+  public function validatePaymentInstrument($values, &$errors) {
+    if ($this->_paymentProcessor['payment_processor_type'] == 'PayPal_Pro') {
+      CRM_Core_Payment_Form::validateCreditCard($values, $errors);
+    }
+  }
+
   /**
    * Express checkout code. Check PayPal documentation for more information
    *