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


PHP CRM_Price_BAO_LineItem::processPriceSet方法代码示例

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


在下文中一共展示了CRM_Price_BAO_LineItem::processPriceSet方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addParticipantWithPayment

 /**
  * Helper function to record participant with paid contribution.
  *
  * @param int $feeTotal
  * @param int $actualPaidAmt
  *
  * @return array
  * @throws Exception
  */
 protected function addParticipantWithPayment($feeTotal, $actualPaidAmt)
 {
     $priceSetId = $this->eventPriceSetCreate($feeTotal);
     CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_eventId, $priceSetId);
     // create participant record
     $eventId = $this->_eventId;
     $participantParams = array('send_receipt' => 1, 'is_test' => 0, 'is_pay_later' => 0, 'event_id' => $eventId, 'register_date' => date('Y-m-d') . " 00:00:00", 'role_id' => 1, 'status_id' => 14, 'source' => 'Event_' . $eventId, 'contact_id' => $this->_contactId, 'note' => 'Note added for Event_' . $eventId, 'fee_level' => 'Price_Field - 55');
     $participant = $this->callAPISuccess('participant', 'create', $participantParams);
     $this->callAPISuccessGetSingle('participant', array('id' => $participant['id']));
     // create participant contribution with partial payment
     $contributionParams = array('total_amount' => $actualPaidAmt, 'source' => 'Fall Fundraiser Dinner: Offline registration', 'currency' => 'USD', 'non_deductible_amount' => 'null', 'receipt_date' => date('Y-m-d') . " 00:00:00", 'contact_id' => $this->_contactId, 'financial_type_id' => 4, 'payment_instrument_id' => 4, 'contribution_status_id' => 1, 'receive_date' => date('Y-m-d') . " 00:00:00", 'skipLineItem' => 1, 'partial_payment_total' => $feeTotal, 'partial_amount_pay' => $actualPaidAmt);
     $contribution = CRM_Contribute_BAO_Contribution::create($contributionParams);
     $contributionId = $contribution->id;
     $participant = $this->callAPISuccessGetSingle('participant', array('id' => $participant['id']));
     // add participant payment entry
     $this->callAPISuccess('participant_payment', 'create', array('participant_id' => $participant['id'], 'contribution_id' => $contributionId));
     // -- processing priceSet using the BAO
     $lineItem = array();
     $priceSet = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId, TRUE, FALSE);
     $priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
     $feeBlock = CRM_Utils_Array::value('fields', $priceSet);
     $params['price_2'] = $feeTotal;
     CRM_Price_BAO_PriceSet::processAmount($feeBlock, $params, $lineItem);
     $lineItemVal[$priceSetId] = $lineItem;
     CRM_Price_BAO_LineItem::processPriceSet($participant['id'], $lineItemVal, $contribution, 'civicrm_participant');
     return array($participant, $contribution);
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:36,代码来源:AdditionalPaymentTest.php

示例2: _addParticipantWithPayment

 function _addParticipantWithPayment($feeTotal, $actualPaidAmt)
 {
     // creating price set, price field
     $paramsSet['title'] = 'Price Set';
     $paramsSet['name'] = CRM_Utils_String::titleToVar('Price Set');
     $paramsSet['is_active'] = FALSE;
     $paramsSet['extends'] = 1;
     $priceset = CRM_Price_BAO_PriceSet::create($paramsSet);
     CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_eventId, $priceset->id);
     $priceSetId = $priceset->id;
     //Checking for priceset added in the table.
     $this->assertDBCompareValue('CRM_Price_BAO_PriceSet', $priceSetId, 'title', 'id', $paramsSet['title'], 'Check DB for created priceset');
     $paramsField = array('label' => 'Price Field', 'name' => CRM_Utils_String::titleToVar('Price Field'), 'html_type' => 'Text', 'price' => $feeTotal, 'option_label' => array('1' => 'Price Field'), 'option_value' => array('1' => $feeTotal), 'option_name' => array('1' => $feeTotal), 'option_weight' => array('1' => 1), 'option_amount' => array('1' => 1), 'is_display_amounts' => 1, 'weight' => 1, 'options_per_line' => 1, 'is_active' => array('1' => 1), 'price_set_id' => $priceset->id, 'is_enter_qty' => 1);
     $ids = array();
     $pricefield = CRM_Price_BAO_PriceField::create($paramsField, $ids);
     //Checking for priceset added in the table.
     $this->assertDBCompareValue('CRM_Price_BAO_PriceField', $pricefield->id, 'label', 'id', $paramsField['label'], 'Check DB for created pricefield');
     // create participant record
     $eventId = $this->_eventId;
     $participantParams = array('send_receipt' => 1, 'is_test' => 0, 'is_pay_later' => 0, 'event_id' => $eventId, 'register_date' => date('Y-m-d') . " 00:00:00", 'role_id' => 1, 'status_id' => 14, 'source' => 'Event_' . $eventId, 'contact_id' => $this->_contactId, 'note' => 'Note added for Event_' . $eventId, 'fee_level' => 'Price_Field - 55');
     $participant = CRM_Event_BAO_Participant::add($participantParams);
     // create participant contribution with partial payment
     $contributionParams = array('total_amount' => $actualPaidAmt, 'source' => 'Fall Fundraiser Dinner: Offline registration', 'currency' => 'USD', 'non_deductible_amount' => 'null', 'receipt_date' => date('Y-m-d') . " 00:00:00", 'contact_id' => $this->_contactId, 'financial_type_id' => 4, 'payment_instrument_id' => 4, 'contribution_status_id' => 1, 'receive_date' => date('Y-m-d') . " 00:00:00", 'skipLineItem' => 1, 'partial_payment_total' => $feeTotal, 'partial_amount_pay' => $actualPaidAmt);
     $contribution = CRM_Contribute_BAO_Contribution::create($contributionParams, CRM_Core_DAO::$_nullArray);
     $contributionId = $contribution->id;
     // add participant payment entry
     $this->participantPaymentCreate($participant->id, $contributionId);
     // -- processing priceSet using the BAO
     $lineItem = array();
     $priceSet = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId, TRUE, FALSE);
     $priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
     $feeBlock = CRM_Utils_Array::value('fields', $priceSet);
     $params['price_2'] = $feeTotal;
     CRM_Price_BAO_PriceSet::processAmount($feeBlock, $params, $lineItem);
     $lineItemVal[$priceSetId] = $lineItem;
     CRM_Price_BAO_LineItem::processPriceSet($participant->id, $lineItemVal, $contribution, 'civicrm_participant');
     return array($participant, $contribution);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:38,代码来源:AdditionalPaymentTest.php

示例3: create

 /**
  * Takes an associative array and creates a membership object.
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  * @param array $ids
  *   The array that holds all the db ids.
  * @param bool $skipRedirect
  * @param string $activityType
  *
  * @throws CRM_Core_Exception
  *
  * @return CRM_Member_BAO_Membership|CRM_Core_Error
  */
 public static function create(&$params, &$ids, $skipRedirect = FALSE, $activityType = 'Membership Signup')
 {
     // always calculate status if is_override/skipStatusCal is not true.
     // giving respect to is_override during import.  CRM-4012
     // To skip status calculation we should use 'skipStatusCal'.
     // eg pay later membership, membership update cron CRM-3984
     if (empty($params['is_override']) && empty($params['skipStatusCal'])) {
         $dates = array('start_date', 'end_date', 'join_date');
         // Declare these out of courtesy as IDEs don't pick up the setting of them below.
         $start_date = $end_date = $join_date = NULL;
         foreach ($dates as $date) {
             ${$date} = $params[$date] = CRM_Utils_Date::processDate(CRM_Utils_Array::value($date, $params), NULL, TRUE, 'Ymd');
         }
         //fix for CRM-3570, during import exclude the statuses those having is_admin = 1
         $excludeIsAdmin = CRM_Utils_Array::value('exclude_is_admin', $params, FALSE);
         //CRM-3724 always skip is_admin if is_override != true.
         if (!$excludeIsAdmin && empty($params['is_override'])) {
             $excludeIsAdmin = TRUE;
         }
         $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($start_date, $end_date, $join_date, 'today', $excludeIsAdmin, CRM_Utils_Array::value('membership_type_id', $params), $params);
         if (empty($calcStatus)) {
             // Redirect the form in case of error
             // @todo this redirect in the BAO layer is really bad & should be moved to the form layer
             // however since we have no idea how (if) this is triggered we can't safely move / remove it
             // NB I tried really hard to trigger this error from backoffice membership form in order to test it
             // and am convinced form validation is complete on that form WRT this error.
             $errorParams = array('message_title' => ts('No valid membership status for given dates.'), 'legacy_redirect_path' => 'civicrm/contact/view', 'legacy_redirect_query' => "reset=1&force=1&cid={$params['contact_id']}&selectedChild=member");
             throw new CRM_Core_Exception(ts("The membership cannot be saved because the status cannot be calculated for start_date: {$start_date} end_date {$end_date} join_date {$join_date} as at " . date('Y-m-d H:i:s')), 0, $errorParams);
         }
         $params['status_id'] = $calcStatus['id'];
     }
     // data cleanup only: all verifications on number of related memberships are done upstream in:
     // CRM_Member_BAO_Membership::createRelatedMemberships()
     // CRM_Contact_BAO_Relationship::relatedMemberships()
     if (isset($params['owner_membership_id'])) {
         unset($params['max_related']);
     } else {
         // if membership allows related, default max_related to value in membership_type
         if (!array_key_exists('max_related', $params) && !empty($params['membership_type_id'])) {
             $membershipType = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($params['membership_type_id']);
             if (isset($membershipType['relationship_type_id'])) {
                 $params['max_related'] = CRM_Utils_Array::value('max_related', $membershipType);
             }
         }
     }
     $transaction = new CRM_Core_Transaction();
     $membership = self::add($params, $ids);
     if (is_a($membership, 'CRM_Core_Error')) {
         $transaction->rollback();
         return $membership;
     }
     // add custom field values
     if (!empty($params['custom']) && is_array($params['custom'])) {
         CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_membership', $membership->id);
     }
     $params['membership_id'] = $membership->id;
     if (isset($ids['membership'])) {
         $ids['contribution'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', $membership->id, 'contribution_id', 'membership_id');
     }
     $params['skipLineItem'] = TRUE;
     //record contribution for this membership
     if (!empty($params['contribution_status_id']) && empty($params['relate_contribution_id'])) {
         $memInfo = array_merge($params, array('membership_id' => $membership->id));
         $params['contribution'] = self::recordMembershipContribution($memInfo, $ids);
     }
     if (!empty($params['lineItems'])) {
         $params['line_item'] = $params['lineItems'];
     }
     //do cleanup line  items if membership edit the Membership type.
     if (empty($ids['contribution']) && !empty($ids['membership'])) {
         CRM_Price_BAO_LineItem::deleteLineItems($ids['membership'], 'civicrm_membership');
     }
     if (!empty($params['line_item']) && empty($ids['contribution'])) {
         CRM_Price_BAO_LineItem::processPriceSet($membership->id, $params['line_item'], CRM_Utils_Array::value('contribution', $params));
     }
     //insert payment record for this membership
     if (!empty($params['relate_contribution_id'])) {
         CRM_Member_BAO_MembershipPayment::create(array('membership_id' => $membership->id, 'membership_type_id' => $membership->membership_type_id, 'contribution_id' => $params['relate_contribution_id']));
     }
     // add activity record only during create mode and renew mode
     // also add activity if status changed CRM-3984 and CRM-2521
     if (empty($ids['membership']) || $activityType == 'Membership Renewal' || !empty($params['createActivity'])) {
         if (!empty($ids['membership'])) {
             $data = array();
             CRM_Core_DAO::commonRetrieveAll('CRM_Member_DAO_Membership', 'id', $membership->id, $data, array('contact_id', 'membership_type_id', 'source'));
             $membership->contact_id = $data[$membership->id]['contact_id'];
//.........这里部分代码省略.........
开发者ID:konadave,项目名称:civicrm-core,代码行数:101,代码来源:Membership.php

示例4: addRecurLineItems

 /**
  * @param $recurId
  * @param $contribution
  *
  * @internal param $contributionId
  *
  * @return array
  */
 function addRecurLineItems($recurId, $contribution)
 {
     $lineSets = array();
     $originalContributionID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $recurId, 'id', 'contribution_recur_id');
     $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($originalContributionID);
     if (count($lineItems) == 1) {
         foreach ($lineItems as $index => $lineItem) {
             if ($lineItem['line_total'] != $contribution->total_amount) {
                 // We are dealing with a changed amount! Per CRM-16397 we can work out what to do with these
                 // if there is only one line item, and the UI should prevent this situation for those with more than one.
                 $lineItems[$index]['line_total'] = $contribution->total_amount;
                 $lineItems[$index]['unit_price'] = round($contribution->total_amount / $lineItems[$index]['qty'], 2);
             }
         }
     }
     if (!empty($lineItems)) {
         foreach ($lineItems as $key => $value) {
             $priceField = new CRM_Price_DAO_PriceField();
             $priceField->id = $value['price_field_id'];
             $priceField->find(TRUE);
             $lineSets[$priceField->price_set_id][] = $value;
         }
     } else {
         CRM_Price_BAO_LineItem::processPriceSet($contribution->id, $lineSets, $contribution);
     }
     return $lineSets;
 }
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:35,代码来源:BaseIPN.php

示例5: postProcess


//.........这里部分代码省略.........
         $params['contribution_contact_id'] = $this->_contributorContactID;
         if (!empty($this->_params['soft_credit_type_id'])) {
             $softParams['soft_credit_type_id'] = $this->_params['soft_credit_type_id'];
             $softParams['contact_id'] = $this->_contactID;
         }
     }
     if (!empty($formValues['record_contribution'])) {
         $recordContribution = array('total_amount', 'financial_type_id', 'payment_instrument_id', 'trxn_id', 'contribution_status_id', 'check_number', 'campaign_id', 'receive_date');
         foreach ($recordContribution as $f) {
             $params[$f] = CRM_Utils_Array::value($f, $formValues);
         }
         if (!$this->_onlinePendingContributionId) {
             if (empty($formValues['source'])) {
                 $params['contribution_source'] = ts('%1 Membership: Offline signup (by %2)', array(1 => $membershipType, 2 => $userName));
             } else {
                 $params['contribution_source'] = $formValues['source'];
             }
         }
         if (empty($params['is_override']) && CRM_Utils_Array::value('contribution_status_id', $params) == array_search('Pending', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'))) {
             $params['status_id'] = array_search('Pending', $allMemberStatus);
             $params['skipStatusCal'] = TRUE;
             $params['is_pay_later'] = 1;
             $this->assign('is_pay_later', 1);
         }
         if (!empty($formValues['send_receipt'])) {
             $params['receipt_date'] = CRM_Utils_Array::value('receive_date', $formValues);
         }
         //insert financial type name in receipt.
         $formValues['contributionType_name'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $formValues['financial_type_id']);
     }
     // process line items, until no previous line items.
     if (!empty($lineItem)) {
         $params['lineItems'] = $lineItem;
         $params['processPriceSet'] = TRUE;
     }
     $createdMemberships = array();
     if ($this->_mode) {
         if (empty($formValues['total_amount']) && !$priceSetId) {
             // if total amount not provided minimum for membership type is used
             $params['total_amount'] = $formValues['total_amount'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $formValues['membership_type_id'][1], 'minimum_fee');
         } else {
             $params['total_amount'] = CRM_Utils_Array::value('total_amount', $formValues, 0);
         }
         if ($priceSetId && !$isQuickConfig) {
             $params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'financial_type_id');
         } else {
             $params['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $formValues);
         }
         $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($formValues['payment_processor_id'], $this->_mode);
         //get the payment processor id as per mode.
         $params['payment_processor_id'] = $this->_params['payment_processor_id'] = $formValues['payment_processor_id'] = $this->_paymentProcessor['id'];
         $now = date('YmdHis');
         $fields = array();
         // set email for primary location.
         $fields['email-Primary'] = 1;
         $formValues['email-5'] = $formValues['email-Primary'] = $this->_memberEmail;
         $params['register_date'] = $now;
         // now set the values for the billing location.
         foreach ($this->_fields as $name => $dontCare) {
             $fields[$name] = 1;
         }
         // also add location name to the array
         $formValues["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_middle_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_last_name', $formValues);
         $formValues["address_name-{$this->_bltID}"] = trim($formValues["address_name-{$this->_bltID}"]);
         $fields["address_name-{$this->_bltID}"] = 1;
         //ensure we don't over-write the payer's email with the member's email
开发者ID:indydas,项目名称:civi-demo,代码行数:67,代码来源:Membership.php

示例6: postProcess


//.........这里部分代码省略.........
             if (empty($ids['contribution'])) {
                 foreach ($this->_contactIds as $num => $contactID) {
                     $ppDAO = new CRM_Event_DAO_ParticipantPayment();
                     $ppDAO->participant_id = $participants[$num]->id;
                     $ppDAO->contribution_id = $contributions[$num]->id;
                     $ppDAO->save();
                 }
             }
             // next create the transaction record
             $transaction = new CRM_Core_Transaction();
             // CRM-11124
             if ($this->_params['discount_id']) {
                 CRM_Event_BAO_Participant::createDiscountTrxn($this->_eventId, $contributionParams, NULL, CRM_Price_BAO_PriceSet::parseFirstPriceSetValueIDFromParams($this->_params));
             }
             $transaction->commit();
         }
     }
     // also store lineitem stuff here
     if ($this->_lineItem & $this->_action & CRM_Core_Action::ADD || $this->_lineItem && CRM_Core_Action::UPDATE && !$this->_paymentId) {
         foreach ($this->_contactIds as $num => $contactID) {
             foreach ($this->_lineItem as $key => $value) {
                 if (is_array($value) && $value != 'skip') {
                     foreach ($value as $lineKey => $line) {
                         //10117 update the line items for participants if contribution amount is recorded
                         if ($this->_quickConfig && !empty($params['total_amount']) && $params['status_id'] != array_search('Partially paid', $participantStatus)) {
                             $line['unit_price'] = $line['line_total'] = $params['total_amount'];
                             if (!empty($params['tax_amount'])) {
                                 $line['unit_price'] = $line['unit_price'] - $params['tax_amount'];
                                 $line['line_total'] = $line['line_total'] - $params['tax_amount'];
                             }
                         }
                         $lineItem[$this->_priceSetId][$lineKey] = $line;
                     }
                     CRM_Price_BAO_LineItem::processPriceSet($participants[$num]->id, $lineItem, CRM_Utils_Array::value($num, $contributions, NULL), 'civicrm_participant');
                     CRM_Contribute_BAO_Contribution::addPayments($value, $contributions);
                 }
             }
         }
     }
     $updateStatusMsg = NULL;
     //send mail when participant status changed, CRM-4326
     if ($this->_id && $this->_statusId && $this->_statusId != CRM_Utils_Array::value('status_id', $params) && !empty($params['is_notify'])) {
         $updateStatusMsg = CRM_Event_BAO_Participant::updateStatusMessage($this->_id, $params['status_id'], $this->_statusId);
     }
     $sent = array();
     $notSent = array();
     if (!empty($params['send_receipt'])) {
         if (array_key_exists($params['from_email_address'], $this->_fromEmails['from_email_id'])) {
             $receiptFrom = $params['from_email_address'];
         }
         $this->assign('module', 'Event Registration');
         //use of the message template below requires variables in different format
         $event = $events = array();
         $returnProperties = array('fee_label', 'start_date', 'end_date', 'is_show_location', 'title');
         //get all event details.
         CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $params['event_id'], $events, $returnProperties);
         $event = $events[$params['event_id']];
         unset($event['start_date']);
         unset($event['end_date']);
         $role = CRM_Event_PseudoConstant::participantRole();
         $participantRoles = CRM_Utils_Array::value('role_id', $params);
         if (is_array($participantRoles)) {
             $selectedRoles = array();
             foreach ($participantRoles as $roleId) {
                 $selectedRoles[] = $role[$roleId];
             }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:67,代码来源:Participant.php

示例7: addRecurLineItems

 /**
  * Add line items for recurring contribution.
  *
  * @param int $recurId
  * @param $contribution
  *
  * @return array
  */
 public static function addRecurLineItems($recurId, $contribution)
 {
     $foundLineItems = FALSE;
     $lineSets = self::calculateRecurLineItems($recurId, $contribution->total_amount, $contribution->financial_type_id);
     foreach ($lineSets as $lineItems) {
         if (!empty($lineItems)) {
             foreach ($lineItems as $key => $value) {
                 if ($value['entity_table'] == 'civicrm_membership') {
                     try {
                         // @todo this should be done by virtue of editing the line item as this link
                         // is deprecated. This may be the case but needs testing.
                         civicrm_api3('membership_payment', 'create', array('membership_id' => $value['entity_id'], 'contribution_id' => $contribution->id));
                     } catch (CiviCRM_API3_Exception $e) {
                         // we are catching & ignoring errors as an extra precaution since lost IPNs may be more serious that lost membership_payment data
                         // this fn is unit-tested so risk of changes elsewhere breaking it are otherwise mitigated
                     }
                 }
             }
             $foundLineItems = TRUE;
         }
     }
     if (!$foundLineItems) {
         CRM_Price_BAO_LineItem::processPriceSet($contribution->id, $lineSets, $contribution);
     }
     return $lineSets;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:34,代码来源:ContributionRecur.php

示例8: recordFinancialAccounts


//.........这里部分代码省略.........
                 $incomeTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' "));
                 $oldFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($params['prevContribution']->financial_type_id, $incomeTypeId);
                 $newFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($params['financial_type_id'], $incomeTypeId);
                 if ($oldFinancialAccount != $newFinancialAccount) {
                     $params['total_amount'] = 0;
                     if (in_array($params['contribution']->contribution_status_id, $pendingStatus)) {
                         $params['trxnParams']['to_financial_account_id'] = CRM_Contribute_PseudoConstant::financialAccountType($params['prevContribution']->financial_type_id, $relationTypeId);
                     } else {
                         $lastFinancialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($params['prevContribution']->id, 'DESC');
                         if (!empty($lastFinancialTrxnId['financialTrxnId'])) {
                             $params['trxnParams']['to_financial_account_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $lastFinancialTrxnId['financialTrxnId'], 'to_financial_account_id');
                         }
                     }
                     self::updateFinancialAccounts($params, 'changeFinancialType');
                     /* $params['trxnParams']['to_financial_account_id'] = $trxnParams['to_financial_account_id']; */
                     $params['financial_account_id'] = $newFinancialAccount;
                     $params['total_amount'] = $params['trxnParams']['total_amount'] = $trxnParams['total_amount'];
                     self::updateFinancialAccounts($params);
                     $params['trxnParams']['to_financial_account_id'] = $trxnParams['to_financial_account_id'];
                 }
             }
             //Update contribution status
             $params['trxnParams']['status_id'] = $params['contribution']->contribution_status_id;
             $params['trxnParams']['trxn_id'] = $params['contribution']->trxn_id;
             if (!empty($params['contribution_status_id']) && $params['prevContribution']->contribution_status_id != $params['contribution']->contribution_status_id) {
                 //Update Financial Records
                 self::updateFinancialAccounts($params, 'changedStatus');
             }
             // change Payment Instrument for a Completed contribution
             // first handle special case when contribution is changed from Pending to Completed status when initial payment
             // instrument is null and now new payment instrument is added along with the payment
             $params['trxnParams']['payment_instrument_id'] = $params['contribution']->payment_instrument_id;
             $params['trxnParams']['check_number'] = CRM_Utils_Array::value('check_number', $params);
             if (array_key_exists('payment_instrument_id', $params)) {
                 $params['trxnParams']['total_amount'] = -$trxnParams['total_amount'];
                 if (CRM_Utils_System::isNull($params['prevContribution']->payment_instrument_id) && !CRM_Utils_System::isNull($params['contribution']->payment_instrument_id)) {
                     //check if status is changed from Pending to Completed
                     // do not update payment instrument changes for Pending to Completed
                     if (!($params['contribution']->contribution_status_id == array_search('Completed', $contributionStatuses) && in_array($params['prevContribution']->contribution_status_id, $pendingStatus))) {
                         // for all other statuses create new financial records
                         self::updateFinancialAccounts($params, 'changePaymentInstrument');
                         $params['total_amount'] = $params['trxnParams']['total_amount'] = $trxnParams['total_amount'];
                         self::updateFinancialAccounts($params, 'changePaymentInstrument');
                     }
                 } elseif ((!CRM_Utils_System::isNull($params['contribution']->payment_instrument_id) || !CRM_Utils_System::isNull($params['prevContribution']->payment_instrument_id)) && $params['contribution']->payment_instrument_id != $params['prevContribution']->payment_instrument_id) {
                     // for any other payment instrument changes create new financial records
                     self::updateFinancialAccounts($params, 'changePaymentInstrument');
                     $params['total_amount'] = $params['trxnParams']['total_amount'] = $trxnParams['total_amount'];
                     self::updateFinancialAccounts($params, 'changePaymentInstrument');
                 } elseif (!CRM_Utils_System::isNull($params['contribution']->check_number) && $params['contribution']->check_number != $params['prevContribution']->check_number) {
                     // another special case when check number is changed, create new financial records
                     // create financial trxn with negative amount
                     $params['trxnParams']['check_number'] = $params['prevContribution']->check_number;
                     self::updateFinancialAccounts($params, 'changePaymentInstrument');
                     // create financial trxn with positive amount
                     $params['trxnParams']['check_number'] = $params['contribution']->check_number;
                     $params['total_amount'] = $params['trxnParams']['total_amount'] = $trxnParams['total_amount'];
                     self::updateFinancialAccounts($params, 'changePaymentInstrument');
                 }
             }
             //if Change contribution amount
             $params['trxnParams']['fee_amount'] = CRM_Utils_Array::value('fee_amount', $params);
             $params['trxnParams']['net_amount'] = CRM_Utils_Array::value('net_amount', $params);
             $params['trxnParams']['total_amount'] = $trxnParams['total_amount'] = $params['total_amount'] = $totalAmount;
             $params['trxnParams']['trxn_id'] = $params['contribution']->trxn_id;
             if (isset($totalAmount) && $totalAmount != $params['prevContribution']->total_amount) {
                 //Update Financial Records
                 $params['trxnParams']['from_financial_account_id'] = NULL;
                 self::updateFinancialAccounts($params, 'changedAmount');
             }
         }
         if (!$update) {
             // records finanical trxn and entity financial trxn
             // also make it available as return value
             $return = $financialTxn = CRM_Core_BAO_FinancialTrxn::create($trxnParams);
             $params['entity_id'] = $financialTxn->id;
         }
     }
     // record line items and financial items
     if (empty($params['skipLineItem'])) {
         CRM_Price_BAO_LineItem::processPriceSet($entityId, CRM_Utils_Array::value('line_item', $params), $params['contribution'], $entityTable, $update);
     }
     // create batch entry if batch_id is passed and
     // ensure no batch entry is been made on 'Pending' or 'Failed' contribution, CRM-16611
     if (!empty($params['batch_id']) && !empty($financialTxn)) {
         $entityParams = array('batch_id' => $params['batch_id'], 'entity_table' => 'civicrm_financial_trxn', 'entity_id' => $financialTxn->id);
         CRM_Batch_BAO_Batch::addBatchEntity($entityParams);
     }
     // when a fee is charged
     if (!empty($params['fee_amount']) && (empty($params['prevContribution']) || $params['contribution']->fee_amount != $params['prevContribution']->fee_amount) && $skipRecords) {
         CRM_Core_BAO_FinancialTrxn::recordFees($params);
     }
     if (!empty($params['prevContribution']) && $entityTable == 'civicrm_participant' && $params['prevContribution']->contribution_status_id != $params['contribution']->contribution_status_id) {
         $eventID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $entityId, 'event_id');
         $feeLevel[] = str_replace('', '', $params['prevContribution']->amount_level);
         CRM_Event_BAO_Participant::createDiscountTrxn($eventID, $params, $feeLevel);
     }
     unset($params['line_item']);
     return $return;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:101,代码来源:Contribution.php

示例9: recordFinancialAccounts


//.........这里部分代码省略.........
                 // CRM-17751 This has previously been deliberately set. No explanation as to why one variant
                 // gets preference over another so I am only 'protecting' a very specific tested flow
                 // and letting natural justice take care of the rest.
                 $params['trxnParams']['trxn_id'] = $params['contribution']->trxn_id;
             }
             if (!empty($params['contribution_status_id']) && $params['prevContribution']->contribution_status_id != $params['contribution']->contribution_status_id) {
                 //Update Financial Records
                 self::updateFinancialAccounts($params, 'changedStatus');
                 $updated = TRUE;
             }
             // change Payment Instrument for a Completed contribution
             // first handle special case when contribution is changed from Pending to Completed status when initial payment
             // instrument is null and now new payment instrument is added along with the payment
             $params['trxnParams']['payment_instrument_id'] = $params['contribution']->payment_instrument_id;
             $params['trxnParams']['check_number'] = CRM_Utils_Array::value('check_number', $params);
             if (array_key_exists('payment_instrument_id', $params)) {
                 $params['trxnParams']['total_amount'] = -$trxnParams['total_amount'];
                 if (CRM_Utils_System::isNull($params['prevContribution']->payment_instrument_id) && !CRM_Utils_System::isNull($params['contribution']->payment_instrument_id)) {
                     //check if status is changed from Pending to Completed
                     // do not update payment instrument changes for Pending to Completed
                     if (!($params['contribution']->contribution_status_id == array_search('Completed', $contributionStatuses) && in_array($params['prevContribution']->contribution_status_id, $pendingStatus))) {
                         // for all other statuses create new financial records
                         self::updateFinancialAccounts($params, 'changePaymentInstrument');
                         $params['total_amount'] = $params['trxnParams']['total_amount'] = $trxnParams['total_amount'];
                         self::updateFinancialAccounts($params, 'changePaymentInstrument');
                         $updated = TRUE;
                     }
                 } elseif ((!CRM_Utils_System::isNull($params['contribution']->payment_instrument_id) || !CRM_Utils_System::isNull($params['prevContribution']->payment_instrument_id)) && $params['contribution']->payment_instrument_id != $params['prevContribution']->payment_instrument_id) {
                     // for any other payment instrument changes create new financial records
                     self::updateFinancialAccounts($params, 'changePaymentInstrument');
                     $params['total_amount'] = $params['trxnParams']['total_amount'] = $trxnParams['total_amount'];
                     self::updateFinancialAccounts($params, 'changePaymentInstrument');
                     $updated = TRUE;
                 } elseif (!CRM_Utils_System::isNull($params['contribution']->check_number) && $params['contribution']->check_number != $params['prevContribution']->check_number) {
                     // another special case when check number is changed, create new financial records
                     // create financial trxn with negative amount
                     $params['trxnParams']['check_number'] = $params['prevContribution']->check_number;
                     self::updateFinancialAccounts($params, 'changePaymentInstrument');
                     // create financial trxn with positive amount
                     $params['trxnParams']['check_number'] = $params['contribution']->check_number;
                     $params['total_amount'] = $params['trxnParams']['total_amount'] = $trxnParams['total_amount'];
                     self::updateFinancialAccounts($params, 'changePaymentInstrument');
                     $updated = TRUE;
                 }
             }
             //if Change contribution amount
             $params['trxnParams']['fee_amount'] = CRM_Utils_Array::value('fee_amount', $params);
             $params['trxnParams']['net_amount'] = CRM_Utils_Array::value('net_amount', $params);
             $params['trxnParams']['total_amount'] = $trxnParams['total_amount'] = $params['total_amount'] = $totalAmount;
             $params['trxnParams']['trxn_id'] = $params['contribution']->trxn_id;
             if (isset($totalAmount) && $totalAmount != $params['prevContribution']->total_amount) {
                 //Update Financial Records
                 $params['trxnParams']['from_financial_account_id'] = NULL;
                 self::updateFinancialAccounts($params, 'changedAmount');
                 $updated = TRUE;
             }
             if (!$updated) {
                 // Looks like we might have a data correction update.
                 // This would be a case where a transaction id has been entered but it is incorrect &
                 // the person goes back in & fixes it, as opposed to a new transaction.
                 // Currently the UI doesn't support multiple refunds against a single transaction & we are only supporting
                 // the data fix scenario.
                 // CRM-17751.
                 if (isset($params['refund_trxn_id'])) {
                     $refundIDs = CRM_Core_BAO_FinancialTrxn::getRefundTransactionIDs($params['id']);
                     if ($refundIDs['trxn_id'] != $params['refund_trxn_id']) {
                         civicrm_api3('FinancialTrxn', 'create', array('id' => $refundIDs['financialTrxnId'], 'trxn_id' => $params['refund_trxn_id']));
                     }
                 }
             }
         }
         if (!$update) {
             // records finanical trxn and entity financial trxn
             // also make it available as return value
             $return = $financialTxn = CRM_Core_BAO_FinancialTrxn::create($trxnParams);
             $params['entity_id'] = $financialTxn->id;
         }
     }
     // record line items and financial items
     if (empty($params['skipLineItem'])) {
         CRM_Price_BAO_LineItem::processPriceSet($entityId, CRM_Utils_Array::value('line_item', $params), $params['contribution'], $entityTable, $update);
     }
     // create batch entry if batch_id is passed and
     // ensure no batch entry is been made on 'Pending' or 'Failed' contribution, CRM-16611
     if (!empty($params['batch_id']) && !empty($financialTxn)) {
         $entityParams = array('batch_id' => $params['batch_id'], 'entity_table' => 'civicrm_financial_trxn', 'entity_id' => $financialTxn->id);
         CRM_Batch_BAO_Batch::addBatchEntity($entityParams);
     }
     // when a fee is charged
     if (!empty($params['fee_amount']) && (empty($params['prevContribution']) || $params['contribution']->fee_amount != $params['prevContribution']->fee_amount) && $skipRecords) {
         CRM_Core_BAO_FinancialTrxn::recordFees($params);
     }
     if (!empty($params['prevContribution']) && $entityTable == 'civicrm_participant' && $params['prevContribution']->contribution_status_id != $params['contribution']->contribution_status_id) {
         $eventID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $entityId, 'event_id');
         $feeLevel[] = str_replace('', '', $params['prevContribution']->amount_level);
         CRM_Event_BAO_Participant::createDiscountTrxn($eventID, $params, $feeLevel);
     }
     unset($params['line_item']);
     return $return;
 }
开发者ID:joshgowans,项目名称:civicrm-core,代码行数:101,代码来源:Contribution.php

示例10: submit


//.........这里部分代码省略.........
         $params['contribution_contact_id'] = $this->_contributorContactID;
         if (!empty($formValues['soft_credit_type_id'])) {
             $softParams['soft_credit_type_id'] = $formValues['soft_credit_type_id'];
             $softParams['contact_id'] = $this->_contactID;
         }
     }
     if (!empty($formValues['record_contribution'])) {
         $recordContribution = array('total_amount', 'financial_type_id', 'payment_instrument_id', 'trxn_id', 'contribution_status_id', 'check_number', 'campaign_id', 'receive_date');
         foreach ($recordContribution as $f) {
             $params[$f] = CRM_Utils_Array::value($f, $formValues);
         }
         if (!$this->_onlinePendingContributionId) {
             if (empty($formValues['source'])) {
                 $params['contribution_source'] = ts('%1 Membership: Offline signup (by %2)', array(1 => $membershipType, 2 => $userName));
             } else {
                 $params['contribution_source'] = $formValues['source'];
             }
         }
         if (empty($params['is_override']) && CRM_Utils_Array::value('contribution_status_id', $params) == array_search('Pending', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'))) {
             $params['status_id'] = array_search('Pending', $allMemberStatus);
             $params['skipStatusCal'] = TRUE;
             $params['is_pay_later'] = 1;
             $this->assign('is_pay_later', 1);
         }
         if (!empty($formValues['send_receipt'])) {
             $params['receipt_date'] = CRM_Utils_Array::value('receive_date', $formValues);
         }
         //insert financial type name in receipt.
         $formValues['contributionType_name'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $formValues['financial_type_id']);
     }
     // process line items, until no previous line items.
     if (!empty($lineItem)) {
         $params['lineItems'] = $lineItem;
         $params['processPriceSet'] = TRUE;
     }
     $createdMemberships = array();
     if ($this->_mode) {
         $params['total_amount'] = CRM_Utils_Array::value('total_amount', $formValues, 0);
         if (!$isQuickConfig) {
             $params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'financial_type_id');
         } else {
             $params['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $formValues);
         }
         $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($formValues['payment_processor_id'], $this->_mode);
         //get the payment processor id as per mode.
         $params['payment_processor_id'] = $formValues['payment_processor_id'] = $this->_paymentProcessor['id'];
         $now = date('YmdHis');
         $fields = array();
         // set email for primary location.
         $fields['email-Primary'] = 1;
         $formValues['email-5'] = $formValues['email-Primary'] = $this->_memberEmail;
         $params['register_date'] = $now;
         // now set the values for the billing location.
         foreach ($this->_fields as $name => $dontCare) {
             $fields[$name] = 1;
         }
         // also add location name to the array
         $formValues["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_middle_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_last_name', $formValues);
         $formValues["address_name-{$this->_bltID}"] = trim($formValues["address_name-{$this->_bltID}"]);
         $fields["address_name-{$this->_bltID}"] = 1;
         //ensure we don't over-write the payer's email with the member's email
         if ($this->_contributorContactID == $this->_contactID) {
             $fields["email-{$this->_bltID}"] = 1;
         }
         $nameFields = array('first_name', 'middle_name', 'last_name');
         foreach ($nameFields as $name) {
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:67,代码来源:Membership.php

示例11: postProcess


//.........这里部分代码省略.........
             $registerDate = date('YmdHis');
         }
         $this->assign('register_date', $registerDate);
         $this->confirmPostProcess($contactID, $contribution, $payment);
     }
     //handle if no additional participant.
     if (!$registerByID) {
         $registerByID = $this->get('registerByID');
     }
     $this->set('participantIDs', $this->_participantIDS);
     // create line items, CRM-5313
     if ($this->_priceSetId && !empty($this->_lineItem)) {
         // take all processed participant ids.
         $allParticipantIds = $this->_participantIDS;
         // when participant re-walk wizard.
         if ($this->_allowConfirmation && !empty($this->_additionalParticipantIds)) {
             $allParticipantIds = array_merge(array($registerByID), $this->_additionalParticipantIds);
         }
         $entityTable = 'civicrm_participant';
         $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
         $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
         $totalTaxAmount = 0;
         $dataArray = array();
         foreach ($this->_lineItem as $key => $value) {
             if ($value == 'skip') {
                 continue;
             }
             if ($entityId = CRM_Utils_Array::value($key, $allParticipantIds)) {
                 // do cleanup line  items if participant re-walking wizard.
                 if ($this->_allowConfirmation) {
                     CRM_Price_BAO_LineItem::deleteLineItems($entityId, $entityTable);
                 }
                 $lineItem[$this->_priceSetId] = $value;
                 CRM_Price_BAO_LineItem::processPriceSet($entityId, $lineItem, $contribution, $entityTable);
             }
             if ($invoicing) {
                 foreach ($value as $line) {
                     if (isset($line['tax_amount']) && isset($line['tax_rate'])) {
                         $totalTaxAmount = $line['tax_amount'] + $totalTaxAmount;
                         if (isset($dataArray[$line['tax_rate']])) {
                             $dataArray[$line['tax_rate']] = $dataArray[$line['tax_rate']] + CRM_Utils_Array::value('tax_amount', $line);
                         } else {
                             $dataArray[$line['tax_rate']] = CRM_Utils_Array::value('tax_amount', $line);
                         }
                     }
                 }
             }
         }
         if ($invoicing) {
             $this->assign('dataArray', $dataArray);
             $this->assign('totalTaxAmount', $totalTaxAmount);
         }
     }
     //update status and send mail to cancelled additional participants, CRM-4320
     if ($this->_allowConfirmation && is_array($cancelledIds) && !empty($cancelledIds)) {
         $cancelledId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'"));
         CRM_Event_BAO_Participant::transitionParticipants($cancelledIds, $cancelledId);
     }
     $isTest = FALSE;
     if ($this->_action & CRM_Core_Action::PREVIEW) {
         $isTest = TRUE;
     }
     // for Transfer checkout.
     // The concept of contributeMode is deprecated.
     if (($this->_contributeMode == 'checkout' || $this->_contributeMode == 'notify') && empty($params[0]['is_pay_later']) && !$this->_allowWaitlist && !$this->_requireApproval && $this->_totalAmount > 0) {
         $primaryParticipant = $this->get('primaryParticipant');
开发者ID:nielosz,项目名称:civicrm-core,代码行数:67,代码来源:Confirm.php

示例12: addRecurLineItems

 /**
  * Add line items for recurring contribution.
  *
  * @param int $recurId
  * @param $contribution
  *
  * @return array
  */
 public static function addRecurLineItems($recurId, $contribution)
 {
     $lineSets = array();
     $originalContributionID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $recurId, 'id', 'contribution_recur_id');
     $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($originalContributionID);
     if (count($lineItems) == 1) {
         foreach ($lineItems as $index => $lineItem) {
             if (isset($contribution->financial_type_id)) {
                 // CRM-17718 allow for possibility of changed financial type ID having been set prior to calling this.
                 $lineItems[$index]['financial_type_id'] = $contribution->financial_type_id;
             }
             if ($lineItem['line_total'] != $contribution->total_amount) {
                 // We are dealing with a changed amount! Per CRM-16397 we can work out what to do with these
                 // if there is only one line item, and the UI should prevent this situation for those with more than one.
                 $lineItems[$index]['line_total'] = $contribution->total_amount;
                 $lineItems[$index]['unit_price'] = round($contribution->total_amount / $lineItems[$index]['qty'], 2);
             }
         }
     }
     if (!empty($lineItems)) {
         foreach ($lineItems as $key => $value) {
             $priceField = new CRM_Price_DAO_PriceField();
             $priceField->id = $value['price_field_id'];
             $priceField->find(TRUE);
             $lineSets[$priceField->price_set_id][] = $value;
             if ($value['entity_table'] == 'civicrm_membership') {
                 try {
                     civicrm_api3('membership_payment', 'create', array('membership_id' => $value['entity_id'], 'contribution_id' => $contribution->id));
                 } catch (CiviCRM_API3_Exception $e) {
                     // we are catching & ignoring errors as an extra precaution since lost IPNs may be more serious that lost membership_payment data
                     // this fn is unit-tested so risk of changes elsewhere breaking it are otherwise mitigated
                 }
             }
         }
     } else {
         CRM_Price_BAO_LineItem::processPriceSet($contribution->id, $lineSets, $contribution);
     }
     return $lineSets;
 }
开发者ID:wdecraene,项目名称:civicrm-core,代码行数:47,代码来源:ContributionRecur.php

示例13: addrecurLineItems

 function addrecurLineItems($recurId, $contributionId, &$input)
 {
     $lineSets = $lineItems = array();
     //Get the first contribution id with recur id
     if ($recurId) {
         $contriID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $recurId, 'id', 'contribution_recur_id');
         $lineItems = CRM_Price_BAO_LineItem::getLineItems($contriID, 'contribution');
         if (!empty($lineItems)) {
             foreach ($lineItems as $key => $value) {
                 $pricesetID = new CRM_Price_DAO_PriceField();
                 $pricesetID->id = $value['price_field_id'];
                 $pricesetID->find(TRUE);
                 $lineSets[$pricesetID->price_set_id][] = $value;
             }
         }
         if (!empty($input)) {
             $input['line_item'] = $lineSets;
         } else {
             CRM_Price_BAO_LineItem::processPriceSet($contributionId, $lineSets);
         }
     }
 }
开发者ID:hguru,项目名称:224Civi,代码行数:22,代码来源:BaseIPN.php

示例14: postProcess

 public function postProcess()
 {
     $transaction = new CRM_Core_Transaction();
     $trxnDetails = NULL;
     $params = $this->_submitValues;
     $main_participants = $this->cart->get_main_event_participants();
     foreach ($main_participants as $participant) {
         $defaults = array();
         $ids = array('contact_id' => $participant->contact_id);
         $contact = CRM_Contact_BAO_Contact::retrieve($ids, $defaults);
         $contact->is_deleted = 0;
         $contact->save();
     }
     $trxn_prefix = 'VR';
     if (array_key_exists('billing_contact_email', $params)) {
         $this->payer_contact_id = self::find_or_create_contact($this->getContactID(), array('email' => $params['billing_contact_email'], 'first_name' => $params['billing_first_name'], 'last_name' => $params['billing_last_name'], 'is_deleted' => FALSE));
         $ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->payer_contact_id, 'contact_type');
         $billing_fields = array("billing_first_name" => 1, "billing_middle_name" => 1, "billing_last_name" => 1, "billing_street_address-{$this->_bltID}" => 1, "billing_city-{$this->_bltID}" => 1, "billing_state_province_id-{$this->_bltID}" => 1, "billing_postal_code-{$this->_bltID}" => 1, "billing_country_id-{$this->_bltID}" => 1, "address_name-{$this->_bltID}" => 1, "email-{$this->_bltID}" => 1);
         $params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params);
         $params["email-{$this->_bltID}"] = $params['billing_contact_email'];
         CRM_Contact_BAO_Contact::createProfileContact($params, $billing_fields, $this->payer_contact_id, NULL, NULL, $ctype, TRUE);
     }
     $params['now'] = date('YmdHis');
     $params['invoiceID'] = md5(uniqid(rand(), TRUE));
     $params['amount'] = $this->total;
     $params['financial_type_id'] = $this->financial_type_id;
     if ($this->payment_required && empty($params['is_pay_later'])) {
         $trxnDetails = $this->make_payment($params);
         $params['trxn_id'] = $trxnDetails['trxn_id'];
         $params['trxn_date'] = $trxnDetails['trxn_date'];
         $params['currencyID'] = $trxnDetails['currency'];
     }
     $this->cart->completed = TRUE;
     $this->cart->save();
     $this->set('last_event_cart_id', $this->cart->id);
     $contribution_statuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     $params['payment_instrument_id'] = NULL;
     if (!empty($params['is_pay_later'])) {
         $params['payment_instrument_id'] = CRM_Core_OptionGroup::getValue('payment_instrument', 'Check', 'name');
         $trxn_prefix = 'CK';
     } else {
         $params['payment_instrument_id'] = CRM_Core_OptionGroup::getValue('payment_instrument', 'Credit Card', 'name');
     }
     if ($this->is_pay_later && empty($params['payment_completed'])) {
         $params['contribution_status_id'] = array_search('Pending', $contribution_statuses);
     } else {
         $params['contribution_status_id'] = array_search('Completed', $contribution_statuses);
         $params['participant_status'] = 'Registered';
         $params['is_pay_later'] = 0;
     }
     if ($trxnDetails == NULL) {
         $params['trxn_id'] = $trxn_prefix . strftime("%Y%m%d%H%M%S");
         $params['trxn_date'] = $params['now'];
     }
     if ($this->payment_required) {
         $this->emailReceipt($this->cart->events_in_carts, $params);
     }
     // n.b. we need to process the subparticipants before main event
     // participants so that session attendance can be included in the email
     $main_participants = $this->cart->get_main_event_participants();
     $this->all_participants = array();
     foreach ($main_participants as $main_participant) {
         $this->all_participants = array_merge($this->all_participants, $this->cart->get_subparticipants($main_participant));
     }
     $this->all_participants = array_merge($this->all_participants, $main_participants);
     $this->sub_trxn_index = 0;
     foreach ($this->all_participants as $mer_participant) {
         $event_in_cart = $this->cart->get_event_in_cart_by_event_id($mer_participant->event_id);
         $this->sub_trxn_index += 1;
         unset($params['contributionID']);
         if ($mer_participant->must_wait) {
             $this->registerParticipant($params, $mer_participant, $event_in_cart->event);
         } else {
             $params['amount'] = $mer_participant->cost - $mer_participant->discount_amount;
             if ($event_in_cart->event->financial_type_id && $mer_participant->cost) {
                 $params['financial_type_id'] = $event_in_cart->event->financial_type_id;
                 $params['participant_contact_id'] = $mer_participant->contact_id;
                 $contribution = $this->record_contribution($mer_participant, $params, $event_in_cart->event);
                 // Record civicrm_line_item
                 CRM_Price_BAO_LineItem::processPriceSet($mer_participant->id, $mer_participant->price_details, $contribution, $entity_table = 'civicrm_participant');
             }
             $this->registerParticipant($params, $mer_participant, $event_in_cart->event);
         }
     }
     $this->trxn_id = $params['trxn_id'];
     $this->trxn_date = $params['trxn_date'];
     $this->saveDataToSession();
     $transaction->commit();
 }
开发者ID:agloa,项目名称:tournament,代码行数:89,代码来源:Payment.php


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