本文整理汇总了PHP中CRM_Core_Payment_BaseIPN::validateData方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Payment_BaseIPN::validateData方法的具体用法?PHP CRM_Core_Payment_BaseIPN::validateData怎么用?PHP CRM_Core_Payment_BaseIPN::validateData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Payment_BaseIPN
的用法示例。
在下文中一共展示了CRM_Core_Payment_BaseIPN::validateData方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateContributionStatus
/**
* Update contribution status - this is only called from one place in the code &
* it is unclear whether it is a function on the way in or on the way out
*
* @param unknown_type $params
* @return void|Ambigous <value, unknown, array>
*/
function updateContributionStatus(&$params)
{
// get minimum required values.
$statusId = CRM_Utils_Array::value('contribution_status_id', $params);
$componentId = CRM_Utils_Array::value('component_id', $params);
$componentName = CRM_Utils_Array::value('componentName', $params);
$contributionId = CRM_Utils_Array::value('contribution_id', $params);
if (!$contributionId || !$componentId || !$componentName || !$statusId) {
return;
}
$input = $ids = $objects = array();
//get the required ids.
$ids['contribution'] = $contributionId;
if (!($ids['contact'] = CRM_Utils_Array::value('contact_id', $params))) {
$ids['contact'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'contact_id');
}
if ($componentName == 'Event') {
$name = 'event';
$ids['participant'] = $componentId;
if (!($ids['event'] = CRM_Utils_Array::value('event_id', $params))) {
$ids['event'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $componentId, 'event_id');
}
}
if ($componentName == 'Membership') {
$name = 'contribute';
$ids['membership'] = $componentId;
}
$ids['contributionPage'] = NULL;
$ids['contributionRecur'] = NULL;
$input['component'] = $name;
$baseIPN = new CRM_Core_Payment_BaseIPN();
$transaction = new CRM_Core_Transaction();
// reset template values.
$template = CRM_Core_Smarty::singleton();
$template->clearTemplateVars();
if (!$baseIPN->validateData($input, $ids, $objects, FALSE)) {
CRM_Core_Error::fatal();
}
$contribution =& $objects['contribution'];
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$input['skipComponentSync'] = CRM_Utils_Array::value('skipComponentSync', $params);
if ($statusId == array_search('Cancelled', $contributionStatuses)) {
$baseIPN->cancelled($objects, $transaction, $input);
$transaction->commit();
return $statusId;
} elseif ($statusId == array_search('Failed', $contributionStatuses)) {
$baseIPN->failed($objects, $transaction, $input);
$transaction->commit();
return $statusId;
}
// status is not pending
if ($contribution->contribution_status_id != array_search('Pending', $contributionStatuses)) {
$transaction->commit();
return;
}
//set values for ipn code.
foreach (array('fee_amount', 'check_number', 'payment_instrument_id') as $field) {
if (!($input[$field] = CRM_Utils_Array::value($field, $params))) {
$input[$field] = $contribution->{$field};
}
}
if (!($input['trxn_id'] = CRM_Utils_Array::value('trxn_id', $params))) {
$input['trxn_id'] = $contribution->invoice_id;
}
if (!($input['amount'] = CRM_Utils_Array::value('total_amount', $params))) {
$input['amount'] = $contribution->total_amount;
}
$input['is_test'] = $contribution->is_test;
$input['net_amount'] = $contribution->net_amount;
if (CRM_Utils_Array::value('fee_amount', $input) && CRM_Utils_Array::value('amount', $input)) {
$input['net_amount'] = $input['amount'] - $input['fee_amount'];
}
//complete the contribution.
$baseIPN->completeTransaction($input, $ids, $objects, $transaction, FALSE);
// reset template values before processing next transactions
$template->clearTemplateVars();
return $statusId;
}
示例2: transitionComponents
/**
* Update contribution as well as related objects.
*
* This function by-passes hooks - to address this - don't use this function.
*
* @deprecated
*
* Use api contribute.completetransaction
* For failures use failPayment (preferably exposing by api in the process).
*
* @param array $params
* @param bool $processContributionObject
*
* @return array
* @throws \Exception
*/
public static function transitionComponents($params, $processContributionObject = FALSE)
{
// get minimum required values.
$contactId = CRM_Utils_Array::value('contact_id', $params);
$componentId = CRM_Utils_Array::value('component_id', $params);
$componentName = CRM_Utils_Array::value('componentName', $params);
$contributionId = CRM_Utils_Array::value('contribution_id', $params);
$contributionStatusId = CRM_Utils_Array::value('contribution_status_id', $params);
// if we already processed contribution object pass previous status id.
$previousContriStatusId = CRM_Utils_Array::value('previous_contribution_status_id', $params);
$updateResult = array();
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
// we process only ( Completed, Cancelled, or Failed ) contributions.
if (!$contributionId || !in_array($contributionStatusId, array(array_search('Completed', $contributionStatuses), array_search('Cancelled', $contributionStatuses), array_search('Failed', $contributionStatuses)))) {
return $updateResult;
}
if (!$componentName || !$componentId) {
// get the related component details.
$componentDetails = self::getComponentDetails($contributionId);
} else {
$componentDetails['contact_id'] = $contactId;
$componentDetails['component'] = $componentName;
if ($componentName == 'event') {
$componentDetails['participant'] = $componentId;
} else {
$componentDetails['membership'] = $componentId;
}
}
if (!empty($componentDetails['contact_id'])) {
$componentDetails['contact_id'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'contact_id');
}
// do check for required ids.
if (empty($componentDetails['membership']) && empty($componentDetails['participant']) && empty($componentDetails['pledge_payment']) || empty($componentDetails['contact_id'])) {
return $updateResult;
}
//now we are ready w/ required ids, start processing.
$baseIPN = new CRM_Core_Payment_BaseIPN();
$input = $ids = $objects = array();
$input['component'] = CRM_Utils_Array::value('component', $componentDetails);
$ids['contribution'] = $contributionId;
$ids['contact'] = CRM_Utils_Array::value('contact_id', $componentDetails);
$ids['membership'] = CRM_Utils_Array::value('membership', $componentDetails);
$ids['participant'] = CRM_Utils_Array::value('participant', $componentDetails);
$ids['event'] = CRM_Utils_Array::value('event', $componentDetails);
$ids['pledge_payment'] = CRM_Utils_Array::value('pledge_payment', $componentDetails);
$ids['contributionRecur'] = NULL;
$ids['contributionPage'] = NULL;
if (!$baseIPN->validateData($input, $ids, $objects, FALSE)) {
CRM_Core_Error::fatal();
}
$memberships =& $objects['membership'];
$participant =& $objects['participant'];
$pledgePayment =& $objects['pledge_payment'];
$contribution =& $objects['contribution'];
if ($pledgePayment) {
$pledgePaymentIDs = array();
foreach ($pledgePayment as $key => $object) {
$pledgePaymentIDs[] = $object->id;
}
$pledgeID = $pledgePayment[0]->pledge_id;
}
$membershipStatuses = CRM_Member_PseudoConstant::membershipStatus();
if ($participant) {
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
$oldStatus = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participant->id, 'status_id');
}
// we might want to process contribution object.
$processContribution = FALSE;
if ($contributionStatusId == array_search('Cancelled', $contributionStatuses)) {
if (is_array($memberships)) {
foreach ($memberships as $membership) {
if ($membership) {
$membership->status_id = array_search('Cancelled', $membershipStatuses);
$membership->save();
$updateResult['updatedComponents']['CiviMember'] = $membership->status_id;
if ($processContributionObject) {
$processContribution = TRUE;
}
}
}
}
if ($participant) {
$updatedStatusId = array_search('Cancelled', $participantStatuses);
CRM_Event_BAO_Participant::updateParticipantStatus($participant->id, $oldStatus, $updatedStatusId, TRUE);
//.........这里部分代码省略.........
示例3: transitionComponents
/**
* This function update contribution as well as related objects.
*/
function transitionComponents($params, $processContributionObject = false)
{
// get minimum required values.
$contactId = CRM_Utils_Array::value('contact_id', $params);
$componentId = CRM_Utils_Array::value('component_id', $params);
$componentName = CRM_Utils_Array::value('componentName', $params);
$contributionId = CRM_Utils_Array::value('contribution_id', $params);
$contributionStatusId = CRM_Utils_Array::value('contribution_status_id', $params);
// if we already processed contribution object pass previous status id.
$previousContriStatusId = CRM_Utils_Array::value('previous_contribution_status_id', $params);
$updateResult = array();
require_once 'CRM/Contribute/PseudoConstant.php';
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(null, 'name');
// we process only ( Completed, Cancelled, or Failed ) contributions.
if (!$contributionId || !in_array($contributionStatusId, array(array_search('Completed', $contributionStatuses), array_search('Cancelled', $contributionStatuses), array_search('Failed', $contributionStatuses)))) {
return $updateResult;
}
if (!$componentName || !$componentId) {
// get the related component details.
$componentDetails = self::getComponentDetails($contributionId);
} else {
$componentDetails['contact_id'] = $contactId;
$componentDetails['component'] = $componentName;
if ($componentName = 'event') {
$componentDetails['participant'] = $componentId;
} else {
$componentDetails['membership'] = $componentId;
}
}
if (CRM_Utils_Array::value('contact_id', $componentDetails)) {
$componentDetails['contact_id'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'contact_id');
}
// do check for required ids.
if (!CRM_Utils_Array::value('membership', $componentDetails) && !CRM_Utils_Array::value('participant', $componentDetails) && !CRM_Utils_Array::value('pledge_payment', $componentDetails) || !CRM_Utils_Array::value('contact_id', $componentDetails)) {
return $updateResult;
}
//now we are ready w/ required ids, start processing.
require_once 'CRM/Core/Payment/BaseIPN.php';
$baseIPN = new CRM_Core_Payment_BaseIPN();
$input = $ids = $objects = array();
$input['component'] = CRM_Utils_Array::value('component', $componentDetails);
$ids['contribution'] = $contributionId;
$ids['contact'] = CRM_Utils_Array::value('contact_id', $componentDetails);
$ids['membership'] = CRM_Utils_Array::value('membership', $componentDetails);
$ids['participant'] = CRM_Utils_Array::value('participant', $componentDetails);
$ids['event'] = CRM_Utils_Array::value('event', $componentDetails);
$ids['pledge_payment'] = CRM_Utils_Array::value('pledge_payment', $componentDetails);
$ids['contributionRecur'] = null;
$ids['contributionPage'] = null;
if (!$baseIPN->validateData($input, $ids, $objects, false)) {
CRM_Core_Error::fatal();
}
$membership =& $objects['membership'];
$participant =& $objects['participant'];
$pledgePayment =& $objects['pledge_payment'];
$contribution =& $objects['contribution'];
if ($pledgePayment) {
require_once 'CRM/Pledge/BAO/Payment.php';
$pledgePaymentIDs = array();
foreach ($pledgePayment as $key => $object) {
$pledgePaymentIDs[] = $object->id;
}
$pledgeID = $pledgePayment[0]->pledge_id;
}
require_once 'CRM/Event/PseudoConstant.php';
require_once 'CRM/Event/BAO/Participant.php';
require_once 'CRM/Pledge/BAO/Pledge.php';
require_once 'CRM/Member/PseudoConstant.php';
require_once 'CRM/Member/BAO/Membership.php';
$membershipStatuses = CRM_Member_PseudoConstant::membershipStatus();
if ($participant) {
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
$oldStatus = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $participant->id, 'status_id');
}
// we might want to process contribution object.
$processContribution = false;
if ($contributionStatusId == array_search('Cancelled', $contributionStatuses)) {
if ($membership) {
$membership->status_id = array_search('Cancelled', $membershipStatuses);
$membership->save();
$updateResult['updatedComponents']['CiviMember'] = $membership->status_id;
if ($processContributionObject) {
$processContribution = true;
}
}
if ($participant) {
$updatedStatusId = array_search('Cancelled', $participantStatuses);
CRM_Event_BAO_Participant::updateParticipantStatus($participant->id, $oldStatus, $updatedStatusId, true);
$updateResult['updatedComponents']['CiviEvent'] = $updatedStatusId;
if ($processContributionObject) {
$processContribution = true;
}
}
if ($pledgePayment) {
CRM_Pledge_BAO_Payment::updatePledgePaymentStatus($pledgeID, $pledgePaymentIDs, $contributionStatusId);
$updateResult['updatedComponents']['CiviPledge'] = $contributionStatusId;
if ($processContributionObject) {
//.........这里部分代码省略.........
示例4: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
*
* @return void
*/
public function postProcess()
{
// get all the details needed to generate a receipt
$contribIDs = implode(',', $this->_contributionIds);
$details = CRM_Contribute_Form_Task_Status::getDetails($contribIDs);
$baseIPN = new CRM_Core_Payment_BaseIPN();
$message = array();
$template = CRM_Core_Smarty::singleton();
$params = $this->controller->exportValues($this->_name);
$createPdf = FALSE;
if ($params['output'] == "pdf_receipt") {
$createPdf = TRUE;
}
$excludeContactIds = array();
if (!$createPdf) {
$returnProperties = array('email' => 1, 'do_not_email' => 1, 'is_deceased' => 1, 'on_hold' => 1);
list($contactDetails) = CRM_Utils_Token::getTokenDetails($this->_contactIds, $returnProperties, FALSE, FALSE);
$suppressedEmails = 0;
foreach ($contactDetails as $id => $values) {
if (empty($values['email']) || !empty($values['do_not_email']) || CRM_Utils_Array::value('is_deceased', $values) || !empty($values['on_hold'])) {
$suppressedEmails++;
$excludeContactIds[] = $values['contact_id'];
}
}
}
foreach ($details as $contribID => $detail) {
$input = $ids = $objects = array();
if (in_array($detail['contact'], $excludeContactIds)) {
continue;
}
$input['component'] = $detail['component'];
$ids['contact'] = $detail['contact'];
$ids['contribution'] = $contribID;
$ids['contributionRecur'] = NULL;
$ids['contributionPage'] = NULL;
$ids['membership'] = CRM_Utils_Array::value('membership', $detail);
$ids['participant'] = CRM_Utils_Array::value('participant', $detail);
$ids['event'] = CRM_Utils_Array::value('event', $detail);
if (!$baseIPN->validateData($input, $ids, $objects, FALSE)) {
CRM_Core_Error::fatal();
}
$contribution =& $objects['contribution'];
// CRM_Core_Error::debug('o',$objects);
// set some fake input values so we can reuse IPN code
$input['amount'] = $contribution->total_amount;
$input['is_test'] = $contribution->is_test;
$input['fee_amount'] = $contribution->fee_amount;
$input['net_amount'] = $contribution->net_amount;
$input['trxn_id'] = $contribution->trxn_id;
$input['trxn_date'] = isset($contribution->trxn_date) ? $contribution->trxn_date : NULL;
// CRM_Contribute_BAO_Contribution::composeMessageArray expects mysql formatted date
$objects['contribution']->receive_date = CRM_Utils_Date::isoToMysql($objects['contribution']->receive_date);
// CRM_Core_Error::debug('input',$input);
$values = array();
$mail = $baseIPN->sendMail($input, $ids, $objects, $values, FALSE, $createPdf);
if ($mail['html']) {
$message[] = $mail['html'];
} else {
$message[] = nl2br($mail['body']);
}
// reset template values before processing next transactions
$template->clearTemplateVars();
}
if ($createPdf) {
CRM_Utils_PDF_Utils::html2pdf($message, 'civicrmContributionReceipt.pdf', FALSE, $params['pdf_format_id']);
CRM_Utils_System::civiExit();
} else {
if ($suppressedEmails) {
$status = ts('Email was NOT sent to %1 contacts (no email address on file, or communication preferences specify DO NOT EMAIL, or contact is deceased).', array(1 => $suppressedEmails));
$msgTitle = ts('Email Error');
$msgType = 'error';
} else {
$status = ts('Your mail has been sent.');
$msgTitle = ts('Sent');
$msgType = 'success';
}
CRM_Core_Session::setStatus($status, $msgTitle, $msgType);
}
}
示例5: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
*
* @return None
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
$statusID = CRM_Utils_Array::value('contribution_status_id', $params);
$baseIPN = new CRM_Core_Payment_BaseIPN();
$transaction = new CRM_Core_Transaction();
// get the missing pieces for each contribution
$contribIDs = implode(',', $this->_contributionIds);
$details = self::getDetails($contribIDs);
$template = CRM_Core_Smarty::singleton();
// for each contribution id, we just call the baseIPN stuff
foreach ($this->_rows as $row) {
$input = $ids = $objects = array();
$input['component'] = $details[$row['contribution_id']]['component'];
$ids['contact'] = $row['contact_id'];
$ids['contribution'] = $row['contribution_id'];
$ids['contributionRecur'] = NULL;
$ids['contributionPage'] = NULL;
$ids['membership'] = CRM_Utils_Array::value('membership', $details[$row['contribution_id']]);
$ids['participant'] = CRM_Utils_Array::value('participant', $details[$row['contribution_id']]);
$ids['event'] = CRM_Utils_Array::value('event', $details[$row['contribution_id']]);
if (!$baseIPN->validateData($input, $ids, $objects, FALSE)) {
CRM_Core_Error::fatal();
}
$contribution =& $objects['contribution'];
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
if ($statusID == array_search('Cancelled', $contributionStatuses)) {
$baseIPN->cancelled($objects, $transaction);
$transaction->commit();
continue;
} elseif ($statusID == array_search('Failed', $contributionStatuses)) {
$baseIPN->failed($objects, $transaction);
$transaction->commit();
continue;
}
// status is not pending
if ($contribution->contribution_status_id != array_search('Pending', $contributionStatuses)) {
$transaction->commit();
continue;
}
// set some fake input values so we can reuse IPN code
$input['amount'] = $contribution->total_amount;
$input['is_test'] = $contribution->is_test;
$input['fee_amount'] = $params["fee_amount_{$row['contribution_id']}"];
$input['check_number'] = $params["check_number_{$row['contribution_id']}"];
$input['payment_instrument_id'] = $params["payment_instrument_id_{$row['contribution_id']}"];
$input['net_amount'] = $contribution->total_amount - $input['fee_amount'];
if (!empty($params["trxn_id_{$row['contribution_id']}"])) {
$input['trxn_id'] = trim($params["trxn_id_{$row['contribution_id']}"]);
} else {
$input['trxn_id'] = $contribution->invoice_id;
}
$input['trxn_date'] = CRM_Utils_Date::processDate($params["trxn_date_{$row['contribution_id']}"]);
$baseIPN->completeTransaction($input, $ids, $objects, $transaction, FALSE);
// reset template values before processing next transactions
$template->clearTemplateVars();
}
CRM_Core_Session::setStatus(ts('Contribution status has been updated for selected record(s).'));
}
示例6: updateContributionStatus
/**
* Update contribution status.
*
* @deprecated
* This is only called from one place in the code &
* it is unclear whether it is a function on the way in or on the way out
*
* @param array $params
*
* @return NULL|int
*/
public static function updateContributionStatus($params)
{
// get minimum required values.
$statusId = CRM_Utils_Array::value('contribution_status_id', $params);
$componentId = CRM_Utils_Array::value('component_id', $params);
$componentName = CRM_Utils_Array::value('componentName', $params);
$contributionId = CRM_Utils_Array::value('contribution_id', $params);
if (!$contributionId || !$componentId || !$componentName || !$statusId) {
return NULL;
}
$input = $ids = $objects = array();
//get the required ids.
$ids['contribution'] = $contributionId;
if (!($ids['contact'] = CRM_Utils_Array::value('contact_id', $params))) {
$ids['contact'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'contact_id');
}
if ($componentName == 'Event') {
$name = 'event';
$ids['participant'] = $componentId;
if (!($ids['event'] = CRM_Utils_Array::value('event_id', $params))) {
$ids['event'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $componentId, 'event_id');
}
}
if ($componentName == 'Membership') {
$name = 'contribute';
$ids['membership'] = $componentId;
}
$ids['contributionPage'] = NULL;
$ids['contributionRecur'] = NULL;
$input['component'] = $name;
$baseIPN = new CRM_Core_Payment_BaseIPN();
$transaction = new CRM_Core_Transaction();
// reset template values.
$template = CRM_Core_Smarty::singleton();
$template->clearTemplateVars();
if (!$baseIPN->validateData($input, $ids, $objects, FALSE)) {
CRM_Core_Error::fatal();
}
$contribution =& $objects['contribution'];
$contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', array('labelColumn' => 'name', 'flip' => 1));
$input['IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved'] = CRM_Utils_Array::value('IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved', $params);
if ($statusId == $contributionStatuses['Cancelled']) {
$baseIPN->cancelled($objects, $transaction, $input);
$transaction->commit();
return $statusId;
} elseif ($statusId == $contributionStatuses['Failed']) {
$baseIPN->failed($objects, $transaction, $input);
$transaction->commit();
return $statusId;
}
// status is not pending
if ($contribution->contribution_status_id != $contributionStatuses['Pending']) {
$transaction->commit();
return;
}
//set values for ipn code.
foreach (array('fee_amount', 'check_number', 'payment_instrument_id') as $field) {
if (!($input[$field] = CRM_Utils_Array::value($field, $params))) {
$input[$field] = $contribution->{$field};
}
}
if (!($input['trxn_id'] = CRM_Utils_Array::value('trxn_id', $params))) {
$input['trxn_id'] = $contribution->invoice_id;
}
if (!($input['amount'] = CRM_Utils_Array::value('total_amount', $params))) {
$input['amount'] = $contribution->total_amount;
}
$input['is_test'] = $contribution->is_test;
$input['net_amount'] = $contribution->net_amount;
if (!empty($input['fee_amount']) && !empty($input['amount'])) {
$input['net_amount'] = $input['amount'] - $input['fee_amount'];
}
//complete the contribution.
$baseIPN->completeTransaction($input, $ids, $objects, $transaction, FALSE);
// reset template values before processing next transactions
$template->clearTemplateVars();
return $statusId;
}
示例7: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
public function postProcess()
{
// get all the details needed to generate a receipt
$contribIDs = implode(',', $this->_contributionIds);
require_once 'CRM/Contribute/Form/Task/Status.php';
$details =& CRM_Contribute_Form_Task_Status::getDetails($contribIDs);
require_once 'CRM/Core/Payment/BaseIPN.php';
$baseIPN = new CRM_Core_Payment_BaseIPN();
$message = array();
$template =& CRM_Core_Smarty::singleton();
foreach ($details as $contribID => $detail) {
$input = $ids = $objects = array();
$input['component'] = $detail['component'];
$ids['contact'] = $detail['contact'];
$ids['contribution'] = $contribID;
$ids['contributionRecur'] = null;
$ids['contributionPage'] = null;
$ids['membership'] = $detail['membership'];
$ids['participant'] = $detail['participant'];
$ids['event'] = $detail['event'];
if (!$baseIPN->validateData($input, $ids, $objects, false)) {
CRM_Core_Error::fatal();
}
$contribution =& $objects['contribution'];
// CRM_Core_Error::debug('o',$objects);
// set some fake input values so we can reuse IPN code
$input['amount'] = $contribution->total_amount;
$input['is_test'] = $contribution->is_test;
$input['fee_amount'] = $contribution->fee_amount;
$input['net_amount'] = $contribution->net_amount;
$input['trxn_id'] = $contribution->trxn_id;
$input['trxn_date'] = isset($contribution->trxn_date) ? $contribution->trxn_date : null;
// CRM_Core_Error::debug('input',$input);
$values = array();
$mail = $baseIPN->sendMail($input, $ids, $objects, $values, false, true);
$mail = str_replace("\n\n", "<p>", $mail);
$mail = str_replace("\n", "<br/>", $mail);
$message[] = $mail;
// reset template values before processing next transactions
$template->clearTemplateVars();
}
require_once 'CRM/Utils/PDF/Utils.php';
CRM_Utils_PDF_Utils::domlib($message, "civicrmContributionReceipt.pdf");
exit;
}
示例8: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
public function postProcess()
{
// get all the details needed to generate a receipt
$contribIDs = implode(',', $this->_contributionIds);
require_once 'CRM/Contribute/Form/Task/Status.php';
$details =& CRM_Contribute_Form_Task_Status::getDetails($contribIDs);
require_once 'CRM/Core/Payment/BaseIPN.php';
$baseIPN = new CRM_Core_Payment_BaseIPN();
$message = array();
$template = CRM_Core_Smarty::singleton();
$params = $this->controller->exportValues($this->_name);
$createPdf = false;
if ($params['output'] == "pdf_receipt") {
$createPdf = true;
}
$excludeContactIds = array();
if (!$createPdf) {
$returnProperties = array('email' => 1, 'do_not_email' => 1, 'is_deceased' => 1, 'on_hold' => 1);
require_once 'CRM/Mailing/BAO/Mailing.php';
list($contactDetails) = CRM_Mailing_BAO_Mailing::getDetails($this->_contactIds, $returnProperties, false, false);
foreach ($contactDetails as $id => $values) {
if (empty($values['email']) || CRM_Utils_Array::value('do_not_email', $values) || CRM_Utils_Array::value('is_deceased', $values) || CRM_Utils_Array::value('on_hold', $values)) {
$suppressedEmails++;
$excludeContactIds[] = $values['contact_id'];
}
}
}
foreach ($details as $contribID => $detail) {
$input = $ids = $objects = array();
if (in_array($detail['contact'], $excludeContactIds)) {
continue;
}
$input['component'] = $detail['component'];
$ids['contact'] = $detail['contact'];
$ids['contribution'] = $contribID;
$ids['contributionRecur'] = null;
$ids['contributionPage'] = null;
$ids['membership'] = $detail['membership'];
$ids['participant'] = $detail['participant'];
$ids['event'] = $detail['event'];
if (!$baseIPN->validateData($input, $ids, $objects, false)) {
CRM_Core_Error::fatal();
}
$contribution =& $objects['contribution'];
// CRM_Core_Error::debug('o',$objects);
// set some fake input values so we can reuse IPN code
$input['amount'] = $contribution->total_amount;
$input['is_test'] = $contribution->is_test;
$input['fee_amount'] = $contribution->fee_amount;
$input['net_amount'] = $contribution->net_amount;
$input['trxn_id'] = $contribution->trxn_id;
$input['trxn_date'] = isset($contribution->trxn_date) ? $contribution->trxn_date : null;
// CRM_Core_Error::debug('input',$input);
$values = array();
$mail = $baseIPN->sendMail($input, $ids, $objects, $values, false, $createPdf);
if (!$mail['html']) {
$mail = str_replace("\n\n", "<p>", $mail);
$mail = str_replace("\n", "<br/>", $mail);
}
$message[] = $mail;
// reset template values before processing next transactions
$template->clearTemplateVars();
}
if ($createPdf) {
require_once 'CRM/Utils/PDF/Utils.php';
CRM_Utils_PDF_Utils::domlib($message, 'civicrmContributionReceipt.pdf', false, 'portrait', 'letter');
CRM_Utils_System::civiExit();
} else {
if ($suppressedEmails) {
$status = array('', ts('Email was NOT sent to %1 contacts (no email address on file, or communication preferences specify DO NOT EMAIL, or contact is deceased).', array(1 => $suppressedEmails)));
} else {
$status = array('', ts('Your mail has been sent.'));
}
CRM_Core_Session::setStatus($status);
}
}