本文整理汇总了PHP中CRM_Contribute_Form_Contribution_Confirm::processContribution方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_Form_Contribution_Confirm::processContribution方法的具体用法?PHP CRM_Contribute_Form_Contribution_Confirm::processContribution怎么用?PHP CRM_Contribute_Form_Contribution_Confirm::processContribution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_Form_Contribution_Confirm
的用法示例。
在下文中一共展示了CRM_Contribute_Form_Contribution_Confirm::processContribution方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processConfirm
/**
* Function to process payment after confirmation
*
* @param object $form form object
* @param array $paymentParams array with payment related key
* value pairs
* @param array $premiumParams array with premium related key
* value pairs
* @param int $contactID contact id
* @param int $contributionTypeId contribution type id
* @param int $component component id
*
* @return array associated array
*
* @static
* @access public
*/
static function processConfirm(&$form, &$paymentParams, &$premiumParams, $contactID, $contributionTypeId, $component = 'contribution')
{
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::mapParams($form->_bltID, $form->_params, $paymentParams, true);
require_once 'CRM/Contribute/DAO/ContributionType.php';
$contributionType = new CRM_Contribute_DAO_ContributionType();
if (isset($paymentParams['contribution_type'])) {
$contributionType->id = $paymentParams['contribution_type'];
} else {
if (CRM_Utils_Array::value('pledge_id', $form->_values)) {
$contributionType->id = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge', $form->_values['pledge_id'], 'contribution_type_id');
} else {
$contributionType->id = $contributionTypeId;
}
}
if (!$contributionType->find(true)) {
CRM_Core_Error::fatal('Could not find a system table');
}
// add some contribution type details to the params list
// if folks need to use it
$paymentParams['contributionType_name'] = $form->_params['contributionType_name'] = $contributionType->name;
$paymentParams['contributionType_accounting_code'] = $form->_params['contributionType_accounting_code'] = $contributionType->accounting_code;
$paymentParams['contributionPageID'] = $form->_params['contributionPageID'] = $form->_values['id'];
if ($form->_values['is_monetary'] && $form->_amount > 0.0 && is_array($form->_paymentProcessor)) {
require_once 'CRM/Core/Payment.php';
$payment =& CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
}
//fix for CRM-2062
$now = date('YmdHis');
$result = null;
if ($form->_contributeMode == 'notify' || $form->_params['is_pay_later']) {
// this is not going to come back, i.e. we fill in the other details
// when we get a callback from the payment processor
// also add the contact ID and contribution ID to the params list
$paymentParams['contactID'] = $form->_params['contactID'] = $contactID;
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $paymentParams, null, $contactID, $contributionType, true, true, true);
$form->_params['contributionID'] = $contribution->id;
$form->_params['contributionTypeID'] = $contributionType->id;
$form->_params['item_name'] = $form->_params['description'];
$form->_params['receive_date'] = $now;
if ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
$form->_params['contributionRecurID'] = $contribution->contribution_recur_id;
}
$form->set('params', $form->_params);
$form->postProcessPremium($premiumParams, $contribution);
if ($form->_values['is_monetary'] && $form->_amount > 0.0) {
// add qfKey so we can send to paypal
$form->_params['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
$membershipResult = array(1 => $contribution);
return $membershipResult;
} else {
if (!$form->_params['is_pay_later']) {
$result =& $payment->doTransferCheckout($form->_params, 'contribute');
} else {
// follow similar flow as IPN
// send the receipt mail
$form->set('params', $form->_params);
if ($contributionType->is_deductible) {
$form->assign('is_deductible', true);
$form->set('is_deductible', true);
}
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
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 {
//.........这里部分代码省略.........
示例2: postProcess
//.........这里部分代码省略.........
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $params['total_amount'];
$this->_params['currencyID'] = $config->defaultCurrency;
$this->_params['description'] = ts('Office Credit Card Membership Signup Contribution');
$this->_params['payment_action'] = 'Sale';
$this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
$this->_params['financial_type_id'] = $params['financial_type_id'];
// at this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
$paymentParams['contactID'] = $this->_contributorContactID;
//CRM-10377 if payment is by an alternate contact then we need to set that person
// as the contact in the payment params
if ($this->_contributorContactID != $this->_contactID) {
if (!empty($this->_params['soft_credit_type_id'])) {
$softParams['contact_id'] = $params['contact_id'];
$softParams['soft_credit_type_id'] = $this->_params['soft_credit_type_id'];
}
}
if (!empty($this->_params['send_receipt'])) {
$paymentParams['email'] = $this->_contributorEmail;
}
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 (!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);
示例3: processCreditCard
//.........这里部分代码省略.........
//Add common data to formatted params
CRM_Contribute_Form_AdditionalInfo::postProcessCommon($params, $this->_params, $this);
if (empty($this->_params['invoice_id'])) {
$this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
} else {
$this->_params['invoiceID'] = $this->_params['invoice_id'];
}
// At this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
$paymentParams['contactID'] = $this->_contactID;
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, TRUE);
$contributionType = new CRM_Financial_DAO_FinancialType();
$contributionType->id = $params['financial_type_id'];
// 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 = array();
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);
try {
$result = $payment->doPayment($paymentParams, 'contribute');
} catch (CRM_Core_Exception $e) {
$message = ts("Payment Processor Error message") . $e->getMessage();
$this->cleanupDBAfterPaymentFailure($paymentParams, $message);
// 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::statusBounce($message, $urlParams, ts('Payment Processor Error'));
}
}
$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);
}
示例4: 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);
//.........这里部分代码省略.........
示例5: postProcessMembership
//.........这里部分代码省略.........
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;
//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, TRUE, $pending);
}
}
$index = CRM_Utils_Array::value('is_separate_payment', $memBlockDetails) ? 2 : 1;
if (!CRM_Utils_Array::value($index, $errors)) {
if (isset($membershipParams['onbehalf']) && CRM_Utils_Array::value('member_campaign_id', $membershipParams['onbehalf'])) {
$form->_params['campaign_id'] = $membershipParams['onbehalf']['member_campaign_id'];
}
if (is_array($membershipTypeID)) {
$typesTerms = CRM_Utils_Array::value('types_terms', $membershipParams, array());
$createdMemberships = array();
foreach ($membershipTypeID as $memType) {
$numTerms = CRM_Utils_Array::value($memType, $typesTerms, 1);
$membership = self::renewMembership($contactID, $memType, $isTest, $form, NULL, CRM_Utils_Array::value('cms_contactID', $membershipParams), $customFieldsFormatted, CRM_Utils_Array::value($memType, $typesTerms, 1));
$createdMemberships[$memType] = $membership;
if (isset($contribution[$index])) {
//insert payment record
$dao = new CRM_Member_DAO_MembershipPayment();
$dao->membership_id = $membership->id;
$dao->contribution_id = $contribution[$index]->id;
//Fixed for avoiding duplicate entry error when user goes
//back and forward during payment mode is notify
if (!$dao->find(TRUE)) {
CRM_Utils_Hook::pre('create', 'MembershipPayment', NULL, $dao);
$dao->save();
CRM_Utils_Hook::post('create', 'MembershipPayment', $dao->id, $dao);
}
}
}
if ($form->_priceSetId && !empty($form->_useForMember) && !empty($form->_lineItem)) {
foreach ($form->_lineItem[$form->_priceSetId] as &$priceFieldOp) {
if (CRM_Utils_Array::value('membership_type_id', $priceFieldOp) && isset($createdMemberships[$priceFieldOp['membership_type_id']])) {
$membershipOb = $createdMemberships[$priceFieldOp['membership_type_id']];
示例6: 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;
}
示例7: processConfirm
/**
* Process payment after confirmation.
*
* @param CRM_Core_Form $form
* Form object.
* @param array $paymentParams
* Array with payment related key.
* value pairs
* @param array $premiumParams
* Array with premium related key.
* value pairs
* @param int $contactID
* Contact id.
* @param int $contributionTypeId
* Financial type id.
* @param int|string $component component id
* @param array $fieldTypes
* Presumably relates to custom field types - used when building data for sendMail.
* @param $isTest
* @param $isPayLater
*
* @throws CRM_Core_Exception
* @throws Exception
* @return array
* associated array
*
*/
public static function processConfirm(&$form, &$paymentParams, &$premiumParams, $contactID, $contributionTypeId, $component = 'contribution', $fieldTypes = NULL, $isTest, $isPayLater)
{
CRM_Core_Payment_Form::mapParams($form->_bltID, $form->_params, $paymentParams, TRUE);
$lineItems = $form->_lineItem;
$isPaymentTransaction = self::isPaymentTransaction($form);
$contributionType = new CRM_Financial_DAO_FinancialType();
$contributionType->id = $contributionTypeId;
if (!$contributionType->find(TRUE)) {
//@todo - surely this check was part of the 4.3 upgrade & can go now?
CRM_Core_Error::fatal('Could not find a system table');
}
// add some financial type details to the params list
// if folks need to use it
//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'] = $contributionType->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'];
$payment = NULL;
$paymentObjError = ts('The system did not record payment details for this payment and so could not process the transaction. Please report this error to the site administrator.');
if ($isPaymentTransaction) {
$payment = CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
}
//fix for CRM-2062
//fix for CRM-16317
$now = $form->_params['receive_date'] = date('YmdHis');
$form->assign('receive_date', CRM_Utils_Date::mysqlToIso($form->_params['receive_date']));
$result = NULL;
if ($form->_contributeMode == 'notify' || $isPayLater) {
// this is not going to come back, i.e. we fill in the other details
// when we get a callback from the payment processor
// also add the contact ID and contribution ID to the params list
$paymentParams['contactID'] = $form->_params['contactID'] = $contactID;
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $paymentParams, NULL, $contactID, $contributionType, TRUE, TRUE, $isTest, $lineItems);
if ($contribution) {
$form->_params['contributionID'] = $contribution->id;
}
$form->_params['contributionTypeID'] = $contributionTypeId;
$form->_params['item_name'] = $form->_params['description'];
if ($contribution && $form->_values['is_recur'] && $contribution->contribution_recur_id) {
$form->_params['contributionRecurID'] = $contribution->contribution_recur_id;
}
$form->set('params', $form->_params);
$form->postProcessPremium($premiumParams, $contribution);
if ($isPaymentTransaction) {
// add qfKey so we can send to paypal
$form->_params['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
$membershipResult = array(1 => $contribution);
return $membershipResult;
} else {
if (!$isPayLater) {
if (is_object($payment)) {
// call postProcess hook before leaving
$form->postProcessHook();
// this does not return
$result = $payment->doTransferCheckout($form->_params, 'contribute');
} else {
CRM_Core_Error::fatal($paymentObjError);
}
} else {
// follow similar flow as IPN
// send the receipt mail
$form->set('params', $form->_params);
if ($contributionType->is_deductible) {
$form->assign('is_deductible', TRUE);
$form->set('is_deductible', TRUE);
}
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
//.........这里部分代码省略.........
示例8: processConfirm
/**
* Function to process payment after confirmation
*
* @param object $form form object
* @param array $paymentParams array with payment related key
* value pairs
* @param array $premiumParams array with premium related key
* value pairs
* @param int $contactID contact id
* @param int $contributionTypeId financial type id
* @param int $component component id
*
* @return array associated array
*
* @static
* @access public
*/
static function processConfirm(&$form, &$paymentParams, &$premiumParams, $contactID, $contributionTypeId, $component = 'contribution', $fieldTypes = NULL)
{
CRM_Core_Payment_Form::mapParams($form->_bltID, $form->_params, $paymentParams, TRUE);
$contributionType = new CRM_Financial_DAO_FinancialType();
if (isset($paymentParams['financial_type'])) {
$contributionType->id = $paymentParams['financial_type'];
} elseif (!empty($form->_values['pledge_id'])) {
$contributionType->id = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge', $form->_values['pledge_id'], 'financial_type_id');
} else {
$contributionType->id = $contributionTypeId;
}
if (!$contributionType->find(TRUE)) {
CRM_Core_Error::fatal('Could not find a system table');
}
// add some financial type details to the params list
// if folks need to use it
$paymentParams['contributionType_name'] = $form->_params['contributionType_name'] = $contributionType->name;
//CRM-11456
$paymentParams['contributionType_accounting_code'] = $form->_params['contributionType_accounting_code'] = CRM_Financial_BAO_FinancialAccount::getAccountingCode($contributionType->id);
$paymentParams['contributionPageID'] = $form->_params['contributionPageID'] = $form->_values['id'];
$payment = NULL;
$paymentObjError = ts('The system did not record payment details for this payment and so could not process the transaction. Please report this error to the site administrator.');
if ($form->_values['is_monetary'] && $form->_amount > 0.0 && is_array($form->_paymentProcessor)) {
$payment = CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
}
//fix for CRM-2062
$now = date('YmdHis');
$result = NULL;
if ($form->_contributeMode == 'notify' || $form->_params['is_pay_later']) {
// this is not going to come back, i.e. we fill in the other details
// when we get a callback from the payment processor
// also add the contact ID and contribution ID to the params list
$paymentParams['contactID'] = $form->_params['contactID'] = $contactID;
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, $paymentParams, NULL, $contactID, $contributionType, TRUE, TRUE, TRUE);
if ($contribution) {
$form->_params['contributionID'] = $contribution->id;
}
$form->_params['contributionTypeID'] = $contributionType->id;
$form->_params['item_name'] = $form->_params['description'];
$form->_params['receive_date'] = $now;
if ($contribution && $form->_values['is_recur'] && $contribution->contribution_recur_id) {
$form->_params['contributionRecurID'] = $contribution->contribution_recur_id;
}
$form->set('params', $form->_params);
$form->postProcessPremium($premiumParams, $contribution);
if ($form->_values['is_monetary'] && $form->_amount > 0.0) {
// add qfKey so we can send to paypal
$form->_params['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
$membershipResult = array(1 => $contribution);
return $membershipResult;
} else {
if (!$form->_params['is_pay_later']) {
if (is_object($payment)) {
// call postprocess hook before leaving
$form->postProcessHook();
// this does not return
$result =& $payment->doTransferCheckout($form->_params, 'contribute');
} else {
CRM_Core_Error::fatal($paymentObjError);
}
} else {
// follow similar flow as IPN
// send the receipt mail
$form->set('params', $form->_params);
if ($contributionType->is_deductible) {
$form->assign('is_deductible', TRUE);
$form->set('is_deductible', TRUE);
}
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
$form->_values['contribution_id'] = $contribution->id;
$form->_values['contribution_page_id'] = $contribution->contribution_page_id;
CRM_Contribute_BAO_ContributionPage::sendMail($contactID, $form->_values, $contribution->is_test);
return;
}
}
//.........这里部分代码省略.........
示例9: postProcess
//.........这里部分代码省略.........
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 {
if (!CRM_Utils_System::isNull($this->_params['receipt_date'])) {
$this->_params['receipt_date'] = CRM_Utils_Date::processDate($this->_params['receipt_date']);
} else {
$this->_params['receipt_date'] = 'null';
}
}
$this->set('params', $this->_params);
$this->assign('trxn_id', $result['trxn_id']);
$this->assign('receive_date', CRM_Utils_Date::processDate($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'])) {
$userID = $session->get('userID');
$userSortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $userID, 'sort_name');
$this->_params['source'] = ts('Submit Credit Card Payment by: %1', array(1 => $userSortName));
}
// build custom data getFields array
$customFieldsContributionType = CRM_Core_BAO_CustomField::getFields('Contribution', false, false, CRM_Utils_Array::value('contribution_type_id', $params));
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsContributionType, CRM_Core_BAO_CustomField::getFields('Contribution', false, false, null, null, true));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_id, 'Contribution');
require_once 'CRM/Contribute/Form/Contribution/Confirm.php';
$contribution =& CRM_Contribute_Form_Contribution_Confirm::processContribution($this, $this->_params, $result, $this->_contactID, $contributionType, false, false, false);
// process line items, until no previous line items.
if (empty($this->_lineItems) && $contribution->id && !empty($lineItem)) {
CRM_Contribute_Form_AdditionalInfo::processPriceSet($contribution->id, $lineItem);
}
//send receipt mail.
if ($contribution->id && CRM_Utils_Array::value('is_email_receipt', $this->_params)) {
$this->_params['trxn_id'] = CRM_Utils_Array::value('trxn_id', $result);
$this->_params['contact_id'] = $this->_contactID;
$this->_params['contribution_id'] = $contribution->id;
$sendReceipt = CRM_Contribute_Form_AdditionalInfo::emailReceipt($this, $this->_params, true);
}
//process the note
if ($contribution->id && isset($params['note'])) {
CRM_Contribute_Form_AdditionalInfo::processNote($params, $contactID, $contribution->id, null);
}
//process premium
if ($contribution->id && isset($params['product_name'][0])) {
CRM_Contribute_Form_AdditionalInfo::processPremium($params, $contribution->id, null, $this->_options);
}
//update pledge payment status.
if ($this->_ppID && $contribution->id) {
//store contribution id in payment record.
CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_Payment', $this->_ppID, 'contribution_id', $contribution->id);
require_once 'CRM/Pledge/BAO/Payment.php';
CRM_Pledge_BAO_Payment::updatePledgePaymentStatus($this->_pledgeID, array($this->_ppID), $contribution->contribution_status_id);
}
if ($contribution->id) {
$statusMsg = ts('The contribution record has been processed.');
if (CRM_Utils_Array::value('is_email_receipt', $this->_params) && $sendReceipt) {
$statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
}
CRM_Core_Session::setStatus($statusMsg);
示例10: postProcess
//.........这里部分代码省略.........
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
$paymentParams['contactID'] = $this->_contactID;
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, TRUE);
$contributionType = new CRM_Contribute_DAO_ContributionType();
$contributionType->id = $params['contribution_type_id'];
if (!$contributionType->find(TRUE)) {
CRM_Core_Error::fatal('Could not find a system table');
}
// add some contribution type details to the params list
// if folks need to use it
$paymentParams['contributionType_name'] = $this->_params['contributionType_name'] = $contributionType->name;
$paymentParams['contributionType_accounting_code'] = $this->_params['contributionType_accounting_code'] = $contributionType->accounting_code;
$paymentParams['contributionPageID'] = NULL;
if (CRM_Utils_Array::value('is_email_receipt', $this->_params)) {
$paymentParams['email'] = $this->userEmail;
$paymentParams['is_email_receipt'] = 1;
} else {
$paymentParams['is_email_receipt'] = 0;
$this->_params['is_email_receipt'] = 0;
}
if (CRM_Utils_Array::value('receive_date', $this->_params)) {
$paymentParams['receive_date'] = $this->_params['receive_date'];
}
if (CRM_Utils_Array::value('receive_date', $this->_params)) {
$paymentParams['receive_date'] = $this->_params['receive_date'];
}
$result = NULL;
// For recurring contribution, create Contribution Record first.
// Contribution ID, Recurring ID and Contact ID needed
// When we get a callback from the payment processor, CRM-7115
if (CRM_Utils_Array::value('is_recur', $paymentParams)) {
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($this, $this->_params, $result, $this->_contactID, $contributionType, FALSE, TRUE, FALSE);
$paymentParams['contributionID'] = $contribution->id;
$paymentParams['contributionTypeID'] = $contribution->contribution_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
if ($paymentParams['amount'] > 0.0) {
// force a reget of the payment processor in case the form changed it, CRM-7179
$payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this, TRUE);
$result = $payment->doDirectPayment($paymentParams);
}
if (is_a($result, 'CRM_Core_Error')) {
//make sure to cleanup db for recurring case.
if (CRM_Utils_Array::value('contributionID', $paymentParams)) {
CRM_Core_Error::debug_log_message(CRM_Core_Error::getMessages($result) . "contact id={$this->_contactID} (deleting contribution {$paymentParams['contributionID']}");
CRM_Contribute_BAO_Contribution::deleteContribution($paymentParams['contributionID']);
}
if (CRM_Utils_Array::value('contributionRecurID', $paymentParams)) {
CRM_Core_Error::debug_log_message(CRM_Core_Error::getMessages($result) . "contact id={$this->_contactID} (deleting recurring contribution {$paymentParams['contributionRecurID']}");
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
//set the contribution mode.
$urlParams = "action=add&cid={$this->_contactID}";
if ($this->_mode) {
$urlParams .= "&mode={$this->_mode}";
}
if (!empty($this->_ppID)) {
$urlParams .= "&context=pledge&ppid={$this->_ppID}";
}
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/contribution', $urlParams));
}
if ($result) {
示例11: postProcess
//.........这里部分代码省略.........
$fields[$name] = 1;
if (array_key_exists("billing_{$name}", $formValues)) {
$formValues[$name] = $formValues["billing_{$name}"];
$formValues['preserveDBName'] = true;
}
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($formValues, $fields, $this->_contactID, null, null, $ctype);
// add all the additioanl payment params we need
$this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
$this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
$this->_params['year'] = $this->_params['credit_card_exp_date']['Y'];
$this->_params['month'] = $this->_params['credit_card_exp_date']['M'];
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $params['total_amount'];
$this->_params['currencyID'] = $config->defaultCurrency;
$this->_params['payment_action'] = 'Sale';
$this->_params['invoiceID'] = md5(uniqid(rand(), true));
$this->_params['contribution_type_id'] = $params['contribution_type_id'];
// at this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
if (CRM_Utils_Array::value('send_receipt', $this->_params)) {
$paymentParams['email'] = $this->_memberEmail;
}
require_once 'CRM/Core/Payment/Form.php';
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);