// add qfKey so we can send to paypal
$form->_params['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
- $membershipResult = array(1 => $contribution);
- return $membershipResult;
+ return array('contribution' => $contribution);
}
else {
if (!$isPayLater) {
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
- if ($component !== 'membership') {
- // This is only called from contribution form.
- // Not sure if there is any reason not to just throw an exception up to it.
- $result['is_payment_failure'] = TRUE;
- return $result;
- }
- $membershipResult[1] = $result;
+ $result['is_payment_failure'] = TRUE;
}
}
- if ($component == 'membership') {
- $membershipResult = array();
- }
-
if ($result || ($form->_amount == 0.0 && !$form->_params['is_pay_later'])) {
if ($result) {
$form->_params = array_merge($form->_params, $result);
if (is_array($result) && !empty($result['trxn_id'])) {
$contribution->trxn_id = $result['trxn_id'];
}
- $membershipResult[1] = $contribution;
+ $result['contribution'] = $contribution;
}
-
- if ($component == 'membership') {
- return $membershipResult;
- }
-
//Do not send an email if Recurring contribution is done via Direct Mode
//We will send email once the IPN is received.
if ($form->_contributeMode == 'direct') {
}
if ($isPaidMembership) {
- $result = CRM_Contribute_BAO_Contribution_Utils::processConfirm($form, $membershipParams,
+ if ($isProcessSeparateMembershipTransaction) {
+ // If we have 2 transactions only one can use the invoice id.
+ $membershipParams['invoiceID'] .= '-2';
+ }
+
+ $paymentResult = CRM_Contribute_BAO_Contribution_Utils::processConfirm($form, $membershipParams,
$premiumParams, $contactID,
$financialTypeID,
'membership',
if (is_a($result[1], 'CRM_Core_Error')) {
$errors[1] = CRM_Core_Error::getMessages($result[1]);
}
- elseif (!empty($result[1])) {
+
+ if (is_a($paymentResult, 'CRM_Core_Error')) {
+ $errors[1] = CRM_Core_Error::getMessages($paymentResult);
+ }
+ elseif (!empty($paymentResult['contribution'])) {
+ //note that this will be over-written if we are using a separate membership transaction. Otherwise there is only one
+ $membershipContribution = $paymentResult['contribution'];
// Save the contribution ID so that I can be used in email receipts
// For example, if you need to generate a tax receipt for the donation only.
- $form->_values['contribution_other_id'] = $result[1]->id;
- //note that this will be over-written if we are using a separate membership transaction. Otherwise there is only one
- $membershipContribution = $result[1];
+ $form->_values['contribution_other_id'] = $membershipContribution->id;
}
}
$form->_values['contribution_id'] = $membershipContributionID;
}
- // Do not send an email if Recurring transaction is done via Direct Mode
- // Email will we sent when the IPN is received.
- if (!empty($form->_params['is_recur']) && $form->_contributeMode == 'direct') {
- if (!empty($membershipContribution->trxn_id)) {
+ if ($form->_contributeMode == 'direct') {
+ if (CRM_Utils_Array::value('contribution_status_id', $paymentResult) == 1) {
try {
civicrm_api3('contribution', 'completetransaction', array(
- 'id' => $membershipContribution->id,
- 'trxn_id' => $membershipContribution->trxn_id,
+ 'id' => $paymentResult['contribution']->id,
+ 'trxn_id' => $paymentResult['contribution']->trxn_id,
+ 'is_transactional' => FALSE,
));
}
catch (CiviCRM_API3_Exception $e) {