$isTest = CRM_Utils_Array::value('is_test', $membershipParams, FALSE);
$errors = $createdMemberships = array();
+ if (CRM_Utils_Array::value('membership_source', $form->_params)) {
+ $membershipParams['contribution_source'] = $form->_params['membership_source'];
+ }
+
if ($isPaidMembership) {
$result = CRM_Contribute_BAO_Contribution_Utils::processConfirm($form, $membershipParams,
$premiumParams, $contactID,
// 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)) {
+ try {
+ civicrm_api3('contribution', 'completetransaction', array('id' => $membershipContribution->id, 'trxn_id' => $membershipContribution->trxn_id));
+ }
+ catch (CiviCRM_API3_Exception $e) {
+ // if for any reason it is already completed this will fail - e.g extensions hacking around core not completing transactions prior to CRM-15296
+ // so let's be gentle here
+ CRM_Core_Error::debug_log_message('contribution ' . $membershipContribution->id . ' not completed with trxn_id ' . $membershipContribution->trxn_id . ' and message ' . $e->getMessage());
+ }
+ }
return;
}
$format
),
'membership_type_id' => $membershipTypeID,
- 'max_related' => $membershipTypeDetails['max_related'],
+ 'max_related' => !empty($membershipTypeDetails['max_related']) ? $membershipTypeDetails['max_related'] : NULL,
);
$session = CRM_Core_Session::singleton();
// If we have an authenticated session, set modified_id to that user's contact_id, else set to membership.contact_id
'contact_id', 'total_amount', 'receive_date', 'financial_type_id',
'payment_instrument_id', 'trxn_id', 'invoice_id', 'is_test',
'contribution_status_id', 'check_number', 'campaign_id', 'is_pay_later',
- 'membership_id', 'skipLineItem'
+ 'membership_id', 'tax_amount', 'skipLineItem'
);
foreach ($recordContribution as $f) {
$contributionParams[$f] = CRM_Utils_Array::value($f, $params);
//CRM-13981, create new soft-credit record as to record payment from different person for this membership
if (!empty($contributionSoftParams)) {
- foreach ($contributionSoftParams as $contributionSoft){
- $contributionSoft['contribution_id'] = $contribution->id;
- $contributionSoft['currency'] = $contribution->currency;
- $contributionSoft['amount'] = $contribution->total_amount;
- CRM_Contribute_BAO_ContributionSoft::add($contributionSoft);
+ if (!empty($params['batch_id'])) {
+ foreach ($contributionSoftParams as $contributionSoft) {
+ $contributionSoft['contribution_id'] = $contribution->id;
+ $contributionSoft['currency'] = $contribution->currency;
+ CRM_Contribute_BAO_ContributionSoft::add($contributionSoft);
+ }
+ }
+ else {
+ $contributionSoftParams['contribution_id'] = $contribution->id;
+ $contributionSoftParams['currency'] = $contribution->currency;
+ $contributionSoftParams['amount'] = $contribution->total_amount;
+ CRM_Contribute_BAO_ContributionSoft::add($contributionSoftParams);
}
}