$membershipTypeIDs = (array) $membershipParams['selectMembership'];
$membershipTypes = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $membershipTypeIDs);
$membershipType = empty($membershipTypes) ? array() : reset($membershipTypes);
+ $isPending = $this->getIsPending();
+
$this->assign('membership_name', CRM_Utils_Array::value('name', $membershipType));
$isPaidMembership = FALSE;
CRM_Member_BAO_Membership::postProcessMembership($membershipParams, $contactID,
$this, $premiumParams, $customFieldsFormatted, $fieldTypes, $membershipType, $membershipTypeIDs, $isPaidMembership, $this->_membershipId, $isProcessSeparateMembershipTransaction, $contributionTypeId,
- $membershipLineItems, $isPayLater
- );
+ $membershipLineItems, $isPayLater, $isPending);
$this->assign('membership_assign', TRUE);
$this->set('membershipTypeID', $membershipParams['selectMembership']);
}
}
}
+ /**
+ * Is the payment a pending payment.
+ *
+ * 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() {
+ if (((isset($this->_contributeMode)) || !empty
+ ($this->_params['is_pay_later'])
+ ) &&
+ (($this->_values['is_monetary'] && $this->_amount > 0.0))
+ ) {
+ return TRUE;
+ }
+ return FALSE;
+ }
+
/**
* Are we going to do 2 financial transactions.
*
* @param array $membershipLineItems
* Line items specific to membership payment that is separate to contribution.
* @param bool $isPayLater
+ * @param bool $isPending
*
* @throws \CRM_Core_Exception
*/
public static function postProcessMembership(
$membershipParams, $contactID, &$form, $premiumParams,
$customFieldsFormatted = NULL, $includeFieldTypes = NULL, $membershipDetails, $membershipTypeIDs, $isPaidMembership, $membershipID,
- $isProcessSeparateMembershipTransaction, $defaultContributionTypeID, $membershipLineItems, $isPayLater) {
+ $isProcessSeparateMembershipTransaction, $defaultContributionTypeID, $membershipLineItems, $isPayLater, $isPending) {
$result = $membershipContribution = NULL;
$isTest = CRM_Utils_Array::value('is_test', $membershipParams, FALSE);
$errors = $createdMemberships = $paymentResult = array();
$pendingStatus = CRM_Core_OptionGroup::getValue('contribution_status', 'Pending', 'name');
$pending = ($membershipContribution->contribution_status_id == $pendingStatus) ? TRUE : FALSE;
}
- self::extractPendingFormValue($form, $memType, $pending);
+ else {
+ $pending = $isPending;
+ }
$membership = self::renewMembershipFormWrapper($contactID, $memType,
$isTest, $form, date('YmdHis'),
CRM_Utils_Array::value('cms_contactID', $membershipParams),
));
}
- /**
- * @param array $membershipParams
- * @param int $contactID
- * @param $customFieldsFormatted
- * @param int $membershipID
- * @param $memType
- * @param bool $isTest
- * @param int $numTerms
- * @param $membershipContribution
- * @param CRM_Core_Form $form
- * @param bool $isPending
- *
- * @return array
- */
- public static function createOrRenewMembership($membershipParams, $contactID, $customFieldsFormatted,
- $membershipID, $memType, $isTest, $numTerms,
- $membershipContribution, &$form, $isPending) {
-
-
- return $membership;
- }
-
/**
* Turn array of errors into message string.
*
return ts('Payment Processor Error message') . ': ' . implode('<br/>', $message);
}
- /**
- * Determine if the form has a pending status.
- *
- * This is an interim refactoring step. This information should be extracted at the form layer.
- *
- * @deprecated
- *
- * @param CRM_Core_Form $form
- * @param int $membershipID
- *
- * @return bool
- */
- public static function extractPendingFormValue($form, $membershipID, $pending = FALSE) {
- $membershipTypeDetails = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($membershipID);
- //@todo this is a BAO function & should not inspect the form - the form should do this
- // & pass required params to the BAO
- if (CRM_Utils_Array::value('minimum_fee', $membershipTypeDetails) > 0.0) {
- if (((isset($form->_contributeMode) && $form->_contributeMode == 'notify') || !empty($form->_params['is_pay_later'])
- ) &&
- (($form->_values['is_monetary'] && $form->_amount > 0.0) ||
- CRM_Utils_Array::value('record_contribution', $form->_params)
- )
- ) {
- $pending = TRUE;
- }
- }
- return $pending;
- }
-
/**
* Extract relevant values from the form so we can separate form logic from BAO logcis.
*
if ($formValues['contribution_status_id'] == array_search('Pending', CRM_Contribute_PseudoConstant::contributionStatus())) {
$this->_params['is_pay_later'] = 1;
}
+
$renewMembership = CRM_Member_BAO_Membership::renewMembershipFormWrapper($this->_contactID,
$formValues['membership_type_id'][1],
$isTestMembership, $this,
NULL,
$customFieldsFormatted, $numRenewTerms,
$this->_membershipId,
- CRM_Member_BAO_Membership::extractPendingFormValue($this, $formValues['membership_type_id'][1])
+ self::extractPendingFormValue($this, $formValues['membership_type_id'][1])
);
$endDate = CRM_Utils_Date::processDate($renewMembership->end_date);
CRM_Core_Session::setStatus($statusMsg, ts('Complete'), 'success');
}
+ /**
+ * Determine if the form has a pending status.
+ *
+ * @deprecated
+ *
+ * @param CRM_Core_Form $form
+ * @param int $membershipID
+ *
+ * @return bool
+ */
+ public static function extractPendingFormValue($form, $membershipID) {
+ $membershipTypeDetails = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($membershipID);
+ $pending = FALSE;
+ // @todo function was shared by 2 not-very-related forms & the below may include irrelevant stuff.
+ if (CRM_Utils_Array::value('minimum_fee', $membershipTypeDetails) > 0.0) {
+ if (((isset($form->_contributeMode) && $form->_contributeMode == 'notify') || !empty($form->_params['is_pay_later'])
+ ) &&
+ (($form->_values['is_monetary'] && $form->_amount > 0.0) ||
+ CRM_Utils_Array::value('record_contribution', $form->_params)
+ )
+ ) {
+ $pending = TRUE;
+ }
+ }
+ return $pending;
+ }
+
}