本文整理汇总了PHP中CRM_Core_Payment_BaseIPN类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Payment_BaseIPN类的具体用法?PHP CRM_Core_Payment_BaseIPN怎么用?PHP CRM_Core_Payment_BaseIPN使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_Payment_BaseIPN类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: cancelRecurContribution
/**
* Cancel Recurring contribution.
*
* @param int $recurId
* Recur contribution id.
* @param array $objects
* An array of objects that is to be cancelled like.
* contribution, membership, event. At least contribution object is a must.
*
* @param array $activityParams
*
* @return bool
*/
public static function cancelRecurContribution($recurId, $objects, $activityParams = array())
{
if (!$recurId) {
return FALSE;
}
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$canceledId = array_search('Cancelled', $contributionStatus);
$recur = new CRM_Contribute_DAO_ContributionRecur();
$recur->id = $recurId;
$recur->whereAdd("contribution_status_id != {$canceledId}");
if ($recur->find(TRUE)) {
$transaction = new CRM_Core_Transaction();
$recur->contribution_status_id = $canceledId;
$recur->start_date = CRM_Utils_Date::isoToMysql($recur->start_date);
$recur->create_date = CRM_Utils_Date::isoToMysql($recur->create_date);
$recur->modified_date = CRM_Utils_Date::isoToMysql($recur->modified_date);
$recur->cancel_date = date('YmdHis');
$recur->save();
$dao = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($recurId);
if ($dao && $dao->recur_id) {
$details = CRM_Utils_Array::value('details', $activityParams);
if ($dao->auto_renew && $dao->membership_id) {
// its auto-renewal membership mode
$membershipTypes = CRM_Member_PseudoConstant::membershipType();
$membershipType = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $dao->membership_id, 'membership_type_id');
$membershipType = CRM_Utils_Array::value($membershipType, $membershipTypes);
$details .= '
<br/>' . ts('Automatic renewal of %1 membership cancelled.', array(1 => $membershipType));
} else {
$details .= '
<br/>' . ts('The recurring contribution of %1, every %2 %3 has been cancelled.', array(1 => $dao->amount, 2 => $dao->frequency_interval, 3 => $dao->frequency_unit));
}
$activityParams = array('source_contact_id' => $dao->contact_id, 'source_record_id' => CRM_Utils_Array::value('source_record_id', $activityParams), 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', 'Cancel Recurring Contribution', 'name'), 'subject' => CRM_Utils_Array::value('subject', $activityParams, ts('Recurring contribution cancelled')), 'details' => $details, 'activity_date_time' => date('YmdHis'), 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'));
$session = CRM_Core_Session::singleton();
$cid = $session->get('userID');
if ($cid) {
$activityParams['target_contact_id'][] = $activityParams['source_contact_id'];
$activityParams['source_contact_id'] = $cid;
}
CRM_Activity_BAO_Activity::create($activityParams);
}
// if there are associated objects, cancel them as well
if ($objects == CRM_Core_DAO::$_nullObject) {
$transaction->commit();
return TRUE;
} else {
$baseIPN = new CRM_Core_Payment_BaseIPN();
return $baseIPN->cancelled($objects, $transaction);
}
} else {
// if already cancelled, return true
$recur->whereAdd();
$recur->whereAdd("contribution_status_id = {$canceledId}");
if ($recur->find(TRUE)) {
return TRUE;
}
}
return FALSE;
}
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:72,代码来源:ContributionRecur.php
示例2: processFailedTransaction
/**
* Process failed transaction - would be nice to do this through api too but for now lets put in
* here - this is a copy & paste of the completetransaction api
* @param unknown $contributionID
*/
function processFailedTransaction($contributionID)
{
$input = $ids = array();
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $contributionID;
$contribution->find(TRUE);
if (!$contribution->id == $contributionID) {
throw new Exception('A valid contribution ID is required', 'invalid_data');
}
try {
if (!$contribution->loadRelatedObjects($input, $ids, FALSE, TRUE)) {
throw new Exception('failed to load related objects');
}
$objects = $contribution->_relatedObjects;
$objects['contribution'] =& $contribution;
$input['component'] = $contribution->_component;
$input['is_test'] = $contribution->is_test;
$input['amount'] = $contribution->total_amount;
// @todo required for base ipn but problematic as api layer handles this
$transaction = new CRM_Core_Transaction();
$ipn = new CRM_Core_Payment_BaseIPN();
$ipn->failed($objects, $transaction, $input);
} catch (Exception $e) {
}
}
开发者ID:torrance,项目名称:nz.co.fuzion.cmcic,代码行数:30,代码来源:CmcicIPN.php
示例3: 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);
//.........这里部分代码省略.........
开发者ID:nganivet,项目名称:civicrm-core,代码行数:101,代码来源:Contribution.php
示例4: updatePendingOnlineContribution
static function updatePendingOnlineContribution($participantId, $statusId)
{
if (!$participantId || !$statusId) {
return;
}
$contributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($participantId, 'Event');
if (!$contributionId) {
return;
}
//status rules.
//1. participant - positive => contribution - completed.
//2. participant - negative => contribution - cancelled.
$positiveStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Positive'");
$negativeStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'");
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$contributionStatusId = NULL;
if (array_key_exists($statusId, $positiveStatuses)) {
$contributionStatusId = array_search('Completed', $contributionStatuses);
}
if (array_key_exists($statusId, $negativeStatuses)) {
$contributionStatusId = array_search('Cancelled', $contributionStatuses);
}
if (!$contributionStatusId) {
return;
}
$params = array('component_id' => $participantId, 'componentName' => 'Event', 'contribution_id' => $contributionId, 'contribution_status_id' => $contributionStatusId);
//change related contribution status.
$updatedStatusId = CRM_Core_Payment_BaseIPN::updateContributionStatus($params);
return $updatedStatusId;
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:30,代码来源:Batch.php
示例5: civicrm_api3_contribution_completetransaction
/**
* Complete an existing (pending) transaction, updating related entities (participant, membership, pledge etc)
* and taking any complete actions from the contribution page (e.g. send receipt)
*
* @todo - most of this should live in the BAO layer but as we want it to be an addition
* to 4.3 which is already stable we should add it to the api layer & re-factor into the BAO layer later
*
* @param array $params input parameters
* {@getfields Contribution_completetransaction}
* @return array Api result array
* @static void
* @access public
*
*/
function civicrm_api3_contribution_completetransaction(&$params)
{
$input = $ids = array();
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $params['id'];
$contribution->find(TRUE);
if (!$contribution->id == $params['id']) {
throw new API_Exception('A valid contribution ID is required', 'invalid_data');
}
try {
if (!$contribution->loadRelatedObjects($input, $ids, FALSE, TRUE)) {
throw new API_Exception('failed to load related objects');
}
$objects = $contribution->_relatedObjects;
$objects['contribution'] =& $contribution;
$input['component'] = $contribution->_component;
$input['is_test'] = $contribution->is_test;
$input['trxn_id'] = $contribution->trxn_id;
$input['amount'] = $contribution->total_amount;
if (isset($params['is_email_receipt'])) {
$input['is_email_receipt'] = $params['is_email_receipt'];
}
// @todo required for base ipn but problematic as api layer handles this
$transaction = new CRM_Core_Transaction();
$ipn = new CRM_Core_Payment_BaseIPN();
$ipn->completeTransaction($input, $ids, $objects, $transaction);
} catch (Exception $e) {
throw new API_Exception('failed to load related objects' . $e->getMessage() . "\n" . $e->getTraceAsString());
}
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:44,代码来源:Contribution.php
示例6: 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;
}
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:85,代码来源:BaseIPN.php
示例7: _ipn_process_transaction
/**
* Calls IPN complete transaction for completing or repeating a transaction.
*
* The IPN function is overloaded with two purposes - this is simply a wrapper for that
* when separating them in the api layer.
*
* @param array $params
* @param CRM_Contribute_BAO_Contribution $contribution
* @param array $input
*
* @param array $ids
*
* @param CRM_Contribute_BAO_Contribution $firstContribution
*
* @return mixed
*/
function _ipn_process_transaction(&$params, $contribution, $input, $ids, $firstContribution = NULL)
{
$objects = $contribution->_relatedObjects;
$objects['contribution'] =& $contribution;
if ($firstContribution) {
$objects['first_contribution'] = $firstContribution;
}
$input['component'] = $contribution->_component;
$input['is_test'] = $contribution->is_test;
$input['amount'] = empty($input['total_amount']) ? $contribution->total_amount : $input['total_amount'];
if (isset($params['is_email_receipt'])) {
$input['is_email_receipt'] = $params['is_email_receipt'];
}
if (empty($contribution->contribution_page_id)) {
static $domainFromName;
static $domainFromEmail;
if (empty($domainFromEmail) && (empty($params['receipt_from_name']) || empty($params['receipt_from_email']))) {
list($domainFromName, $domainFromEmail) = CRM_Core_BAO_Domain::getNameAndEmail(TRUE);
}
$input['receipt_from_name'] = CRM_Utils_Array::value('receipt_from_name', $params, $domainFromName);
$input['receipt_from_email'] = CRM_Utils_Array::value('receipt_from_email', $params, $domainFromEmail);
}
// @todo required for base ipn but problematic as api layer handles this
$transaction = new CRM_Core_Transaction();
$ipn = new CRM_Core_Payment_BaseIPN();
$ipn->completeTransaction($input, $ids, $objects, $transaction, !empty($contribution->contribution_recur_id));
return $params;
}
开发者ID:riyadennis,项目名称:my_civicrm,代码行数:44,代码来源:Contribution.php
示例8: 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).'));
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:66,代码来源:Status.php
示例9: cancelRecurContribution
/**
* Cancel Recurring contribution.
*
* @param integer $recurId recur contribution id.
* @param array $objects an array of objects that is to be cancelled like
* contribution, membership, event. At least contribution object is a must.
*
* @return true / false.
* @access public
* @static
*/
static function cancelRecurContribution($recurId, $objects)
{
if (!$recurId) {
return false;
}
require_once 'CRM/Contribute/PseudoConstant.php';
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(null, 'name');
$canceledId = array_search('Cancelled', $contributionStatus);
$recur = new CRM_Contribute_DAO_ContributionRecur();
$recur->id = $recurId;
$recur->whereAdd("contribution_status_id != {$canceledId}");
if ($recur->find(true)) {
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
$recur->contribution_status_id = $canceledId;
$recur->start_date = CRM_Utils_Date::isoToMysql($recur->start_date);
$recur->create_date = CRM_Utils_Date::isoToMysql($recur->create_date);
$recur->modified_date = CRM_Utils_Date::isoToMysql($recur->modified_date);
$recur->cancel_date = date('YmdHis');
$recur->save();
require_once 'CRM/Core/Payment/BaseIPN.php';
$baseIPN = new CRM_Core_Payment_BaseIPN();
return $baseIPN->cancelled($objects, $transaction);
}
return false;
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:37,代码来源:ContributionRecur.php
示例10: 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;
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:89,代码来源:Batch.php
示例11: 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;
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:51,代码来源:PDF.php
示例12: 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) {
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Contribution.php
示例13: 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);
}
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:86,代码来源:PDF.php
示例14: 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($mess
|
请发表评论