本文整理汇总了PHP中CRM_Financial_BAO_PaymentProcessor::getCreditCards方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Financial_BAO_PaymentProcessor::getCreditCards方法的具体用法?PHP CRM_Financial_BAO_PaymentProcessor::getCreditCards怎么用?PHP CRM_Financial_BAO_PaymentProcessor::getCreditCards使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Financial_BAO_PaymentProcessor
的用法示例。
在下文中一共展示了CRM_Financial_BAO_PaymentProcessor::getCreditCards方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreditCardCSSName
public function testCreditCardCSSName()
{
$params = array('name' => 'API_Test_PP_Type', 'title' => 'API Test Payment Processor Type', 'class_name' => 'CRM_Core_Payment_APITest', 'billing_mode' => 'form', 'payment_processor_type_id' => 1, 'is_recur' => 0, 'domain_id' => 1, 'accepted_credit_cards' => json_encode(array('Visa' => 'Visa', 'Mastercard' => 'Mastercard', 'Amex' => 'Amex')));
$paymentProcessor = CRM_Financial_BAO_PaymentProcessor::create($params);
$cards = CRM_Financial_BAO_PaymentProcessor::getCreditCards($paymentProcessor->id);
$CSSCards = CRM_Core_Payment_Form::getCreditCardCSSNames($cards);
$expectedCSSCards = array('visa' => 'Visa', 'mastercard' => 'Mastercard', 'amex' => 'Amex');
$this->assertEquals($CSSCards, $expectedCSSCards, 'Verify correct credit card types are returned');
$CSSCards2 = CRM_Core_Payment_Form::getCreditCardCSSNames(array());
$allCards = array('visa' => 'Visa', 'mastercard' => 'MasterCard', 'amex' => 'Amex', 'discover' => 'Discover');
$this->assertEquals($CSSCards2, $allCards, 'Verify correct credit card types are returned');
}
示例2: validateCreditCard
/**
* 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($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'])) {
$errors['credit_card_number'] = ts('Please enter a valid Card Number');
}
if (!empty($values['cvv2']) && !CRM_Utils_Rule::cvv($values['cvv2'], $values['credit_card_type'])) {
$errors['cvv2'] = ts('Please enter a valid Card Verification Number');
}
}
}
示例3: addCreditCardJs
/**
* Add JS to show icons for the accepted credit cards.
*/
public static function addCreditCardJs($paymentProcessorID = NULL)
{
$creditCards = array();
$creditCards = CRM_Financial_BAO_PaymentProcessor::getCreditCards($paymentProcessorID);
$creditCardTypes = CRM_Core_Payment_Form::getCreditCardCSSNames($creditCards);
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Core/BillingBlock.js', 10)->addScript('CRM.config.creditCardTypes = ' . json_encode($creditCardTypes) . ';');
}