class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_ContributionPage {
/**
- * Takes an associative array and creates a contribution page object.
+ * Creates a contribution page.
*
* @param array $params
- * (reference ) an assoc array of name/value pairs.
*
* @return CRM_Contribute_DAO_ContributionPage
*/
- public static function &create(&$params) {
+ public static function create($params) {
$financialTypeId = NULL;
if (!empty($params['id']) && !CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $params['id'], NULL, 1)) {
$financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $params['id'], 'financial_type_id');
}
+
+ if (isset($params['payment_processor']) && is_array($params['payment_processor'])) {
+ $params['payment_processor'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $params['payment_processor']);
+ }
$hook = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($hook, 'ContributionPage', CRM_Utils_Array::value('id', $params), $params);
$dao = new CRM_Contribute_DAO_ContributionPage();
$this->callAPISuccess('contribution', 'getsingle', array('contribution_page_id' => $this->_ids['contribution_page']));
}
+ /**
+ * Test process with instant payment when more than one configured for the page.
+ *
+ * CRM-16923
+ */
+ public function testSubmitRecurMultiProcessorInstantPayment() {
+ $this->setUpContributionPage();
+ $this->setupPaymentProcessor();
+ $paymentProcessor2ID = $this->paymentProcessorCreate(array(
+ 'payment_processor_type_id' => 'Dummy',
+ 'name' => 'processor 2',
+ 'class_name' => 'Payment_Dummy',
+ 'billing_mode' => 1,
+ ));
+ $dummyPP = Civi\Payment\System::singleton()->getById($paymentProcessor2ID);
+ $dummyPP->setDoDirectPaymentResult(array('payment_status_id' => 1, 'trxn_id' => 'create_first_success'));
+ $this->callAPISuccess('ContributionPage', 'create', array(
+ 'id' =>$this->_ids['contribution_page'],
+ 'payment_processor' => array($paymentProcessor2ID, $this->_ids['payment_processor'])
+ ));
+
+ $priceFieldID = reset($this->_ids['price_field']);
+ $priceFieldValueID = reset($this->_ids['price_field_value']);
+ $submitParams = array(
+ 'price_' . $priceFieldID => $priceFieldValueID,
+ 'id' => (int) $this->_ids['contribution_page'],
+ 'amount' => 10,
+ 'is_recur' => 1,
+ 'frequency_interval' => 1,
+ 'frequency_unit' => 'month',
+ 'payment_processor_id' => $paymentProcessor2ID,
+ );
+
+ $this->callAPISuccess('contribution_page', 'submit', $submitParams);
+ $this->callAPISuccess('contribution', 'getsingle', array(
+ 'contribution_page_id' => $this->_ids['contribution_page'],
+ 'contribution_status_id' => 1,
+ ));
+ }
/**
* Test submit with a membership block in place.
*/
'billing_middle_name' => 'Goat',
'billing_last_name' => 'Gruff',
'selectMembership' => $this->_ids['membership_type'],
- 'payment_processor_id' => 1,
+ 'payment_processor_id' => $this->_paymentProcessor['id'],
'credit_card_number' => '4111111111111111',
'credit_card_type' => 'Visa',
'credit_card_exp_date' => array('M' => 9, 'Y' => 2040),