本文整理汇总了PHP中CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution方法的具体用法?PHP CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution怎么用?PHP CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_ContributionRecur
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cancelRecurring
/**
* In case user cancel recurring contribution,
* When we get the control back from payment gate way
* lets delete the recurring and related contribution.
*
**/
public function cancelRecurring()
{
$isCancel = CRM_Utils_Request::retrieve('cancel', 'Boolean', CRM_Core_DAO::$_nullObject);
if ($isCancel) {
$isRecur = CRM_Utils_Request::retrieve('isRecur', 'Boolean', CRM_Core_DAO::$_nullObject);
$recurId = CRM_Utils_Request::retrieve('recurId', 'Positive', CRM_Core_DAO::$_nullObject);
//clean db for recurring contribution.
if ($isRecur && $recurId) {
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($recurId);
}
$contribId = CRM_Utils_Request::retrieve('contribId', 'Positive', CRM_Core_DAO::$_nullObject);
if ($contribId) {
CRM_Contribute_BAO_Contribution::deleteContribution($contribId);
}
}
}
示例2: postProcess
//.........这里部分代码省略.........
$result = NULL;
if (!empty($paymentParams['is_recur'])) {
$contributionType = new CRM_Financial_DAO_FinancialType();
$contributionType->id = $params['financial_type_id'];
if (!$contributionType->find(TRUE)) {
CRM_Core_Error::fatal('Could not find a system table');
}
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($this, $paymentParams, $result, $this->_contributorContactID, $contributionType, TRUE, FALSE, $isTest, $lineItems);
//create new soft-credit record, CRM-13981
if ($softParams) {
$softParams['contribution_id'] = $contribution->id;
$softParams['currency'] = $contribution->currency;
$softParams['amount'] = $contribution->total_amount;
CRM_Contribute_BAO_ContributionSoft::add($softParams);
}
$paymentParams['contactID'] = $this->_contactID;
$paymentParams['contributionID'] = $contribution->id;
$paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
$ids['contribution'] = $contribution->id;
$params['contribution_recur_id'] = $paymentParams['contributionRecurID'];
}
if ($params['total_amount'] > 0.0) {
$payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
$result = $payment->doDirectPayment($paymentParams);
}
if (is_a($result, 'CRM_Core_Error')) {
//make sure to cleanup db for recurring case.
if (!empty($paymentParams['contributionID'])) {
CRM_Contribute_BAO_Contribution::deleteContribution($paymentParams['contributionID']);
}
if (!empty($paymentParams['contributionRecurID'])) {
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=add&cid={$this->_contactID}&context=&mode={$this->_mode}"));
}
if ($result) {
$this->_params = array_merge($this->_params, $result);
//assign amount to template if payment was successful
$this->assign('amount', $params['total_amount']);
}
// if the payment processor returns a contribution_status_id -> use it!
if (isset($result['contribution_status_id'])) {
$result['payment_status_id'] = $result['contribution_status_id'];
}
if (isset($result['payment_status_id'])) {
// CRM-16737 $result['contribution_status_id'] is deprecated in favour
// of payment_status_id as the payment processor only knows whether the payment is complete
// not whether payment completes the contribution
$params['contribution_status_id'] = $result['payment_status_id'];
} else {
$params['contribution_status_id'] = !empty($paymentParams['is_recur']) ? 2 : 1;
}
if ($params['contribution_status_id'] != array_search('Completed', $allContributionStatus)) {
$params['status_id'] = array_search('Pending', $allMemberStatus);
$params['skipStatusCal'] = TRUE;
// unset send-receipt option, since receipt will be sent when ipn is received.
unset($this->_params['send_receipt'], $formValues['send_receipt']);
//as membership is pending set dates to null.
$memberDates = array('join_date' => 'joinDate', 'start_date' => 'startDate', 'end_date' => 'endDate');
foreach ($memberDates as $dp => $dv) {
${$dv} = NULL;
foreach ($this->_memTypeSelected as $memType) {
$membershipTypeValues[$memType][$dv] = NULL;
示例3: processConfirm
//.........这里部分代码省略.........
$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);
$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;
return $result;
} catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
// Clean up DB as appropriate.
if (!empty($paymentParams['contributionID'])) {
CRM_Contribute_BAO_Contribution::failPayment($paymentParams['contributionID'], $paymentParams['contactID'], $e->getMessage());
}
if (!empty($paymentParams['contributionRecurID'])) {
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
$result['is_payment_failure'] = TRUE;
$result['error'] = $e;
return $result;
}
}
}
// Only pay later or unpaid should reach this point. The theory is that paylater should get a receipt now &
// processor
// transaction receipts should be outcome driven.
$form->set('params', $form->_params);
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);
}
示例4: processConfirm
//.........这里部分代码省略.........
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
require_once 'CRM/Contribute/BAO/ContributionPage.php';
$form->_values['contribution_id'] = $contribution->id;
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test);
return;
}
}
}
} elseif ($form->_contributeMode == 'express') {
if ($form->_values['is_monetary'] && $form->_amount > 0.0) {
//LCD determine if express + recurring and direct accordingly
if ($paymentParams['is_recur'] == 1) {
$result =& $payment->createRecurringPayments($paymentParams);
} else {
$result =& $payment->doExpressCheckout($paymentParams);
}
}
} elseif ($form->_values['is_monetary'] && $form->_amount > 0.0) {
if ($paymentParams['is_recur'] && $form->_contributeMode == 'direct') {
// For recurring contribution, create Contribution Record first.
// Contribution ID, Recurring ID and Contact ID needed
// When we get a callback from the payment processor
$paymentParams['contactID'] = $contactID;
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $paymentParams, null, $contactID, $contributionType, true, true, true);
$paymentParams['contributionID'] = $contribution->id;
$paymentParams['contributionTypeID'] = $contribution->contribution_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
if ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
}
$result =& $payment->doDirectPayment($paymentParams);
}
if ($component == 'membership') {
$membershipResult = array();
}
if (is_a($result, 'CRM_Core_Error')) {
//make sure to cleanup db for recurring case.
if (CRM_Utils_Array::value('contributionID', $paymentParams)) {
CRM_Contribute_BAO_Contribution::deleteContribution($paymentParams['contributionID']);
}
if (CRM_Utils_Array::value('contributionRecurID', $paymentParams)) {
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
if ($component !== 'membership') {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=true&qfKey={$form->_params['qfKey']}"));
}
$membershipResult[1] = $result;
} else {
if ($result) {
$form->_params = array_merge($form->_params, $result);
}
$form->_params['receive_date'] = $now;
$form->set('params', $form->_params);
$form->assign('trxn_id', $result['trxn_id']);
$form->assign('receive_date', CRM_Utils_Date::mysqlToIso($form->_params['receive_date']));
// result has all the stuff we need
// lets archive it to a financial transaction
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'];
}
// check if pending was set to true by payment processor
$pending = false;
if (CRM_Utils_Array::value('contribution_status_pending', $form->_params)) {
$pending = true;
}
if (!($paymentParams['is_recur'] && $form->_contributeMode == 'direct')) {
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $form->_params, $result, $contactID, $contributionType, true, $pending, true);
}
$form->postProcessPremium($premiumParams, $contribution);
$membershipResult[1] = $contribution;
}
if ($component == 'membership') {
return $membershipResult;
}
//Do not send an email if Recurring contribution is done via Direct Mode
//Email will we send once the IPN will receive.
if ($paymentParams['is_recur'] && $form->_contributeMode == 'direct') {
return true;
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
// finally send an email receipt
require_once 'CRM/Contribute/BAO/ContributionPage.php';
$form->_values['contribution_id'] = $contribution->id;
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test);
}
示例5: submit
//.........这里部分代码省略.........
if (!empty($paymentParams['is_recur'])) {
$financialType = new CRM_Financial_DAO_FinancialType();
$financialType->id = $params['financial_type_id'];
$financialType->find(TRUE);
$this->_params = $formValues;
$contribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($this, $paymentParams, NULL, array('contact_id' => $this->_contributorContactID, 'line_item' => $lineItem, 'is_test' => $isTest, 'campaign_id' => CRM_Utils_Array::value('campaign_id', $paymentParams), 'contribution_page_id' => CRM_Utils_Array::value('contribution_page_id', $formValues), 'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)), 'thankyou_date' => CRM_Utils_Array::value('thankyou_date', $paymentParams), 'payment_instrument_id' => $this->_paymentProcessor['payment_instrument_id']), $financialType, TRUE, FALSE, $this->_bltID);
//create new soft-credit record, CRM-13981
if ($softParams) {
$softParams['contribution_id'] = $contribution->id;
$softParams['currency'] = $contribution->currency;
$softParams['amount'] = $contribution->total_amount;
CRM_Contribute_BAO_ContributionSoft::add($softParams);
}
$paymentParams['contactID'] = $this->_contactID;
$paymentParams['contributionID'] = $contribution->id;
$paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
$ids['contribution'] = $contribution->id;
$params['contribution_recur_id'] = $paymentParams['contributionRecurID'];
}
if ($params['total_amount'] > 0.0) {
$payment = $this->_paymentProcessor['object'];
try {
$result = $payment->doPayment($paymentParams);
$formValues = array_merge($formValues, $result);
// Assign amount to template if payment was successful.
$this->assign('amount', $params['total_amount']);
} catch (PaymentProcessorException $e) {
if (!empty($paymentParams['contributionID'])) {
CRM_Contribute_BAO_Contribution::failPayment($paymentParams['contributionID'], $this->_contactID, $e->getMessage());
}
if (!empty($paymentParams['contributionRecurID'])) {
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=add&cid={$this->_contactID}&context=&mode={$this->_mode}"));
}
}
if ($formValues['payment_status_id'] != array_search('Completed', $allContributionStatus)) {
$params['status_id'] = array_search('Pending', $allMemberStatus);
$params['skipStatusCal'] = TRUE;
// unset send-receipt option, since receipt will be sent when ipn is received.
unset($formValues['send_receipt'], $formValues['send_receipt']);
//as membership is pending set dates to null.
$memberDates = array('join_date' => 'joinDate', 'start_date' => 'startDate', 'end_date' => 'endDate');
foreach ($memberDates as $dv) {
${$dv} = NULL;
foreach ($this->_memTypeSelected as $memType) {
$membershipTypeValues[$memType][$dv] = NULL;
}
}
}
$params['receive_date'] = $now;
$params['invoice_id'] = $formValues['invoiceID'];
$params['contribution_source'] = ts('%1 Membership Signup: Credit card or direct debit (by %2)', array(1 => $membershipType, 2 => $userName));
$params['source'] = $formValues['source'] ? $formValues['source'] : $params['contribution_source'];
$params['trxn_id'] = CRM_Utils_Array::value('trxn_id', $result);
$params['payment_instrument_id'] = 1;
$params['is_test'] = $this->_mode == 'live' ? 0 : 1;
if (!empty($formValues['send_receipt'])) {
$params['receipt_date'] = $now;
} else {
$params['receipt_date'] = NULL;
}
$this->set('params', $formValues);
示例6: cleanupDBAfterPaymentFailure
/**
* Clean up DB after payment fails.
*
* This function removes related DB entries. Note that it has been agreed in principle,
* but not implemented, that contributions should be retained as 'Failed' rather than
* deleted.
*
* @todo it doesn't clean up line items.
*
* @param array $paymentParams
* @param string $message
*/
public function cleanupDBAfterPaymentFailure($paymentParams, $message)
{
// Make sure to cleanup db for recurring case.
if (!empty($paymentParams['contributionID'])) {
CRM_Core_Error::debug_log_message($message . "contact id={$this->_contactID} (deleting contribution {$paymentParams['contributionID']}");
CRM_Contribute_BAO_Contribution::deleteContribution($paymentParams['contributionID']);
}
if (!empty($paymentParams['contributionRecurID'])) {
CRM_Core_Error::debug_log_message($message . "contact id={$this->_contactID} (deleting recurring contribution {$paymentParams['contributionRecurID']}");
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
}
示例7: processCreditCard
//.........这里部分代码省略.........
$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'];
}
// 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 (!empty($paymentParams['is_recur'])) {
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($this, $this->_params, NULL, $this->_contactID, $contributionType, TRUE, FALSE, $isTest, $this->_lineItem);
$paymentParams['contributionID'] = $contribution->id;
$paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
$result = NULL;
if ($paymentParams['amount'] > 0.0) {
// force a re-get 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 (!empty($paymentParams['contributionID'])) {
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 (!empty($paymentParams['contributionRecurID'])) {
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) {
$this->_params = array_merge($this->_params, $result);
}
$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('trxn_id', $result['trxn_id']);
$this->assign('receive_date', $this->_params['receive_date']);
// result has all the stuff we need
// lets archive it to a financial transaction
if ($contributionType->is_deductible) {
$this->assign('is_deductible', TRUE);
$this->set('is_deductible', TRUE);
}
// set source if not set
if (empty($this->_params['source'])) {
示例8: processConfirm
//.........这里部分代码省略.........
$cachedParamValue = CRM_Utils_Array::value('is_recur', $paymentParams);
unset($form->_values['is_recur']);
unset($paymentParams['is_recur']);
} else {
$pending = TRUE;
}
}
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $paymentParams, NULL, $contactID, $contributionType, $pending, TRUE, $isTest, $lineItems);
// 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 ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
}
if (is_object($payment)) {
$result = $payment->doDirectPayment($paymentParams);
} else {
CRM_Core_Error::fatal($paymentObjError);
}
}
if ($component == 'membership') {
$membershipResult = array();
}
if (is_a($result, 'CRM_Core_Error')) {
//make sure to cleanup db for recurring case.
//@todo this clean up has always been controversial as many orgs prefer to see failed transactions.
// most recent discussion has been that they should be retained and this could be altered
if (!empty($paymentParams['contributionID'])) {
CRM_Contribute_BAO_Contribution::deleteContribution($paymentParams['contributionID']);
}
if (!empty($paymentParams['contributionRecurID'])) {
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
if ($component !== 'membership') {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=true&qfKey={$form->_params['qfKey']}"));
}
$membershipResult[1] = $result;
} elseif ($result || $form->_amount == 0.0 && !$form->_params['is_pay_later']) {
if ($result) {
$form->_params = array_merge($form->_params, $result);
}
$form->set('params', $form->_params);
$form->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $result));
// result has all the stuff we need
// lets archive it to a financial transaction
//@todo - this is done in 2 places - can't we just do it once straight after retrieving contribution type -
// when would this be a bad thing?
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'];
}
// check if pending was set to true by payment processor
$pending = FALSE;
if (!empty($form->_params['contribution_status_pending'])) {
$pending = TRUE;
}
if (!(!empty($paymentParams['is_recur']) && $form->_contributeMode == 'direct')) {
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $form->_params, $result, $contactID, $contributionType, $pending, TRUE, $isTest, $lineItems);
}
$form->postProcessPremium($premiumParams, $contribution);
if (is_array($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'];
}
}
$membershipResult[1] = $contribution;
}
if ($component == 'membership') {
return $membershipResult;
}
//Do not send an email if Recurring contribution is done via Direct Mode
//We will send email once the IPN is received.
if (!empty($paymentParams['is_recur']) && $form->_contributeMode == 'direct') {
return TRUE;
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
// finally send an email receipt
if ($contribution) {
$form->_values['contribution_id'] = $contribution->id;
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test, FALSE, $fieldTypes);
}
}
示例9: processConfirm
//.........这里部分代码省略.........
$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()) {
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test);
}
return $result;
} catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
// Clean up DB as appropriate.
if (!empty($paymentParams['contributionID'])) {
CRM_Contribute_BAO_Contribution::failPayment($paymentParams['contributionID'], $paymentParams['contactID'], $e->getMessage());
}
if (!empty($paymentParams['contributionRecurID'])) {
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
$result['is_payment_failure'] = TRUE;
$result['error'] = $e;
return $result;
}
}
}
// Only pay later or unpaid should reach this point, although pay later likely does not & is handled via the
// manual processor, so it's unclear what this set is for and whether the following send ever fires.
$form->set('params', $form->_params);
if ($form->_params['amount'] == 0) {
// This is kind of a back-up for pay-later $0 transactions.
// In other flows they pick up the manual processor & get dealt with above (I
// think that might be better...).
return array('payment_status_id' => 1, 'contribution' => $contribution, 'payment_processor_id' => 0);
} elseif (empty($form->_values['amount'])) {
// If the amount is not in _values[], set it
$form->_values['amount'] = $form->_params['amount'];
}
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test);
}
示例10: processConfirm
//.........这里部分代码省略.........
} elseif ($form->_contributeMode == 'express') {
if ($form->_values['is_monetary'] && $form->_amount > 0.0) {
// determine if express + recurring and direct accordingly
if ($paymentParams['is_recur'] == 1) {
if (is_object($payment)) {
$result = $payment->createRecurringPayments($paymentParams);
} else {
CRM_Core_Error::fatal($paymentObjError);
}
} else {
if (is_object($payment)) {
$result = $payment->doExpressCheckout($paymentParams);
} else {
CRM_Core_Error::fatal($paymentObjError);
}
}
}
} elseif ($form->_values['is_monetary'] && $form->_amount > 0.0) {
if (!empty($paymentParams['is_recur']) && $form->_contributeMode == 'direct') {
// For recurring contribution, create Contribution Record first.
// Contribution ID, Recurring ID and Contact ID needed
// When we get a callback from the payment processor
$paymentParams['contactID'] = $contactID;
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $paymentParams, NULL, $contactID, $contributionType, TRUE, TRUE, TRUE);
$paymentParams['contributionID'] = $contribution->id;
$paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
if ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
}
if (is_object($payment)) {
$result = $payment->doDirectPayment($paymentParams);
} else {
CRM_Core_Error::fatal($paymentObjError);
}
}
if ($component == 'membership') {
$membershipResult = array();
}
if (is_a($result, 'CRM_Core_Error')) {
//make sure to cleanup db for recurring case.
if (!empty($paymentParams['contributionID'])) {
CRM_Contribute_BAO_Contribution::deleteContribution($paymentParams['contributionID']);
}
if (!empty($paymentParams['contributionRecurID'])) {
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
if ($component !== 'membership') {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=true&qfKey={$form->_params['qfKey']}"));
}
$membershipResult[1] = $result;
} elseif ($result || $form->_amount == 0.0 && !$form->_params['is_pay_later']) {
if ($result) {
$form->_params = array_merge($form->_params, $result);
}
$form->_params['receive_date'] = $now;
$form->set('params', $form->_params);
$form->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $result));
$form->assign('receive_date', CRM_Utils_Date::mysqlToIso($form->_params['receive_date']));
// result has all the stuff we need
// lets archive it to a financial transaction
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'];
}
// check if pending was set to true by payment processor
$pending = FALSE;
if (!empty($form->_params['contribution_status_pending'])) {
$pending = TRUE;
}
if (!(!empty($paymentParams['is_recur']) && $form->_contributeMode == 'direct')) {
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $form->_params, $result, $contactID, $contributionType, TRUE, $pending, TRUE);
}
$form->postProcessPremium($premiumParams, $contribution);
$membershipResult[1] = $contribution;
}
if ($component == 'membership') {
return $membershipResult;
}
//Do not send an email if Recurring contribution is done via Direct Mode
//We will send email once the IPN is received.
if (!empty($paymentParams['is_recur']) && $form->_contributeMode == 'direct') {
return TRUE;
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
// finally send an email receipt
if ($contribution) {
$form->_values['contribution_id'] = $contribution->id;
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test, FALSE, $fieldTypes);
}
}
示例11: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
public function postProcess()
{
$session = CRM_Core_Session::singleton();
if ($this->_action & CRM_Core_Action::DELETE) {
// Delete the linked contributions
$contribution = new CRM_Contribute_DAO_Contribution();
$contribution->contribution_recur_id = $this->_id;
$contribution->find();
while ($contribution->fetch()) {
CRM_Contribute_BAO_Contribution::deleteContribution($contribution->id);
}
// Delete recurring contribution record
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($this->_id);
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactID}&selectedChild=contribute-recur"));
return NULL;
}
// get the submitted form values.
$submittedValues = $this->controller->exportValues($this->_name);
// get the required field value only.
$formValues = $submittedValues;
$ids = array();
if ($this->_contactID) {
$params['contact_id'] = $this->_contactID;
}
$params['currency'] = CRM_Contribute_Form_AbstractEditPayment::getCurrency($submittedValues);
$dates = array('start_date', 'end_date', 'cancel_date', 'next_sched_contribution_date');
foreach ($dates as $d) {
$params[$d] = CRM_Utils_Date::processDate($formValues[$d], $formValues[$d . '_time'], TRUE);
}
if (empty($this->_id)) {
$params['create_date'] = CRM_Utils_Date::processDate(date('Y-m-d'));
}
if ($this->_action & CRM_Core_Action::ADD) {
$params['next_sched_contribution_date'] = $params['start_date'];
}
$fields = array('payment_processor_id', 'processor_id', 'trxn_id', 'financial_type_id', 'amount', 'payment_instrument_id', 'frequency_interval', 'frequency_unit', 'cycle_day', 'contribution_status_id');
foreach ($fields as $f) {
$params[$f] = CRM_Utils_Array::value($f, $formValues);
}
$params['id'] = $this->_id;
// build custom data getFields array
$customFields = CRM_Core_BAO_CustomField::getFields('ContributionRecur', FALSE, FALSE, NULL, NULL, TRUE);
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($_POST, $this->_id, 'ContributionRecur');
$contributionRecur = CRM_Contribute_BAO_ContributionRecur::create($params);
// Link the recurring contribution with membership record, if selected
if ($this->_action == 1 && !empty($formValues['membership_id'])) {
civicrm_api3('Membership', 'create', array('id' => $formValues['membership_id'], 'contribution_recur_id' => $contributionRecur->id));
}
// Move the recurring record
if (isset($submittedValues['move_recurring_record']) && $submittedValues['move_recurring_record'] == 1) {
self::moveRecurringRecord($submittedValues);
}
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactID}&selectedChild=contribute-recur"));
}
开发者ID:Kajakaran,项目名称:uk.co.vedaconsulting.offlinerecurringcontributions,代码行数:60,代码来源:ContributionRecur.php
示例12: createSimpleContribution
public function createSimpleContribution($contactID, $params, $isTest, $creditInfo)
{
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
$bltID = array_search('Billing', $locationTypes);
$settings = civicrm_api3('Setting', 'get', array('domain_id' => $domainID, 'return' => "simple_donation_page"));
$donatePageID = $settings['values'][$domainID]['simple_donation_page'];
$donateConfig = $donatePage = civicrm_api3('ContributionPage', 'getsingle', array('id' => $donatePageID));
$contributionparams = array();
$isrecur = $params['recur'];
$contributionparams = array("billing_first_name" => $params['first_name'], "first_name" => $params['first_name'], "billing_middle_name" => $params['middle_name'], "middle_name" => $params['middle_name'], "billing_last_name" => $params['last_name'], "last_name" => $params['last_name'], "billing_street_address-{$bltID}" => $params['address'], "street_address" => $params['address'], "billing_city-{$bltID}" => $params['city'], "city" => $params['city'], "billing_country_id-{$bltID}" => $params['country'], "country_id" => $params['country'], "billing_state_province_id-{$bltID}" => $params['state'], "state_province_id" => $params['state'], "state_province" => CRM_Core_PseudoConstant::stateProvince($params['state']), "billing_postal_code-{$bltID}" => $params['zip'], "postal_code" => $params['zip'], "year" => "20" . substr($params['cardExpiry'], 2, 3), "month" => substr($params['cardExpiry'], 0, 2), "email" => $params['email'], "contribution_page_id" => $donatePageID, "payment_processor_id" => CRM_Utils_Array::value('payment_processor', $params), "is_test" => $isTest, "is_pay_later" => $params['is_pay_later'], "total_amount" => $params['amount'], "financial_type_id" => $donateConfig['financial_type_id'], "currencyID" => $donateConfig['currency'], "currency" => $donateConfig['currency'], "skipLineItem" => 0, "skipRecentView" => 1, 'is_email_receipt' => 1, "contact_id" => $contactID, "source" => "Online Contribution: {$donateConfig['title']}");
if ($params['is_pay_later']) {
$contributionparams["contribution_status_id"] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
$contributionparams["payment_processor_id"] = 1;
}
if (!empty($params['creditType'])) {
$contributionparams['credit_card_number'] = $creditInfo['credit_card_number'];
$contributionparams['cvv2'] = $creditInfo['cvv2'];
$contributionparams['credit_card_type'] = $creditInfo['credit_card_type'];
}
if (!empty($params['debitType'])) {
$contributionparams['bank_identification_number'] = $creditInfo['bank_identification_number'];
$contributionparams['bank_name'] = $creditInfo['bank_name'];
$contributionparams['bank_account_number'] = $creditInfo['bank_account_number'];
$contributionparams['payment_type'] = $creditInfo['payment_type'];
$contributionparams['account_holder'] = $creditInfo['account_holder'];
}
//unset the billing parameters if it is pay later mode
//to avoid creation of billing location
if ($params['is_pay_later']) {
$billingFields = array('billing_first_name', 'billing_middle_name', 'billing_last_name', "billing_street_address-{$bltID}", "billing_city-{$bltID}", "billing_state_province-{$bltID}", "billing_state_province_id-{$bltID}", "billing_postal_code-{$bltID}", "billing_country-{$bltID}", "billing_country_id-{$bltID}");
foreach ($billingFields as $value) {
unset($contributionparams[$value]);
}
}
//check for recurring contribution
if ($isrecur) {
$recurParams = array('contact_id' => $contactID);
$recurParams['amount'] = $params['amount'];
$recurParams['auto_renew'] = 1;
$recurParams['frequency_unit'] = 'month';
$recurParams['frequency_interval'] = 1;
$recurParams['financial_type_id'] = $donateConfig['financial_type_id'];
$recurParams['is_test'] = $isTest;
$recurParams['start_date'] = $recurParams['create_date'] = $recurParams['modified_date'] = date('YmdHis');
$recurParams['invoice_id'] = $recurParams['trxn_id'] = md5(uniqid(rand(), TRUE));
$recurParams['contribution_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
$recurParams['payment_processor_id'] = CRM_Utils_Array::value('payment_processor_id', $contributionparams);
$recurParams['is_email_receipt'] = 1;
//create recurring contribution record
$recurring = CRM_Contribute_BAO_ContributionRecur::add($recurParams);
$recurContriID = $recurring->id;
$contributionparams['contributionRecurID'] = $recurContriID;
//$contribution->id;
$contributionparams['contribution_recur_id'] = $recurContriID;
//$contribution->id;
}
//call transact api
try {
$result = civicrm_api3('Contribution', 'transact', $contributionparams);
} catch (CiviCRM_API3_Exception $e) {
$error = $e->getMessage();
$errorList['error'] = $error;
return $errorList;
}
if ($result['error']) {
//make sure to cleanup db for recurring case.
if ($recurContriID) {
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($recurContriID);
}
return $result['error'];
} else {
if ($result) {
$contributionID = $result['id'];
// Send receipt
// send recurring Notification email for user
if ($recurContriID) {
CRM_Contribute_BAO_ContributionPage::recurringNotify(CRM_Core_Payment::RECURRING_PAYMENT_START, $contactID, $donatePageID, $recurring);
}
civicrm_api3('contribution', 'sendconfirmation', array('id' => $contributionID) + $donateConfig);
return $result;
}
}
}
示例13: processConfirm
//.........这里部分代码省略.........
$form->_values['contribution_page_id'] = $contribution->contribution_page_id;
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test);
return;
}
}
}
} elseif ($form->_contributeMode == 'express') {
if ($form->_values['is_monetary'] && $form->_amount > 0.0) {
// determine if express + recurring and direct accordingly
if (!empty($paymentParams['is_recur']) && $paymentParams['is_recur'] == 1) {
if (is_object($payment)) {
$result = $payment->createRecurringPayments($paymentParams);
} else {
CRM_Core_Error::fatal($paymentObjError);
}
} else {
if (is_object($payment)) {
$result = $payment->doExpressCheckout($paymentParams);
} else {
CRM_Core_Error::fatal($paymentObjError);
}
}
}
} elseif ($isPaymentTransaction) {
if ($form->_contributeMode == 'direct') {
$paymentParams['contactID'] = $contactID;
// 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']);
}
}
$contribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($form, $paymentParams, NULL, $contactID, $financialType, TRUE, TRUE, $isTest, $lineItems, $form->_bltID);
// 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 ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
}
try {
$result = $payment->doPayment($paymentParams);
} catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
// Clean up DB as appropriate.
if (!empty($paymentParams['contributionID'])) {
CRM_Contribute_BAO_Contribution::failPayment($paymentParams['contributionID'], $paymentParams['contactID'], $e->getMessage());
}
if (!empty($paymentParams['contributionRecurID'])) {
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
$result['is_payment_failure'] = TRUE;
$result['error'] = $e;
}
}
if ($result || $form->_amount == 0.0 && !$form->_params['is_pay_later']) {
if ($result) {
$form->_params = array_merge($form->_params, $result);
}
$form->set('params', $form->_params);
$form->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $result));
// result has all the stuff we need
// lets archive it to a financial transaction
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
$form->postProcessPremium($premiumParams, $contribution);
if (is_array($result) && !empty($result['trxn_id'])) {
$contribution->trxn_id = $result['trxn_id'];
}
$result['contribution'] = $contribution;
}
//Do not send an email if Recurring contribution is done via Direct Mode
//We will send email once the IPN is received.
if ($form->_contributeMode == 'direct') {
return $result;
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
// finally send an email receipt
if ($contribution) {
$form->_values['contribution_id'] = $contribution->id;
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test, FALSE, $fieldTypes);
}
}
示例14: postProcess
//.........这里部分代码省略.........
$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) {
$this->_params = array_merge($this->_params, $result);
}
$this->_params['receive_date'] = $now;
if (CRM_Utils_Array::value('is_email_receipt', $this->_params)) {
$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('trxn_id', $result['trxn_id']);
$this->assign('receive_date', $this->_params['receive_date']);
// result has all the stuff we need
// lets archive it to a financial transaction
if ($contributionType->is_deductible) {
$this->assign('is_deductible', TRUE);
$this->set('is_deductible', TRUE);
}
// set source if not set
if (empty($this->_params['source'])) {
示例15: postProcess
//.........这里部分代码省略.........
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, true);
// CRM-7137 -for recurring membership,
// we do need contribution and recuring records.
$result = null;
if (CRM_Utils_Array::value('is_recur', $paymentParams)) {
$allStatus = CRM_Member_PseudoConstant::membershipStatus();
require_once 'CRM/Contribute/Form/Contribution/Confirm.php';
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($this, $this->_params, $result, $contactID, $params['contribution_type_id'], false, true, false);
$paymentParams['contactID'] = $contactID;
$paymentParams['contributionID'] = $contribution->id;
$paymentParams['contributionTypeID'] = $contribution->contribution_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
$ids['contribution'] = $contribution->id;
$params['contribution_recur_id'] = $paymentParams['contributionRecurID'];
$params['status_id'] = array_search('Pending', $allStatus);
$params['skipStatusCal'] = true;
//as membership is pending set dates to null.
$memberDates = array('join_date' => 'joinDate', 'start_date' => 'startDate', 'end_date' => 'endDate');
foreach ($memberDates as $dp => $dv) {
$params[$dp] = ${$dv} = null;
}
}
$payment =& CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
$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)) {
require_once 'CRM/Contribute/BAO/Contribution.php';
CRM_Contribute_BAO_Contribution::deleteContribution($paymentParams['contributionID']);
}
if (CRM_Utils_Array::value('contributionRecurID', $paymentParams)) {
require_once 'CRM/Contribute/BAO/ContributionRecur.php';
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=add&cid={$this->_contactID}&context=&mode={$this->_mode}"));
}
if ($result) {
$this->_params = array_merge($this->_params, $result);
}
$params['contribution_status_id'] = CRM_Utils_Array::value('is_recur', $paymentParams) ? 2 : 1;
$params['receive_date'] = $now;
$params['invoice_id'] = $this->_params['invoiceID'];
$params['contribution_source'] = ts('Online Membership: Admin Interface');
$params['source'] = $formValues['source'] ? $formValues['source'] : $params['contribution_source'];
$params['trxn_id'] = $result['trxn_id'];
$params['payment_instrument_id'] = 1;
$params['is_test'] = $this->_mode == 'live' ? 0 : 1;
if (CRM_Utils_Array::value('send_receipt', $this->_params)) {
$params['receipt_date'] = $now;
} else {
$params['receipt_date'] = null;
}
$this->set('params', $this->_params);
$this->assign('trxn_id', $result['trxn_id']);
$this->assign('receive_date', CRM_Utils_Date::mysqlToIso($params['receive_date']));
// required for creating membership for related contacts
$params['action'] = $this->_action;
//create membership record.
$membership =& CRM_Member_BAO_Membership::create($params, $ids);
if (!CRM_Utils_Array::value('is_recur', $params)) {
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->trxn_id = $result['trxn_id'];
if ($contribution->find(true)) {
// next create the transaction record