CRM-19372 allow payment processors to define an array of accepted credit card types
[civicrm-core.git] / CRM / Financial / BAO / PaymentProcessor.php
index b2e13d985d6ec9b988532230c0dff6b37b1032d7..f5cb848d13971c0026ba30d420f6b6faffad8728 100644 (file)
@@ -90,6 +90,22 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
     parent::__construct();
   }
 
+  /**
+   * Retieve array of allowed credit cards for this payment processor.
+   * @param interger|null $paymentProcessorID id of processor.
+   * @return array
+   */
+  public static function getCreditCards($paymentProcessorID = NULL) {
+    if (!empty($paymentProcessorID)) {
+      $processor = new CRM_Financial_DAO_PaymentProcessor();
+      $processor->id = $paymentProcessorID;
+      $processor->find(TRUE);
+      $cards = json_decode($processor->accepted_credit_cards, TRUE);
+      return $cards;
+    }
+    return array();
+  }
+
   /**
    * Retrieve DB object based on input parameters.
    *