/**
  * Check method getFinancialAccount()
  */
 public function testGetFinancialAccount()
 {
     list($financialAccount, $financialType, $financialAccountType) = $this->createFinancialAccount('Asset');
     $params = array('financial_account_id' => $financialAccount->id, 'payment_processor_type_id' => 1, 'domain_id' => 1, 'billing_mode' => 1, 'name' => 'paymentProcessor');
     $processor = CRM_Financial_BAO_PaymentProcessor::create($params);
     $account = CRM_Financial_BAO_FinancialTypeAccount::getFinancialAccount($processor->id, 'civicrm_payment_processor');
     $this->assertEquals($account, $financialAccount->name, 'Verify Financial Account Name');
 }
 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');
 }
Example #3
0
 /**
  * Function tests that additional financial records are created for online contribution with pending option.
  */
 public function testCreateContributionPendingOnline()
 {
     $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::create($this->_processorParams);
     $contributionPage = $this->callAPISuccess('contribution_page', 'create', $this->_pageParams);
     $this->assertAPISuccess($contributionPage);
     $params = array('contact_id' => $this->_individualId, 'receive_date' => '20120511', 'total_amount' => 100.0, 'financial_type_id' => 1, 'contribution_page_id' => $contributionPage['id'], 'trxn_id' => 12345, 'invoice_id' => 67890, 'source' => 'SSF', 'contribution_status_id' => 2);
     $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__);
     $this->assertEquals($contribution['values'][$contribution['id']]['contact_id'], $this->_individualId);
     $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.0);
     $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], 1);
     $this->assertEquals($contribution['values'][$contribution['id']]['trxn_id'], 12345);
     $this->assertEquals($contribution['values'][$contribution['id']]['invoice_id'], 67890);
     $this->assertEquals($contribution['values'][$contribution['id']]['source'], 'SSF');
     $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status_id'], 2);
     $this->_checkFinancialRecords($contribution, 'pending');
 }
 /**
  * check method getFinancialAccount()
  */
 function testGetFinancialAccount()
 {
     $params = array('name' => 'TestFinancialAccount', 'accounting_code' => 4800, 'is_deductible' => 0, 'is_active' => 1, 'is_reserved' => 0);
     $ids = array();
     $financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, $ids);
     $params = array('financial_account_id' => $financialAccount->id, 'payment_processor_type_id' => 1, 'domain_id' => 1, 'billing_mode' => 1, 'name' => 'paymentProcessor');
     $processor = CRM_Financial_BAO_PaymentProcessor::create($params);
     $account = CRM_Financial_BAO_FinancialTypeAccount::getFinancialAccount($processor->id, 'civicrm_payment_processor');
     $this->assertEquals($account, 'TestFinancialAccount', 'Verify Financial Account Name');
 }
Example #5
0
 /**
  * Install an extension and create a payment processor which uses it.
  * Attempts to uninstall fail
  */
 public function testInstall_Add_FailUninstall()
 {
     $manager = $this->system->getManager();
     $this->assertDBQuery(0, 'SELECT count(*) FROM civicrm_payment_processor_type WHERE class_name = "test.extension.manager.paymenttest"');
     $manager->install(array('test.extension.manager.paymenttest'));
     $this->assertEquals(1, test_extension_manager_paymenttest::$counts['install']);
     $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_payment_processor_type WHERE class_name = "test.extension.manager.paymenttest" AND is_active = 1');
     $payment_processor_type_id = CRM_Core_DAO::singleValueQuery('SELECT id FROM civicrm_payment_processor_type  WHERE class_name = "test.extension.manager.paymenttest"');
     $ppDAO = CRM_Financial_BAO_PaymentProcessor::create(array('payment_processor_type_id' => $payment_processor_type_id, 'domain_id' => CRM_Core_Config::domainID()));
     $manager->disable(array('test.extension.manager.paymenttest'));
     $this->assertEquals(1, test_extension_manager_paymenttest::$counts['disable']);
     $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_payment_processor_type WHERE class_name = "test.extension.manager.paymenttest"');
     $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_payment_processor_type WHERE class_name = "test.extension.manager.paymenttest" AND is_active = 0');
     // first attempt to uninstall -- fail
     try {
         $manager->uninstall(array('test.extension.manager.paymenttest'));
         $this->fail('Failed to catch expected exception');
     } catch (CRM_Extension_Exception_DependencyException $e) {
     }
     $this->assertEquals(0, test_extension_manager_paymenttest::getCount('uninstall'));
     $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_payment_processor_type WHERE class_name = "test.extension.manager.paymenttest"');
     $ppDAO->delete();
     // second attempt to uninstall -- ok
     $manager->uninstall(array('test.extension.manager.paymenttest'));
     $this->assertEquals(1, test_extension_manager_paymenttest::getCount('uninstall'));
     $this->assertDBQuery(0, 'SELECT count(*) FROM civicrm_payment_processor_type WHERE class_name = "test.extension.manager.paymenttest"');
 }
 /**
  * Create Payment Processor.
  *
  * @return CRM_Financial_DAO_PaymentProcessor
  *   instance of Payment Processsor
  */
 public function processorCreate()
 {
     $processorParams = array('domain_id' => 1, 'name' => 'Dummy', 'payment_processor_type_id' => 10, 'financial_account_id' => 12, 'is_test' => TRUE, 'is_active' => 1, 'user_name' => '', 'url_site' => 'http://dummy.com', 'url_recur' => 'http://dummy.com', 'billing_mode' => 1);
     $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::create($processorParams);
     return $paymentProcessor;
 }