| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
use Civi\Payment\System;
protected $_paymentProcessor;
/**
- * Singleton function used to manage this object
+ * Singleton function used to manage this object.
* We will migrate to calling Civi\Payment\System::singleton()->getByProcessor($paymentProcessor)
* & Civi\Payment\System::singleton()->getById($paymentProcessor) directly as the main access methods & work
* to remove this function all together
*
* @return CRM_Core_Payment
* @throws \CRM_Core_Exception
- * @static
*/
public static function &singleton($mode = 'test', &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) {
// make sure paymentProcessor is not empty
}
/**
- * Check if capability is supported
+ * Check if capability is supported.
* @param string $capability
* E.g BackOffice, LiveMode, FutureRecurStartDate.
*
}
/**
- * Are test payments supported
+ * Are test payments supported.
* @return bool
*/
protected function supportsTestMode() {
}
/**
- * Should the first payment date be configurable when setting up back office recurring payments
+ * Should the first payment date be configurable when setting up back office recurring payments.
* We set this to false for historical consistency but in fact most new processors use tokens for recurring and can support this
* @return bool
*/
return FALSE;
}
+ /**
+ * 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
+ */
+ public function validatePaymentInstrument($values, &$errors) {
+ if ($this->_paymentProcessor['payment_type'] == 1) {
+ CRM_Core_Payment_Form::validateCreditCard($values, $errors);
+ }
+ }
+
/**
* Setter for the payment form that wants to use the processor
* @deprecated
}
/**
- * Getter for payment form that is using the processor
+ * Getter for payment form that is using the processor.
* @deprecated
* @return CRM_Core_Form
* A form object
}
/**
- * Getter for accessing member vars
+ * Getter for accessing member vars.
* @todo believe this is unused
* @param string $name
*
}
/**
- * Get name for the payment information type
+ * Get name for the payment information type.
* @todo - use option group + name field (like Omnipay does)
* @return string
*/
}
/**
- * Get label for the payment information type
+ * Get label for the payment information type.
* @todo - use option group + labels (like Omnipay does)
* @return string
*/
}
/**
- * Get array of fields that should be displayed on the payment form
+ * Get array of fields that should be displayed on the payment form.
* @todo make payment type an option value & use it in the function name - currently on debit & credit card work
* @return array
* @throws CiviCRM_API3_Exception
}
/**
- * Get array of fields that should be displayed on the payment form for credit cards
+ * Get array of fields that should be displayed on the payment form for credit cards.
*
* @return array
*/
}
/**
- * Get array of fields that should be displayed on the payment form for direct debits
+ * Get array of fields that should be displayed on the payment form for direct debits.
*
* @return array
*/
}
/**
- * Return an array of all the details about the fields potentially required for payment fields
+ * Return an array of all the details about the fields potentially required for payment fields.
* Only those determined by getPaymentFormFields will actually be assigned to the form
*
* @return array
'rule_message' => ts('Please enter a valid value for your card security code. This is usually the last 3-4 digits on the card\'s signature panel.'),
'rule_name' => 'integer',
'rule_parameters' => NULL,
- )
+ ),
),
),
'credit_card_exp_date' => array(
'rule_message' => ts('Card expiration date cannot be a past date.'),
'rule_name' => 'currentDate',
'rule_parameters' => TRUE,
- )
+ ),
),
),
'credit_card_type' => array(
'rule_message' => ts('Please enter a valid Bank Identification Number (value must not contain punctuation characters).'),
'rule_name' => 'nopunctuation',
'rule_parameters' => NULL,
- )
+ ),
),
'is_required' => TRUE,
),
'rule_message' => ts('Please enter a valid Bank Identification Number (value must not contain punctuation characters).'),
'rule_name' => 'nopunctuation',
'rule_parameters' => NULL,
- )
+ ),
),
),
'bank_name' => array(
}
/**
- * This function collects all the information from a web/api form and invokes
- * the relevant payment processor specific functions to perform the transaction
+ * Calling this from outside the payment subsystem is deprecated - use doPayment.
+ *
+ * Does a server to server payment transaction.
+ *
+ * Note that doPayment will throw an exception so the code may need to be modified
*
* @param array $params
* Assoc array of input parameters for this transaction.
* the result in an nice formatted array (or an error object)
* @abstract
*/
- abstract function doDirectPayment(&$params);
+ abstract protected function doDirectPayment(&$params);
/**
* Process payment - this function wraps around both doTransferPayment and doDirectPayment
* (modified)
* @throws CRM_Core_Exception
*/
- public function doPayment(&$params, $component) {
+ public function doPayment(&$params, $component = 'contribute') {
if ($this->_paymentProcessor['billing_mode'] == 4) {
$result = $this->doTransferCheckout($params, $component);
}
}
/**
- * This function checks to see if we have the right config values
+ * This function checks to see if we have the right config values.
*
* @return string
* the error message if any
*/
- abstract function checkConfig();
+ abstract protected function checkConfig();
/**
* @param $paymentProcessor
* @param string $method
* Method to check for.
*
- * @return boolean
+ * @return bool
*/
public function isSupported($method = 'cancelSubscription') {
return method_exists(CRM_Utils_System::getClassName($this), $method);
// Else default
return $this->_paymentProcessor['url_recur'];
}
+
}