'accepted_credit_cards'
), TRUE);
$acceptedCards = array();
- foreach ($cards as $card => $val) {
- $acceptedCards[$card] = 1;
+ if (!empty($cards)) {
+ foreach ($cards as $card => $val) {
+ $acceptedCards[$card] = 1;
+ }
}
$defaults['accept_credit_cards'] = $acceptedCards;
unset($defaults['accepted_credit_cards']);
}
}
}
- CRM_Financial_Form_Payment::addCreditCardJs();
+ CRM_Financial_Form_Payment::addCreditCardJs($id);
}
$this->assign('recurringPaymentProcessorIds',
empty($this->_recurPaymentProcessors) ? '' : implode(',', array_keys($this->_recurPaymentProcessors))
public function validatePaymentInstrument($values, &$errors) {
CRM_Core_Form::validateMandatoryFields($this->getMandatoryFields(), $values, $errors);
if ($this->_paymentProcessor['payment_type'] == 1) {
- CRM_Core_Payment_Form::validateCreditCard($values, $errors);
+ CRM_Core_Payment_Form::validateCreditCard($this->_paymentProcessor['id'], $values, $errors);
}
}
* Make sure that credit card number and cvv are valid.
* Called within the scope of a QF formRule function
*
+ * @param int $processorID
* @param array $values
* @param array $errors
*/
- public static function validateCreditCard($values, &$errors) {
+ public static function validateCreditCard($processorID = NULL, $values, &$errors) {
if (!empty($values['credit_card_type']) || !empty($values['credit_card_number'])) {
+ if (!empty($values['credit_card_type'])) {
+ $processorCards = CRM_Financial_BAO_PaymentProcessor::getCreditCards($processorID);
+ if (!empty($processorCards) && !in_array($values['credit_card_type'], $processorCards)) {
+ $errors['credit_card_type'] = ts('This procesor does not support credit card type ' . $values['credit_card_type']);
+ }
+ }
if (!empty($values['credit_card_number']) &&
!CRM_Utils_Rule::creditCardNumber($values['credit_card_number'], $values['credit_card_type'])
) {
*/
public function validatePaymentInstrument($values, &$errors) {
if ($this->_paymentProcessor['payment_processor_type'] == 'PayPal' && !$this->isPaypalExpress($values)) {
- CRM_Core_Payment_Form::validateCreditCard($values, $errors);
+ CRM_Core_Payment_Form::validateCreditCard($this->_paymentProcessor['id'], $values, $errors);
CRM_Core_Form::validateMandatoryFields($this->getMandatoryFields(), $values, $errors);
}
}
* @return bool
*/
public static function creditCardNumber($value, $type) {
- require_once 'Validate/Finance/CreditCard.php';
return Validate_Finance_CreditCard::number($value, $type);
}
* @return bool
*/
public static function cvv($value, $type) {
- require_once 'Validate/Finance/CreditCard.php';
-
return Validate_Finance_CreditCard::cvv($value, $type);
}
$.each(card_types, function(key, pattern) {
if (ccnumber.match('^' + pattern + '$')) {
var value = card_values[key];
- $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + key).css('opacity', 1);
- $('select#credit_card_type').val(value);
- return false;
+ //$.each(CRM.config.creditCardTypes, function(key2, val) {
+ // if (value == val) {
+ $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + key).css('opacity', 1);
+ $('select#credit_card_type').val(value);
+ return false;
+ // }
+ // else {
+ // $
+ // });
}
});
}