//Get the require fields value only.
$params = $this->_params = $submittedValues;
- $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_params['payment_processor_id'],
+ $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($params['payment_processor_id'],
$this->_mode
);
CRM_Contribute_Form_AdditionalInfo::processNote($params, $contactID, $contribution->id, NULL);
}
- //process premium
- if ($contribution->id && isset($params['product_name'][0])) {
- CRM_Contribute_Form_AdditionalInfo::processPremium($params, $contribution->id, NULL, $this->_options);
- }
-
if ($contribution->id) {
array_unshift($this->statusMessage, ts('The contribution record has been processed.'));
if (!empty($this->_params['is_email_receipt']) && $sendReceipt) {
*
* @param array $params
* @param int $action
+ * @param string|null $creditCardMode
+ *
+ * @throws \CiviCRM_API3_Exception
*/
- public function testSubmit($params, $action) {
+ public function testSubmit($params, $action, $creditCardMode = NULL) {
$defaults = array(
'soft_credit_contact_id' => array(),
'receipt_date' => '',
$existingContribution
);
+ if ($creditCardMode) {
+ $this->_mode = $creditCardMode;
+ }
+
+ // Required because processCreditCard calls set method on this.
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ $this->controller = new CRM_Core_Controller();
+
CRM_Contribute_Form_AdditionalInfo::buildPremium($this);
+ $this->_fields = array();
$this->submit(array_merge($defaults, $params), $action, CRM_Utils_Array::value('pledge_payment_id', $params));
}
* @return CRM_Core_Payment
* @throws \CRM_Core_Exception
*/
- public static function &singleton($mode = 'test', &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) {
+ public static function singleton($mode = 'test', &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) {
// make sure paymentProcessor is not empty
// CRM-7424
if (empty($paymentProcessor)) {
}
$result['payment_processor_type'] = CRM_Core_PseudoConstant::paymentProcessorType(FALSE, $dao->payment_processor_type_id, 'name');
- $result['instance'] = $result['object'] =& CRM_Core_Payment::singleton($mode, $result);
+ $result['instance'] = $result['object'] = CRM_Core_Payment::singleton($mode, $result);
return $result;
}
*/
protected $products = array();
+ /**
+ * Dummy payment processor.
+ *
+ * @var array
+ */
+ protected $paymentProcessor = array();
+
/**
* Setup function.
*/
public function setUp() {
+ $this->_apiversion = 3;
parent::setUp();
+ $this->createLoggedInUser();
- $this->_apiversion = 3;
$this->_individualId = $this->individualCreate();
$paymentProcessor = $this->processorCreate();
$this->_params = array(
));
$this->products[] = $product1['values'][$product1['id']];
+ $this->paymentProcessor = $this->processorCreate();
+
}
/**
$mut->stop();
}
+ /**
+ * Test functions involving premiums.
+ */
+ public function testPremiumUpdateCreditCard() {
+ $form = new CRM_Contribute_Form_Contribution();
+ $mut = new CiviMailUtils($this, TRUE);
+ $form->testSubmit(array(
+ 'total_amount' => 50,
+ 'financial_type_id' => 1,
+ 'receive_date' => '04/21/2015',
+ 'receive_date_time' => '11:27PM',
+ 'contact_id' => $this->_individualId,
+ 'payment_instrument_id' => array_search('Check', $this->paymentInstruments),
+ 'contribution_status_id' => 1,
+ 'product_name' => array($this->products[0]['id'], 1),
+ 'fulfilled_date' => '',
+ 'is_email_receipt' => TRUE,
+ 'from_email_address' => 'test@test.com',
+ 'payment_processor_id' => $this->paymentProcessor->id,
+ 'credit_card_exp_date' => array('M' => 5, 'Y' => 2012),
+ 'credit_card_number' => '411111111111111',
+ ), CRM_Core_Action::ADD,
+ 'live');
+ $contributionProduct = $this->callAPISuccess('contribution_product', 'getsingle', array());
+ $this->assertEquals('clumsy smurf', $contributionProduct['product_option']);
+ $mut->checkMailLog(array(
+ 'Premium Information',
+ 'Smurf',
+ 'clumsy smurf',
+ ));
+ $mut->stop();
+ }
+
}