+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
protected $_memTypeSelected;
/**
- * Display name of the member
+ * Display name of the member.
*
* @var string
*/
protected $_memberEmail = NULL;
/**
- * Contact ID of the member
+ * Contact ID of the member.
*
* @var int
*/
protected $_contributorContactID = NULL;
/**
- * ID of the person the receipt is to go to
+ * ID of the person the receipt is to go to.
*
* @var int
*/
}
/**
- * Build the form object
+ * Build the form object.
*
* @return void
*/
if ($this->_mode) {
//get the valid recurring processors.
- $recurring = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, 'is_recur = 1');
+ $test = strtolower($this->_mode) == 'test' ? TRUE : FALSE;
+ $recurring = CRM_Core_PseudoConstant::paymentProcessor(FALSE, $test, 'is_recur = 1');
$recurProcessor = array_intersect_assoc($this->_processors, $recurring);
$autoRenew = array();
if (!empty($recurProcessor)) {
}
/**
- * Validation
+ * Validation.
*
* @param array $params
* (ref.) an assoc array of name/value pairs.
$ids = implode(',', $priceFieldIDS);
$count = CRM_Price_BAO_PriceSet::getMembershipCount($ids);
- foreach ($count as $id => $occurance) {
- if ($occurance > 1) {
+ foreach ($count as $id => $occurrence) {
+ if ($occurrence > 1) {
$errors['_qf_default'] = ts('Select at most one option associated with the same membership type.');
}
}
}
if (!empty($params['payment_processor_id'])) {
- // make sure that credit card number and cvv are valid
- CRM_Core_Payment_Form::validateCreditCard($params, $errors);
+ // validate payment instrument (e.g. credit card number)
+ CRM_Core_Payment_Form::validatePaymentInstrument($params['payment_processor_id'], $params, $errors, $self);
}
$joinDate = NULL;
}
/**
- * Process the form submission
+ * Process the form submission.
*
*
* @return void
return;
}
+ $allMemberStatus = CRM_Member_PseudoConstant::membershipStatus();
+ $allContributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
+
$isTest = ($this->_mode == 'test') ? 1 : 0;
$lineItems = NULL;
}
$count++;
}
-
- // unset send-receipt option, since receipt will be sent when ipn is received.
- unset($this->_params['send_receipt'], $formValues['send_receipt']);
}
// process price set and get total amount and line items.
if (empty($params['is_override']) &&
CRM_Utils_Array::value('contribution_status_id', $params) == array_search('Pending', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'))
) {
- $allStatus = CRM_Member_PseudoConstant::membershipStatus();
- $params['status_id'] = array_search('Pending', $allStatus);
+ $params['status_id'] = array_search('Pending', $allMemberStatus);
$params['skipStatusCal'] = TRUE;
$params['is_pay_later'] = 1;
$this->assign('is_pay_later', 1);
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, TRUE);
// CRM-7137 -for recurring membership,
- // we do need contribution and recuring records.
+ // we do need contribution and recurring records.
$result = NULL;
if (!empty($paymentParams['is_recur'])) {
- $allStatus = CRM_Member_PseudoConstant::membershipStatus();
-
$contributionType = new CRM_Financial_DAO_FinancialType();
$contributionType->id = $params['financial_type_id'];
if (!$contributionType->find(TRUE)) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
$ids['contribution'] = $contribution->id;
$params['contribution_recur_id'] = $paymentParams['contributionRecurID'];
- $params['status_id'] = array_search('Pending', $allStatus);
- $params['skipStatusCal'] = TRUE;
-
- //as membership is pending set dates to null.
- $memberDates = array(
- 'join_date' => 'joinDate',
- 'start_date' => 'startDate',
- 'end_date' => 'endDate',
- );
-
- foreach ($memberDates as $dp => $dv) {
- $$dv = NULL;
- foreach ($this->_memTypeSelected as $memType) {
- $membershipTypeValues[$memType][$dv] = NULL;
- }
- }
}
if ($params['total_amount'] > 0.0) {
$this->assign('amount', $params['total_amount']);
}
- $params['contribution_status_id'] = !empty($paymentParams['is_recur']) ? 2 : 1;
+ // if the payment processor returns a contribution_status_id -> use it!
+ if (isset($result['contribution_status_id'])) {
+ $params['contribution_status_id'] = $result['contribution_status_id'];
+ }
+ // do what used to happen previously
+ else {
+ $params['contribution_status_id'] = !empty($paymentParams['is_recur']) ? 2 : 1;
+ }
+ if ($params['contribution_status_id'] != array_search('Completed', $allContributionStatus)) {
+ $params['status_id'] = array_search('Pending', $allMemberStatus);
+ $params['skipStatusCal'] = TRUE;
+ // unset send-receipt option, since receipt will be sent when ipn is received.
+ unset($this->_params['send_receipt'], $formValues['send_receipt']);
+ //as membership is pending set dates to null.
+ $memberDates = array(
+ 'join_date' => 'joinDate',
+ 'start_date' => 'startDate',
+ 'end_date' => 'endDate',
+ );
+ foreach ($memberDates as $dp => $dv) {
+ $$dv = NULL;
+ foreach ($this->_memTypeSelected as $memType) {
+ $membershipTypeValues[$memType][$dv] = NULL;
+ }
+ }
+ }
$params['receive_date'] = $now;
$params['invoice_id'] = $this->_params['invoiceID'];
$params['contribution_source'] = ts('%1 Membership Signup: Credit card or direct debit (by %2)',
$this->assign('lineItem', !empty($lineItem) && !$isQuickConfig ? $lineItem : FALSE);
$receiptSend = FALSE;
- if (!empty($formValues['send_receipt'])) {
- $receiptSend = TRUE;
+ $contributionId = CRM_Member_BAO_Membership::getMembershipContributionId($membership->id);
+ $membershipIds = $this->_membershipIDs;
+ if ($contributionId && !empty($membershipIds)) {
+ $contributionDetails = CRM_Contribute_BAO_Contribution::getContributionDetails(
+ CRM_Export_Form_Select::MEMBER_EXPORT, $this->_membershipIDs);
+ if ($contributionDetails[$membership->id]['contribution_status'] == 'Completed') {
+ $receiptSend = TRUE;
+ }
+ }
+ if (!empty($formValues['send_receipt']) && $receiptSend) {
$formValues['contact_id'] = $this->_contactID;
+ $formValues['contribution_id'] = $contributionId;
- $formValues['contribution_id'] = CRM_Member_BAO_Membership::getMembershipContributionId($membership->id);
// send email receipt
$mailSend = self::emailReceipt($this, $formValues, $membership);
}
}
/**
- * Send email receipt
+ * Send email receipt.
*
* @param CRM_Core_Form $form
* Form object.
// & we should aim to move this function to the BAO layer in future.
// however, we can assume that the contact_id passed in by the batch
// function will be the recipient
- list(
- $form->_contributorDisplayName,
- $form->_contributorEmail
- ) = CRM_Contact_BAO_Contact_Location::getEmailDetails(
- $formValues['contact_id']
- );
+ list($form->_contributorDisplayName, $form->_contributorEmail)
+ = CRM_Contact_BAO_Contact_Location::getEmailDetails($formValues['contact_id']);
if (empty($form->_receiptContactId) || $isBatchProcess) {
$form->_receiptContactId = $formValues['contact_id'];
}
return TRUE;
}
+
}