本文整理汇总了PHP中CRM_Core_Error::getMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Error::getMessages方法的具体用法?PHP CRM_Core_Error::getMessages怎么用?PHP CRM_Core_Error::getMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Error
的用法示例。
在下文中一共展示了CRM_Core_Error::getMessages方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processFormContribution
/**
* Process the contribution.
*
* @param CRM_Core_Form $form
* @param array $params
* @param array $result
* @param array $contributionParams
* Parameters to be passed to contribution create action.
* This differs from params in that we are currently adding params to it and 1) ensuring they are being
* passed consistently & 2) documenting them here.
* - contact_id
* - line_item
* - is_test
* - campaign_id
* - contribution_page_id
* - source
* - payment_type_id
* - thankyou_date (not all forms will set this)
*
* @param CRM_Financial_DAO_FinancialType $financialType
* @param bool $online
* Is the form a front end form? If so set a bunch of unpredictable things that should be passed in from the form.
*
* @param int $billingLocationID
* ID of billing location type.
* @param bool $isRecur
* Is this recurring?
*
* @return \CRM_Contribute_DAO_Contribution
* @throws \Exception
*/
public static function processFormContribution(&$form, $params, $result, $contributionParams, $financialType, $online, $billingLocationID, $isRecur)
{
$transaction = new CRM_Core_Transaction();
$contactID = $contributionParams['contact_id'];
$isEmailReceipt = !empty($form->_values['is_email_receipt']);
$isSeparateMembershipPayment = empty($params['separate_membership_payment']) ? FALSE : TRUE;
$pledgeID = !empty($params['pledge_id']) ? $params['pledge_id'] : CRM_Utils_Array::value('pledge_id', $form->_values);
if (!$isSeparateMembershipPayment && !empty($form->_values['pledge_block_id']) && (!empty($params['is_pledge']) || $pledgeID)) {
$isPledge = TRUE;
} else {
$isPledge = FALSE;
}
// add these values for the recurringContrib function ,CRM-10188
$params['financial_type_id'] = $financialType->id;
$contributionParams['address_id'] = CRM_Contribute_BAO_Contribution::createAddress($params, $billingLocationID);
//@todo - this is being set from the form to resolve CRM-10188 - an
// eNotice caused by it not being set @ the front end
// however, we then get it being over-written with null for backend contributions
// a better fix would be to set the values in the respective forms rather than require
// a function being shared by two forms to deal with their respective values
// moving it to the BAO & not taking the $form as a param would make sense here.
if (!isset($params['is_email_receipt']) && $isEmailReceipt) {
$params['is_email_receipt'] = $isEmailReceipt;
}
$params['is_recur'] = $isRecur;
$recurringContributionID = self::processRecurringContribution($form, $params, $contactID, $financialType);
$nonDeductibleAmount = self::getNonDeductibleAmount($params, $financialType, $online);
$now = date('YmdHis');
$receiptDate = CRM_Utils_Array::value('receipt_date', $params);
if ($isEmailReceipt) {
$receiptDate = $now;
}
if (isset($params['amount'])) {
$contributionParams = array_merge(self::getContributionParams($params, $financialType->id, $nonDeductibleAmount, TRUE, $result, $receiptDate, $recurringContributionID), $contributionParams);
$contribution = CRM_Contribute_BAO_Contribution::add($contributionParams);
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
if ($invoicing) {
$dataArray = array();
// @todo - interrogate the line items passed in on the params array.
// No reason to assume line items will be set on the form.
foreach ($form->_lineItem as $lineItemKey => $lineItemValue) {
foreach ($lineItemValue as $key => $value) {
if (isset($value['tax_amount']) && isset($value['tax_rate'])) {
if (isset($dataArray[$value['tax_rate']])) {
$dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + CRM_Utils_Array::value('tax_amount', $value);
} else {
$dataArray[$value['tax_rate']] = CRM_Utils_Array::value('tax_amount', $value);
}
}
}
}
$smarty = CRM_Core_Smarty::singleton();
$smarty->assign('dataArray', $dataArray);
$smarty->assign('totalTaxAmount', $params['tax_amount']);
}
if (is_a($contribution, 'CRM_Core_Error')) {
$message = CRM_Core_Error::getMessages($contribution);
CRM_Core_Error::fatal($message);
}
// lets store it in the form variable so postProcess hook can get to this and use it
$form->_contributionID = $contribution->id;
}
// process soft credit / pcp params first
CRM_Contribute_BAO_ContributionSoft::formatSoftCreditParams($params, $form);
//CRM-13981, processing honor contact into soft-credit contribution
CRM_Contribute_BAO_ContributionSoft::processSoftContribution($params, $contribution);
//handle pledge stuff.
if ($isPledge) {
//.........这里部分代码省略.........
示例2: postProcessMembership
/**
* Process the Memberships
*
* @param array $membershipParams array of membership fields
* @param int $contactID contact id
* @param object $form form object
*
* @return void
* @access public
*/
public function postProcessMembership($membershipParams, $contactID, &$form, &$premiumParams)
{
$tempParams = $membershipParams;
$paymentDone = false;
$result = null;
$isTest = CRM_Utils_Array::value('is_test', $membershipParams, false);
$form->assign('membership_assign', true);
$form->set('membershipTypeID', $membershipParams['selectMembership']);
require_once 'CRM/Member/BAO/MembershipType.php';
require_once 'CRM/Member/BAO/Membership.php';
$membershipTypeID = $membershipParams['selectMembership'];
$membershipDetails = self::buildMembershipTypeValues($form, $membershipTypeID);
$form->assign('membership_name', $membershipDetails['name']);
$minimumFee = CRM_Utils_Array::value('minimum_fee', $membershipDetails);
$contributionTypeId = null;
if ($form->_values['amount_block_is_active']) {
$contributionTypeId = $form->_values['contribution_type_id'];
} else {
$paymentDone = true;
$params['amount'] = $minimumFee;
$contributionTypeId = $membershipDetails['contribution_type_id'];
}
//amount must be greater than zero for
//adding contribution record to contribution table.
//this condition is arises when separate membership payment is
//enable and contribution amount is not selected. fix for CRM-3010
require_once 'CRM/Contribute/BAO/Contribution/Utils.php';
if ($form->_amount > 0.0) {
$result = CRM_Contribute_BAO_Contribution_Utils::processConfirm($form, $membershipParams, $premiumParams, $contactID, $contributionTypeId, 'membership');
} else {
// create the CMS contact here since we normally do this under processConfirm
CRM_Contribute_BAO_Contribution_Utils::createCMSUser($membershipParams, $membershipParams['cms_contactID'], 'email-' . $form->_bltID);
}
$errors = array();
if (is_a($result[1], 'CRM_Core_Error')) {
$errors[1] = CRM_Core_Error::getMessages($result[1]);
} else {
$contribution[1] = $result[1];
}
$memBlockDetails = CRM_Member_BAO_Membership::getMembershipBlock($form->_id);
if ($memBlockDetails['is_separate_payment'] && !$paymentDone) {
require_once 'CRM/Contribute/DAO/ContributionType.php';
$contributionType = new CRM_Contribute_DAO_ContributionType();
$contributionType->id = $membershipDetails['contribution_type_id'];
if (!$contributionType->find(true)) {
CRM_Core_Error::fatal("Could not find a system table");
}
$tempParams['amount'] = $minimumFee;
$invoiceID = md5(uniqid(rand(), true));
$tempParams['invoiceID'] = $invoiceID;
//we don't allow recurring membership.CRM-3781.
if (CRM_Utils_Array::value('is_recur', $tempParams)) {
$tempParams['is_recur'] = 0;
}
$result = null;
if ($form->_values['is_monetary'] && !$form->_params['is_pay_later']) {
require_once 'CRM/Core/Payment.php';
$payment =& CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
if ($form->_contributeMode == 'express') {
$result =& $payment->doExpressCheckout($tempParams);
} else {
$result =& $payment->doDirectPayment($tempParams);
}
}
if (is_a($result, 'CRM_Core_Error')) {
$errors[2] = CRM_Core_Error::getMessages($result);
} else {
//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 dont need to create the user twice, so lets disable cms_create_account
// irrespective of the value, CRM-2888
$tempParams['cms_create_account'] = 0;
$pending = $form->_params['is_pay_later'] ? true : false;
//set this variable as we are not creating pledge for
//separate membership payment contribution.
//so for differentiating membership contributon from
//main contribution.
$form->_params['separate_membership_payment'] = 1;
$contribution[2] = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $tempParams, $result, $contactID, $contributionType, false, $pending);
//.........这里部分代码省略.........
示例3: processContribution
//.........这里部分代码省略.........
}
$ids = array();
if (isset($contribParams['invoice_id'])) {
$contribID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contribParams['invoice_id'], 'id', 'invoice_id');
if (isset($contribID)) {
$ids['contribution'] = $contribID;
$contribParams['id'] = $contribID;
}
}
//create an contribution address
if ($form->_contributeMode != 'notify' && empty($params['is_pay_later']) && !empty($form->_values['is_monetary'])) {
$contribParams['address_id'] = CRM_Contribute_BAO_Contribution::createAddress($params, $form->_bltID);
}
// CRM-4038: for non-en_US locales, CRM_Contribute_BAO_Contribution::add() expects localised amounts
$contribParams['non_deductible_amount'] = trim(CRM_Utils_Money::format($contribParams['non_deductible_amount'], ' '));
$contribParams['total_amount'] = trim(CRM_Utils_Money::format($contribParams['total_amount'], ' '));
// Prepare soft contribution due to pcp or Submit Credit / Debit Card Contribution by admin.
if (!empty($params['pcp_made_through_id']) || !empty($params['soft_credit_to'])) {
// if its due to pcp
if (!empty($params['pcp_made_through_id'])) {
$contribSoftContactId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $params['pcp_made_through_id'], 'contact_id');
} else {
$contribSoftContactId = CRM_Utils_Array::value('soft_credit_to', $params);
}
// Pass these details onto with the contribution to make them
// available at hook_post_process, CRM-8908
$contribParams['soft_credit_to'] = $params['soft_credit_to'] = $contribSoftContactId;
}
if (isset($params['amount'])) {
$contribParams['line_item'] = $form->_lineItem;
//add contribution record
$contribution = CRM_Contribute_BAO_Contribution::add($contribParams, $ids);
if (is_a($contribution, 'CRM_Core_Error')) {
$message = CRM_Core_Error::getMessages($contribution);
CRM_Core_Error::fatal($message);
}
// lets store it in the form variable so postProcess hook can get to this and use it
$form->_contributionID = $contribution->id;
}
//CRM-13981, processing honor contact into soft-credit contribution
CRM_Contact_Form_ProfileContact::postProcess($form);
// process soft credit / pcp pages
CRM_Contribute_Form_Contribution_Confirm::processPcpSoft($params, $contribution);
//handle pledge stuff.
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'];
示例4: doPayment
/**
* Process payment - this function wraps around both doTransferPayment and doDirectPayment.
*
* The function ensures an exception is thrown & moves some of this logic out of the form layer and makes the forms
* more agnostic.
*
* Payment processors should set payment_status_id. This function adds some historical defaults ie. the
* assumption that if a 'doDirectPayment' processors comes back it completed the transaction & in fact
* doTransferCheckout would not traditionally come back.
*
* doDirectPayment does not do an immediate payment for Authorize.net or Paypal so the default is assumed
* to be Pending.
*
* Once this function is fully rolled out then it will be preferred for processors to throw exceptions than to
* return Error objects
*
* @param array $params
*
* @param string $component
*
* @return array
* Result array
*
* @throws \Civi\Payment\Exception\PaymentProcessorException
*/
public function doPayment(&$params, $component = 'contribute')
{
$this->_component = $component;
$statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id');
if ($this->_paymentProcessor['billing_mode'] == 4) {
$result = $this->doTransferCheckout($params, $component);
if (is_array($result) && !isset($result['payment_status_id'])) {
$result['payment_status_id'] = array_search('Pending', $statuses);
}
} else {
$result = $this->doDirectPayment($params, $component);
if (is_array($result) && !isset($result['payment_status_id'])) {
if (!empty($params['is_recur'])) {
// See comment block.
$result['payment_status_id'] = array_search('Pending', $statuses);
} else {
$result['payment_status_id'] = array_search('Completed', $statuses);
}
}
}
if (is_a($result, 'CRM_Core_Error')) {
throw new PaymentProcessorException(CRM_Core_Error::getMessages($result));
}
return $result;
}
示例5: doPayment
/**
* Process payment - this function wraps around both doTransferPayment and doDirectPayment.
*
* The function ensures an exception is thrown & moves some of this logic out of the form layer and makes the forms
* more agnostic.
*
* @param array $params
*
* @param $component
*
* @return array
* (modified)
* @throws CRM_Core_Exception
*/
public function doPayment(&$params, $component = 'contribute')
{
if ($this->_paymentProcessor['billing_mode'] == 4) {
$result = $this->doTransferCheckout($params, $component);
} else {
$result = $this->doDirectPayment($params, $component);
}
if (is_a($result, 'CRM_Core_Error')) {
throw new CRM_Core_Exception(CRM_Core_Error::getMessages($result));
}
//CRM-15767 - Submit Credit Card Contribution not being saved
return $result;
}
示例6: doExpressCheckout
/**
* Do the express checkout at paypal.
*
* Check PayPal documentation for more information
*
* @param array $params
*
* @return array
* The result in an nice formatted array.
*
* @throws \Civi\Payment\Exception\PaymentProcessorException
*/
public function doExpressCheckout(&$params)
{
$statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id');
if (!empty($params['is_recur'])) {
return $this->createRecurringPayments($params);
}
$args = array();
$this->initialize($args, 'DoExpressCheckoutPayment');
$args['token'] = $params['token'];
$args['paymentAction'] = 'Sale';
$args['amt'] = $params['amount'];
$args['currencyCode'] = $params['currencyID'];
$args['payerID'] = $params['payer_id'];
$args['invnum'] = $params['invoiceID'];
$args['returnURL'] = $this->getReturnSuccessUrl($params['qfKey']);
$args['cancelURL'] = $this->getCancelUrl($params['qfKey'], NULL);
$args['desc'] = $params['description'];
// add CiviCRM BN code
$args['BUTTONSOURCE'] = 'CiviCRM_SP';
$result = $this->invokeAPI($args);
if (is_a($result, 'CRM_Core_Error')) {
throw new PaymentProcessorException(CRM_Core_Error::getMessages($result));
}
/* Success */
$params['trxn_id'] = $result['transactionid'];
$params['gross_amount'] = $result['amt'];
$params['fee_amount'] = $result['feeamt'];
$params['net_amount'] = CRM_Utils_Array::value('settleamt', $result);
if ($params['net_amount'] == 0 && $params['fee_amount'] != 0) {
$params['net_amount'] = number_format($params['gross_amount'] - $params['fee_amount'], 2);
}
$params['payment_status'] = $result['paymentstatus'];
$params['pending_reason'] = $result['pendingreason'];
if (!empty($params['is_recur'])) {
// See comment block.
$params['payment_status_id'] = array_search('Pending', $statuses);
} else {
$params['payment_status_id'] = array_search('Completed', $statuses);
}
return $params;
}
示例7: 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;
}
示例8: postProcessMembership
/**
* Process the Memberships
*
* @param array $membershipParams array of membership fields
* @param int $contactID contact id
* @param object $form form object
*
* @return void
* @access public
*/
public static function postProcessMembership($membershipParams, $contactID, &$form, &$premiumParams, $customFieldsFormatted = NULL, $includeFieldTypes = NULL)
{
$tempParams = $membershipParams;
$paymentDone = FALSE;
$result = NULL;
$isTest = CRM_Utils_Array::value('is_test', $membershipParams, FALSE);
$form->assign('membership_assign', TRUE);
$form->set('membershipTypeID', $membershipParams['selectMembership']);
$singleMembershipTypeID = $membershipTypeID = $membershipParams['selectMembership'];
if (is_array($membershipTypeID) && count($membershipTypeID) == 1) {
$singleMembershipTypeID = $membershipTypeID[0];
}
$membershipDetails = self::buildMembershipTypeValues($form, $singleMembershipTypeID);
$form->assign('membership_name', CRM_Utils_Array::value('name', $membershipDetails));
$minimumFee = CRM_Utils_Array::value('minimum_fee', $membershipDetails);
$contributionTypeId = NULL;
if ($form->_values['amount_block_is_active']) {
$contributionTypeId = $form->_values['financial_type_id'];
} else {
$paymentDone = TRUE;
$params['amount'] = $minimumFee;
$contributionTypeId = CRM_Utils_Array::value('financial_type_id', $membershipDetails);
if (!$contributionTypeId) {
$contributionTypeId = CRM_Utils_Array::value('financial_type_id', $membershipParams);
}
}
//amount must be greater than zero for
//adding contribution record to contribution table.
//this condition arises when separate membership payment is
//enabled and contribution amount is not selected. fix for CRM-3010
if ($form->_amount > 0.0 && $membershipParams['amount']) {
$result = CRM_Contribute_BAO_Contribution_Utils::processConfirm($form, $membershipParams, $premiumParams, $contactID, $contributionTypeId, 'membership');
} else {
// we need to explicitly create a CMS user in case of free memberships
// since the below has already been done under processConfirm for paid memberships
CRM_Contribute_BAO_Contribution_Utils::createCMSUser($membershipParams, $membershipParams['cms_contactID'], 'email-' . $form->_bltID);
}
$errors = array();
if (is_a($result[1], 'CRM_Core_Error')) {
$errors[1] = CRM_Core_Error::getMessages($result[1]);
} elseif (CRM_Utils_Array::value(1, $result)) {
// Save the contribution ID so that I can be used in email receipts
// For example, if you need to generate a tax receipt for the donation only.
$form->_values['contribution_other_id'] = $result[1]->id;
$contribution[1] = $result[1];
}
$memBlockDetails = CRM_Member_BAO_Membership::getMembershipBlock($form->_id);
if (CRM_Utils_Array::value('is_separate_payment', $memBlockDetails) && !$paymentDone) {
$form->_lineItem = $form->_memLineItem;
$contributionType = new CRM_Financial_DAO_FinancialType();
$contributionType->id = CRM_Utils_Array::value('financial_type_id', $membershipDetails);
if (!$contributionType->find(TRUE)) {
CRM_Core_Error::fatal(ts("Could not find a system table"));
}
$tempParams['amount'] = $minimumFee;
$invoiceID = md5(uniqid(rand(), TRUE));
$tempParams['invoiceID'] = $invoiceID;
//we don't allow recurring membership.CRM-3781.
if (CRM_Utils_Array::value('is_recur', $tempParams)) {
$tempParams['is_recur'] = 0;
}
$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);
} else {
$result =& $payment->doDirectPayment($tempParams);
}
}
if (is_a($result, 'CRM_Core_Error')) {
$errors[2] = CRM_Core_Error::getMessages($result);
} else {
//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 dont need to create the user twice, so lets disable cms_create_account
// irrespective of the value, CRM-2888
$tempParams['cms_create_account'] = 0;
$pending = $form->_params['is_pay_later'] ? CRM_Utils_Array::value('minimum_fee', $membershipDetails, 0) > 0.0 ? TRUE : FALSE : FALSE;
//.........这里部分代码省略.........
示例9: processCreditCard
//.........这里部分代码省略.........
// add some financial type details to the params list
// if folks need to use it
$paymentParams['contributionType_name'] = $this->_params['contributionType_name'] = $contributionType->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'];
}
// 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) {
示例10: doPayment
/**
* Process payment - this function wraps around both doTransferPayment and doDirectPayment.
*
* The function ensures an exception is thrown & moves some of this logic out of the form layer and makes the forms
* more agnostic.
*
* Payment processors should set payment_status_id. This function adds some historical defaults ie. the
* assumption that if a 'doDirectPayment' processors comes back it completed the transaction & in fact
* doTransferCheckout would not traditionally come back.
*
* doDirectPayment does not do an immediate payment for Authorize.net or Paypal so the default is assumed
* to be Pending.
*
* Once this function is fully rolled out then it will be preferred for processors to throw exceptions than to
* return Error objects
*
* @param array $params
*
* @param string $component
*
* @return array
* Result array
*
* @throws \Civi\Payment\Exception\PaymentProcessorException
*/
public function doPayment(&$params, $component = 'contribute')
{
$this->_component = $component;
$statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id');
// If we have a $0 amount, skip call to processor and set payment_status to Completed.
// Conceivably a processor might override this - perhaps for setting up a token - but we don't
// have an example of that at the mome.
if ($params['amount'] == 0) {
$result['payment_status_id'] = array_search('Completed', $statuses);
return $result;
}
if ($this->_paymentProcessor['billing_mode'] == 4) {
$result = $this->doTransferCheckout($params, $component);
if (is_array($result) && !isset($result['payment_status_id'])) {
$result['payment_status_id'] = array_search('Pending', $statuses);
}
} else {
$result = $this->doDirectPayment($params, $component);
if (is_array($result) && !isset($result['payment_status_id'])) {
if (!empty($params['is_recur'])) {
// See comment block.
$result['payment_status_id'] = array_search('Pending', $statuses);
} else {
$result['payment_status_id'] = array_search('Completed', $statuses);
}
}
}
if (is_a($result, 'CRM_Core_Error')) {
throw new PaymentProcessorException(CRM_Core_Error::getMessages($result));
}
return $result;
}
示例11: processFormContribution
//.........这里部分代码省略.........
// if its due to pcp
if (!empty($params['pcp_made_through_id'])) {
$contribSoftContactId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $params['pcp_made_through_id'], 'contact_id');
} else {
$contribSoftContactId = CRM_Utils_Array::value('soft_credit_to', $params);
}
// Pass these details onto with the contribution to make them
// available at hook_post_process, CRM-8908
$params['soft_credit_to'] = $contribSoftContactId;
}
if (isset($params['amount'])) {
$contribParams = self::getContributionParams($params, $contactID, $financialType->id, $online, $contributionPageId, $nonDeductibleAmount, $campaignId, $isMonetary, $pending, $result, $receiptDate, $recurringContributionID, $isTest, $addressID, $contribSoftContactId, $lineItems);
$contribution = CRM_Contribute_BAO_Contribution::add($contribParams);
$invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
if ($invoicing) {
$dataArray = array();
foreach ($form->_lineItem as $lineItemKey => $lineItemValue) {
foreach ($lineItemValue as $key => $value) {
if (isset($value['tax_amount']) && isset($value['tax_rate'])) {
if (isset($dataArray[$value['tax_rate']])) {
$dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + CRM_Utils_Array::value('tax_amount', $value);
} else {
$dataArray[$value['tax_rate']] = CRM_Utils_Array::value('tax_amount', $value);
}
}
}
}
$smarty = CRM_Core_Smarty::singleton();
$smarty->assign('dataArray', $dataArray);
$smarty->assign('totalTaxAmount', $params['tax_amount']);
}
if (is_a($contribution, 'CRM_Core_Error')) {
$message = CRM_Core_Error::getMessages($contribution);
CRM_Core_Error::fatal($message);
}
// lets store it in the form variable so postProcess hook can get to this and use it
$form->_contributionID = $contribution->id;
}
//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 ($isPledge) {
if ($pledgeID) {
//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($pledgeID);
} 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'];
示例12: postProcess
//.........这里部分代码省略.........
$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) {
$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) {