本文整理汇总了PHP中CRM_Contribute_Form_Contribution_Confirm类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_Form_Contribution_Confirm类的具体用法?PHP CRM_Contribute_Form_Contribution_Confirm怎么用?PHP CRM_Contribute_Form_Contribution_Confirm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Contribute_Form_Contribution_Confirm类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: postProcess
//.........这里部分代码省略.........
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
$paymentParams['contactID'] = $this->_contactID;
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, TRUE);
$contributionType = new CRM_Contribute_DAO_ContributionType();
$contributionType->id = $params['contribution_type_id'];
if (!$contributionType->find(TRUE)) {
CRM_Core_Error::fatal('Could not find a system table');
}
// add some contribution type details to the params list
// if folks need to use it
$paymentParams['contributionType_name'] = $this->_params['contributionType_name'] = $contributionType->name;
$paymentParams['contributionType_accounting_code'] = $this->_params['contributionType_accounting_code'] = $contributionType->accounting_code;
$paymentParams['contributionPageID'] = NULL;
if (CRM_Utils_Array::value('is_email_receipt', $this->_params)) {
$paymentParams['email'] = $this->userEmail;
$paymentParams['is_email_receipt'] = 1;
} else {
$paymentParams['is_email_receipt'] = 0;
$this->_params['is_email_receipt'] = 0;
}
if (CRM_Utils_Array::value('receive_date', $this->_params)) {
$paymentParams['receive_date'] = $this->_params['receive_date'];
}
if (CRM_Utils_Array::value('receive_date', $this->_params)) {
$paymentParams['receive_date'] = $this->_params['receive_date'];
}
$result = NULL;
// For recurring contribution, create Contribution Record first.
// Contribution ID, Recurring ID and Contact ID needed
// When we get a callback from the payment processor, CRM-7115
if (CRM_Utils_Array::value('is_recur', $paymentParams)) {
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($this, $this->_params, $result, $this->_contactID, $contributionType, FALSE, TRUE, FALSE);
$paymentParams['contributionID'] = $contribution->id;
$paymentParams['contributionTypeID'] = $contribution->contribution_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
if ($paymentParams['amount'] > 0.0) {
// force a reget of the payment processor in case the form changed it, CRM-7179
$payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this, TRUE);
$result = $payment->doDirectPayment($paymentParams);
}
if (is_a($result, 'CRM_Core_Error')) {
//make sure to cleanup db for recurring case.
if (CRM_Utils_Array::value('contributionID', $paymentParams)) {
CRM_Core_Error::debug_log_message(CRM_Core_Error::getMessages($result) . "contact id={$this->_contactID} (deleting contribution {$paymentParams['contributionID']}");
CRM_Contribute_BAO_Contribution::deleteContribution($paymentParams['contributionID']);
}
if (CRM_Utils_Array::value('contributionRecurID', $paymentParams)) {
CRM_Core_Error::debug_log_message(CRM_Core_Error::getMessages($result) . "contact id={$this->_contactID} (deleting recurring contribution {$paymentParams['contributionRecurID']}");
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
//set the contribution mode.
$urlParams = "action=add&cid={$this->_contactID}";
if ($this->_mode) {
$urlParams .= "&mode={$this->_mode}";
}
if (!empty($this->_ppID)) {
$urlParams .= "&context=pledge&ppid={$this->_ppID}";
}
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/contribution', $urlParams));
}
if ($result) {
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:67,代码来源:Contribution.php
示例2: preProcess
/**
* Set variables up before form is built.
*/
public function preProcess()
{
parent::preProcess();
// lineItem isn't set until Register postProcess
$this->_lineItem = $this->get('lineItem');
$this->_params = $this->get('params');
$this->_params[0]['tax_amount'] = $this->get('tax_amount');
$this->_params[0]['is_pay_later'] = $this->get('is_pay_later');
$this->assign('is_pay_later', $this->_params[0]['is_pay_later']);
if ($this->_params[0]['is_pay_later']) {
$this->assign('pay_later_receipt', $this->_values['event']['pay_later_receipt']);
}
CRM_Utils_Hook::eventDiscount($this, $this->_params);
if (!empty($this->_params[0]['discount']) && !empty($this->_params[0]['discount']['applied'])) {
$this->set('hookDiscount', $this->_params[0]['discount']);
$this->assign('hookDiscount', $this->_params[0]['discount']);
}
// The concept of contributeMode is deprecated.
if ($this->_contributeMode == 'express') {
$params = array();
// rfp == redirect from paypal
// rfp is probably not required - the getPreApprovalDetails should deal with any payment-processor specific 'stuff'
$rfp = CRM_Utils_Request::retrieve('rfp', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET');
//we lost rfp in case of additional participant. So set it explicitly.
if ($rfp || CRM_Utils_Array::value('additional_participants', $this->_params[0], FALSE)) {
if (!empty($this->_paymentProcessor) && $this->_paymentProcessor['object']->supports('preApproval')) {
$preApprovalParams = $this->_paymentProcessor['object']->getPreApprovalDetails($this->get('pre_approval_parameters'));
$params = array_merge($this->_params, $preApprovalParams);
}
CRM_Core_Payment_Form::mapParams($this->_bltID, $params, $params, FALSE);
// set a few other parameters that are not really specific to this method because we don't know what
// will break if we change this.
$params['amount'] = $this->_params[0]['amount'];
if (!empty($this->_params[0]['discount'])) {
$params['discount'] = $this->_params[0]['discount'];
$params['discountAmount'] = $this->_params[0]['discountAmount'];
$params['discountMessage'] = $this->_params[0]['discountMessage'];
}
$params['amount_level'] = $this->_params[0]['amount_level'];
$params['currencyID'] = $this->_params[0]['currencyID'];
// also merge all the other values from the profile fields
$values = $this->controller->exportValues('Register');
$skipFields = array('amount', "street_address-{$this->_bltID}", "city-{$this->_bltID}", "state_province_id-{$this->_bltID}", "postal_code-{$this->_bltID}", "country_id-{$this->_bltID}");
foreach ($values as $name => $value) {
// skip amount field
if (!in_array($name, $skipFields)) {
$params[$name] = $value;
}
if (substr($name, 0, 6) == 'price_') {
$params[$name] = $this->_params[0][$name];
}
}
$this->set('getExpressCheckoutDetails', $params);
}
$this->_params[0] = array_merge($this->_params[0], $params);
$this->_params[0]['is_primary'] = 1;
} else {
//process only primary participant params.
$registerParams = $this->_params[0];
if (isset($registerParams["billing_state_province_id-{$this->_bltID}"]) && $registerParams["billing_state_province_id-{$this->_bltID}"]) {
$registerParams["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($registerParams["billing_state_province_id-{$this->_bltID}"]);
}
if (isset($registerParams["billing_country_id-{$this->_bltID}"]) && $registerParams["billing_country_id-{$this->_bltID}"]) {
$registerParams["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($registerParams["billing_country_id-{$this->_bltID}"]);
}
if (isset($registerParams['credit_card_exp_date'])) {
$registerParams['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($registerParams);
$registerParams['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($registerParams);
}
if ($this->_values['event']['is_monetary']) {
$registerParams['ip_address'] = CRM_Utils_System::ipAddress();
$registerParams['currencyID'] = $this->_params[0]['currencyID'];
}
//assign back primary participant params.
$this->_params[0] = $registerParams;
}
if ($this->_values['event']['is_monetary']) {
$this->_params[0]['invoiceID'] = $this->get('invoiceID');
}
$this->assign('defaultRole', FALSE);
if (CRM_Utils_Array::value('defaultRole', $this->_params[0]) == 1) {
$this->assign('defaultRole', TRUE);
}
if (empty($this->_params[0]['participant_role_id']) && $this->_values['event']['default_role_id']) {
$this->_params[0]['participant_role_id'] = $this->_values['event']['default_role_id'];
}
if (isset($this->_values['event']['confirm_title'])) {
CRM_Utils_System::setTitle($this->_values['event']['confirm_title']);
}
if ($this->_pcpId) {
$params = CRM_Contribute_Form_Contribution_Confirm::processPcp($this, $this->_params[0]);
$this->_params[0] = $params;
}
$this->set('params', $this->_params);
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:98,代码来源:Confirm.php
示例3: submit
/**
* Submit function.
*
* @param array $params
*
* @throws CiviCRM_API3_Exception
*/
public static function submit($params)
{
$form = new CRM_Contribute_Form_Contribution_Confirm();
$form->_id = $params['id'];
CRM_Contribute_BAO_ContributionPage::setValues($form->_id, $form->_values);
$form->_separateMembershipPayment = CRM_Contribute_BAO_ContributionPage::getIsMembershipPayment($form->_id);
//this way the mocked up controller ignores the session stuff
$_SERVER['REQUEST_METHOD'] = 'GET';
$form->controller = new CRM_Contribute_Controller_Contribution();
$params['invoiceID'] = md5(uniqid(rand(), TRUE));
$paramsProcessedForForm = $form->_params = self::getFormParams($params['id'], $params);
$form->_amount = $params['amount'];
// hack these in for test support.
$form->_fields['billing_first_name'] = 1;
$form->_fields['billing_last_name'] = 1;
$priceSetID = $form->_params['priceSetId'] = $paramsProcessedForForm['price_set_id'];
$priceFields = CRM_Price_BAO_PriceSet::getSetDetail($priceSetID);
$priceSetFields = reset($priceFields);
$form->_values['fee'] = $priceSetFields['fields'];
$form->_priceSetId = $priceSetID;
$form->setFormAmountFields($priceSetID);
if (!empty($params['payment_processor_id'])) {
$form->_paymentProcessor = civicrm_api3('payment_processor', 'getsingle', array('id' => $params['payment_processor_id']));
// The concept of contributeMode is deprecated as is the billing_mode concept.
if ($form->_paymentProcessor['billing_mode'] == 1) {
$form->_contributeMode = 'direct';
} else {
$form->_contributeMode = 'notify';
}
} else {
$form->_params['payment_processor_id'] = 0;
}
$priceFields = $priceFields[$priceSetID]['fields'];
CRM_Price_BAO_PriceSet::processAmount($priceFields, $paramsProcessedForForm, $lineItems, 'civicrm_contribution');
$form->_lineItem = array($priceSetID => $lineItems);
$form->processFormSubmission(CRM_Utils_Array::value('contact_id', $params));
}
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:44,代码来源:Confirm.php
示例4: processCreditCard
//.........这里部分代码省略.........
} else {
$this->_params['invoiceID'] = $this->_params['invoice_id'];
}
// At this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
$paymentParams['contactID'] = $contactID;
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, TRUE);
$financialType = new CRM_Financial_DAO_FinancialType();
$financialType->id = $params['financial_type_id'];
$financialType->find(TRUE);
// Add some financial type details to the params list
// if folks need to use it.
$paymentParams['contributionType_name'] = $this->_params['contributionType_name'] = $financialType->name;
$paymentParams['contributionPageID'] = NULL;
if (!empty($this->_params['is_email_receipt'])) {
$paymentParams['email'] = $this->userEmail;
$paymentParams['is_email_receipt'] = 1;
} else {
$paymentParams['is_email_receipt'] = 0;
$this->_params['is_email_receipt'] = 0;
}
if (!empty($this->_params['receive_date'])) {
$paymentParams['receive_date'] = $this->_params['receive_date'];
}
$this->_params['receive_date'] = $now;
if (!empty($this->_params['is_email_receipt'])) {
$this->_params['receipt_date'] = $now;
} else {
$this->_params['receipt_date'] = CRM_Utils_Date::processDate($this->_params['receipt_date'], $params['receipt_date_time'], TRUE);
}
$this->set('params', $this->_params);
$this->assign('receive_date', $this->_params['receive_date']);
// Result has all the stuff we need
// lets archive it to a financial transaction
if ($financialType->is_deductible) {
$this->assign('is_deductible', TRUE);
$this->set('is_deductible', TRUE);
}
$contributionParams = array('contact_id' => $contactID, 'line_item' => $lineItem, 'is_test' => $isTest, 'campaign_id' => CRM_Utils_Array::value('campaign_id', $this->_params), 'contribution_page_id' => CRM_Utils_Array::value('contribution_page_id', $this->_params), 'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)), 'thankyou_date' => CRM_Utils_Array::value('thankyou_date', $this->_params));
if (empty($paymentParams['is_pay_later'])) {
// @todo look up payment_instrument_id on payment processor table.
$contributionParams['payment_instrument_id'] = 1;
}
$contribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($this, $this->_params, NULL, $contributionParams, $financialType, FALSE, $this->_bltID, CRM_Utils_Array::value('is_recur', $this->_params));
$paymentParams['contributionID'] = $contribution->id;
$paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
if ($paymentParams['amount'] > 0.0) {
// force a re-get of the payment processor in case the form changed it, CRM-7179
// NOTE - I expect this is obsolete.
$payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
try {
$statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id');
$result = $payment->doPayment($paymentParams, 'contribute');
$this->assign('trxn_id', $result['trxn_id']);
$contribution->trxn_id = $result['trxn_id'];
/* Our scenarios here are
* 1) the payment failed & an Exception should have been thrown
* 2) the payment succeeded but the payment is not immediate (for example a recurring payment
* with a delayed start)
* 3) the payment succeeded with an immediate payment.
*
* The doPayment function ensures that payment_status_id is always set
* as historically we have had to guess from the context - ie doDirectPayment
* = error or success, unless it is a recurring contribution in which case it is pending.
*/
if ($result['payment_status_id'] == array_search('Completed', $statuses)) {
try {
civicrm_api3('contribution', 'completetransaction', array('id' => $contribution->id, 'trxn_id' => $result['trxn_id'], 'payment_processor_id' => $this->_paymentProcessor['id'], 'is_transactional' => FALSE, 'fee_amount' => CRM_Utils_Array::value('fee_amount', $result)));
// This has now been set to 1 in the DB - declare it here also
$contribution->contribution_status_id = 1;
} catch (CiviCRM_API3_Exception $e) {
if ($e->getErrorCode() != 'contribution_completed') {
throw new CRM_Core_Exception('Failed to update contribution in database');
}
}
} else {
// Save the trxn_id.
$contribution->save();
}
} catch (PaymentProcessorException $e) {
CRM_Contribute_BAO_Contribution::failPayment($contribution->id, $paymentParams['contactID'], $e->getMessage());
throw new PaymentProcessorException($e->getMessage());
}
}
// Send receipt mail.
array_unshift($this->statusMessage, ts('The contribution record has been saved.'));
if ($contribution->id && !empty($this->_params['is_email_receipt'])) {
$this->_params['trxn_id'] = CRM_Utils_Array::value('trxn_id', $result);
$this->_params['contact_id'] = $contactID;
$this->_params['contribution_id'] = $contribution->id;
if (CRM_Contribute_Form_AdditionalInfo::emailReceipt($this, $this->_params, TRUE)) {
$this->statusMessage[] = ts('A receipt has been emailed to the contributor.');
}
}
return $contribution;
}
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:101,代码来源:Contribution.php
示例5: processConfirm
/**
* Process payment after confirmation.
*
* @param CRM_Core_Form $form
* Form object.
* @param array $paymentParams
* Array with payment related key.
* value pairs
* @param int $contactID
* Contact id.
* @param int $contributionTypeId
* Financial type id.
* @param int|string $component component id
* @param $isTest
*
* @throws CRM_Core_Exception
* @throws Exception
* @return array
* associated array
*
*/
public static function processConfirm(&$form, &$paymentParams, $contactID, $contributionTypeId, $component = 'contribution', $isTest)
{
CRM_Core_Payment_Form::mapParams($form->_bltID, $form->_params, $paymentParams, TRUE);
$lineItems = $form->_lineItem;
$isPaymentTransaction = self::isPaymentTransaction($form);
$financialType = new CRM_Financial_DAO_FinancialType();
$financialType->id = $contributionTypeId;
$financialType->find(TRUE);
if ($financialType->is_deductible) {
$form->assign('is_deductible', TRUE);
$form->set('is_deductible', TRUE);
}
// add some financial type details to the params list
// if folks need to use it
//CRM-15297 - contributionType is obsolete - pass financial type as well so people can deprecate it
$paymentParams['financialType_name'] = $paymentParams['contributionType_name'] = $form->_params['contributionType_name'] = $financialType->name;
//CRM-11456
$paymentParams['financialType_accounting_code'] = $paymentParams['contributionType_accounting_code'] = $form->_params['contributionType_accounting_code'] = CRM_Financial_BAO_FinancialAccount::getAccountingCode($contributionTypeId);
$paymentParams['contributionPageID'] = $form->_params['contributionPageID'] = $form->_values['id'];
$paymentParams['contactID'] = $form->_params['contactID'] = $contactID;
//fix for CRM-16317
$form->_params['receive_date'] = date('YmdHis');
$form->assign('receive_date', CRM_Utils_Date::mysqlToIso($form->_params['receive_date']));
if ($isPaymentTransaction) {
// Fix for CRM-14354. If the membership is recurring, don't create a
// civicrm_contribution_recur record for the additional contribution
// (i.e., the amount NOT associated with the membership). Temporarily
// cache the is_recur values so we can process the additional gift as a
// one-off payment.
if (!empty($form->_values['is_recur'])) {
if ($form->_membershipBlock['is_separate_payment'] && !empty($form->_params['auto_renew'])) {
$cachedFormValue = CRM_Utils_Array::value('is_recur', $form->_values);
$cachedParamValue = CRM_Utils_Array::value('is_recur', $paymentParams);
unset($form->_values['is_recur']);
unset($paymentParams['is_recur']);
}
}
$contributionParams = array('contact_id' => $contactID, 'line_item' => $lineItems, 'is_test' => $isTest, 'campaign_id' => CRM_Utils_Array::value('campaign_id', $paymentParams, CRM_Utils_Array::value('campaign_id', $form->_values)), 'contribution_page_id' => $form->_id, 'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)));
$isMonetary = !empty($form->_values['is_monetary']);
if ($isMonetary) {
if (empty($paymentParams['is_pay_later'])) {
// @todo look up payment_instrument_id on payment processor table.
$contributionParams['payment_instrument_id'] = 1;
}
}
$contribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($form, $paymentParams, NULL, $contributionParams, $financialType, TRUE, TRUE, $form->_bltID);
$paymentParams['contributionTypeID'] = $contributionTypeId;
$paymentParams['item_name'] = $form->_params['description'];
if ($contribution && $form->_values['is_recur'] && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
$paymentParams['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
return array('contribution' => $contribution);
}
// restore cached values (part of fix for CRM-14354)
if (!empty($cachedFormValue)) {
$form->_values['is_recur'] = $cachedFormValue;
$paymentParams['is_recur'] = $cachedParamValue;
}
$paymentParams['contributionID'] = $contribution->id;
//CRM-15297 deprecate contributionTypeID
$paymentParams['financialTypeID'] = $paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
if (isset($paymentParams['contribution_source'])) {
$paymentParams['source'] = $paymentParams['contribution_source'];
}
if ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
if ($form->_contributeMode && $form->_amount > 0.0) {
try {
$payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
if ($form->_contributeMode == 'notify') {
// We want to get rid of this & make it generic - eg. by making payment processing the last thing
// and always calling it first.
$form->postProcessHook();
}
$result = $payment->doPayment($paymentParams);
//.........这里部分代码省略.........
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:101,代码来源:Utils.php
示例6: processContribution
//.........这里部分代码省略.........
//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.
if (empty($form->_params['separate_membership_payment']) && !empty($form->_values['pledge_block_id']) && (!empty($form->_params['is_pledge']) || !empty($form->_values['pledge_id']))) {
if (!empty($form->_values['pledge_id'])) {
//when user doing pledge payments.
//update the schedule when payment(s) are made
foreach ($form->_params['pledge_amount'] as $paymentId => $dontCare) {
$scheduledAmount = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $paymentId, 'scheduled_amount', 'id');
$pledgePaymentParams = array('id' => $paymentId, 'contribution_id' => $contribution->id, 'status_id' => $contribution->contribution_status_id, 'actual_amount' => $scheduledAmount);
CRM_Pledge_BAO_PledgePayment::add($pledgePaymentParams);
}
//update pledge status according to the new payment statuses
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($form->_values['pledge_id']);
} else {
//when user creating pledge record.
$pledgeParams = array();
$pledgeParams['contact_id'] = $contribution->contact_id;
$pledgeParams['installment_amount'] = $pledgeParams['actual_amount'] = $contribution->total_amount;
$pledgeParams['contribution_id'] = $contribution->id;
$pledgeParams['contribution_page_id'] = $contribution->contribution_page_id;
$pledgeParams['financial_type_id'] = $contribution->financial_type_id;
$pledgeParams['frequency_interval'] = $params['pledge_frequency_interval'];
$pledgeParams['installments'] = $params['pledge_installments'];
$pledgeParams['frequency_unit'] = $params['pledge_frequency_unit'];
if ($pledgeParams['frequency_unit'] == 'month') {
$pledgeParams['frequency_day'] = intval(date("d"));
} else {
$pledgeParams['frequency_day'] = 1;
}
$pledgeParams['create_date'] = $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date("Ymd");
$pledgeParams['status_id'] = $contribution->contribution_status_id;
$pledgeParams['max_reminders'] = $form->_values['max_reminders'];
$pledgeParams['initial_reminder_day'] = $form->_values['initial_reminder_day'];
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:67,代码来源:Confirm.php
示例7: 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
示例8: processSecondaryFinancialTransaction
/**
* Where a second separate financial transaction is supported we will process it here.
*
* @param int $contactID
* @param CRM_Contribute_Form_Contribution_Confirm $form
* @param array $tempParams
* @param $isTest
* @param array $lineItems
* @param $minimumFee
* @param int $financialTypeID
*
* @throws CRM_Core_Exception
* @throws Exception
* @return CRM_Contribute_BAO_Contribution
*/
public static function processSecondaryFinancialTransaction($contactID, &$form, $tempParams, $isTest, $lineItems, $minimumFee, $financialTypeID)
{
$financialType = new CRM_Financial_DAO_FinancialType();
$financialType->id = $financialTypeID;
if (!$financialType->find(TRUE)) {
CRM_Core_Error::fatal(ts("Could not find a system table"));
}
$tempParams['amount'] = $minimumFee;
$tempParams['invoiceID'] = md5(uniqid(rand(), TRUE));
$result = NULL;
if ($form->_values['is_monetary'] && !$form->_params['is_pay_later'] && $minimumFee > 0.0) {
$payment = CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
if ($form->_contributeMode == 'express') {
$result = $payment->doExpressCheckout($tempParams);
if (is_a($result, 'CRM_Core_Error')) {
throw new CRM_Core_Exception(CRM_Core_Error::getMessages($result));
}
} else {
$result = $payment->doPayment($tempParams, 'contribute');
}
}
//assign receive date when separate membership payment
//and contribution amount not selected.
if ($form->_amount == 0) {
$now = date('YmdHis');
$form->_params['receive_date'] = $now;
$receiveDate = CRM_Utils_Date::mysqlToIso($now);
$form->set('params', $form->_params);
$form->assign('receive_date', $receiveDate);
}
$form->set('membership_trx_id', $result['trxn_id']);
$form->set('membership_amount', $minimumFee);
$form->assign('membership_trx_id', $result['trxn_id']);
$form->assign('membership_amount', $minimumFee);
// we don't need to create the user twice, so lets disable cms_create_account
// irrespective of the value, CRM-2888
$tempParams['cms_create_account'] = 0;
//CRM-16165, scenarios are
// 1) If contribution is_pay_later and if contribution amount is > 0.0 we set pending = TRUE, vice-versa FALSE
// 2) If not pay later but auto-renewal membership is chosen then pending = TRUE as it later triggers
// pending recurring contribution, vice-versa FALSE
$pending = $form->_params['is_pay_later'] ? $minimumFee > 0.0 ? TRUE : FALSE : (!empty($form->_params['auto_renew']) ? TRUE : FALSE);
//set this variable as we are not creating pledge for
//separate membership payment contribution.
//so for differentiating membership contribution from
//main contribution.
$form->_params['separate_membership_payment'] = 1;
$membershipContribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $tempParams, $result, $contactID, $financialType, $pending, TRUE, $isTest, $lineItems);
return $membershipContribution;
}
开发者ID:kidaa30,项目名称:yes,代码行数:65,代码来源:Membership.php
示例9: processConfirm
/**
* Process payment after confirmation.
*
* @param CRM_Core_Form $form
* Form object.
* @param array $paymentParams
* Array with payment related key.
* value pairs
* @param int $contactID
* Contact id.
* @param int $contributionTypeId
* Financial type id.
* @param int|string $component component id
* @param bool $isTest
* @param bool $isRecur
*
* @throws CRM_Core_Exception
* @throws Exception
* @return array
* associated array
*
*/
public static function processConfirm(&$form, &$paymentParams, $contactID, $contributionTypeId, $component = 'contribution', $isTest, $isRecur)
{
CRM_Core_Payment_Form::mapParams($form->_bltID, $form->_params, $paymentParams, TRUE);
$lineItems = $form->_lineItem;
$isPaymentTransaction = self::isPaymentTransaction($form);
$financialType = new CRM_Financial_DAO_FinancialType();
$financialType->id = $contributionTypeId;
$financialType->find(TRUE);
if ($financialType->is_deductible) {
$form->assign('is_deductible', TRUE);
$form->set('is_deductible', TRUE);
}
// add some financial type details to the params list
// if folks need to use it
//CRM-15297 - contributionType is obsolete - pass financial type as well so people can deprecate it
$paymentParams['financialType_name'] = $paymentParams['contributionType_name'] = $form->_params['contributionType_name'] = $financialType->name;
//CRM-11456
$paymentParams['financialType_accounting_code'] = $paymentParams['contributionType_accounting_code'] = $form->_params['contributionType_accounting_code'] = CRM_Financial_BAO_FinancialAccount::getAccountingCode($contributionTypeId);
$paymentParams['contributionPageID'] = $form->_params['contributionPageID'] = $form->_values['id'];
$paymentParams['contactID'] = $form->_params['contactID'] = $contactID;
//fix for CRM-16317
$form->_params['receive_date'] = date('YmdHis');
$form->assign('receive_date', CRM_Utils_Date::mysqlToIso($form->_params['receive_date']));
if ($isPaymentTransaction) {
$contributionParams = array('id' => CRM_Utils_Array::value('contribution_id', $paymentParams), 'contact_id' => $contactID, 'line_item' => $lineItems, 'is_test' => $isTest, 'campaign_id' => CRM_Utils_Array::value('campaign_id', $paymentParams, CRM_Utils_Array::value('campaign_id', $form->_values)), 'contribution_page_id' => $form->_id, 'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)));
$isMonetary = !empty($form->_values['is_monetary']);
if ($isMonetary) {
if (empty($paymentParams['is_pay_later'])) {
// @todo look up payment_instrument_id on payment processor table.
$contributionParams['payment_instrument_id'] = 1;
}
}
$contribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($form, $paymentParams, NULL, $contributionParams, $financialType, TRUE, $form->_bltID, $isRecur);
$paymentParams['contributionTypeID'] = $contributionTypeId;
$paymentParams['item_name'] = $form->_params['description'];
$paymentParams['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
return array('contribution' => $contribution);
}
$paymentParams['contributionID'] = $contribution->id;
//CRM-15297 deprecate contributionTypeID
$paymentParams['financialTypeID'] = $paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
if (isset($paymentParams['contribution_source'])) {
$paymentParams['source'] = $paymentParams['contribution_source'];
}
if ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
$form->_values['contribution_id'] = $contribution->id;
$form->_values['contribution_page_id'] = $contribution->contribution_page_id;
if (!empty($form->_paymentProcessor)) {
try {
$payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
if ($form->_contributeMode == 'notify') {
// We want to get rid of this & make it generic - eg. by making payment processing the last thing
// and always calling it first.
$form->postProcessHook();
}
$result = $payment->doPayment($paymentParams);
$form->_params = array_merge($form->_params, $result);
$form->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $result));
if (!empty($result['trxn_id'])) {
$contribution->trxn_id = $result['trxn_id'];
}
if (!empty($result['payment_status_id'])) {
$contribution->payment_status_id = $result['payment_status_id'];
}
$result['contribution'] = $contribution;
if ($result['payment_status_id'] == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'status_id', 'Pending') && $payment->isSendReceiptForPending()) {
//.........这里部分代码省略.........
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:101,代码来源:Utils.php
示例10: processConfirm
/**
* Function to process payment after confirmation
*
* @param object $form form object
* @param array $paymentParams array with payment related key
* value pairs
* @param array $premiumParams array with premium related key
* value pairs
* @param int $contactID contact id
* @param int $contributionTypeId financial type id
* @param int $component component id
*
* @return array associated array
*
* @static
* @access public
*/
static function processConfirm(&$form, &$paymentParams, &$premiumParams, $contactID, $contributionTypeId, $component = 'contribution', $fieldTypes = NULL)
{
CRM_Core_Payment_Form::mapParams($form->_bltID, $form->_params, $paymentParams, TRUE);
$contributionType = new CRM_Financial_DAO_FinancialType();
if (isset($paymentParams['financial_type'])) {
$contributionType->id = $paymentParams['financial_type'];
} elseif (!empty($form->_values['pledge_id'])) {
$contributionType->id = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge', $form->_values['pledge_id'], 'financial_type_id');
} else {
$contributionType->id = $contributionTypeId;
}
if (!$contributionType->find(TRUE)) {
CRM_Core_Error::fatal('Could not find a system table');
}
// add some financial type details to the params list
// if folks need to use it
$paymentParams['contributionType_name'] = $form->_params['contributionType_name'] = $contributionType->name;
//CRM-11456
$paymentParams['contributionType_accounting_code'] = $form->_params['contributionType_accounting_code'] = CRM_Financial_BAO_FinancialAccount::getAccountingCode($contributionType->id);
$paymentParams['contributionPageID'] = $form->_params['contributionPageID'] = $form->_values['id'];
$payment = NULL;
$paymentObjError = ts('The system did not record payment details for this payment and so could not process the transaction. Please report this error to the site administrator.');
if ($form->_values['is_monetary'] && $form->_amount > 0.0 && is_array($form->_paymentProcessor)) {
$payment = CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
}
//fix for CRM-2062
$now = date('YmdHis');
$result = NULL;
if ($form->_contributeMode == 'notify' || $form->_params['is_pay_later']) {
// this is not going to come back, i.e. we fill in the other details
// when we get a callback from the payment processor
// also add the contact ID and contribution ID to the params list
$paymentParams['contactID'] = $form->_params['contactID'] = $contactID;
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $paymentParams, NULL, $contactID, $contributionType, TRUE, TRUE, TRUE);
if ($contribution) {
$form->_params['contributionID'] = $contribution->id;
}
$form->_params['contributionTypeID'] = $contributionType->id;
$form->_params['item_name'] = $form->_params['description'];
$form->_params['receive_date'] = $now;
if ($contribution && $form->_values['is_recur'] && $contribution->contribution_recur_id) {
$form->_params['contributionRecurID'] = $contribution->contribution_recur_id;
}
$form->set('params', $form->_params);
$form->postProcessPremium($premiumParams, $contribution);
if ($form->_values['is_monetary'] && $form->_amount > 0.0) {
// add qfKey so we can send to paypal
$form->_params['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
$membershipResult = array(1 => $contribution);
return $membershipResult;
} else {
if (!$form->_params['is_pay_later']) {
if (is_object($payment)) {
// call postprocess hook before leaving
$form->postProcessHook();
// this does not return
$result =& $payment->doTransferCheckout($form->_params, 'contribute');
} else {
CRM_Core_Error::fatal($paymentObjError);
}
} else {
// follow similar flow as IPN
// send the receipt mail
$form->set('params', $form->_params);
if ($contributionType->is_deductible) {
$form->assign('is_deductible', TRUE);
$form->set('is_deductible', TRUE);
}
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
$form->_values['contribution_id'] = $contribution->id;
$form->_values['contribution_page_id'] = $contribution->contribution_page_id;
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test);
return;
}
}
//.........这里部
|
请发表评论