$contributionParams['contribution_recur_id'] = $recurringContributionID;
}
- $contributionParams['contribution_status_id'] = $pending ? 2 : 1;
+ $contributionParams['contribution_status_id'] = ($pending && $contributionParams['total_amount'] != 0) ? 2 : 1;
if (isset($contributionParams['invoice_id'])) {
$contributionParams['id'] = CRM_Core_DAO::getFieldValue(
'CRM_Contribute_DAO_Contribution',
// We may have fetched some billing details from the getPreApprovalDetails function so we
// want to ensure we set this after that function has been called.
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $this->_params, FALSE);
- if (!empty($this->_params["billing_state_province_id-{$this->_bltID}"])) {
- $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
- }
- if (!empty($this->_params["billing_country_id-{$this->_bltID}"])) {
- $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
- }
$this->_params['is_pay_later'] = $this->get('is_pay_later');
$this->assign('is_pay_later', $this->_params['is_pay_later']);
);
}
else {
+ // The concept of contributeMode is deprecated.
+ // the is_monetary concept probably should be too as it can be calculated from
+ // the existence of 'amount' & seems fragile.
if ($this->_contributeMode == 'notify' || !$this->_values['is_monetary'] ||
$this->_amount <= 0.0 || $this->_params['is_pay_later'] ||
($this->_separateMembershipPayment && $this->_amount <= 0.0)
TRUE, NULL, FALSE, TRUE
);
// set email in the template here
- // get the billing location type
- $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
- $billingLocationTypeId = array_search('Billing', $locationTypes);
- if ($billingLocationTypeId) {
- list($donorName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution->contact_id, FALSE, $billingLocationTypeId);
+ if (CRM_Core_BAO_LocationType::getBilling()) {
+ list($donorName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution->contact_id,
+ FALSE, CRM_Core_BAO_LocationType::getBilling());
}
// get primary location email if no email exist( for billing location).
if (!$email) {
$isProcessSeparateMembershipTransaction, $financialTypeID, $membershipLineItems, $isPayLater, $isPending) {
$membershipContribution = NULL;
$isTest = CRM_Utils_Array::value('is_test', $membershipParams, FALSE);
- $errors = $createdMemberships = $paymentResult = array();
+ $errors = $createdMemberships = $paymentResults = array();
if ($isPaidMembership) {
if ($isProcessSeparateMembershipTransaction) {
if (empty($form->_params['auto_renew']) && !empty($membershipParams['is_recur'])) {
unset($membershipParams['is_recur']);
}
- $membershipContribution = $this->processSecondaryFinancialTransaction($contactID, $form, $membershipParams,
+ list($membershipContribution, $secondPaymentResult) = $this->processSecondaryFinancialTransaction($contactID, $form, $membershipParams,
$isTest, $membershipLineItems, CRM_Utils_Array::value('minimum_fee', $membershipDetails, 0), CRM_Utils_Array::value('financial_type_id', $membershipDetails));
+ $paymentResults[] = array('contribution_id' => $membershipContribution->id, 'result' => $secondPaymentResult);
}
catch (CRM_Core_Exception $e) {
$errors[2] = $e->getMessage();
if (isset($membershipContributionID)) {
$form->_values['contribution_id'] = $membershipContributionID;
}
- if ($form->_contributeMode) {
+
+ if ($form->_paymentProcessor) {
+ // the is_monetary concept probably should be deprecated as it can be calculated from
+ // the existence of 'amount' & seems fragile.
if ($form->_values['is_monetary'] && $form->_amount > 0.0 && !$form->_params['is_pay_later']) {
// call postProcess hook before leaving
$form->postProcessHook();
}
+
$payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
$paymentActionResult = $payment->doPayment($form->_params, 'contribute');
- $this->completeTransaction($paymentActionResult, $paymentResult['contribution']->id);
+ $paymentResults[] = array('contribution_id' => $paymentResult['contribution']->id, 'result' => $paymentActionResult);
// Do not send an email if Recurring transaction is done via Direct Mode
// Email will we sent when the IPN is received.
+ foreach ($paymentResults as $result) {
+ $this->completeTransaction($result['result'], $result['contribution_id']);
+ }
return;
}
$result = $payment->doPayment($tempParams, 'contribute');
$form->set('membership_trx_id', $result['trxn_id']);
$form->assign('membership_trx_id', $result['trxn_id']);
- $this->completeTransaction($result, $membershipContribution->id);
}
- return $membershipContribution;
+ return array($membershipContribution, $result);
}
/**
* We are moving towards always creating as pending and updating at the end (based on payment), so this should be
* an interim refactoring. It was shared with another unrelated form & some parameters may not apply to this form.
*
- *
* @return bool
*/
protected function getIsPending() {
+ // The concept of contributeMode is deprecated.
+ // the is_monetary concept probably should be too as it can be calculated from
+ // the existence of 'amount' & seems fragile.
if (((isset($this->_contributeMode)) || !empty
($this->_params['is_pay_later'])
) &&
}
if ($isQuickConfig && !empty($this->_params["price_{$priceField->id}"])) {
if ($this->_values['fee'][$priceField->id]['html_type'] != 'Text') {
+ // @todo - stop setting amount level in this function & call the CRM_Price_BAO_PriceSet::getAmountLevel
+ // function to get correct amount level consistently. Remove setting of the amount level in
+ // CRM_Price_BAO_PriceSet::processAmount. Extend the unit tests in CRM_Price_BAO_PriceSetTest
+ // to cover all variants.
$this->_params['amount_level'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue',
$this->_params["price_{$priceField->id}"], 'label');
}
$params['invoiceID'] = md5(uniqid(rand(), TRUE));
$paramsProcessedForForm = $form->_params = self::getFormParams($params['id'], $params);
$form->_amount = $params['amount'];
+ // hack these in for test support.
+ $form->_fields['billing_first_name'] = 1;
+ $form->_fields['billing_last_name'] = 1;
$priceSetID = $form->_params['priceSetId'] = $paramsProcessedForForm['price_set_id'];
$priceFields = CRM_Price_BAO_PriceSet::getSetDetail($priceSetID);
$priceSetFields = reset($priceFields);
$form->_paymentProcessor = civicrm_api3('payment_processor', 'getsingle', array(
'id' => $params['payment_processor_id'],
));
+ // The concept of contributeMode is deprecated as is the billing_mode concept.
if ($form->_paymentProcessor['billing_mode'] == 1) {
$form->_contributeMode = 'direct';
}
// billing email address
$fields["email-{$this->_bltID}"] = 1;
- //unset the billing parameters if it is pay later mode
- //to avoid creation of billing location
- // @todo - note that elsewhere we don't unset these - we simply make
- // a sensible decision about including them when building the form
- // and if they are submitted we handle them. Check out abstractEditPaymentForm.
- if ($isPayLater && !$this->_isBillingAddressRequiredForPayLater) {
- $billingFields = array(
- 'billing_first_name',
- 'billing_middle_name',
- 'billing_last_name',
- "billing_street_address-{$this->_bltID}",
- "billing_city-{$this->_bltID}",
- "billing_state_province-{$this->_bltID}",
- "billing_state_province_id-{$this->_bltID}",
- "billing_postal_code-{$this->_bltID}",
- "billing_country-{$this->_bltID}",
- "billing_country_id-{$this->_bltID}",
- );
-
- foreach ($billingFields as $value) {
- unset($params[$value]);
- unset($fields[$value]);
- }
- }
-
// if onbehalf-of-organization contribution, take out
// organization params in a separate variable, to make sure
// normal behavior is continued. And use that variable to
* @param bool $isPayLater
*/
protected function doMembershipProcessing($contactID, $membershipParams, $premiumParams, $isPayLater) {
-
+ // This could be set by a hook.
+ if (!empty($this->_params['installments'])) {
+ $membershipParams['installments'] = $this->_params['installments'];
+ }
// added new parameter for cms user contact id, needed to distinguish behaviour for on behalf of sign-ups
if (isset($this->_params['related_contact'])) {
$membershipParams['cms_contactID'] = $this->_params['related_contact'];