本文整理汇总了PHP中CRM_Member_BAO_Membership::linkMembershipPayment方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_BAO_Membership::linkMembershipPayment方法的具体用法?PHP CRM_Member_BAO_Membership::linkMembershipPayment怎么用?PHP CRM_Member_BAO_Membership::linkMembershipPayment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Member_BAO_Membership
的用法示例。
在下文中一共展示了CRM_Member_BAO_Membership::linkMembershipPayment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcessMembership
//.........这里部分代码省略.........
if (!empty($membershipContribution)) {
$pendingStatus = CRM_Core_OptionGroup::getValue('contribution_status', 'Pending', 'name');
$pending = $membershipContribution->contribution_status_id == $pendingStatus ? TRUE : FALSE;
} else {
$pending = $isPending;
}
$contributionRecurID = isset($form->_params['contributionRecurID']) ? $form->_params['contributionRecurID'] : NULL;
$membershipSource = NULL;
if (!empty($form->_params['membership_source'])) {
$membershipSource = $form->_params['membership_source'];
} elseif (isset($form->_values['title']) && !empty($form->_values['title'])) {
$membershipSource = ts('Online Contribution:') . ' ' . $form->_values['title'];
}
$isPayLater = NULL;
if (isset($form->_params)) {
$isPayLater = CRM_Utils_Array::value('is_pay_later', $form->_params);
}
$campaignId = NULL;
if (isset($form->_values) && is_array($form->_values) && !empty($form->_values)) {
$campaignId = CRM_Utils_Array::value('campaign_id', $form->_params);
if (!array_key_exists('campaign_id', $form->_params)) {
$campaignId = CRM_Utils_Array::value('campaign_id', $form->_values);
}
}
list($membership, $renewalMode, $dates) = CRM_Member_BAO_Membership::renewMembership($contactID, $memType, $isTest, date('YmdHis'), CRM_Utils_Array::value('cms_contactID', $membershipParams), $customFieldsFormatted, $numTerms, $membershipID, $pending, $contributionRecurID, $membershipSource, $isPayLater, $campaignId);
$form->set('renewal_mode', $renewalMode);
if (!empty($dates)) {
$form->assign('mem_start_date', CRM_Utils_Date::customFormat($dates['start_date'], '%Y%m%d'));
$form->assign('mem_end_date', CRM_Utils_Date::customFormat($dates['end_date'], '%Y%m%d'));
}
if (!empty($membershipContribution)) {
// update recurring id for membership record
CRM_Member_BAO_Membership::updateRecurMembership($membership, $membershipContribution);
CRM_Member_BAO_Membership::linkMembershipPayment($membership, $membershipContribution);
}
}
if ($form->_priceSetId && !empty($form->_useForMember) && !empty($form->_lineItem)) {
foreach ($form->_lineItem[$form->_priceSetId] as &$priceFieldOp) {
if (!empty($priceFieldOp['membership_type_id']) && isset($createdMemberships[$priceFieldOp['membership_type_id']])) {
$membershipOb = $createdMemberships[$priceFieldOp['membership_type_id']];
$priceFieldOp['start_date'] = $membershipOb->start_date ? CRM_Utils_Date::customFormat($membershipOb->start_date, '%B %E%f, %Y') : '-';
$priceFieldOp['end_date'] = $membershipOb->end_date ? CRM_Utils_Date::customFormat($membershipOb->end_date, '%B %E%f, %Y') : '-';
} else {
$priceFieldOp['start_date'] = $priceFieldOp['end_date'] = 'N/A';
}
}
$form->_values['lineItem'] = $form->_lineItem;
$form->assign('lineItem', $form->_lineItem);
}
}
if (!empty($errors)) {
$message = $this->compileErrorMessage($errors);
throw new CRM_Core_Exception($message);
}
$form->_params['createdMembershipIDs'] = array();
// CRM-7851 - Moved after processing Payment Errors
//@todo - the reasoning for this being here seems a little outdated
foreach ($createdMemberships as $createdMembership) {
CRM_Core_BAO_CustomValueTable::postProcess($form->_params, 'civicrm_membership', $createdMembership->id, 'Membership');
$form->_params['createdMembershipIDs'][] = $createdMembership->id;
}
if (count($createdMemberships) == 1) {
//presumably this is only relevant for exactly 1 membership
$form->_params['membershipID'] = $createdMembership->id;
}
//CRM-15232: Check if membership is created and on the basis of it use
示例2: postProcessMembership
//.........这里部分代码省略.........
foreach ($membershipTypeIDs as $memType) {
$numTerms = CRM_Utils_Array::value($memType, $typesTerms, 1);
if (!empty($membershipContribution)) {
$pendingStatus = CRM_Core_OptionGroup::getValue('contribution_status', 'Pending', 'name');
$pending = $membershipContribution->contribution_status_id == $pendingStatus ? TRUE : FALSE;
} else {
$pending = $isPending;
}
$contributionRecurID = isset($form->_params['contributionRecurID']) ? $form->_params['contributionRecurID'] : NULL;
$membershipSource = NULL;
if (!empty($form->_params['membership_source'])) {
$membershipSource = $form->_params['membership_source'];
} elseif (isset($form->_values['title']) && !empty($form->_values['title'])) {
$membershipSource = ts('Online Contribution:') . ' ' . $form->_values['title'];
}
$isPayLater = NULL;
if (isset($form->_params)) {
$isPayLater = CRM_Utils_Array::value('is_pay_later', $form->_params);
}
$campaignId = NULL;
if (isset($form->_values) && is_array($form->_values) && !empty($form->_values)) {
$campaignId = CRM_Utils_Array::value('campaign_id', $form->_params);
if (!array_key_exists('campaign_id', $form->_params)) {
$campaignId = CRM_Utils_Array::value('campaign_id', $form->_values);
}
}
list($membership, $renewalMode, $dates) = CRM_Member_BAO_Membership::renewMembership($contactID, $memType, $isTest, date('YmdHis'), CRM_Utils_Array::value('cms_contactID', $membershipParams), $customFieldsFormatted, $numTerms, $membershipID, $pending, $contributionRecurID, $membershipSource, $isPayLater, $campaignId);
$form->set('renewal_mode', $renewalMode);
if (!empty($dates)) {
$form->assign('mem_start_date', CRM_Utils_Date::customFormat($dates['start_date'], '%Y%m%d'));
$form->assign('mem_end_date', CRM_Utils_Date::customFormat($dates['end_date'], '%Y%m%d'));
}
if (!empty($membershipContribution)) {
// update recurring id for membership record
CRM_Member_BAO_Membership::updateRecurMembership($membership, $membershipContribution);
CRM_Member_BAO_Membership::linkMembershipPayment($membership, $membershipContribution);
}
}
if ($form->_priceSetId && !empty($form->_useForMember) && !empty($form->_lineItem)) {
foreach ($form->_lineItem[$form->_priceSetId] as &$priceFieldOp) {
if (!empty($priceFieldOp['membership_type_id']) && isset($createdMemberships[$priceFieldOp['membership_type_id']])) {
$membershipOb = $createdMemberships[$priceFieldOp['membership_type_id']];
$priceFieldOp['start_date'] = $membershipOb->start_date ? CRM_Utils_Date::customFormat($membershipOb->start_date, '%B %E%f, %Y') : '-';
$priceFieldOp['end_date'] = $membershipOb->end_date ? CRM_Utils_Date::customFormat($membershipOb->end_date, '%B %E%f, %Y') : '-';
} else {
$priceFieldOp['start_date'] = $priceFieldOp['end_date'] = 'N/A';
}
}
$form->_values['lineItem'] = $form->_lineItem;
$form->assign('lineItem', $form->_lineItem);
}
}
if (!empty($errors)) {
$message = $this->compileErrorMessage($errors);
throw new CRM_Core_Exception($message);
}
$form->_params['createdMembershipIDs'] = array();
// CRM-7851 - Moved after processing Payment Errors
//@todo - the reasoning for this being here seems a little outdated
foreach ($createdMemberships as $createdMembership) {
CRM_Core_BAO_CustomValueTable::postProcess($form->_params, 'civicrm_membership', $createdMembership->id, 'Membership');
$form->_params['createdMembershipIDs'][] = $createdMembership->id;
}
if (count($createdMemberships) == 1) {
//presumably this is only relevant for exactly 1 membership
$form->_params['membershipID'] = $createdMembership->id;
}
//CRM-15232: Check if membership is created and on the basis of it use
//membership receipt template to send payment receipt
if (count($createdMemberships)) {
$form->_values['isMembership'] = TRUE;
}
if (isset($membershipContributionID)) {
$form->_values['contribution_id'] = $membershipContributionID;
}
if ($form->_contributeMode) {
if ($form->_values['is_monetary'] && $form->_amount > 0.0 && !$form->_params['is_pay_later']) {
// call postProcess hook before leaving
$form->postProcessHook();
}
$payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
$result = $payment->doPayment($form->_params, 'contribute');
if (CRM_Utils_Array::value('payment_status_id', $result) == 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, 'trxn_id' => $paymentResult['contribution']->trxn_id, 'is_transactional' => FALSE));
} 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());
}
}
// Do not send an email if Recurring transaction is done via Direct Mode
// Email will we sent when the IPN is received.
return;
}
//finally send an email receipt
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $isTest, FALSE, $includeFieldTypes);
}