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


PHP CRM_Contribute_BAO_Contribution::add方法代码示例

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


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

示例1: testCreateSingleNowDated

 /**
  * Create a single post dated payment as a recurring transaction.
  *
  * Test works but not both due to some form of caching going on in the SmartySingleton
  */
 public function testCreateSingleNowDated()
 {
     $firstName = 'John_' . substr(sha1(rand()), 0, 7);
     $lastName = 'Smith_' . substr(sha1(rand()), 0, 7);
     $nameParams = array('first_name' => $firstName, 'last_name' => $lastName);
     $contactId = $this->individualCreate($nameParams);
     $invoiceID = sha1(rand());
     $amount = rand(100, 1000) . '.00';
     $contributionRecurParams = array('contact_id' => $contactId, 'amount' => $amount, 'currency' => 'USD', 'frequency_unit' => 'week', 'frequency_interval' => 1, 'installments' => 2, 'start_date' => date('Ymd'), 'create_date' => date('Ymd'), 'invoice_id' => $invoiceID, 'contribution_status_id' => 2, 'is_test' => 1, 'payment_processor_id' => $this->_paymentProcessorID);
     $recur = CRM_Contribute_BAO_ContributionRecur::add($contributionRecurParams);
     $contributionParams = array('contact_id' => $contactId, 'financial_type_id' => $this->_financialTypeId, 'receive_date' => date('Ymd'), 'total_amount' => $amount, 'invoice_id' => $invoiceID, 'currency' => 'USD', 'contribution_recur_id' => $recur->id, 'is_test' => 1, 'contribution_status_id' => 2);
     $contribution = CRM_Contribute_BAO_Contribution::add($contributionParams);
     $params = array('qfKey' => '08ed21c7ca00a1f7d32fff2488596ef7_4454', 'hidden_CreditCard' => 1, 'billing_first_name' => $firstName, 'billing_middle_name' => "", 'billing_last_name' => $lastName, 'billing_street_address-5' => '8 Hobbitton Road', 'billing_city-5' => 'The Shire', 'billing_state_province_id-5' => 1012, 'billing_postal_code-5' => 5010, 'billing_country_id-5' => 1228, 'credit_card_number' => '4007000000027', 'cvv2' => 123, 'credit_card_exp_date' => array('M' => 10, 'Y' => 2019), 'credit_card_type' => 'Visa', 'is_recur' => 1, 'frequency_interval' => 1, 'frequency_unit' => 'month', 'installments' => 12, 'financial_type_id' => $this->_financialTypeId, 'is_email_receipt' => 1, 'from_email_address' => "{$firstName}.{$lastName}@example.com", 'receive_date' => date('Ymd'), 'receipt_date_time' => '', 'payment_processor_id' => $this->_paymentProcessorID, 'price_set_id' => '', 'total_amount' => $amount, 'currency' => 'USD', 'source' => "Mordor", 'soft_credit_to' => '', 'soft_contact_id' => '', 'billing_state_province-5' => 'IL', 'state_province-5' => 'IL', 'billing_country-5' => 'US', 'country-5' => 'US', 'year' => 2019, 'month' => 10, 'ip_address' => '127.0.0.1', 'amount' => 7, 'amount_level' => 0, 'currencyID' => 'USD', 'pcp_display_in_roll' => "", 'pcp_roll_nickname' => "", 'pcp_personal_note' => "", 'non_deductible_amount' => "", 'fee_amount' => "", 'net_amount' => "", 'invoiceID' => $invoiceID, 'contribution_page_id' => "", 'thankyou_date' => NULL, 'honor_contact_id' => NULL, 'first_name' => $firstName, 'middle_name' => '', 'last_name' => $lastName, 'street_address' => '8 Hobbiton Road', 'city' => 'The Shire', 'state_province' => 'IL', 'postal_code' => 5010, 'country' => 'US', 'contributionType_name' => 'My precious', 'contributionType_accounting_code' => '', 'contributionPageID' => '', 'email' => "{$firstName}.{$lastName}@example.com", 'contactID' => $contactId, 'contributionID' => $contribution->id, 'contributionTypeID' => $this->_financialTypeId, 'contributionRecurID' => $recur->id);
     // turn verifySSL off
     CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');
     $this->processor->doPayment($params);
     // turn verifySSL on
     CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');
     // if subscription was successful, processor_id / subscription-id must not be null
     $this->assertDBNotNull('CRM_Contribute_DAO_ContributionRecur', $recur->id, 'processor_id', 'id', 'Failed to create subscription with Authorize.');
     // cancel it or the transaction will be rejected by A.net if the test is re-run
     $subscriptionID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionRecur', $recur->id, 'processor_id');
     $message = '';
     $result = $this->processor->cancelSubscription($message, array('subscriptionId' => $subscriptionID));
     $this->assertTrue($result, 'Failed to cancel subscription with Authorize.');
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:31,代码来源:AuthorizeNetTest.php

示例2: postProcess

 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     $params = $this->exportValues();
     $dates = array('receive_date', 'receipt_date', 'thankyou_date', 'cancel_date');
     if (isset($params['field'])) {
         foreach ($params['field'] as $key => $value) {
             $value['custom'] = CRM_Core_BAO_CustomField::postProcess($value, CRM_Core_DAO::$_nullObject, $key, 'Contribution');
             $ids['contribution'] = $key;
             foreach ($dates as $val) {
                 $value[$val] = CRM_Utils_Date::processDate($value[$val]);
             }
             if ($value['contribution_type']) {
                 $value['contribution_type_id'] = $value['contribution_type'];
             }
             if ($value['payment_instrument']) {
                 $value['payment_instrument_id'] = $value['payment_instrument'];
             }
             if ($value['contribution_source']) {
                 $value['source'] = $value['contribution_source'];
             }
             unset($value['contribution_type']);
             unset($value['contribution_source']);
             $contribution = CRM_Contribute_BAO_Contribution::add($value, $ids);
             // add custom field values
             if (CRM_Utils_Array::value('custom', $value) && is_array($value['custom'])) {
                 require_once 'CRM/Core/BAO/CustomValueTable.php';
                 CRM_Core_BAO_CustomValueTable::store($value['custom'], 'civicrm_contribution', $contribution->id);
             }
         }
         CRM_Core_Session::setStatus("Your updates have been saved.");
     } else {
         CRM_Core_Session::setStatus("No updates have been saved.");
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:40,代码来源:Batch.php

示例3: processFormContribution

 /**
  * Process the contribution.
  *
  * @param CRM_Core_Form $form
  * @param array $params
  * @param array $result
  * @param array $contributionParams
  *   Parameters to be passed to contribution create action.
  *   This differs from params in that we are currently adding params to it and 1) ensuring they are being
  *   passed consistently & 2) documenting them here.
  *   - contact_id
  *   - line_item
  *   - is_test
  *   - campaign_id
  *   - contribution_page_id
  *   - source
  *   - payment_type_id
  *   - thankyou_date (not all forms will set this)
  *
  * @param CRM_Financial_DAO_FinancialType $financialType
  * @param bool $online
  *   Is the form a front end form? If so set a bunch of unpredictable things that should be passed in from the form.
  *
  * @param int $billingLocationID
  *   ID of billing location type.
  * @param bool $isRecur
  *   Is this recurring?
  *
  * @return \CRM_Contribute_DAO_Contribution
  * @throws \Exception
  */
 public static function processFormContribution(&$form, $params, $result, $contributionParams, $financialType, $online, $billingLocationID, $isRecur)
 {
     $transaction = new CRM_Core_Transaction();
     $contactID = $contributionParams['contact_id'];
     $isEmailReceipt = !empty($form->_values['is_email_receipt']);
     $isSeparateMembershipPayment = empty($params['separate_membership_payment']) ? FALSE : TRUE;
     $pledgeID = !empty($params['pledge_id']) ? $params['pledge_id'] : CRM_Utils_Array::value('pledge_id', $form->_values);
     if (!$isSeparateMembershipPayment && !empty($form->_values['pledge_block_id']) && (!empty($params['is_pledge']) || $pledgeID)) {
         $isPledge = TRUE;
     } else {
         $isPledge = FALSE;
     }
     // add these values for the recurringContrib function ,CRM-10188
     $params['financial_type_id'] = $financialType->id;
     $contributionParams['address_id'] = CRM_Contribute_BAO_Contribution::createAddress($params, $billingLocationID);
     //@todo - this is being set from the form to resolve CRM-10188 - an
     // eNotice caused by it not being set @ the front end
     // however, we then get it being over-written with null for backend contributions
     // a better fix would be to set the values in the respective forms rather than require
     // a function being shared by two forms to deal with their respective values
     // moving it to the BAO & not taking the $form as a param would make sense here.
     if (!isset($params['is_email_receipt']) && $isEmailReceipt) {
         $params['is_email_receipt'] = $isEmailReceipt;
     }
     $params['is_recur'] = $isRecur;
     $recurringContributionID = self::processRecurringContribution($form, $params, $contactID, $financialType);
     $nonDeductibleAmount = self::getNonDeductibleAmount($params, $financialType, $online);
     $now = date('YmdHis');
     $receiptDate = CRM_Utils_Array::value('receipt_date', $params);
     if ($isEmailReceipt) {
         $receiptDate = $now;
     }
     if (isset($params['amount'])) {
         $contributionParams = array_merge(self::getContributionParams($params, $financialType->id, $nonDeductibleAmount, TRUE, $result, $receiptDate, $recurringContributionID), $contributionParams);
         $contribution = CRM_Contribute_BAO_Contribution::add($contributionParams);
         $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
         $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
         if ($invoicing) {
             $dataArray = array();
             // @todo - interrogate the line items passed in on the params array.
             // No reason to assume line items will be set on the form.
             foreach ($form->_lineItem as $lineItemKey => $lineItemValue) {
                 foreach ($lineItemValue as $key => $value) {
                     if (isset($value['tax_amount']) && isset($value['tax_rate'])) {
                         if (isset($dataArray[$value['tax_rate']])) {
                             $dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + CRM_Utils_Array::value('tax_amount', $value);
                         } else {
                             $dataArray[$value['tax_rate']] = CRM_Utils_Array::value('tax_amount', $value);
                         }
                     }
                 }
             }
             $smarty = CRM_Core_Smarty::singleton();
             $smarty->assign('dataArray', $dataArray);
             $smarty->assign('totalTaxAmount', $params['tax_amount']);
         }
         if (is_a($contribution, 'CRM_Core_Error')) {
             $message = CRM_Core_Error::getMessages($contribution);
             CRM_Core_Error::fatal($message);
         }
         // lets store it in the form variable so postProcess hook can get to this and use it
         $form->_contributionID = $contribution->id;
     }
     // process soft credit / pcp params first
     CRM_Contribute_BAO_ContributionSoft::formatSoftCreditParams($params, $form);
     //CRM-13981, processing honor contact into soft-credit contribution
     CRM_Contribute_BAO_ContributionSoft::processSoftContribution($params, $contribution);
     //handle pledge stuff.
     if ($isPledge) {
//.........这里部分代码省略.........
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:101,代码来源:Confirm.php

示例4: processContribution


//.........这里部分代码省略.........
         $campaignId = CRM_Utils_Array::value('campaign_id', $params);
     }
     // first create the contribution record
     $contribParams = array('contact_id' => $contactID, 'financial_type_id' => $contributionType->id, 'contribution_page_id' => $contributionPageId, 'receive_date' => CRM_Utils_Array::value('receive_date', $params) ? CRM_Utils_Date::processDate($params['receive_date']) : date('YmdHis'), 'non_deductible_amount' => $nonDeductibleAmount, 'total_amount' => $params['amount'], 'amount_level' => CRM_Utils_Array::value('amount_level', $params), 'invoice_id' => $params['invoiceID'], 'currency' => $params['currencyID'], 'source' => !$online || !empty($params['source']) ? CRM_Utils_Array::value('source', $params) : CRM_Utils_Array::value('description', $params), 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0), 'cancel_reason' => CRM_Utils_Array::value('cancel_reason', $params, 0), 'cancel_date' => isset($params['cancel_date']) ? CRM_Utils_Date::format($params['cancel_date']) : NULL, 'thankyou_date' => isset($params['thankyou_date']) ? CRM_Utils_Date::format($params['thankyou_date']) : NULL, 'campaign_id' => $campaignId);
     if (!$online && isset($params['thankyou_date'])) {
         $contribParams['thankyou_date'] = $params['thankyou_date'];
     }
     if (!$online || $form->_values['is_monetary']) {
         if (empty($params['is_pay_later'])) {
             $contribParams['payment_instrument_id'] = 1;
         }
     }
     if (!$pending && $result) {
         $contribParams += array('fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['amount']), 'trxn_id' => $result['trxn_id'], 'receipt_date' => $receiptDate, 'trxn_result_code' => CRM_Utils_Array::value('trxn_result_code', $result), 'payment_processor' => CRM_Utils_Array::value('payment_processor', $result));
     }
     if ($recurringContributionID) {
         $contribParams['contribution_recur_id'] = $recurringContributionID;
     }
     $contribParams['contribution_status_id'] = $pending ? 2 : 1;
     $contribParams['is_test'] = 0;
     if ($form->_mode == 'test') {
         $contribParams['is_test'] = 1;
     }
     $ids = array();
     if (isset($contribParams['invoice_id'])) {
         $contribID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contribParams['invoice_id'], 'id', 'invoice_id');
         if (isset($contribID)) {
             $ids['contribution'] = $contribID;
             $contribParams['id'] = $contribID;
         }
     }
     //create an contribution address
     if ($form->_contributeMode != 'notify' && empty($params['is_pay_later']) && !empty($form->_values['is_monetary'])) {
         $contribParams['address_id'] = CRM_Contribute_BAO_Contribution::createAddress($params, $form->_bltID);
     }
     // CRM-4038: for non-en_US locales, CRM_Contribute_BAO_Contribution::add() expects localised amounts
     $contribParams['non_deductible_amount'] = trim(CRM_Utils_Money::format($contribParams['non_deductible_amount'], ' '));
     $contribParams['total_amount'] = trim(CRM_Utils_Money::format($contribParams['total_amount'], ' '));
     // Prepare soft contribution due to pcp or Submit Credit / Debit Card Contribution by admin.
     if (!empty($params['pcp_made_through_id']) || !empty($params['soft_credit_to'])) {
         // if its due to pcp
         if (!empty($params['pcp_made_through_id'])) {
             $contribSoftContactId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $params['pcp_made_through_id'], 'contact_id');
         } else {
             $contribSoftContactId = CRM_Utils_Array::value('soft_credit_to', $params);
         }
         // Pass these details onto with the contribution to make them
         // available at hook_post_process, CRM-8908
         $contribParams['soft_credit_to'] = $params['soft_credit_to'] = $contribSoftContactId;
     }
     if (isset($params['amount'])) {
         $contribParams['line_item'] = $form->_lineItem;
         //add contribution record
         $contribution = CRM_Contribute_BAO_Contribution::add($contribParams, $ids);
         if (is_a($contribution, 'CRM_Core_Error')) {
             $message = CRM_Core_Error::getMessages($contribution);
             CRM_Core_Error::fatal($message);
         }
         // lets store it in the form variable so postProcess hook can get to this and use it
         $form->_contributionID = $contribution->id;
     }
     //CRM-13981, processing honor contact into soft-credit contribution
     CRM_Contact_Form_ProfileContact::postProcess($form);
     // process soft credit / pcp pages
     CRM_Contribute_Form_Contribution_Confirm::processPcpSoft($params, $contribution);
     //handle pledge stuff.
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:67,代码来源:Confirm.php

示例5: processContribution

 /**
  * Process the contribution.
  *
  * @param CRM_Core_Form $form
  * @param array $params
  * @param array $result
  * @param int $contactID
  * @param bool $pending
  * @param bool $isAdditionalAmount
  *
  * @return \CRM_Contribute_BAO_Contribution
  */
 public static function processContribution(&$form, $params, $result, $contactID, $pending = FALSE, $isAdditionalAmount = FALSE)
 {
     $transaction = new CRM_Core_Transaction();
     $now = date('YmdHis');
     $receiptDate = NULL;
     if (!empty($form->_values['event']['is_email_confirm'])) {
         $receiptDate = $now;
     }
     //CRM-4196
     if ($isAdditionalAmount) {
         $params['amount_level'] = $params['amount_level'] . ts(' (multiple participants)') . CRM_Core_DAO::VALUE_SEPARATOR;
     }
     $contribParams = array('contact_id' => $contactID, 'financial_type_id' => !empty($form->_values['event']['financial_type_id']) ? $form->_values['event']['financial_type_id'] : $params['financial_type_id'], 'receive_date' => $now, 'total_amount' => $params['amount'], 'tax_amount' => $params['tax_amount'], 'amount_level' => $params['amount_level'], 'invoice_id' => $params['invoiceID'], 'currency' => $params['currencyID'], 'source' => !empty($params['participant_source']) ? $params['participant_source'] : $params['description'], 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0), 'campaign_id' => CRM_Utils_Array::value('campaign_id', $params));
     if (empty($params['is_pay_later'])) {
         $contribParams['payment_instrument_id'] = 1;
     }
     if (!$pending && $result) {
         $contribParams += array('fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['amount']), 'trxn_id' => $result['trxn_id'], 'receipt_date' => $receiptDate);
     }
     $allStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     $contribParams['contribution_status_id'] = array_search('Completed', $allStatuses);
     if ($pending) {
         $contribParams['contribution_status_id'] = array_search('Pending', $allStatuses);
     }
     $contribParams['is_test'] = 0;
     if ($form->_action & CRM_Core_Action::PREVIEW || CRM_Utils_Array::value('mode', $params) == 'test') {
         $contribParams['is_test'] = 1;
     }
     $contribID = NULL;
     if (!empty($contribParams['invoice_id'])) {
         $contribID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contribParams['invoice_id'], 'id', 'invoice_id');
     }
     $ids = array();
     if ($contribID) {
         $ids['contribution'] = $contribID;
         $contribParams['id'] = $contribID;
     }
     if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
         $eventStartDate = CRM_Utils_Array::value('start_date', CRM_Utils_Array::value('event', $form->_values));
         if ($eventStartDate) {
             $contribParams['revenue_recognition_date'] = date('Ymd', strtotime($eventStartDate));
         }
     }
     //create an contribution address
     // The concept of contributeMode is deprecated. Elsewhere we use the function processBillingAddress() - although
     // currently that is only inherited by back-office forms.
     if ($form->_contributeMode != 'notify' && empty($params['is_pay_later'])) {
         $contribParams['address_id'] = CRM_Contribute_BAO_Contribution::createAddress($params, $form->_bltID);
     }
     $contribParams['payment_processor'] = CRM_Utils_Array::value('payment_processor', $params);
     $contribParams['skipLineItem'] = 1;
     // create contribution record
     $contribution = CRM_Contribute_BAO_Contribution::add($contribParams, $ids);
     // CRM-11124
     CRM_Event_BAO_Participant::createDiscountTrxn($form->_eventId, $contribParams, NULL, CRM_Price_BAO_PriceSet::parseFirstPriceSetValueIDFromParams($params));
     // process soft credit / pcp pages
     if (!empty($params['pcp_made_through_id'])) {
         CRM_Contribute_BAO_ContributionSoft::formatSoftCreditParams($params, $form);
         CRM_Contribute_BAO_ContributionSoft::processSoftContribution($params, $contribution);
     }
     $transaction->commit();
     return $contribution;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:75,代码来源:Confirm.php

示例6: record_contribution

 /**
  * @param $mer_participant
  * @param array $params
  * @param $event
  *
  * @return object
  * @throws Exception
  */
 public function record_contribution(&$mer_participant, &$params, $event)
 {
     if (self::is_administrator() && !empty($params['payment_type'])) {
         $params['payment_instrument_id'] = $params['payment_type'];
     }
     if ($this->payer_contact_id) {
         $payer = $this->payer_contact_id;
     } elseif (self::getContactID()) {
         $payer = self::getContactID();
     } else {
         $payer = $params['participant_contact_id'];
     }
     $contribParams = array('contact_id' => $payer, 'financial_type_id' => $params['financial_type_id'], 'receive_date' => $params['now'], 'total_amount' => $params['amount'], 'amount_level' => $mer_participant->fee_level, 'net_amount' => $params['amount'], 'invoice_id' => "{$params['invoiceID']}-{$this->sub_trxn_index}", 'trxn_id' => "{$params['trxn_id']}-{$this->sub_trxn_index}", 'currency' => CRM_Utils_Array::value('currencyID', $params), 'source' => $event->title, 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0), 'contribution_status_id' => $params['contribution_status_id'], 'payment_instrument_id' => $params['payment_instrument_id'], 'check_number' => CRM_Utils_Array::value('check_number', $params), 'skipLineItem' => 1);
     if (is_array($this->_paymentProcessor)) {
         $contribParams['payment_processor'] = $this->_paymentProcessor['id'];
     }
     $contribution =& CRM_Contribute_BAO_Contribution::add($contribParams);
     if (is_a($contribution, 'CRM_Core_Error')) {
         CRM_Core_Error::fatal(ts("There was an error creating a contribution record for your event. Please report this error to the webmaster. Details: %1", array(1 => $contribution->getMessages($contribution))));
     }
     $mer_participant->contribution_id = $contribution->id;
     $params['contributionID'] = $contribution->id;
     return $contribution;
 }
开发者ID:agloa,项目名称:tournament,代码行数:32,代码来源:Payment.php

示例7: array

 /**
  * takes an associative array and creates a contribution object
  *
  * @param array $params (reference ) an assoc array of name/value pairs
  * @param array $ids    the array that holds all the db ids
  *
  * @return object CRM_Contribute_BAO_Contribution object 
  * @access public
  * @static
  */
 function &create(&$params, &$ids)
 {
     require_once 'CRM/Utils/Money.php';
     require_once 'CRM/Utils/Date.php';
     // FIXME: a cludgy hack to fix the dates to MySQL format
     $dateFields = array('receive_date', 'cancel_date', 'receipt_date', 'thankyou_date');
     foreach ($dateFields as $df) {
         if (isset($params[$df])) {
             $params[$df] = CRM_Utils_Date::isoToMysql($params[$df]);
         }
     }
     CRM_Core_DAO::transaction('BEGIN');
     $contribution = CRM_Contribute_BAO_Contribution::add($params, $ids);
     if (is_a($contribution, 'CRM_Core_Error')) {
         CRM_Core_DAO::transaction('ROLLBACK');
         return $contribution;
     }
     $params['contribution_id'] = $contribution->id;
     // add custom field values
     if (CRM_Utils_Array::value('custom', $params)) {
         foreach ($params['custom'] as $customValue) {
             $cvParams = array('entity_table' => 'civicrm_contribution', 'entity_id' => $contribution->id, 'value' => $customValue['value'], 'type' => $customValue['type'], 'custom_field_id' => $customValue['custom_field_id']);
             if ($customValue['id']) {
                 $cvParams['id'] = $customValue['id'];
             }
             CRM_Core_BAO_CustomValue::create($cvParams);
         }
     }
     // let's create an (or update the relevant) Acitivity History record
     $contributionType = CRM_Contribute_PseudoConstant::contributionType($contribution->contribution_type_id);
     if (!$contributionType) {
         $contributionType = ts('Contribution');
     }
     if (!$GLOBALS['_CRM_CONTRIBUTE_BAO_CONTRIBUTION']['insertDate']) {
         $GLOBALS['_CRM_CONTRIBUTE_BAO_CONTRIBUTION']['insertDate'] = CRM_Utils_Date::customFormat(date('Y-m-d H:i'));
     }
     $activitySummary = ts('%1 - %2 (updated on %3)', array(1 => CRM_Utils_Money::format($contribution->total_amount, $contribution->currency), 2 => $contributionType, 3 => $GLOBALS['_CRM_CONTRIBUTE_BAO_CONTRIBUTION']['insertDate']));
     $historyParams = array('entity_table' => 'civicrm_contact', 'entity_id' => $contribution->contact_id, 'activity_type' => $contributionType, 'module' => 'CiviContribute', 'callback' => 'CRM_Contribute_Page_Contribution::details', 'activity_id' => $contribution->id, 'activity_summary' => $activitySummary, 'activity_date' => $contribution->receive_date);
     if (CRM_Utils_Array::value('contribution', $ids)) {
         // this contribution should have an Activity History record already
         $getHistoryParams = array('module' => 'CiviContribute', 'activity_id' => $contribution->id);
         $getHistoryValues =& CRM_Core_BAO_History::getHistory($getHistoryParams, 0, 1, null, 'Activity');
         if (!empty($getHistoryValues)) {
             $tmp = array_keys($getHistoryValues);
             $ids['activity_history'] = $tmp[0];
         }
     }
     $historyDAO =& CRM_Core_BAO_History::create($historyParams, $ids, 'Activity');
     if (is_a($historyDAO, 'CRM_Core_Error')) {
         CRM_Core_Error::fatal("Failed creating Activity History for contribution of id {$contribution->id}");
     }
     CRM_Core_DAO::transaction('COMMIT');
     return $contribution;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:64,代码来源:Contribution.php

示例8: testCreate

 /**
  * check method create()
  */
 function testCreate()
 {
     $firstName = 'Shane';
     $lastName = 'Whatson';
     $params = array('first_name' => $firstName, 'last_name' => $lastName, 'contact_type' => 'Individual');
     $contact = CRM_Contact_BAO_Contact::add($params);
     $price = 100.0;
     $cParams = array('contact_id' => $contact->id, 'total_amount' => $price, 'financial_type_id' => 1, 'is_active' => 1, 'skipLineItem' => 1);
     $defaults = array();
     $contribution = CRM_Contribute_BAO_Contribution::add($cParams, $defaults);
     $lParams = array('entity_id' => $contribution->id, 'entity_table' => 'civicrm_contribution', 'price_field_id' => 1, 'qty' => 1, 'label' => 'Contribution Amount', 'unit_price' => $price, 'line_total' => $price, 'price_field_value_id' => 1, 'financial_type_id' => 1);
     $lineItem = CRM_Price_BAO_LineItem::create($lParams);
     $fParams = array('contact_id' => $contact->id, 'description' => 'Contribution Amount', 'amount' => $price, 'financial_account_id' => 1, 'status_id' => 1, 'transaction_date' => date('YmdHis'), 'entity_id' => $lineItem->id, 'entity_table' => 'civicrm_line_item');
     CRM_Financial_BAO_FinancialItem::create($fParams);
     $entityTrxn = new CRM_Financial_DAO_EntityFinancialTrxn();
     $entityTrxn->entity_table = 'civicrm_contribution';
     $entityTrxn->entity_id = $contribution->id;
     $entityTrxn->amount = $price;
     if ($entityTrxn->find(TRUE)) {
         $entityId = $entityTrxn->entity_id;
     }
     $result = $this->assertDBNotNull('CRM_Financial_DAO_FinancialItem', $lineItem->id, 'amount', 'entity_id', 'Database check on added financial item record.');
     $this->assertEquals($result, $price, 'Verify Amount for Financial Item');
     $entityResult = $this->assertDBNotNull('CRM_Financial_DAO_EntityFinancialTrxn', $entityId, 'amount', 'entity_id', 'Database check on added entity financial trxn record.');
     $this->assertEquals($entityResult, $price, 'Verify Amount for Financial Item');
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:29,代码来源:FinancialItemTest.php

示例9: processContribution

 /**
  * Process the contribution
  *
  * @return void
  * @access public
  */
 static function processContribution(&$form, $params, $result, $contactID, $contributionType, $deductibleMode = true, $pending = false, $online = true)
 {
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     $honorCId = $recurringContributionID = null;
     if ($online) {
         if ($form->get('honor_block_is_active')) {
             $honorCId = $form->createHonorContact();
         }
         $recurringContributionID = $form->processRecurringContribution($params, $contactID);
     } else {
         if (!$online && isset($params['honor_contact_id'])) {
             $honorCId = $params['honor_contact_id'];
         }
     }
     $config =& CRM_Core_Config::singleton();
     if (!$online && isset($params['non_deductible_amount'])) {
         $nonDeductibleAmount = $params['non_deductible_amount'];
     } else {
         $nonDeductibleAmount = $params['amount'];
     }
     if ($online && $contributionType->is_deductible && $deductibleMode) {
         $selectProduct = CRM_Utils_Array::value('selectProduct', $premiumParams);
         if ($selectProduct && $selectProduct != 'no_thanks') {
             require_once 'CRM/Contribute/DAO/Product.php';
             $productDAO =& new CRM_Contribute_DAO_Product();
             $productDAO->id = $selectProduct;
             $productDAO->find(true);
             if ($params['amount'] < $productDAO->price) {
                 $nonDeductibleAmount = $params['amount'];
             } else {
                 $nonDeductibleAmount = $productDAO->price;
             }
         } else {
             $nonDeductibleAmount = '0.00';
         }
     }
     $now = date('YmdHis');
     $receiptDate = CRM_Utils_Array::value('receipt_date', $params);
     if (CRM_Utils_Array::value('is_email_receipt', $form->_values)) {
         $receiptDate = $now;
     }
     // check contribution Type
     // first create the contribution record
     $contribParams = array('contact_id' => $contactID, 'contribution_type_id' => $contributionType->id, 'contribution_page_id' => $online ? $form->_id : null, 'receive_date' => $now, 'non_deductible_amount' => $nonDeductibleAmount, 'total_amount' => $params['amount'], 'amount_level' => CRM_Utils_Array::value('amount_level', $params), 'invoice_id' => $params['invoiceID'], 'currency' => $params['currencyID'], 'source' => !$online || CRM_Utils_Array::value('source', $params) ? CRM_Utils_Array::value('source', $params) : CRM_Utils_Array::value('description', $params), 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0), 'cancel_reason' => CRM_Utils_Array::value('cancel_reason', $params, 0), 'cancel_date' => isset($params['cancel_date']) ? CRM_Utils_Date::format($params['cancel_date']) : null, 'thankyou_date' => isset($params['thankyou_date']) ? CRM_Utils_Date::format($params['thankyou_date']) : null);
     if (!$online && isset($params['thankyou_date'])) {
         $contribParams['thankyou_date'] = $params['thankyou_date'];
     }
     if (!$online || $form->_values['is_monetary']) {
         if (!CRM_Utils_Array::value('is_pay_later', $params)) {
             $contribParams['payment_instrument_id'] = 1;
         }
     }
     if (!$pending && $result) {
         $contribParams += array('fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['amount']), 'trxn_id' => $result['trxn_id'], 'receipt_date' => $receiptDate, 'trxn_result_code' => $result['trxn_result_code'], 'payment_processor' => $result['payment_processor']);
     }
     if (isset($honorCId)) {
         $contribParams["honor_contact_id"] = $honorCId;
         $contribParams["honor_type_id"] = $params['honor_type_id'];
     }
     if ($recurringContributionID) {
         $contribParams['contribution_recur_id'] = $recurringContributionID;
     }
     $contribParams["contribution_status_id"] = $pending ? 2 : 1;
     if ($form->_mode == 'test') {
         $contribParams["is_test"] = 1;
     }
     $ids = array();
     if (isset($contribParams['invoice_id'])) {
         $contribID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contribParams['invoice_id'], 'id', 'invoice_id');
         if (isset($contribID)) {
             $ids['contribution'] = $contribID;
             $contribParams['id'] = $contribID;
         }
     }
     foreach (array('pcp_display_in_roll', 'pcp_roll_nickname', 'pcp_personal_note') as $val) {
         if (CRM_Utils_Array::value($val, $params)) {
             $contribSoftParams[$val] = $params[$val];
         }
     }
     require_once 'CRM/Contribute/BAO/Contribution.php';
     //create an contribution address
     if ($form->_contributeMode != 'notify' && !CRM_Utils_Array::value('is_pay_later', $params)) {
         $contribParams['address_id'] = CRM_Contribute_BAO_Contribution::createAddress($params, $form->_bltID);
     }
     // CRM-4038: for non-en_US locales, CRM_Contribute_BAO_Contribution::add() expects localised amounts
     require_once 'CRM/Utils/Money.php';
     $contribParams['non_deductible_amount'] = trim(CRM_Utils_Money::format($contribParams['non_deductible_amount'], ' '));
     $contribParams['total_amount'] = trim(CRM_Utils_Money::format($contribParams['total_amount'], ' '));
     //add contribution record
     $contribution =& CRM_Contribute_BAO_Contribution::add($contribParams, $ids);
     // process price set, CRM-5095
     if ($contribution->id && $form->_priceSetId) {
         require_once 'CRM/Contribute/Form/AdditionalInfo.php';
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:civicrm,代码行数:101,代码来源:Confirm.php

示例10: processContribution

 /**
  * Process the contribution
  *
  * @return void
  * @access public
  */
 static function processContribution(&$form, $params, $result, $contactID, $pending = false, $isAdditionalAmount = false)
 {
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     $config =& CRM_Core_Config::singleton();
     $now = date('YmdHis');
     $receiptDate = null;
     if ($form->_values['event']['is_email_confirm']) {
         $receiptDate = $now;
     }
     //CRM-4196
     if ($isAdditionalAmount) {
         $params['amount_level'] = $params['amount_level'] . ts(' (multiple participants)') . CRM_Core_BAO_CustomOption::VALUE_SEPERATOR;
     }
     $contribParams = array('contact_id' => $contactID, 'contribution_type_id' => $form->_values['event']['contribution_type_id'] ? $form->_values['event']['contribution_type_id'] : $params['contribution_type_id'], 'receive_date' => $now, 'total_amount' => $params['amount'], 'amount_level' => $params['amount_level'], 'invoice_id' => $params['invoiceID'], 'currency' => $params['currencyID'], 'source' => $params['description'], 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0));
     if (!CRM_Utils_Array::value('is_pay_later', $params)) {
         $contribParams['payment_instrument_id'] = 1;
     }
     if (!$pending && $result) {
         $contribParams += array('fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['amount']), 'trxn_id' => $result['trxn_id'], 'receipt_date' => $receiptDate);
     }
     require_once 'CRM/Contribute/PseudoConstant.php';
     $allStatuses = CRM_Contribute_PseudoConstant::contributionStatus();
     $contribParams["contribution_status_id"] = array_search('Completed', $allStatuses);
     if ($pending) {
         $contribParams["contribution_status_id"] = array_search('Pending', $allStatuses);
     }
     $contribParams["is_test"] = 0;
     if ($form->_action & CRM_Core_Action::PREVIEW || CRM_Utils_Array::value('mode', $params) == 'test') {
         $contribParams["is_test"] = 1;
     }
     $contribID = null;
     if (CRM_Utils_Array::value('invoice_id', $contribParams)) {
         $contribID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contribParams['invoice_id'], 'id', 'invoice_id');
     }
     $ids = array();
     if ($contribID) {
         $ids['contribution'] = $contribID;
         $contribParams['id'] = $contribID;
     }
     require_once 'CRM/Contribute/BAO/Contribution.php';
     //create an contribution address
     if ($form->_contributeMode != 'notify' && !CRM_Utils_Array::value('is_pay_later', $params)) {
         $contribParams['address_id'] = CRM_Contribute_BAO_Contribution::createAddress($params, $form->_bltID);
     }
     // create contribution record
     $contribution =& CRM_Contribute_BAO_Contribution::add($contribParams, $ids);
     // return if pending
     if ($pending || $contribution->total_amount == 0) {
         $transaction->commit();
         return $contribution;
     }
     // next create the transaction record
     $trxnParams = array('contribution_id' => $contribution->id, 'trxn_date' => $now, 'trxn_type' => 'Debit', 'total_amount' => $params['amount'], 'fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['amount']), 'currency' => $params['currencyID'], 'payment_processor' => $form->_paymentProcessor['payment_processor_type'], 'trxn_id' => $result['trxn_id']);
     require_once 'CRM/Contribute/BAO/FinancialTrxn.php';
     $trxn =& CRM_Contribute_BAO_FinancialTrxn::create($trxnParams);
     $transaction->commit();
     return $contribution;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:65,代码来源:Confirm.php

示例11: processContribution

 /**
  * Process the contribution
  *
  * @return void
  * @access public
  */
 static function processContribution(&$form, $params, $result, $contactID, $pending = FALSE, $isAdditionalAmount = FALSE)
 {
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     $config = CRM_Core_Config::singleton();
     $now = date('YmdHis');
     $receiptDate = NULL;
     if ($form->_values['event']['is_email_confirm']) {
         $receiptDate = $now;
     }
     //CRM-4196
     if ($isAdditionalAmount) {
         $params['amount_level'] = $params['amount_level'] . ts(' (multiple participants)') . CRM_Core_DAO::VALUE_SEPARATOR;
     }
     $contribParams = array('contact_id' => $contactID, 'contribution_type_id' => $form->_values['event']['contribution_type_id'] ? $form->_values['event']['contribution_type_id'] : $params['contribution_type_id'], 'receive_date' => $now, 'total_amount' => $params['amount'], 'amount_level' => $params['amount_level'], 'invoice_id' => $params['invoiceID'], 'currency' => $params['currencyID'], 'source' => $params['description'], 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0), 'campaign_id' => CRM_Utils_Array::value('campaign_id', $params));
     if (!CRM_Utils_Array::value('is_pay_later', $params)) {
         $contribParams['payment_instrument_id'] = 1;
     }
     if (!$pending && $result) {
         $contribParams += array('fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['amount']), 'trxn_id' => $result['trxn_id'], 'receipt_date' => $receiptDate);
     }
     $allStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     $contribParams['contribution_status_id'] = array_search('Completed', $allStatuses);
     if ($pending) {
         $contribParams['contribution_status_id'] = array_search('Pending', $allStatuses);
     }
     $contribParams['is_test'] = 0;
     if ($form->_action & CRM_Core_Action::PREVIEW || CRM_Utils_Array::value('mode', $params) == 'test') {
         $contribParams['is_test'] = 1;
     }
     $contribID = NULL;
     if (CRM_Utils_Array::value('invoice_id', $contribParams)) {
         $contribID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contribParams['invoice_id'], 'id', 'invoice_id');
     }
     $ids = array();
     if ($contribID) {
         $ids['contribution'] = $contribID;
         $contribParams['id'] = $contribID;
     }
     //create an contribution address
     if ($form->_contributeMode != 'notify' && !CRM_Utils_Array::value('is_pay_later', $params)) {
         $contribParams['address_id'] = CRM_Contribute_BAO_Contribution::createAddress($params, $form->_bltID);
     }
     // Prepare soft contribution due to pcp or Submit Credit / Debit Card Contribution by admin.
     if (CRM_Utils_Array::value('pcp_made_through_id', $params) || CRM_Utils_Array::value('soft_credit_to', $params)) {
         // if its due to pcp
         if (CRM_Utils_Array::value('pcp_made_through_id', $params)) {
             $contribSoftContactId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $params['pcp_made_through_id'], 'contact_id');
         } else {
             $contribSoftContactId = CRM_Utils_Array::value('soft_credit_to', $params);
         }
         // Pass these details onto with the contribution to make them
         // available at hook_post_process, CRM-8908
         $contribParams['soft_credit_to'] = $params['soft_credit_to'] = $contribSoftContactId;
     }
     // create contribution record
     $contribution = CRM_Contribute_BAO_Contribution::add($contribParams, $ids);
     // process soft credit / pcp pages
     CRM_Contribute_Form_Contribution_Confirm::processPcpSoft($params, $contribution);
     // return if pending
     if ($pending || $contribution->total_amount == 0) {
         $transaction->commit();
         return $contribution;
     }
     // next create the transaction record
     $trxnParams = array('contribution_id' => $contribution->id, 'trxn_date' => $now, 'trxn_type' => 'Debit', 'total_amount' => $params['amount'], 'fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['amount']), 'currency' => $params['currencyID'], 'payment_processor' => $form->_paymentProcessor['payment_processor_type'], 'trxn_id' => $result['trxn_id']);
     $trxn = CRM_Core_BAO_FinancialTrxn::create($trxnParams);
     $transaction->commit();
     return $contribution;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:76,代码来源:Confirm.php

示例12: postProcess

 /**
  * Process the form after the input has been submitted and validated.
  */
 public function postProcess()
 {
     $params = $this->exportValues();
     $dates = array('receive_date', 'receipt_date', 'thankyou_date', 'cancel_date');
     if (isset($params['field'])) {
         foreach ($params['field'] as $key => $value) {
             $value['custom'] = CRM_Core_BAO_CustomField::postProcess($value, $key, 'Contribution');
             $ids['contribution'] = $key;
             foreach ($dates as $val) {
                 if (isset($value[$val])) {
                     $value[$val] = CRM_Utils_Date::processDate($value[$val]);
                 }
             }
             if (!empty($value['financial_type'])) {
                 $value['financial_type_id'] = $value['financial_type'];
             }
             if (!empty($value['payment_instrument'])) {
                 $value['payment_instrument_id'] = $value['payment_instrument'];
             }
             if (!empty($value['contribution_source'])) {
                 $value['source'] = $value['contribution_source'];
             }
             unset($value['financial_type']);
             unset($value['contribution_source']);
             $contribution = CRM_Contribute_BAO_Contribution::add($value, $ids);
             // add custom field values
             if (!empty($value['custom']) && is_array($value['custom'])) {
                 CRM_Core_BAO_CustomValueTable::store($value['custom'], 'civicrm_contribution', $contribution->id);
             }
         }
         CRM_Core_Session::setStatus(ts("Your updates have been saved."), ts('Saved'), 'success');
     } else {
         CRM_Core_Session::setStatus(ts("No updates have been saved."), ts('Not Saved'), 'alert');
     }
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:38,代码来源:Batch.php

示例13: processContribution

 /**
  * Process the contribution
  *
  * @return void
  * @access public
  */
 static function processContribution(&$form, $params, $result, $contactID, $contributionType, $deductibleMode = TRUE, $pending = FALSE, $online = TRUE)
 {
     $transaction = new CRM_Core_Transaction();
     $className = get_class($form);
     $honorCId = $recurringContributionID = NULL;
     if ($online && $form->get('honor_block_is_active')) {
         $honorCId = $form->createHonorContact();
     }
     // add these values for the recurringContrib function ,CRM-10188
     $params['contribution_type_id'] = $contributionType->id;
     $params['is_email_receipt'] = CRM_Utils_Array::value('is_email_receipt', $form->_values);
     $recurringContributionID = self::processRecurringContribution($form, $params, $contactID, $contributionType, $online);
     if (!$online && isset($params['honor_contact_id'])) {
         $honorCId = $params['honor_contact_id'];
     }
     $config = CRM_Core_Config::singleton();
     if (!$online && isset($params['non_deductible_amount'])) {
         $nonDeductibleAmount = $params['non_deductible_amount'];
     } else {
         $nonDeductibleAmount = $params['amount'];
     }
     if ($online && $contributionType->is_deductible && $deductibleMode) {
         $selectProduct = CRM_Utils_Array::value('selectProduct', $params);
         if ($selectProduct && $selectProduct != 'no_thanks') {
             $productDAO = new CRM_Contribute_DAO_Product();
             $productDAO->id = $selectProduct;
             $productDAO->find(TRUE);
             if ($params['amount'] < $productDAO->price) {
                 $nonDeductibleAmount = $params['amount'];
             } else {
                 $nonDeductibleAmount = $productDAO->price;
             }
         } else {
             $nonDeductibleAmount = '0.00';
         }
     }
     $now = date('YmdHis');
     $receiptDate = CRM_Utils_Array::value('receipt_date', $params);
     if (CRM_Utils_Array::value('is_email_receipt', $form->_values)) {
         $receiptDate = $now;
     }
     //get the contrib page id.
     $campaignId = $contributionPageId = NULL;
     if ($online) {
         $contributionPageId = $form->_id;
         $campaignId = CRM_Utils_Array::value('campaign_id', $params);
         if (!array_key_exists('campaign_id', $params)) {
             $campaignId = CRM_Utils_Array::value('campaign_id', $form->_values);
         }
     } else {
         //also for offline we do support - CRM-7290
         $contributionPageId = CRM_Utils_Array::value('contribution_page_id', $params);
         $campaignId = CRM_Utils_Array::value('campaign_id', $params);
     }
     // first create the contribution record
     $contribParams = array('contact_id' => $contactID, 'contribution_type_id' => $contributionType->id, 'contribution_page_id' => $contributionPageId, 'receive_date' => CRM_Utils_Array::value('receive_date', $params) ? CRM_Utils_Date::processDate($params['receive_date']) : date('YmdHis'), 'non_deductible_amount' => $nonDeductibleAmount, 'total_amount' => $params['amount'], 'amount_level' => CRM_Utils_Array::value('amount_level', $params), 'invoice_id' => $params['invoiceID'], 'currency' => $params['currencyID'], 'source' => !$online || CRM_Utils_Array::value('source', $params) ? CRM_Utils_Array::value('source', $params) : CRM_Utils_Array::value('description', $params), 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0), 'cancel_reason' => CRM_Utils_Array::value('cancel_reason', $params, 0), 'cancel_date' => isset($params['cancel_date']) ? CRM_Utils_Date::format($params['cancel_date']) : NULL, 'thankyou_date' => isset($params['thankyou_date']) ? CRM_Utils_Date::format($params['thankyou_date']) : NULL, 'campaign_id' => $campaignId);
     if (!$online && isset($params['thankyou_date'])) {
         $contribParams['thankyou_date'] = $params['thankyou_date'];
     }
     if (!$online || $form->_values['is_monetary']) {
         if (!CRM_Utils_Array::value('is_pay_later', $params)) {
             $contribParams['payment_instrument_id'] = 1;
         }
     }
     if (!$pending && $result) {
         $contribParams += array('fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['amount']), 'trxn_id' => $result['trxn_id'], 'receipt_date' => $receiptDate, 'trxn_result_code' => CRM_Utils_Array::value('trxn_result_code', $result), 'payment_processor' => CRM_Utils_Array::value('payment_processor', $result));
     }
     if (isset($honorCId)) {
         $contribParams['honor_contact_id'] = $honorCId;
         $contribParams['honor_type_id'] = $params['honor_type_id'];
     }
     if ($recurringContributionID) {
         $contribParams['contribution_recur_id'] = $recurringContributionID;
     }
     $contribParams['contribution_status_id'] = $pending ? 2 : 1;
     $contribParams['is_test'] = 0;
     if ($form->_mode == 'test') {
         $contribParams['is_test'] = 1;
     }
     $ids = array();
     if (isset($contribParams['invoice_id'])) {
         $contribID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contribParams['invoice_id'], 'id', 'invoice_id');
         if (isset($contribID)) {
             $ids['contribution'] = $contribID;
             $contribParams['id'] = $contribID;
         }
     }
     //create an contribution address
     if ($form->_contributeMode != 'notify' && !CRM_Utils_Array::value('is_pay_later', $params) && CRM_Utils_Array::value('is_monetary', $form->_values)) {
         $contribParams['address_id'] = CRM_Contribute_BAO_Contribution::createAddress($params, $form->_bltID);
     }
     // CRM-4038: for non-en_US locales, CRM_Contribute_BAO_Contribution::add() expects localised amounts
     $contribParams['non_deductible_amount'] = trim(CRM_Utils_Money::format($contribParams['non_deductible_amount'], ' '));
     $contribParams['total_amount'] = trim(CRM_Utils_Money::format($contribParams['total_amount'], ' '));
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Confirm.php

示例14: processFormContribution

 /**
  * Process the contribution.
  *
  * @param CRM_Core_Form $form
  * @param array $params
  * @param array $result
  * @param int $contactID
  * @param CRM_Financial_DAO_FinancialType $financialType
  * @param bool $pending
  * @param bool $online
  *
  * @param bool $isTest
  * @param array $lineItems
  *
  * @param int $billingLocationID
  *   ID of billing location type.
  *
  * @return \CRM_Contribute_DAO_Contribution
  * @throws \Exception
  */
 public static function processFormContribution(&$form, $params, $result, $contactID, $financialType, $pending, $online, $isTest, $lineItems, $billingLocationID)
 {
     $transaction = new CRM_Core_Transaction();
     $contribSoftContactId = $addressID = NULL;
     $contributeMode = $form->_contributeMode;
     $isMonetary = !empty($form->_values['is_monetary']);
     $isEmailReceipt = !empty($form->_values['is_email_receipt']);
     // How do these vary from params? These are currently passed to
     // - custom data function....
     $formParams = $form->_params;
     $isSeparateMembershipPayment = empty($formParams['separate_membership_payment']) ? FALSE : TRUE;
     $pledgeID = empty($formParams['pledge_id']) ? NULL : $formParams['pledge_id'];
     if (!$isSeparateMembershipPayment && !empty($form->_values['pledge_block_id']) && (!empty($formParams['is_pledge']) || $pledgeID)) {
         $isPledge = TRUE;
     } else {
         $isPledge = FALSE;
     }
     // add these values for the recurringContrib function ,CRM-10188
     $params['financial_type_id'] = $financialType->id;
     //create an contribution address
     if ($contributeMode != 'notify' && empty($params['is_pay_later']) && $isMonetary) {
         $addressID = CRM_Contribute_BAO_Contribution::createAddress($params, $billingLocationID);
     }
     //@todo - this is being set from the form to resolve CRM-10188 - an
     // eNotice caused by it not being set @ the front end
     // however, we then get it being over-written with null for backend contributions
     // a better fix would be to set the values in the respective forms rather than require
     // a function being shared by two forms to deal with their respective values
     // moving it to the BAO & not taking the $form as a param would make sense here.
     if (!isset($params['is_email_receipt']) && $isEmailReceipt) {
         $params['is_email_receipt'] = $isEmailReceipt;
     }
     $recurringContributionID = self::processRecurringContribution($form, $params, $contactID, $financialType, $online);
     $nonDeductibleAmount = self::getNonDeductibleAmount($params, $financialType, $online);
     $now = date('YmdHis');
     $receiptDate = CRM_Utils_Array::value('receipt_date', $params);
     if ($isEmailReceipt) {
         $receiptDate = $now;
     }
     //get the contrib page id.
     $contributionPageId = NULL;
     if ($online) {
         $contributionPageId = $form->_id;
         $campaignId = CRM_Utils_Array::value('campaign_id', $params);
         if (!array_key_exists('campaign_id', $params)) {
             $campaignId = CRM_Utils_Array::value('campaign_id', $form->_values);
         }
     } else {
         //also for offline we do support - CRM-7290
         $contributionPageId = CRM_Utils_Array::value('contribution_page_id', $params);
         $campaignId = CRM_Utils_Array::value('campaign_id', $params);
     }
     // Prepare soft contribution due to pcp or Submit Credit / Debit Card Contribution by admin.
     if (!empty($params['pcp_made_through_id']) || !empty($params['soft_credit_to'])) {
         // if its due to pcp
         if (!empty($params['pcp_made_through_id'])) {
             $contribSoftContactId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $params['pcp_made_through_id'], 'contact_id');
         } else {
             $contribSoftContactId = CRM_Utils_Array::value('soft_credit_to', $params);
         }
         // Pass these details onto with the contribution to make them
         // available at hook_post_process, CRM-8908
         $params['soft_credit_to'] = $contribSoftContactId;
     }
     if (isset($params['amount'])) {
         $contribParams = self::getContributionParams($params, $contactID, $financialType->id, $online, $contributionPageId, $nonDeductibleAmount, $campaignId, $isMonetary, $pending, $result, $receiptDate, $recurringContributionID, $isTest, $addressID, $contribSoftContactId, $lineItems);
         $contribution = CRM_Contribute_BAO_Contribution::add($contribParams);
         $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
         $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
         if ($invoicing) {
             $dataArray = array();
             foreach ($form->_lineItem as $lineItemKey => $lineItemValue) {
                 foreach ($lineItemValue as $key => $value) {
                     if (isset($value['tax_amount']) && isset($value['tax_rate'])) {
                         if (isset($dataArray[$value['tax_rate']])) {
                             $dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + CRM_Utils_Array::value('tax_amount', $value);
                         } else {
                             $dataArray[$value['tax_rate']] = CRM_Utils_Array::value('tax_amount', $value);
                         }
                     }
//.........这里部分代码省略.........
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:101,代码来源:Confirm.php

示例15: record_contribution

 function record_contribution(&$mer_participant, &$params, $event)
 {
     if (self::is_administrator() && CRM_Utils_Array::value('payment_type', $params)) {
         $params['payment_instrument_id'] = $params['payment_type'];
     }
     if ($this->payer_contact_id) {
         $payer = $this->payer_contact_id;
     } elseif (self::getContactID()) {
         $payer = self::getContactID();
     } else {
         $payer = $params['participant_contact_id'];
     }
     $contribParams = array('contact_id' => $payer, 'contribution_type_id' => $params['contribution_type_id'], 'receive_date' => $params['now'], 'total_amount' => $params['amount'], 'amount_level' => $mer_participant->fee_level, 'fee_amount' => $mer_participant->cost, 'net_amount' => $params['amount'], 'invoice_id' => "{$params['invoiceID']}-{$this->sub_trxn_index}", 'trxn_id' => "{$params['trxn_id']}-{$this->sub_trxn_index}", 'currency' => CRM_Utils_Array::value('currencyID', $params), 'source' => $event->title, 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0), 'contribution_status_id' => $params['contribution_status_id'], 'payment_instrument_id' => $params['payment_instrument_id'], 'check_number' => CRM_Utils_Array::value('check_number', $params));
     $contribution =& CRM_Contribute_BAO_Contribution::add($contribParams, $ids);
     if (is_a($contribution, 'CRM_Core_Error')) {
         CRM_Core_Error::fatal(ts("There was an error creating a contribution record for your event. Please report this error to the webmaster. Details: %1\n", array(1 => $contribution->getMessages($contribution))));
     }
     $mer_participant->contribution_id = $contribution->id;
     $params['contributionID'] = $contribution->id;
     $params['receive_date'] = $contribution->receive_date;
     if (CRM_Utils_Array::value('financial_trxn_id', $params)) {
         $entity_financial_trxn_params = array('entity_table' => "civicrm_contribution", 'entity_id' => $contribution->id, 'financial_trxn_id' => $params['financial_trxn_id'], 'amount' => $params['amount'], 'currency' => CRM_Utils_Array::value('currencyID', $params));
         $entity_trxn =& new CRM_Core_DAO_EntityFinancialTrxn();
         $entity_trxn->copyValues($entity_financial_trxn_params);
         $entity_trxn->save();
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:27,代码来源:Payment.php


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