当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_Payment_BaseIPN::cancelled方法代码示例

本文整理汇总了PHP中CRM_Core_Payment_BaseIPN::cancelled方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Payment_BaseIPN::cancelled方法的具体用法?PHP CRM_Core_Payment_BaseIPN::cancelled怎么用?PHP CRM_Core_Payment_BaseIPN::cancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_Payment_BaseIPN的用法示例。


在下文中一共展示了CRM_Core_Payment_BaseIPN::cancelled方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:85,代码来源:BaseIPN.php

示例2: 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

示例3: 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

示例4: 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

示例5: 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


注:本文中的CRM_Core_Payment_BaseIPN::cancelled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。