$params['membership_id'] = $membership->id;
if (isset($ids['membership'])) {
$ids['contribution'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment',
- $ids['membership'],
+ $membership->id,
'contribution_id',
'membership_id'
);
}
if ($form->_contributeMode == 'direct') {
- if (CRM_Utils_Array::value('contribution_status_id', $paymentResult) == 1) {
+ if (CRM_Utils_Array::value('payment_status_id', $paymentResult) == 1) {
+ // Refer to CRM-16737. Payment processors 'should' return payment_status_id
+ // to denote the outcome of the transaction.
try {
civicrm_api3('contribution', 'completetransaction', array(
'id' => $paymentResult['contribution']->id,
CRM_Core_Error::debug_log_message('contribution ' . $membershipContribution->id . ' not completed with trxn_id ' . $membershipContribution->trxn_id . ' and message ' . $e->getMessage());
}
}
+ // Do not send an email if Recurring transaction is done via Direct Mode
+ // Email will we sent when the IPN is received.
return;
}
}
/**
+ * Build an array of available membership types.
+ *
* @param CRM_Core_Form $form
* @param int $membershipTypeID
+ * @param bool $activeOnly
+ * Do we only want active ones?
+ * (probably this should default to TRUE but as a newly added parameter we are leaving default b
+ * behaviour unchanged).
*
* @return array
*/
- public static function buildMembershipTypeValues(&$form, $membershipTypeID = NULL) {
+ public static function buildMembershipTypeValues(&$form, $membershipTypeID = NULL, $activeOnly = FALSE) {
$whereClause = " WHERE domain_id = " . CRM_Core_Config::domainID();
+ if ($activeOnly) {
+ $whereClause .= " AND is_active = 1 ";
+ }
if (is_array($membershipTypeID)) {
$allIDs = implode(',', $membershipTypeID);
$whereClause .= " AND id IN ( $allIDs )";
'relationship_type_id',
'relationship_direction',
'max_related',
+ 'duration_unit',
+ 'duration_interval',
);
while ($dao->fetch()) {
* @param CRM_Core_Form $qf
* @param array $membershipType
* Array with membership type and organization.
- * @param int $priceSetId
*
+ * @return int $priceSetId
*/
- public static function createLineItems(&$qf, $membershipType, &$priceSetId) {
+ public static function createLineItems(&$qf, $membershipType) {
$qf->_priceSetId = $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_membership_type_amount', 'id', 'name');
- if ($priceSetId) {
- $qf->_priceSet = $priceSets = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
- }
+ $qf->_priceSet = $priceSets = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
+
+ // The name of the price field corresponds to the membership_type organization contact.
$editedFieldParams = array(
'price_set_id' => $priceSetId,
'name' => $membershipType[0],
$fieldID = key($qf->_priceSet['fields']);
$qf->_params['price_' . $fieldID] = CRM_Utils_Array::value('id', $editedResults);
+ return $priceSetId;
}
/**