本文整理汇总了PHP中CRM_Contribute_BAO_ContributionPage::sendMail方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_ContributionPage::sendMail方法的具体用法?PHP CRM_Contribute_BAO_ContributionPage::sendMail怎么用?PHP CRM_Contribute_BAO_ContributionPage::sendMail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_ContributionPage
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_ContributionPage::sendMail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testsendMail
/**
* test setMail() method
*/
function testsendMail()
{
$this->markTestSkipped('throws fatals');
$contactId = Contact::createIndividual();
$params = array('title' => 'Test Cotribution Page', 'contribution_type_id' => $this->_contributionTypeID, 'is_active' => 1);
require_once 'CRM/Contribute/BAO/ContributionPage.php';
$contributionpage = CRM_Contribute_BAO_ContributionPage::create($params, $ids);
$contactId = Contact::createIndividual();
$ids = array('contribution' => null);
$params = array('contact_id' => $contactId, 'currency' => 'USD', 'contribution_type_id' => 1, 'contribution_status_id' => 1, 'payment_instrument_id' => 1, 'source' => 'STUDENT', 'receive_date' => '20080522000000', 'receipt_date' => '20080522000000', 'id' => $contributionpage->id, 'non_deductible_amount' => 0.0, 'total_amount' => 200.0, 'fee_amount' => 5, 'net_amount' => 195, 'trxn_id' => '22ereerwww322323', 'invoice_id' => '22ed39c9e9ee6ef6031621ce0eafe6da70', 'thankyou_date' => '20080522');
require_once 'CRM/Contribute/BAO/Contribution.php';
$contribution = CRM_Contribute_BAO_Contribution::create($params, $ids);
$params = array('id' => 1, 'title' => test, 'contribution_type_id' => $this->_contributionTypeID, 'payment_processor_id' => 1, 'is_credit_card_only' => 0, 'is_monetary' => 1, 'is_recur' => 0, 'is_pay_later' => 1, 'pay_later_text' => 'I will send payment by check', 'pay_later_receipt' => 'test', 'is_allow_other_amount' => 0, 'is_for_organization' => 0, 'for_organization' => 'I am contributing on behalf of an organization.', 'is_email_receipt' => 1, 'is_active' => 1, 'amount_block_is_active' => 1, 'honor_block_is_active' => 0, 'start_date' => '2009-10-22 11:01:00', 'end_date' => '1970-01-01 00:00:00', 'amount' => array(), 'custom_post_id' => null, 'custom_pre_id' => 1, 'accountingCode' => null, 'footer_text' => 'test', 'contribution_id' => $contribution->id);
$sendmail = CRM_Contribute_BAO_ContributionPage::sendMail($contactId, &$params, $isTest = false, $returnMessageText = false);
}
示例2: composeMessageArray
/**
* Create array of message information - ie. return html version, txt version, to field
*
* @param array $input
* Incoming information.
* - is_recur - should this be treated as recurring (not sure why you wouldn't
* just check presence of recur object but maintaining legacy approach
* to be careful)
* @param array $ids
* IDs of related objects.
* @param array $values
* Any values that may have already been compiled by calling process.
* This is augmented by values 'gathered' by gatherMessageValues
* @param bool $recur
* @param bool $returnMessageText
* Distinguishes between whether to send message or return.
* message text. We are working towards this function ALWAYS returning message text & calling
* function doing emails / pdfs with it
*
* @return array
* messages
* @throws Exception
*/
public function composeMessageArray(&$input, &$ids, &$values, $recur = FALSE, $returnMessageText = TRUE)
{
$this->loadRelatedObjects($input, $ids);
if (empty($this->_component)) {
$this->_component = CRM_Utils_Array::value('component', $input);
}
//not really sure what params might be passed in but lets merge em into values
$values = array_merge($this->_gatherMessageValues($input, $values, $ids), $values);
$template = CRM_Core_Smarty::singleton();
$this->_assignMessageVariablesToTemplate($values, $input, $template, $recur, $returnMessageText);
//what does recur 'mean here - to do with payment processor return functionality but
// what is the importance
if ($recur && !empty($this->_relatedObjects['paymentProcessor'])) {
$paymentObject = Civi\Payment\System::singleton()->getByProcessor($this->_relatedObjects['paymentProcessor']);
$entityID = $entity = NULL;
if (isset($ids['contribution'])) {
$entity = 'contribution';
$entityID = $ids['contribution'];
}
if (!empty($ids['membership'])) {
//not sure whether is is possible for this not to be an array - load related contacts loads an array but this code was expecting a string
// the addition of the casting is in case it could get here & be a string. Added in 4.6 - maybe remove later? This AuthorizeNetIPN & PaypalIPN tests hit this
// line having loaded an array
$ids['membership'] = (array) $ids['membership'];
$entity = 'membership';
$entityID = $ids['membership'][0];
}
$template->assign('cancelSubscriptionUrl', $paymentObject->subscriptionURL($entityID, $entity));
$template->assign('updateSubscriptionBillingUrl', $paymentObject->subscriptionURL($entityID, $entity, 'billing'));
$template->assign('updateSubscriptionUrl', $paymentObject->subscriptionURL($entityID, $entity, 'update'));
if ($this->_relatedObjects['paymentProcessor']['billing_mode'] & CRM_Core_Payment::BILLING_MODE_FORM) {
//direct mode showing billing block, so use directIPN for temporary
$template->assign('contributeMode', 'directIPN');
}
}
// todo remove strtolower - check consistency
if (strtolower($this->_component) == 'event') {
$eventParams = array('id' => $this->_relatedObjects['participant']->event_id);
$values['event'] = array();
CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
//get location details
$locationParams = array('entity_id' => $this->_relatedObjects['participant']->event_id, 'entity_table' => 'civicrm_event');
$values['location'] = CRM_Core_BAO_Location::getValues($locationParams);
$ufJoinParams = array('entity_table' => 'civicrm_event', 'entity_id' => $ids['event'], 'module' => 'CiviEvent');
list($custom_pre_id, $custom_post_ids) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
$values['custom_pre_id'] = $custom_pre_id;
$values['custom_post_id'] = $custom_post_ids;
//for tasks 'Change Participant Status' and 'Batch Update Participants Via Profile' case
//and cases involving status updation through ipn
// whatever that means!
// total_amount appears to be the preferred input param & it is unclear why we support amount here
// perhaps we should throw an e-notice if amount is set & force total_amount?
if (!empty($input['amount'])) {
$values['totalAmount'] = $input['amount'];
}
if ($values['event']['is_email_confirm']) {
$values['is_email_receipt'] = 1;
}
return CRM_Event_BAO_Event::sendMail($ids['contact'], $values, $this->_relatedObjects['participant']->id, $this->is_test, $returnMessageText);
} else {
$values['contribution_id'] = $this->id;
if (!empty($ids['related_contact'])) {
$values['related_contact'] = $ids['related_contact'];
if (isset($ids['onbehalf_dupe_alert'])) {
$values['onbehalf_dupe_alert'] = $ids['onbehalf_dupe_alert'];
}
$entityBlock = array('contact_id' => $ids['contact'], 'location_type_id' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_LocationType', 'Home', 'id', 'name'));
$address = CRM_Core_BAO_Address::getValues($entityBlock);
$template->assign('onBehalfAddress', $address[$entityBlock['location_type_id']]['display']);
}
$isTest = FALSE;
if ($this->is_test) {
$isTest = TRUE;
}
if (!empty($this->_relatedObjects['membership'])) {
foreach ($this->_relatedObjects['membership'] as $membership) {
if ($membership->id) {
//.........这里部分代码省略.........
示例3: postProcessMembership
//.........这里部分代码省略.........
$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->_paymentProcessor) {
// the is_monetary concept probably should be deprecated as it can be calculated from
// the existence of 'amount' & seems fragile.
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);
// The contribution_other_id is effectively the ID for the only contribution or the non-membership contribution.
// Since we have called the membership contribution (in a 2 contribution scenario) this is out
// primary-contribution compared to that - but let's face it - it's all just too hard & confusing at the moment!
$paymentParams = array_merge($form->_params, array('contributionID' => $form->_values['contribution_other_id']));
$paymentActionResult = $payment->doPayment($paymentParams, 'contribute');
$paymentResults[] = array('contribution_id' => $paymentResult['contribution']->id, 'result' => $paymentActionResult);
// Do not send an email if Recurring transaction is done via Direct Mode
// Email will we sent when the IPN is received.
foreach ($paymentResults as $result) {
$this->completeTransaction($result['result'], $result['contribution_id']);
}
return;
}
$emailValues = $form->_values;
// Finally send an email receipt for pay-later scenario (although it might sometimes be caught above!)
if ($totalAmount == 0) {
// This feels like a bizarre hack as the variable name doesn't seem to be directly connected to it's use in the template.
$emailValues['useForMember'] = 0;
$emailValues['membership_assign'] = 1;
$emailValues['amount'] = 0;
}
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $emailValues, $isTest, FALSE, $includeFieldTypes);
}
示例4: processConfirm
/**
* Function to process payment after confirmation
*
* @param object $form form object
* @param array $paymentParams array with payment related key
* value pairs
* @param array $premiumParams array with premium related key
* value pairs
* @param int $contactID contact id
* @param int $contributionTypeId contribution type id
* @param int $component component id
*
* @return array associated array
*
* @static
* @access public
*/
static function processConfirm(&$form, &$paymentParams, &$premiumParams, $contactID, $contributionTypeId, $component = 'contribution')
{
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::mapParams($form->_bltID, $form->_params, $paymentParams, true);
require_once 'CRM/Contribute/DAO/ContributionType.php';
$contributionType = new CRM_Contribute_DAO_ContributionType();
if (isset($paymentParams['contribution_type'])) {
$contributionType->id = $paymentParams['contribution_type'];
} else {
if (CRM_Utils_Array::value('pledge_id', $form->_values)) {
$contributionType->id = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge', $form->_values['pledge_id'], 'contribution_type_id');
} else {
$contributionType->id = $contributionTypeId;
}
}
if (!$contributionType->find(true)) {
CRM_Core_Error::fatal('Could not find a system table');
}
// add some contribution type details to the params list
// if folks need to use it
$paymentParams['contributionType_name'] = $form->_params['contributionType_name'] = $contributionType->name;
$paymentParams['contributionType_accounting_code'] = $form->_params['contributionType_accounting_code'] = $contributionType->accounting_code;
$paymentParams['contributionPageID'] = $form->_params['contributionPageID'] = $form->_values['id'];
if ($form->_values['is_monetary'] && $form->_amount > 0.0 && is_array($form->_paymentProcessor)) {
require_once 'CRM/Core/Payment.php';
$payment =& CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
}
//fix for CRM-2062
$now = date('YmdHis');
$result = null;
if ($form->_contributeMode == 'notify' || $form->_params['is_pay_later']) {
// this is not going to come back, i.e. we fill in the other details
// when we get a callback from the payment processor
// also add the contact ID and contribution ID to the params list
$paymentParams['contactID'] = $form->_params['contactID'] = $contactID;
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $paymentParams, null, $contactID, $contributionType, true, true, true);
$form->_params['contributionID'] = $contribution->id;
$form->_params['contributionTypeID'] = $contributionType->id;
$form->_params['item_name'] = $form->_params['description'];
$form->_params['receive_date'] = $now;
if ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
$form->_params['contributionRecurID'] = $contribution->contribution_recur_id;
}
$form->set('params', $form->_params);
$form->postProcessPremium($premiumParams, $contribution);
if ($form->_values['is_monetary'] && $form->_amount > 0.0) {
// add qfKey so we can send to paypal
$form->_params['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
$membershipResult = array(1 => $contribution);
return $membershipResult;
} else {
if (!$form->_params['is_pay_later']) {
$result =& $payment->doTransferCheckout($form->_params, 'contribute');
} else {
// follow similar flow as IPN
// send the receipt mail
$form->set('params', $form->_params);
if ($contributionType->is_deductible) {
$form->assign('is_deductible', true);
$form->set('is_deductible', true);
}
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
require_once 'CRM/Contribute/BAO/ContributionPage.php';
$form->_values['contribution_id'] = $contribution->id;
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test);
return;
}
}
}
} elseif ($form->_contributeMode == 'express') {
if ($form->_values['is_monetary'] && $form->_amount > 0.0) {
//LCD determine if express + recurring and direct accordingly
if ($paymentParams['is_recur'] == 1) {
$result =& $payment->createRecurringPayments($paymentParams);
} else {
//.........这里部分代码省略.........
示例5: postProcessMembership
//.........这里部分代码省略.........
CRM_Core_Error::fatal("Could not find a system table");
}
$tempParams['amount'] = $minimumFee;
$invoiceID = md5(uniqid(rand(), true));
$tempParams['invoiceID'] = $invoiceID;
//we don't allow recurring membership.CRM-3781.
if (CRM_Utils_Array::value('is_recur', $tempParams)) {
$tempParams['is_recur'] = 0;
}
$result = null;
if ($form->_values['is_monetary'] && !$form->_params['is_pay_later']) {
require_once 'CRM/Core/Payment.php';
$payment =& CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
if ($form->_contributeMode == 'express') {
$result =& $payment->doExpressCheckout($tempParams);
} else {
$result =& $payment->doDirectPayment($tempParams);
}
}
if (is_a($result, 'CRM_Core_Error')) {
$errors[2] = CRM_Core_Error::getMessages($result);
} else {
//assign receive date when separate membership payment
//and contribution amount not selected.
if ($form->_amount == 0) {
$now = date('YmdHis');
$form->_params['receive_date'] = $now;
$receiveDate = CRM_Utils_Date::mysqlToIso($now);
$form->set('params', $form->_params);
$form->assign('receive_date', $receiveDate);
}
$form->set('membership_trx_id', $result['trxn_id']);
$form->set('membership_amount', $minimumFee);
$form->assign('membership_trx_id', $result['trxn_id']);
$form->assign('membership_amount', $minimumFee);
// we dont need to create the user twice, so lets disable cms_create_account
// irrespective of the value, CRM-2888
$tempParams['cms_create_account'] = 0;
$pending = $form->_params['is_pay_later'] ? true : false;
//set this variable as we are not creating pledge for
//separate membership payment contribution.
//so for differentiating membership contributon from
//main contribution.
$form->_params['separate_membership_payment'] = 1;
$contribution[2] = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $tempParams, $result, $contactID, $contributionType, false, $pending);
}
}
$index = $memBlockDetails['is_separate_payment'] ? 2 : 1;
if (!CRM_Utils_Array::value($index, $errors)) {
$membership = self::renewMembership($contactID, $membershipTypeID, $isTest, $form, null, CRM_Utils_Array::value('cms_contactID', $membershipParams));
if (isset($contribution[$index])) {
//insert payment record
require_once 'CRM/Member/DAO/MembershipPayment.php';
$dao = new CRM_Member_DAO_MembershipPayment();
$dao->membership_id = $membership->id;
$dao->contribution_id = $contribution[$index]->id;
//Fixed for avoiding duplicate entry error when user goes
//back and forward during payment mode is notify
if (!$dao->find(true)) {
CRM_Utils_Hook::pre('create', 'MembershipPayment', null, $dao);
$dao->save();
CRM_Utils_Hook::post('create', 'MembershipPayment', $dao->id, $dao);
}
}
}
require_once 'CRM/Core/BAO/CustomValueTable.php';
CRM_Core_BAO_CustomValueTable::postProcess($form->_params, CRM_Core_DAO::$_nullArray, 'civicrm_membership', $membership->id, 'Membership');
if (!empty($errors)) {
foreach ($errors as $error) {
if (is_string($error)) {
$message[] = $error;
}
}
$message = ts("Payment Processor Error message") . ": " . implode('<br/>', $message);
$session = CRM_Core_Session::singleton();
$session->setStatus($message);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=true&qfKey={$form->_params['qfKey']}"));
}
$form->_params['membershipID'] = $membership->id;
if ($form->_contributeMode == 'notify') {
if ($form->_values['is_monetary'] && $form->_amount > 0.0 && !$form->_params['is_pay_later']) {
// this does not return
require_once 'CRM/Core/Payment.php';
$payment =& CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
$payment->doTransferCheckout($form->_params, 'contribute');
}
}
$form->_values['membership_id'] = $membership->id;
if (isset($contribution[$index]->id)) {
$form->_values['contribution_id'] = $contribution[$index]->id;
}
// Do not send an email if Recurring transaction is done via Direct Mode
// Email will we sent when the IPN is received.
if ($form->_params['is_recur'] && $form->_contributeMode == 'direct') {
return true;
}
//finally send an email receipt
require_once "CRM/Contribute/BAO/ContributionPage.php";
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $isTest);
}
示例6: processConfirm
//.........这里部分代码省略.........
$paymentParams['contactID'] = $form->_params['contactID'] = $contactID;
//fix for CRM-16317
$form->_params['receive_date'] = date('YmdHis');
$form->assign('receive_date', CRM_Utils_Date::mysqlToIso($form->_params['receive_date']));
if ($isPaymentTransaction) {
// Fix for CRM-14354. If the membership is recurring, don't create a
// civicrm_contribution_recur record for the additional contribution
// (i.e., the amount NOT associated with the membership). Temporarily
// cache the is_recur values so we can process the additional gift as a
// one-off payment.
if (!empty($form->_values['is_recur'])) {
if ($form->_membershipBlock['is_separate_payment'] && !empty($form->_params['auto_renew'])) {
$cachedFormValue = CRM_Utils_Array::value('is_recur', $form->_values);
$cachedParamValue = CRM_Utils_Array::value('is_recur', $paymentParams);
unset($form->_values['is_recur']);
unset($paymentParams['is_recur']);
}
}
$contributionParams = array('contact_id' => $contactID, 'line_item' => $lineItems, 'is_test' => $isTest, 'campaign_id' => CRM_Utils_Array::value('campaign_id', $paymentParams, CRM_Utils_Array::value('campaign_id', $form->_values)), 'contribution_page_id' => $form->_id, 'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)));
$isMonetary = !empty($form->_values['is_monetary']);
if ($isMonetary) {
if (empty($paymentParams['is_pay_later'])) {
// @todo look up payment_instrument_id on payment processor table.
$contributionParams['payment_instrument_id'] = 1;
}
}
$contribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($form, $paymentParams, NULL, $contributionParams, $financialType, TRUE, TRUE, $form->_bltID);
$paymentParams['contributionTypeID'] = $contributionTypeId;
$paymentParams['item_name'] = $form->_params['description'];
if ($contribution && $form->_values['is_recur'] && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
$paymentParams['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
return array('contribution' => $contribution);
}
// restore cached values (part of fix for CRM-14354)
if (!empty($cachedFormValue)) {
$form->_values['is_recur'] = $cachedFormValue;
$paymentParams['is_recur'] = $cachedParamValue;
}
$paymentParams['contributionID'] = $contribution->id;
//CRM-15297 deprecate contributionTypeID
$paymentParams['financialTypeID'] = $paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
if (isset($paymentParams['contribution_source'])) {
$paymentParams['source'] = $paymentParams['contribution_source'];
}
if ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
if ($form->_contributeMode && $form->_amount > 0.0) {
try {
$payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
if ($form->_contributeMode == 'notify') {
// We want to get rid of this & make it generic - eg. by making payment processing the last thing
// and always calling it first.
$form->postProcessHook();
}
$result = $payment->doPayment($paymentParams);
$form->_params = array_merge($form->_params, $result);
$form->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $result));
if (!empty($result['trxn_id'])) {
$contribution->trxn_id = $result['trxn_id'];
}
if (!empty($result['payment_status_id'])) {
$contribution->payment_status_id = $result['payment_status_id'];
}
$result['contribution'] = $contribution;
return $result;
} catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
// Clean up DB as appropriate.
if (!empty($paymentParams['contributionID'])) {
CRM_Contribute_BAO_Contribution::failPayment($paymentParams['contributionID'], $paymentParams['contactID'], $e->getMessage());
}
if (!empty($paymentParams['contributionRecurID'])) {
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
$result['is_payment_failure'] = TRUE;
$result['error'] = $e;
return $result;
}
}
}
// Only pay later or unpaid should reach this point. The theory is that paylater should get a receipt now &
// processor
// transaction receipts should be outcome driven.
$form->set('params', $form->_params);
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
$form->_values['contribution_id'] = $contribution->id;
$form->_values['contribution_page_id'] = $contribution->contribution_page_id;
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test);
}
示例7: postProcessMembership
//.........这里部分代码省略.........
$membershipContribution = $result[1];
}
}
if ($isProcessSeparateMembershipTransaction) {
try {
$lineItems = $form->_lineItem = $membershipLineItems;
if (empty($form->_params['auto_renew']) && !empty($membershipParams['is_recur'])) {
unset($membershipParams['is_recur']);
}
$membershipContribution = self::processSecondaryFinancialTransaction($contactID, $form, $membershipParams, $isTest, $membershipLineItems, CRM_Utils_Array::value('minimum_fee', $membershipDetails, 0), CRM_Utils_Array::value('financial_type_id', $membershipDetails));
} catch (CRM_Core_Exception $e) {
$errors[2] = $e->getMessage();
$membershipContribution = NULL;
}
}
$membership = NULL;
if (!empty($membershipContribution) && !is_a($membershipContribution, 'CRM_Core_Error')) {
$membershipContributionID = $membershipContribution->id;
}
//@todo - why is this nested so deep? it seems like it could be just set on the calling function on the form layer
if (isset($membershipParams['onbehalf']) && !empty($membershipParams['onbehalf']['member_campaign_id'])) {
$form->_params['campaign_id'] = $membershipParams['onbehalf']['member_campaign_id'];
}
//@todo it should no longer be possible for it to get to this point & membership to not be an array
if (is_array($membershipTypeIDs) && !empty($membershipContributionID)) {
$typesTerms = CRM_Utils_Array::value('types_terms', $membershipParams, array());
foreach ($membershipTypeIDs as $memType) {
$numTerms = CRM_Utils_Array::value($memType, $typesTerms, 1);
$createdMemberships[$memType] = self::createOrRenewMembership($membershipParams, $contactID, $customFieldsFormatted, $membershipID, $memType, $isTest, $numTerms, $membershipContribution, $form);
}
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 = self::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, CRM_Core_DAO::$_nullArray, '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 reciept template to send payment reciept
if (count($createdMemberships)) {
$form->_values['isMembership'] = TRUE;
}
if ($form->_contributeMode == 'notify') {
if ($form->_values['is_monetary'] && $form->_amount > 0.0 && !$form->_params['is_pay_later']) {
// call postProcess hook before leaving
$form->postProcessHook();
// this does not return
$payment = CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
$payment->doTransferCheckout($form->_params, 'contribute');
}
}
if (isset($membershipContributionID)) {
$form->_values['contribution_id'] = $membershipContributionID;
}
// Refer to CRM-16737. Payment processors 'should' return payment_status_id
// to denote the outcome of the transaction.
//
// In 4.7 trxn_id will no longer denote the outcome & all processor transactions must return an array
// containing payment_status_id.
// In 4.6 support (such as there was) for other ways of denoting payment outcome is retained but the use
// of payment_status_id is strongly encouraged.
if (!empty($form->_params['is_recur']) && $form->_contributeMode == 'direct') {
if (!empty($membershipContribution->trxn_id) && !isset($membershipContribution->payment_status_id) || !empty($membershipContribution->payment_status_id) && $membershipContribution->payment_status_id == 1) {
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());
}
}
// 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);
}
示例8: sendMail
function sendMail(&$input, &$ids, &$objects, &$values, $recur = false, $returnMessageText = false)
{
$contribution =& $objects['contribution'];
$membership =& $objects['membership'];
$participant =& $objects['participant'];
$event =& $objects['event'];
if (empty($values)) {
$values = array();
if ($input['component'] == 'contribute') {
require_once 'CRM/Contribute/BAO/ContributionPage.php';
if (isset($contribution->contribution_page_id)) {
CRM_Contribute_BAO_ContributionPage::setValues($contribution->contribution_page_id, $values);
} else {
// Handle re-print receipt for offline contributions (call from PDF.php - no contribution_page_id)
$values['is_email_receipt'] = 1;
$values['title'] = 'Contribution';
}
} else {
// event
$eventParams = array('id' => $objects['event']->id);
$values['event'] = array();
require_once 'CRM/Event/BAO/Event.php';
CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
$eventParams = array('id' => $objects['event']->id);
$values['event'] = array();
require_once 'CRM/Event/BAO/Event.php';
CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
//get location details
$locationParams = array('entity_id' => $objects['event']->id, 'entity_table' => 'civicrm_event');
require_once 'CRM/Core/BAO/Location.php';
require_once 'CRM/Event/Form/ManageEvent/Location.php';
$values['location'] = CRM_Core_BAO_Location::getValues($locationParams);
require_once 'CRM/Core/BAO/UFJoin.php';
$ufJoinParams = array('entity_table' => 'civicrm_event', 'entity_id' => $ids['event'], 'weight' => 1);
$values['custom_pre_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
$ufJoinParams['weight'] = 2;
$values['custom_post_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
}
}
$template =& CRM_Core_Smarty::singleton();
// CRM_Core_Error::debug('tpl',$template);
//assign honor infomation to receiptmessage
if ($honarID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contribution->id, 'honor_contact_id')) {
$honorDefault = array();
$honorIds = array();
$honorIds['contribution'] = $contribution->id;
$idParams = array('id' => $honarID, 'contact_id' => $honarID);
require_once "CRM/Contact/BAO/Contact.php";
CRM_Contact_BAO_Contact::retrieve($idParams, $honorDefault, $honorIds);
require_once "CRM/Core/PseudoConstant.php";
$honorType = CRM_Core_PseudoConstant::honor();
$prefix = CRM_Core_PseudoConstant::individualPrefix();
$template->assign('honor_block_is_active', 1);
$template->assign('honor_prefix', $prefix[$honorDefault["prefix_id"]]);
$template->assign('honor_first_name', CRM_Utils_Array::value("first_name", $honorDefault));
$template->assign('honor_last_name', CRM_Utils_Array::value("last_name", $honorDefault));
$template->assign('honor_email', CRM_Utils_Array::value("email", $honorDefault["email"][1]));
$template->assign('honor_type', $honorType[$contribution->honor_type_id]);
}
require_once 'CRM/Contribute/DAO/ContributionProduct.php';
$dao =& new CRM_Contribute_DAO_ContributionProduct();
$dao->contribution_id = $contribution->id;
if ($dao->find(true)) {
$premiumId = $dao->product_id;
$template->assign('option', $dao->product_option);
require_once 'CRM/Contribute/DAO/Product.php';
$productDAO =& new CRM_Contribute_DAO_Product();
$productDAO->id = $premiumId;
$productDAO->find(true);
$template->assign('selectPremium', true);
$template->assign('product_name', $productDAO->name);
$template->assign('price', $productDAO->price);
$template->assign('sku', $productDAO->sku);
}
// add the new contribution values
if ($input['component'] == 'contribute') {
$template->assign('title', $values['title']);
$template->assign('amount', $input['amount']);
//PCP Info
require_once 'CRM/Contribute/DAO/ContributionSoft.php';
$softDAO =& new CRM_Contribute_DAO_ContributionSoft();
$softDAO->contribution_id = $contribution->id;
if ($softDAO->find(true)) {
$template->assign('pcpBlock', true);
$template->assign('pcp_display_in_roll', $softDAO->pcp_display_in_roll);
$template->assign('pcp_roll_nickname', $softDAO->pcp_roll_nickname);
$template->assign('pcp_personal_note', $softDAO->pcp_personal_note);
//assign the pcp page title for email subject
require_once 'CRM/Contribute/DAO/PCP.php';
$pcpDAO =& new CRM_Contribute_DAO_PCP();
$pcpDAO->id = $softDAO->pcp_id;
if ($pcpDAO->find(true)) {
$template->assign('title', $pcpDAO->title);
}
}
} else {
$template->assign('title', $values['event']['title']);
$template->assign('totalAmount', $input['amount']);
}
$template->assign('trxn_id', $contribution->trxn_id);
//.........这里部分代码省略.........
示例9: composeMessageArray
function composeMessageArray(&$input, &$ids, &$values, $recur = FALSE, $returnMessageText = TRUE)
{
if (empty($this->_relatedObjects)) {
$this->loadRelatedObjects($input, $ids);
}
if (empty($this->_component)) {
$this->_component = CRM_Utils_Array::value('component', $input);
}
//not really sure what params might be passed in but lets merge em into values
$values = array_merge($this->_gatherMessageValues($input, $values, $ids), $values);
$template = CRM_Core_Smarty::singleton();
$this->_assignMessageVariablesToTemplate($values, $input, $template, $recur, $returnMessageText);
//what does recur 'mean here - to do with payment processor return functionality but
// what is the importance
if ($recur && !empty($this->_relatedObjects['paymentProcessor'])) {
$paymentObject =& CRM_Core_Payment::singleton($this->is_test ? 'test' : 'live', $this->_relatedObjects['paymentProcessor']);
$entityID = $entity = NULL;
if (isset($ids['contribution'])) {
$entity = 'contribution';
$entityID = $ids['contribution'];
}
if (!empty($ids['membership'])) {
//not sure whether is is possible for this not to be an array - load related contacts loads an array but this code was expecting a string
// the addition of the casting is in case it could get here & be a string. Added in 4.6 - maybe remove later? This AuthorizeNetIPN & PaypalIPN tests hit this
// line having loaded an array
$ids['membership'] = (array) $ids['membership'];
$entity = 'membership';
$entityID = $ids['membership'][0];
}
$url = $paymentObject->subscriptionURL($entityID, $entity);
$template->assign('cancelSubscriptionUrl', $url);
$url = $paymentObject->subscriptionURL($entityID, $entity, 'billing');
$template->assign('updateSubscriptionBillingUrl', $url);
$url = $paymentObject->subscriptionURL($entityID, $entity, 'update');
$template->assign('updateSubscriptionUrl', $url);
if ($this->_relatedObjects['paymentProcessor']['billing_mode'] & CRM_Core_Payment::BILLING_MODE_FORM) {
//direct mode showing billing block, so use directIPN for temporary
$template->assign('contributeMode', 'directIPN');
}
}
// todo remove strtolower - check consistency
if (strtolower($this->_component) == 'event') {
return CRM_Event_BAO_Event::sendMail($ids['contact'], $values, $this->_relatedObjects['participant']->id, $this->is_test, $returnMessageText);
} else {
$values['contribution_id'] = $this->id;
if (CRM_Utils_Array::value('related_contact', $ids)) {
$values['related_contact'] = $ids['related_contact'];
if (isset($ids['onbehalf_dupe_alert'])) {
$values['onbehalf_dupe_alert'] = $ids['onbehalf_dupe_alert'];
}
$entityBlock = array('contact_id' => $ids['contact'], 'location_type_id' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_LocationType', 'Home', 'id', 'name'));
$address = CRM_Core_BAO_Address::getValues($entityBlock);
$template->assign('onBehalfAddress', $address[$entityBlock['location_type_id']]['display']);
}
$isTest = FALSE;
if ($this->is_test) {
$isTest = TRUE;
}
if (!empty($this->_relatedObjects['membership'])) {
foreach ($this->_relatedObjects['membership'] as $membership) {
if ($membership->id) {
$values['membership_id'] = $membership->id;
// need to set the membership values here
$template->assign('membership_assign', 1);
$template->assign('membership_name', CRM_Member_PseudoConstant::membershipType($membership->membership_type_id));
$template->assign('mem_start_date', $membership->start_date);
$template->assign('mem_join_date', $membership->join_date);
$template->assign('mem_end_date', $membership->end_date);
$membership_status = CRM_Member_PseudoConstant::membershipStatus($membership->status_id, NULL, 'label');
$template->assign('mem_status', $membership_status);
if ($membership_status == 'Pending' && $membership->is_pay_later == 1) {
$template->assign('is_pay_later', 1);
}
// if separate payment there are two contributions recorded and the
// admin will need to send a receipt for each of them separately.
// we dont link the two in the db (but can potentially infer it if needed)
$template->assign('is_separate_payment', 0);
if ($recur && $paymentObject) {
$url = $paymentObject->subscriptionURL($membership->id, 'membership');
$template->assign('cancelSubscriptionUrl', $url);
$url = $paymentObject->subscriptionURL($membership->id, 'membership', 'billing');
$template->assign('updateSubscriptionBillingUrl', $url);
$url = $paymentObject->subscriptionURL($entityID, $entity, 'update');
$template->assign('updateSubscriptionUrl', $url);
}
$result = CRM_Contribute_BAO_ContributionPage::sendMail($ids['contact'], $values, $isTest, $returnMessageText);
return $result;
// otherwise if its about sending emails, continue sending without return, as we
// don't want to exit the loop.
}
}
} else {
return CRM_Contribute_BAO_ContributionPage::sendMail($ids['contact'], $values, $isTest, $returnMessageText);
}
}
}
示例10: postProcessMembership
//.........这里部分代码省略.........
// irrespective of the value, CRM-2888
$tempParams['cms_create_account'] = 0;
$pending = $form->_params['is_pay_later'] ? CRM_Utils_Array::value('minimum_fee', $membershipDetails, 0) > 0.0 ? TRUE : FALSE : FALSE;
//set this variable as we are not creating pledge for
//separate membership payment contribution.
//so for differentiating membership contributon from
//main contribution.
$form->_params['separate_membership_payment'] = 1;
$contribution[2] = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $tempParams, $result, $contactID, $contributionType, TRUE, $pending);
}
}
$index = CRM_Utils_Array::value('is_separate_payment', $memBlockDetails) ? 2 : 1;
if (!CRM_Utils_Array::value($index, $errors)) {
if (isset($membershipParams['onbehalf']) && CRM_Utils_Array::value('member_campaign_id', $membershipParams['onbehalf'])) {
$form->_params['campaign_id'] = $membershipParams['onbehalf']['member_campaign_id'];
}
if (is_array($membershipTypeID)) {
$typesTerms = CRM_Utils_Array::value('types_terms', $membershipParams, array());
$createdMemberships = array();
foreach ($membershipTypeID as $memType) {
$numTerms = CRM_Utils_Array::value($memType, $typesTerms, 1);
$membership = self::renewMembership($contactID, $memType, $isTest, $form, NULL, CRM_Utils_Array::value('cms_contactID', $membershipParams), $customFieldsFormatted, CRM_Utils_Array::value($memType, $typesTerms, 1));
$createdMemberships[$memType] = $membership;
if (isset($contribution[$index])) {
//insert payment record
$dao = new CRM_Member_DAO_MembershipPayment();
$dao->membership_id = $membership->id;
$dao->contribution_id = $contribution[$index]->id;
//Fixed for avoiding duplicate entry error when user goes
//back and forward during payment mode is notify
if (!$dao->find(TRUE)) {
CRM_Utils_Hook::pre('create', 'MembershipPayment', NULL, $dao);
$dao->save();
CRM_Utils_Hook::post('create', 'MembershipPayment', $dao->id, $dao);
}
}
}
if ($form->_priceSetId && !empty($form->_useForMember) && !empty($form->_lineItem)) {
foreach ($form->_lineItem[$form->_priceSetId] as &$priceFieldOp) {
if (CRM_Utils_Array::value('membership_type_id', $priceFieldOp) && 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, '%d%f %b, %Y') : '-';
$priceFieldOp['end_date'] = $membershipOb->end_date ? CRM_Utils_Date::customFormat($membershipOb->end_date, '%d%f %b, %Y') : '-';
} else {
$priceFieldOp['start_date'] = $priceFieldOp['end_date'] = 'N/A';
}
}
$form->_values['lineItem'] = $form->_lineItem;
$form->assign('lineItem', $form->_lineItem);
}
} else {
$membership = self::renewMembership($contactID, $membershipTypeID, $isTest, $form, NULL, CRM_Utils_Array::value('cms_contactID', $membershipParams), $customFieldsFormatted, CRM_Utils_Array::value('types_terms', $membershipParams, 1), CRM_Utils_Array::value('contribution_status_id', $result) == 2 ? TRUE : FALSE);
if (isset($contribution[$index])) {
//insert payment record
$dao = new CRM_Member_DAO_MembershipPayment();
$dao->membership_id = $membership->id;
$dao->contribution_id = $contribution[$index]->id;
//Fixed for avoiding duplicate entry error when user goes
//back and forward during payment mode is notify
if (!$dao->find(TRUE)) {
CRM_Utils_Hook::pre('create', 'MembershipPayment', NULL, $dao);
$dao->save();
CRM_Utils_Hook::post('create', 'MembershipPayment', $dao->id, $dao);
}
}
}
}
if (!empty($errors)) {
foreach ($errors as $error) {
if (is_string($error)) {
$message[] = $error;
}
}
$message = ts('Payment Processor Error message') . ': ' . implode('<br/>', $message);
throw new CRM_Core_Exception($message);
}
// CRM-7851
CRM_Core_BAO_CustomValueTable::postProcess($form->_params, CRM_Core_DAO::$_nullArray, 'civicrm_membership', $membership->id, 'Membership');
$form->_params['membershipID'] = $membership->id;
if ($form->_contributeMode == 'notify') {
if ($form->_values['is_monetary'] && $form->_amount > 0.0 && !$form->_params['is_pay_later']) {
// call postprocess hook before leaving
$form->postProcessHook();
// this does not return
$payment = CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
$payment->doTransferCheckout($form->_params, 'contribute');
}
}
$form->_values['membership_id'] = $membership->id;
if (isset($contribution[$index]->id)) {
$form->_values['contribution_id'] = $contribution[$index]->id;
}
// Do not send an email if Recurring transaction is done via Direct Mode
// Email will we sent when the IPN is received.
if (CRM_Utils_Array::value('is_recur', $form->_params) && $form->_contributeMode == 'direct') {
return TRUE;
}
//finally send an email receipt
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $isTest, FALSE, $includeFieldTypes);
}
示例11: processConfirm
//.........这里部分代码省略.........
// add qfKey so we can send to paypal
$form->_params['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
$membershipResult = array(1 => $contribution);
return $membershipResult;
} else {
if (!$isPayLater) {
if (is_object($payment)) {
// call postProcess hook before leaving
$form->postProcessHook();
// this does not return
$result = $payment->doTransferCheckout($form->_params, 'contribute');
} else {
CRM_Core_Error::fatal($paymentObjError);
}
} else {
// follow similar flow as IPN
// send the receipt mail
$form->set('params', $form->_params);
if ($contributionType->is_deductible) {
$form->assign('is_deductible', TRUE);
$form->set('is_deductible', TRUE);
}
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
$form->_values['contribution_id'] = $contribution->id;
$form->_values['contribution_page_id'] = $contribution->contribution_page_id;
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test);
return;
}
}
}
} elseif ($form->_contributeMode == 'express') {
if ($form->_values['is_monetary'] && $form->_amount > 0.0) {
// determine if express + recurring and direct accordingly
if (!empty($paymentParams['is_recur']) && $paymentParams['is_recur'] == 1) {
if (is_object($payment)) {
$result = $payment->createRecurringPayments($paymentParams);
} else {
CRM_Core_Error::fatal($paymentObjError);
}
} else {
if (is_object($payment)) {
$result = $payment->doExpressCheckout($paymentParams);
} else {
CRM_Core_Error::fatal($paymentObjError);
}
}
}
} elseif ($isPaymentTransaction) {
if (!empty($paymentParams['is_recur']) && $form->_contributeMode == 'direct') {
// For recurring contribution, create Contribution Record first.
// Contribution ID, Recurring ID and Contact ID needed
// When we get a callback from the payment processor
$paymentParams['contactID'] = $contactID;
// Fix for CRM-14354. If the membership is recurring, don't create a
// civicrm_contribution_recur record for the additional contribution
// (i.e., the amount NOT associated with the membership). Temporarily
// cache the is_recur values so we can process the additional gift as a
// one-off payment.
示例12: processConfirm
/**
* Function to process payment after confirmation
*
* @param object $form form object
* @param array $paymentParams array with payment related key
* value pairs
* @param array $premiumParams array with premium related key
* value pairs
* @param int $contactID contact id
* @param int $contributionTypeId financial type id
* @param int $component component id
*
* @return array associated array
*
* @static
* @access public
*/
static function processConfirm(&$form, &$paymentParams, &$premiumParams, $contactID, $contributionTypeId, $component = 'contribution', $fieldTypes = NULL)
{
CRM_Core_Payment_Form::mapParams($form->_bltID, $form->_params, $paymentParams, TRUE);
$contributionType = new CRM_Financial_DAO_FinancialType();
if (isset($paymentParams['financial_type'])) {
$contributionType->id = $paymentParams['financial_type'];
} elseif (!empty($form->_values['pledge_id'])) {
$contributionType->id = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge', $form->_values['pledge_id'], 'financial_type_id');
} else {
$contributionType->id = $contributionTypeId;
}
if (!$contributionType->find(TRUE)) {
CRM_Core_Error::fatal('Could not find a system table');
}
// add some financial type details to the params list
// if folks need to use it
$paymentParams['contributionType_name'] = $form->_params['contributionType_name'] = $contributionType->name;
//CRM-11456
$paymentParams['contributionType_accounting_code'] = $form->_params['contributionType_accounting_code'] = CRM_Financial_BAO_FinancialAccount::getAccountingCode($contributionType->id);
$paymentParams['contributionPageID'] = $form->_params['contributionPageID'] = $form->_values['id'];
$payment = NULL;
$paymentObjError = ts('The system did not record payment details for this payment and so could not process the transaction. Please report this error to the site administrator.');
if ($form->_values['is_monetary'] && $form->_amount > 0.0 && is_array($form->_paymentProcessor)) {
$payment = CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
}
//fix for CRM-2062
$now = date('YmdHis');
$result = NULL;
if ($form->_contributeMode == 'notify' || $form->_params['is_pay_later']) {
// this is not going to come back, i.e. we fill in the other details
// when we get a callback from the payment processor
// also add the contact ID and contribution ID to the params list
$paymentParams['contactID'] = $form->_params['contactID'] = $contactID;
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $paymentParams, NULL, $contactID, $contributionType, TRUE, TRUE, TRUE);
if ($contribution) {
$form->_params['contributionID'] = $contribution->id;
}
$form->_params['contributionTypeID'] = $contributionType->id;
$form->_params['item_name'] = $form->_params['description'];
$form->_params['receive_date'] = $now;
if ($contribution && $form->_values['is_recur'] && $contribution->contribution_recur_id) {
$form->_params['contributionRecurID'] = $contribution->contribution_recur_id;
}
$form->set('params', $form->_params);
$form->postProcessPremium($premiumParams, $contribution);
if ($form->_values['is_monetary'] && $form->_amount > 0.0) {
// add qfKey so we can send to paypal
$form->_params['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
$membershipResult = array(1 => $contribution);
return $membershipResult;
} else {
if (!$form->_params['is_pay_later']) {
if (is_object($payment)) {
// call postprocess hook before leaving
$form->postProcessHook();
// this does not return
$result =& $payment->doTransferCheckout($form->_params, 'contribute');
} else {
CRM_Core_Error::fatal($paymentObjError);
}
} else {
// follow similar flow as IPN
// send the receipt mail
$form->set('params', $form->_params);
if ($contributionType->is_deductible) {
$form->assign('is_deductible', TRUE);
$form->set('is_deductible', TRUE);
}
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
$form->_values['contribution_id'] = $contribution->id;
$form->_values['contribution_page_id'] = $contribution->contribution_page_id;
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test);
return;
}
}
//.........这里部分代码省略.........
示例13: 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);
}
示例14: processConfirm
//.........这里部分代码省略.........
$form->assign('is_deductible', TRUE);
$form->set('is_deductible', TRUE);
}
// add some financial type details to the params list
// if folks need to use it
//CRM-15297 - contributionType is obsolete - pass financial type as well so people can deprecate it
$paymentParams['financialType_name'] = $paymentParams['contributionType_name'] = $form->_params['contributionType_name'] = $financialType->name;
//CRM-11456
$paymentParams['financialType_accounting_code'] = $paymentParams['contributionType_accounting_code'] = $form->_params['contributionType_accounting_code'] = CRM_Financial_BAO_FinancialAccount::getAccountingCode($contributionTypeId);
$paymentParams['contributionPageID'] = $form->_params['contributionPageID'] = $form->_values['id'];
$paymentParams['contactID'] = $form->_params['contactID'] = $contactID;
//fix for CRM-16317
$form->_params['receive_date'] = date('YmdHis');
$form->assign('receive_date', CRM_Utils_Date::mysqlToIso($form->_params['receive_date']));
if ($isPaymentTransaction) {
$contributionParams = array('id' => CRM_Utils_Array::value('contribution_id', $paymentParams), 'contact_id' => $contactID, 'line_item' => $lineItems, 'is_test' => $isTest, 'campaign_id' => CRM_Utils_Array::value('campaign_id', $paymentParams, CRM_Utils_Array::value('campaign_id', $form->_values)), 'contribution_page_id' => $form->_id, 'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)));
$isMonetary = !empty($form->_values['is_monetary']);
if ($isMonetary) {
if (empty($paymentParams['is_pay_later'])) {
// @todo look up payment_instrument_id on payment processor table.
$contributionParams['payment_instrument_id'] = 1;
}
}
$contribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($form, $paymentParams, NULL, $contributionParams, $financialType, TRUE, $form->_bltID, $isRecur);
$paymentParams['contributionTypeID'] = $contributionTypeId;
$paymentParams['item_name'] = $form->_params['description'];
$paymentParams['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
return array('contribution' => $contribution);
}
$paymentParams['contributionID'] = $contribution->id;
//CRM-15297 deprecate contributionTypeID
$paymentParams['financialTypeID'] = $paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
if (isset($paymentParams['contribution_source'])) {
$paymentParams['source'] = $paymentParams['contribution_source'];
}
if ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
$form->_values['contribution_id'] = $contribution->id;
$form->_values['contribution_page_id'] = $contribution->contribution_page_id;
if (!empty($form->_paymentProcessor)) {
try {
$payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
if ($form->_contributeMode == 'notify') {
// We want to get rid of this & make it generic - eg. by making payment processing the last thing
// and always calling it first.
$form->postProcessHook();
}
$result = $payment->doPayment($paymentParams);
$form->_params = array_merge($form->_params, $result);
$form->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $result));
if (!empty($result['trxn_id'])) {
$contribution->trxn_id = $result['trxn_id'];
}
if (!empty($result['payment_status_id'])) {
$contribution->payment_status_id = $result['payment_status_id'];
}
$result['contribution'] = $contribution;
if ($result['payment_status_id'] == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'status_id', 'Pending') && $payment->isSendReceiptForPending()) {
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test);
}
return $result;
} catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
// Clean up DB as appropriate.
if (!empty($paymentParams['contributionID'])) {
CRM_Contribute_BAO_Contribution::failPayment($paymentParams['contributionID'], $paymentParams['contactID'], $e->getMessage());
}
if (!empty($paymentParams['contributionRecurID'])) {
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
$result['is_payment_failure'] = TRUE;
$result['error'] = $e;
return $result;
}
}
}
// Only pay later or unpaid should reach this point, although pay later likely does not & is handled via the
// manual processor, so it's unclear what this set is for and whether the following send ever fires.
$form->set('params', $form->_params);
if ($form->_params['amount'] == 0) {
// This is kind of a back-up for pay-later $0 transactions.
// In other flows they pick up the manual processor & get dealt with above (I
// think that might be better...).
return array('payment_status_id' => 1, 'contribution' => $contribution, 'payment_processor_id' => 0);
} elseif (empty($form->_values['amount'])) {
// If the amount is not in _values[], set it
$form->_values['amount'] = $form->_params['amount'];
}
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test);
}
示例15: processConfirm
//.........这里部分代码省略.........
$form->_params['contributionRecurID'] = $contribution->contribution_recur_id;
}
$form->set('params', $form->_params);
$form->postProcessPremium($premiumParams, $contribution);
if ($isPaymentTransaction) {
// add qfKey so we can send to paypal
$form->_params['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
return array('contribution' => $contribution);
} else {
if (!$isPayLater) {
if (is_object($payment)) {
// call postProcess hook before leaving
$form->postProcessHook();
// this does not return
$result = $payment->doTransferCheckout($form->_params, 'contribute');
} else {
CRM_Core_Error::fatal($paymentObjError);
}
} else {
// follow similar flow as IPN
// send the receipt mail
$form->set('params', $form->_params);
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
$form->_values['contribution_id'] = $contribution->id;
$form->_values['contribution_page_id'] = $contribution->contribution_page_id;
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test);
return;
}
}
}
} elseif ($form->_contributeMode == 'express') {
if ($form->_values['is_monetary'] && $form->_amount > 0.0) {
// determine if express + recurring and direct accordingly
if (!empty($paymentParams['is_recur']) && $paymentParams['is_recur'] == 1) {
if (is_object($payment)) {
$result = $payment->createRecurringPayments($paymentParams);
} else {
CRM_Core_Error::fatal($paymentObjError);
}
} else {
if (is_object($payment)) {
$result = $payment->doExpressCheckout($paymentParams);
} else {
CRM_Core_Error::fatal($paymentObjError);
}
}
}
} elseif ($isPaymentTransaction) {
if ($form->_contributeMode == 'direct') {
$paymentParams['contactID'] = $contactID;
// Fix for CRM-14354. If the membership is recurring, don't create a
// civicrm_contribution_recur record for the additional contribution
// (i.e., the amount NOT associated with the membership). Temporarily
// cache the is_recur values so we can process the additional gift as a
// one-off payment.
if (!empty($form->_values['is_recur'])) {
if ($form->_membershipBlock['is_separate_payment'] && !empty($form->_params['auto_renew'])) {
$cachedFormValue = CRM_Utils_Array::value('is_recur', $form->_values);