本文整理汇总了PHP中CRM_Core_Payment_Form::mapParams方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Payment_Form::mapParams方法的具体用法?PHP CRM_Core_Payment_Form::mapParams怎么用?PHP CRM_Core_Payment_Form::mapParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Payment_Form
的用法示例。
在下文中一共展示了CRM_Core_Payment_Form::mapParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
$financialType = new CRM_Financial_DAO_FinancialType();
$financialType->id = $contributionTypeId;
$financialType->find(TRUE);
if ($financialType->is_deductible) {
$form->assign('is_deductible', TRUE);
$form->set('is_deductible', TRUE);
}
// add some financial type details to the params list
// if folks need to use it
//CRM-15297 - contributionType is obsolete - pass financial type as well so people can deprecate it
$paymentParams['financialType_name'] = $paymentParams['contributionType_name'] = $form->_params['contributionType_name'] = $financialType->name;
//CRM-11456
$paymentParams['financialType_accounting_code'] = $paymentParams['contributionType_accounting_code'] = $form->_params['contributionType_accounting_code'] = CRM_Financial_BAO_FinancialAccount::getAccountingCode($contributionTypeId);
$paymentParams['contributionPageID'] = $form->_params['contributionPageID'] = $form->_values['id'];
$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 && !empty($form->_paymentProcessor)) {
// @todo - remove this line once we are sure we can just use $form->_paymentProcessor['object'] consistently.
$payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
}
//fix for CRM-16317
$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::processFormContribution($form, $paymentParams, NULL, $contactID, $financialType, TRUE, TRUE, $isTest, $lineItems, $form->_bltID);
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') {
return array('contribution' => $contribution);
} 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 (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;
//.........这里部分代码省略.........
示例2: postProcess
//.........这里部分代码省略.........
$value['accountingCode'] = CRM_Utils_Array::value('accountingCode', $this->_values['event']);
$pending = FALSE;
if ($this->_allowWaitlist || $this->_requireApproval) {
//get the participant statuses.
$waitingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
if ($this->_allowWaitlist) {
$value['participant_status_id'] = $value['participant_status'] = array_search('On waitlist', $waitingStatuses);
} else {
$value['participant_status_id'] = $value['participant_status'] = array_search('Awaiting approval', $waitingStatuses);
}
//there might be case user seleted pay later and
//now becomes part of run time waiting list.
$value['is_pay_later'] = FALSE;
}
// required only if paid event
if ($this->_values['event']['is_monetary'] && !($this->_allowWaitlist || $this->_requireApproval)) {
if (is_array($this->_paymentProcessor)) {
$payment = $this->_paymentProcessor['object'];
}
if (!empty($this->_paymentProcessor) && $this->_paymentProcessor['object']->supports('preApproval')) {
$preApprovalParams = $this->_paymentProcessor['object']->getPreApprovalDetails($this->get('pre_approval_parameters'));
$value = array_merge($value, $preApprovalParams);
}
$result = NULL;
if (!empty($value['is_pay_later']) || $value['amount'] == 0 || $this->_contributeMode == 'checkout' || $this->_contributeMode == 'notify') {
if ($value['amount'] != 0) {
$pending = TRUE;
//get the participant statuses.
$pendingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Pending'");
$status = !empty($value['is_pay_later']) ? 'Pending from pay later' : 'Pending from incomplete transaction';
$value['participant_status_id'] = $value['participant_status'] = array_search($status, $pendingStatuses);
}
} elseif (!empty($value['is_primary'])) {
CRM_Core_Payment_Form::mapParams($this->_bltID, $value, $value, TRUE);
// payment email param can be empty for _bltID mapping
// thus provide mapping for it with a different email value
if (empty($value['email'])) {
$value['email'] = CRM_Utils_Array::valueByRegexKey('/^email-/', $value);
}
if (is_object($payment)) {
try {
$result = $payment->doPayment($value);
$value = array_merge($value, $result);
} catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
CRM_Core_Session::singleton()->setStatus($e->getMessage());
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/register', "id={$this->_eventId}"));
}
} else {
CRM_Core_Error::fatal($paymentObjError);
}
}
$value['receive_date'] = $now;
if ($this->_allowConfirmation) {
$value['participant_register_date'] = $this->_values['participant']['register_date'];
}
$createContrib = $value['amount'] != 0 ? TRUE : FALSE;
// force to create zero amount contribution, CRM-5095
if (!$createContrib && $value['amount'] == 0 && $this->_priceSetId && $this->_lineItem) {
$createContrib = TRUE;
}
if ($createContrib && !empty($value['is_primary']) && !$this->_allowWaitlist && !$this->_requireApproval) {
// if paid event add a contribution record
//if primary participant contributing additional amount
//append (multiple participants) to its fee level. CRM-4196.
$isAdditionalAmount = FALSE;
if (count($params) > 1) {
示例3: processFormSubmission
//.........这里部分代码省略.........
}
$dedupeParams = CRM_Dedupe_Finder::formatParams($dupeParams, 'Individual');
$dedupeParams['check_permission'] = FALSE;
$ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
// if we find more than one contact, use the first one
$contactID = CRM_Utils_Array::value(0, $ids);
// Fetch default greeting id's if creating a contact
if (!$contactID) {
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
if (!isset($params[$greeting])) {
$params[$greeting] = CRM_Contact_BAO_Contact_Utils::defaultGreeting('Individual', $greeting);
}
}
}
$contactType = NULL;
} else {
$contactType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'contact_type');
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $contactID, $addToGroups, NULL, $contactType, TRUE);
// Make the contact ID associated with the contribution available at the Class level.
// Also make available to the session.
//@todo consider handling this in $this->getContactID();
$this->set('contactID', $contactID);
$this->_contactID = $contactID;
//get email primary first if exist
$subscriptionEmail = array('email' => CRM_Utils_Array::value('email-Primary', $params));
if (!$subscriptionEmail['email']) {
$subscriptionEmail['email'] = CRM_Utils_Array::value("email-{$this->_bltID}", $params);
}
// subscribing contact to groups
if (!empty($subscribeGroupIds) && $subscriptionEmail['email']) {
CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($subscribeGroupIds, $subscriptionEmail, $contactID);
}
// If onbehalf-of-organization contribution / signup, add organization
// and it's location.
if (isset($this->_values['onbehalf_profile_id']) && isset($behalfOrganization['organization_name'])) {
$ufFields = array();
foreach ($this->_fields['onbehalf'] as $name => $value) {
$ufFields[$name] = 1;
}
self::processOnBehalfOrganization($behalfOrganization, $contactID, $this->_values, $this->_params, $ufFields);
} elseif (!empty($this->_membershipContactID) && $contactID != $this->_membershipContactID) {
// this is an onbehalf renew case for inherited membership. For e.g a permissioned member of household,
// store current user id as related contact for later use for mailing / activity..
$this->_values['related_contact'] = $contactID;
$this->_params['related_contact'] = $contactID;
// swap contact like we do for on-behalf-org case, so parent/primary membership is affected
$contactID = $this->_membershipContactID;
}
// lets store the contactID in the session
// for things like tell a friend
$session = CRM_Core_Session::singleton();
if (!$session->get('userID')) {
$session->set('transaction.userID', $contactID);
} else {
$session->set('transaction.userID', NULL);
}
$this->_useForMember = $this->get('useForMember');
// store the fact that this is a membership and membership type is selected
if (!empty($membershipParams['selectMembership']) && $membershipParams['selectMembership'] != 'no_thanks' || $this->_useForMember) {
if (!$this->_useForMember) {
$this->assign('membership_assign', TRUE);
$this->set('membershipTypeID', $this->_params['selectMembership']);
}
if ($this->_action & CRM_Core_Action::PREVIEW) {
$membershipParams['is_test'] = 1;
}
if ($this->_params['is_pay_later']) {
$membershipParams['is_pay_later'] = 1;
}
//inherit campaign from contribution page.
if (!array_key_exists('campaign_id', $membershipParams)) {
$membershipParams['campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values);
}
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $membershipParams, TRUE);
$this->doMembershipProcessing($contactID, $membershipParams, $premiumParams, $isPayLater);
} else {
// 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 (!empty($paymentParams['onbehalf']) && is_array($paymentParams['onbehalf'])) {
foreach ($paymentParams['onbehalf'] as $key => $value) {
if (strstr($key, 'custom_')) {
$this->_params[$key] = $value;
}
}
}
$result = CRM_Contribute_BAO_Contribution_Utils::processConfirm($this, $paymentParams, $contactID, $this->wrangleFinancialTypeID($this->_values['financial_type_id']), 'contribution', $this->_mode == 'test' ? 1 : 0, CRM_Utils_Array::value('is_recur', $paymentParams));
if (empty($result['is_payment_failure'])) {
// @todo move premium processing to complete transaction if it truly is an 'after' action.
$this->postProcessPremium($premiumParams, $result['contribution']);
}
if (!empty($result['contribution'])) {
// Not quite sure why it would be empty at this stage but tests show it can be ... at least in tests.
$this->completeTransaction($result, $result['contribution']->id);
}
return $result;
}
}
示例4: postProcess
//.........这里部分代码省略.........
$customFieldsEventType = CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, $this->_eventTypeId, $this->_eventTypeCustomDataTypeID);
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsRole, CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, NULL, NULL, TRUE));
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsEvent, $customFields);
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsEventType, $customFields);
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->_id, 'Participant');
}
//do cleanup line items if participant edit the Event Fee.
if (($this->_lineItem || !isset($params['proceSetId'])) && !$this->_paymentId && $this->_id) {
CRM_Price_BAO_LineItem::deleteLineItems($this->_id, 'civicrm_participant');
}
if ($this->_mode) {
// add all the additional 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'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
$this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $params['fee_amount'];
$this->_params['amount_level'] = $params['amount_level'];
$this->_params['currencyID'] = $config->defaultCurrency;
$this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
// 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 (!empty($this->_params['send_receipt'])) {
$paymentParams['email'] = $this->_contributorEmail;
}
// The only reason for merging in the 'contact_id' rather than ensuring it is set
// is that this patch is being done around the time of the stable release
// so more conservative approach is called for.
// In fact the use of $params and $this->_params & $this->_contactId vs $contactID
// needs rationalising.
$mapParams = array_merge(array('contact_id' => $contactID), $this->_params);
CRM_Core_Payment_Form::mapParams($this->_bltID, $mapParams, $paymentParams, TRUE);
$payment = $this->_paymentProcessor['object'];
// CRM-15622: fix for incorrect contribution.fee_amount
$paymentParams['fee_amount'] = NULL;
$result = $payment->doPayment($paymentParams);
if (is_a($result, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/participant', "reset=1&action=add&cid={$this->_contactId}&context=participant&mode={$this->_mode}"));
}
if ($result) {
$this->_params = array_merge($this->_params, $result);
}
$this->_params['receive_date'] = $now;
if (!empty($this->_params['send_receipt'])) {
$this->_params['receipt_date'] = $now;
} 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']));
//add contribution record
$this->_params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['event_id'], 'financial_type_id');
$this->_params['mode'] = $this->_mode;
//add contribution record
$contributions[] = $contribution = CRM_Event_Form_Registration_Confirm::processContribution($this, $this->_params, $result, $contactID, FALSE);
// add participant record
$participants = array();
if (!empty($this->_params['role_id']) && is_array($this->_params['role_id'])) {
$this->_params['role_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_params['role_id']);
}
//CRM-15372 patch to fix fee amount replacing amount
示例5: processConfirm
/**
* Process payment after confirmation.
*
* @param CRM_Core_Form $form
* Form object.
* @param array $paymentParams
* Array with payment related key.
* value pairs
* @param int $contactID
* Contact id.
* @param int $contributionTypeId
* Financial type id.
* @param int|string $component component id
* @param $isTest
*
* @throws CRM_Core_Exception
* @throws Exception
* @return array
* associated array
*
*/
public static function processConfirm(&$form, &$paymentParams, $contactID, $contributionTypeId, $component = 'contribution', $isTest)
{
CRM_Core_Payment_Form::mapParams($form->_bltID, $form->_params, $paymentParams, TRUE);
$lineItems = $form->_lineItem;
$isPaymentTransaction = self::isPaymentTransaction($form);
$financialType = new CRM_Financial_DAO_FinancialType();
$financialType->id = $contributionTypeId;
$financialType->find(TRUE);
if ($financialType->is_deductible) {
$form->assign('is_deductible', TRUE);
$form->set('is_deductible', TRUE);
}
// add some financial type details to the params list
// if folks need to use it
//CRM-15297 - contributionType is obsolete - pass financial type as well so people can deprecate it
$paymentParams['financialType_name'] = $paymentParams['contributionType_name'] = $form->_params['contributionType_name'] = $financialType->name;
//CRM-11456
$paymentParams['financialType_accounting_code'] = $paymentParams['contributionType_accounting_code'] = $form->_params['contributionType_accounting_code'] = CRM_Financial_BAO_FinancialAccount::getAccountingCode($contributionTypeId);
$paymentParams['contributionPageID'] = $form->_params['contributionPageID'] = $form->_values['id'];
$paymentParams['contactID'] = $form->_params['contactID'] = $contactID;
//fix for CRM-16317
$form->_params['receive_date'] = date('YmdHis');
$form->assign('receive_date', CRM_Utils_Date::mysqlToIso($form->_params['receive_date']));
if ($isPaymentTransaction) {
// Fix for CRM-14354. If the membership is recurring, don't create a
// civicrm_contribution_recur record for the additional contribution
// (i.e., the amount NOT associated with the membership). Temporarily
// cache the is_recur values so we can process the additional gift as a
// one-off payment.
if (!empty($form->_values['is_recur'])) {
if ($form->_membershipBlock['is_separate_payment'] && !empty($form->_params['auto_renew'])) {
$cachedFormValue = CRM_Utils_Array::value('is_recur', $form->_values);
$cachedParamValue = CRM_Utils_Array::value('is_recur', $paymentParams);
unset($form->_values['is_recur']);
unset($paymentParams['is_recur']);
}
}
$contributionParams = array('contact_id' => $contactID, 'line_item' => $lineItems, 'is_test' => $isTest, 'campaign_id' => CRM_Utils_Array::value('campaign_id', $paymentParams, CRM_Utils_Array::value('campaign_id', $form->_values)), 'contribution_page_id' => $form->_id, 'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)));
$isMonetary = !empty($form->_values['is_monetary']);
if ($isMonetary) {
if (empty($paymentParams['is_pay_later'])) {
// @todo look up payment_instrument_id on payment processor table.
$contributionParams['payment_instrument_id'] = 1;
}
}
$contribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($form, $paymentParams, NULL, $contributionParams, $financialType, TRUE, TRUE, $form->_bltID);
$paymentParams['contributionTypeID'] = $contributionTypeId;
$paymentParams['item_name'] = $form->_params['description'];
if ($contribution && $form->_values['is_recur'] && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
$paymentParams['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
return array('contribution' => $contribution);
}
// restore cached values (part of fix for CRM-14354)
if (!empty($cachedFormValue)) {
$form->_values['is_recur'] = $cachedFormValue;
$paymentParams['is_recur'] = $cachedParamValue;
}
$paymentParams['contributionID'] = $contribution->id;
//CRM-15297 deprecate contributionTypeID
$paymentParams['financialTypeID'] = $paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
if (isset($paymentParams['contribution_source'])) {
$paymentParams['source'] = $paymentParams['contribution_source'];
}
if ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
if ($form->_contributeMode && $form->_amount > 0.0) {
try {
$payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
if ($form->_contributeMode == 'notify') {
// We want to get rid of this & make it generic - eg. by making payment processing the last thing
// and always calling it first.
$form->postProcessHook();
}
$result = $payment->doPayment($paymentParams);
//.........这里部分代码省略.........
示例6: postProcess
//.........这里部分代码省略.........
// this is an onbehalf renew case for inherited membership. For e.g a permissioned member of household,
// store current user id as related contact for later use for mailing / activity..
$this->_values['related_contact'] = $contactID;
$this->_params['related_contact'] = $contactID;
// swap contact like we do for on-behalf-org case, so parent/primary membership is affected
$contactID = $this->_membershipContactID;
}
}
// lets store the contactID in the session
// for things like tell a friend
$session = CRM_Core_Session::singleton();
if (!$session->get('userID')) {
$session->set('transaction.userID', $contactID);
} else {
$session->set('transaction.userID', NULL);
}
$this->_useForMember = $this->get('useForMember');
// store the fact that this is a membership and membership type is selected
$processMembership = FALSE;
if (!empty($membershipParams['selectMembership']) && $membershipParams['selectMembership'] != 'no_thanks' || $this->_useForMember) {
$processMembership = TRUE;
if (!$this->_useForMember) {
$this->assign('membership_assign', TRUE);
$this->set('membershipTypeID', $this->_params['selectMembership']);
}
if ($this->_action & CRM_Core_Action::PREVIEW) {
$membershipParams['is_test'] = 1;
}
if ($this->_params['is_pay_later']) {
$membershipParams['is_pay_later'] = 1;
}
}
if ($processMembership) {
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $membershipParams, TRUE);
// added new parameter for cms user contact id, needed to distinguish behaviour for on behalf of sign-ups
if (isset($this->_params['related_contact'])) {
$membershipParams['cms_contactID'] = $this->_params['related_contact'];
} else {
$membershipParams['cms_contactID'] = $contactID;
}
//inherit campaign from contirb page.
if (!array_key_exists('campaign_id', $membershipParams)) {
$membershipParams['campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values);
}
if (!empty($membershipParams['onbehalf']) && is_array($membershipParams['onbehalf']) && !empty($membershipParams['onbehalf']['member_campaign_id'])) {
$this->_params['campaign_id'] = $membershipParams['onbehalf']['member_campaign_id'];
}
$customFieldsFormatted = $fieldTypes = array();
if (!empty($membershipParams['onbehalf']) && is_array($membershipParams['onbehalf'])) {
foreach ($membershipParams['onbehalf'] as $key => $value) {
if (strstr($key, 'custom_')) {
$customFieldId = explode('_', $key);
CRM_Core_BAO_CustomField::formatCustomField($customFieldId[1], $customFieldsFormatted, $value, 'Membership', NULL, $contactID);
}
}
$fieldTypes = array('Contact', 'Organization', 'Membership');
}
$priceFieldIds = $this->get('memberPriceFieldIDS');
if (!empty($priceFieldIds)) {
$contributionTypeID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceFieldIds['id'], 'financial_type_id');
unset($priceFieldIds['id']);
$membershipTypeIds = array();
$membershipTypeTerms = array();
foreach ($priceFieldIds as $priceFieldId) {
if ($id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_type_id')) {
$membershipTypeIds[] = $id;
示例7: postProcess
//.........这里部分代码省略.........
if (is_array($this->_paymentProcessor)) {
$payment =& CRM_Core_Payment::singleton($this->_mode, 'Event', $this->_paymentProcessor, $this);
}
$pending = false;
$result = null;
require_once 'CRM/Event/PseudoConstant.php';
if ($this->_allowWaitlist || $this->_requireApproval) {
//get the participant statuses.
$waitingStatuses = CRM_Event_PseudoConstant::participantStatus(null, "class = 'Waiting'");
if ($this->_allowWaitlist) {
$value['participant_status_id'] = array_search('On waitlist', $waitingStatuses);
} else {
$value['participant_status_id'] = array_search('Awaiting approval', $waitingStatuses);
}
//there might be case user seleted pay later and
//now becomes part of run time waiting list.
$value['is_pay_later'] = false;
} else {
if (CRM_Utils_Array::value('is_pay_later', $value) || $value['amount'] == 0 || $this->_contributeMode == 'checkout' || $this->_contributeMode == 'notify') {
if ($value['amount'] != 0) {
$pending = true;
//get the participant statuses.
require_once 'CRM/Event/PseudoConstant.php';
$pendingStatuses = CRM_Event_PseudoConstant::participantStatus(null, "class = 'Pending'");
$status = CRM_Utils_Array::value('is_pay_later', $value) ? 'Pending from pay later' : 'Pending from incomplete transaction';
$value['participant_status_id'] = array_search($status, $pendingStatuses);
}
} else {
if ($this->_contributeMode == 'express' && CRM_Utils_Array::value('is_primary', $value)) {
$result =& $payment->doExpressCheckout($value);
} else {
if (CRM_Utils_Array::value('is_primary', $value)) {
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::mapParams($this->_bltID, $value, $value, true);
$result =& $payment->doDirectPayment($value);
}
}
}
}
if (is_a($result, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/register', "id={$this->_eventId}"));
}
if ($result) {
$value = array_merge($value, $result);
}
$value['receive_date'] = $now;
if ($this->_allowConfirmation) {
$value['participant_register_date'] = $this->_values['participant']['register_date'];
}
$createContrib = $value['amount'] != 0 ? true : false;
// force to create zero amount contribution, CRM-5095
if (!$createContrib && $value['amount'] == 0 && $this->_priceSetId && $this->_lineItem) {
$createContrib = true;
}
if ($createContrib && CRM_Utils_Array::value('is_primary', $value) && !$this->_allowWaitlist && !$this->_requireApproval) {
// if paid event add a contribution record
//if primary participant contributing additional amount
//append (multiple participants) to its fee level. CRM-4196.
$isAdditionalAmount = false;
if (count($params) > 1) {
$isAdditionalAmount = true;
}
//passing contribution id is already registered.
$contribution =& self::processContribution($this, $value, $result, $contactID, $pending, $isAdditionalAmount);
$value['contributionID'] = $contribution->id;
示例8: submit
/**
* Process form submission.
*
* This function is also accessed by a unit test.
*/
protected function submit()
{
$this->storeContactFields($this->_params);
$this->beginPostProcess();
$now = CRM_Utils_Date::getToday(NULL, 'YmdHis');
$this->convertDateFieldsToMySQL($this->_params);
$this->assign('receive_date', $this->_params['receive_date']);
$this->processBillingAddress();
list($userName) = CRM_Contact_BAO_Contact_Location::getEmailDetails(CRM_Core_Session::singleton()->get('userID'));
$this->_params['total_amount'] = CRM_Utils_Array::value('total_amount', $this->_params, CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'minimum_fee'));
$this->_membershipId = $this->_id;
$customFieldsFormatted = CRM_Core_BAO_CustomField::postProcess($this->_params, $this->_id, 'Membership');
if (empty($this->_params['financial_type_id'])) {
$this->_params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'financial_type_id');
}
$contributionRecurID = NULL;
$this->assign('membershipID', $this->_id);
$this->assign('contactID', $this->_contactID);
$this->assign('module', 'Membership');
$this->assign('receiptType', 'membership renewal');
$this->_params['currencyID'] = CRM_Core_Config::singleton()->defaultCurrency;
$this->_params['invoice_id'] = $this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
if (!empty($this->_params['send_receipt'])) {
$this->_params['receipt_date'] = $now;
$this->assign('receipt_date', CRM_Utils_Date::mysqlToIso($this->_params['receipt_date']));
} else {
$this->_params['receipt_date'] = NULL;
}
if ($this->_mode) {
$this->_params['register_date'] = $now;
$this->_params['description'] = ts("Contribution submitted by a staff person using member's credit card for renewal");
$this->_params['amount'] = $this->_params['total_amount'];
// 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 passed params
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
if (!empty($this->_params['send_receipt'])) {
$paymentParams['email'] = $this->_contributorEmail;
}
$paymentParams['contactID'] = $this->_contributorContactID;
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, TRUE);
$payment = $this->_paymentProcessor['object'];
if (!empty($this->_params['auto_renew'])) {
$contributionRecurParams = $this->processRecurringContribution($paymentParams);
$contributionRecurID = $contributionRecurParams['contributionRecurID'];
$paymentParams = array_merge($paymentParams, $contributionRecurParams);
}
$result = $payment->doPayment($paymentParams);
$this->_params = array_merge($this->_params, $result);
$this->_params['contribution_status_id'] = $result['payment_status_id'];
$this->_params['trxn_id'] = $result['trxn_id'];
$this->_params['payment_instrument_id'] = 1;
$this->_params['is_test'] = $this->_mode == 'live' ? 0 : 1;
$this->set('params', $this->_params);
$this->assign('trxn_id', $result['trxn_id']);
}
$renewalDate = !empty($this->_params['renewal_date']) ? $renewalDate = CRM_Utils_Date::processDate($this->_params['renewal_date']) : NULL;
// check for test membership.
$isTestMembership = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_membershipId, 'is_test');
// chk for renewal for multiple terms CRM-8750
$numRenewTerms = 1;
if (is_numeric(CRM_Utils_Array::value('num_terms', $this->_params))) {
$numRenewTerms = $this->_params['num_terms'];
}
//if contribution status is pending then set pay later
$this->_params['is_pay_later'] = FALSE;
if ($this->_params['contribution_status_id'] == array_search('Pending', CRM_Contribute_PseudoConstant::contributionStatus())) {
$this->_params['is_pay_later'] = 1;
}
// These variable sets prior to renewMembership may not be required for this form. They were in
// a function this form shared with other forms.
$membershipSource = NULL;
if (!empty($this->_params['membership_source'])) {
$membershipSource = $this->_params['membership_source'];
}
$isPending = $this->_params['contribution_status_id'] == 2 ? TRUE : FALSE;
list($renewMembership) = CRM_Member_BAO_Membership::renewMembership($this->_contactID, $this->_params['membership_type_id'][1], $isTestMembership, $renewalDate, NULL, $customFieldsFormatted, $numRenewTerms, $this->_membershipId, $isPending, $contributionRecurID, $membershipSource, $this->_params['is_pay_later'], CRM_Utils_Array::value('campaign_id', $this->_params));
$this->endDate = CRM_Utils_Date::processDate($renewMembership->end_date);
$this->membershipTypeName = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $renewMembership->membership_type_id, 'name');
if (!empty($this->_params['record_contribution']) || $this->_mode) {
// set the source
$this->_params['contribution_source'] = "{$this->membershipTypeName} Membership: Offline membership renewal (by {$userName})";
//create line items
$lineItem = array();
$this->_params = $this->setPriceSetParameters($this->_params);
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $this->_params, $lineItem[$this->_priceSetId]);
//CRM-11529 for quick config backoffice transactions
//when financial_type_id is passed in form, update the
//line items with the financial type selected in form
if ($submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $this->_params)) {
foreach ($lineItem[$this->_priceSetId] as &$li) {
$li['financial_type_id'] = $submittedFinancialType;
}
}
if (!empty($lineItem)) {
//.........这里部分代码省略.........
示例9: 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;
}
}
//.........这里部分代码省略.........
示例10: make_payment
/**
* @param array $params
*
* @return array|void
* @throws Exception
*/
public function make_payment(&$params)
{
$config = CRM_Core_Config::singleton();
if (isset($params["billing_state_province_id-{$this->_bltID}"]) && $params["billing_state_province_id-{$this->_bltID}"]) {
$params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($params["billing_state_province_id-{$this->_bltID}"]);
}
if (isset($params["billing_country_id-{$this->_bltID}"]) && $params["billing_country_id-{$this->_bltID}"]) {
$params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($params["billing_country_id-{$this->_bltID}"]);
}
$params['ip_address'] = CRM_Utils_System::ipAddress();
$params['currencyID'] = $config->defaultCurrency;
$payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
CRM_Core_Payment_Form::mapParams($this->_bltID, $params, $params, TRUE);
$params['month'] = $params['credit_card_exp_date']['M'];
$params['year'] = $params['credit_card_exp_date']['Y'];
try {
$result = $payment->doPayment($params);
} catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/cart_checkout', "_qf_Payment_display=1&qfKey={$this->controller->_key}", TRUE, NULL, FALSE));
}
$trxnDetails = array('trxn_id' => $result['trxn_id'], 'trxn_date' => $result['now'], 'currency' => CRM_Utils_Array::value('currencyID', $result));
return $trxnDetails;
}
示例11: processConfirm
/**
* Process payment after confirmation.
*
* @param CRM_Core_Form $form
* Form object.
* @param array $paymentParams
* Array with payment related key.
* value pairs
* @param int $contactID
* Contact id.
* @param int $contributionTypeId
* Financial type id.
* @param int|string $component component id
* @param bool $isTest
* @param bool $isRecur
*
* @throws CRM_Core_Exception
* @throws Exception
* @return array
* associated array
*
*/
public static function processConfirm(&$form, &$paymentParams, $contactID, $contributionTypeId, $component = 'contribution', $isTest, $isRecur)
{
CRM_Core_Payment_Form::mapParams($form->_bltID, $form->_params, $paymentParams, TRUE);
$lineItems = $form->_lineItem;
$isPaymentTransaction = self::isPaymentTransaction($form);
$financialType = new CRM_Financial_DAO_FinancialType();
$financialType->id = $contributionTypeId;
$financialType->find(TRUE);
if ($financialType->is_deductible) {
$form->assign('is_deductible', TRUE);
$form->set('is_deductible', TRUE);
}
// add some financial type details to the params list
// if folks need to use it
//CRM-15297 - contributionType is obsolete - pass financial type as well so people can deprecate it
$paymentParams['financialType_name'] = $paymentParams['contributionType_name'] = $form->_params['contributionType_name'] = $financialType->name;
//CRM-11456
$paymentParams['financialType_accounting_code'] = $paymentParams['contributionType_accounting_code'] = $form->_params['contributionType_accounting_code'] = CRM_Financial_BAO_FinancialAccount::getAccountingCode($contributionTypeId);
$paymentParams['contributionPageID'] = $form->_params['contributionPageID'] = $form->_values['id'];
$paymentParams['contactID'] = $form->_params['contactID'] = $contactID;
//fix for CRM-16317
$form->_params['receive_date'] = date('YmdHis');
$form->assign('receive_date', CRM_Utils_Date::mysqlToIso($form->_params['receive_date']));
if ($isPaymentTransaction) {
$contributionParams = array('id' => CRM_Utils_Array::value('contribution_id', $paymentParams), 'contact_id' => $contactID, 'line_item' => $lineItems, 'is_test' => $isTest, 'campaign_id' => CRM_Utils_Array::value('campaign_id', $paymentParams, CRM_Utils_Array::value('campaign_id', $form->_values)), 'contribution_page_id' => $form->_id, 'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)));
$isMonetary = !empty($form->_values['is_monetary']);
if ($isMonetary) {
if (empty($paymentParams['is_pay_later'])) {
// @todo look up payment_instrument_id on payment processor table.
$contributionParams['payment_instrument_id'] = 1;
}
}
$contribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($form, $paymentParams, NULL, $contributionParams, $financialType, TRUE, $form->_bltID, $isRecur);
$paymentParams['contributionTypeID'] = $contributionTypeId;
$paymentParams['item_name'] = $form->_params['description'];
$paymentParams['qfKey'] = $form->controller->_key;
if ($component == 'membership') {
return array('contribution' => $contribution);
}
$paymentParams['contributionID'] = $contribution->id;
//CRM-15297 deprecate contributionTypeID
$paymentParams['financialTypeID'] = $paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
if (isset($paymentParams['contribution_source'])) {
$paymentParams['source'] = $paymentParams['contribution_source'];
}
if ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
if (isset($paymentParams['contribution_source'])) {
$form->_params['source'] = $paymentParams['contribution_source'];
}
// get the price set values for receipt.
if ($form->_priceSetId && $form->_lineItem) {
$form->_values['lineItem'] = $form->_lineItem;
$form->_values['priceSetID'] = $form->_priceSetId;
}
$form->_values['contribution_id'] = $contribution->id;
$form->_values['contribution_page_id'] = $contribution->contribution_page_id;
if (!empty($form->_paymentProcessor)) {
try {
$payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
if ($form->_contributeMode == 'notify') {
// We want to get rid of this & make it generic - eg. by making payment processing the last thing
// and always calling it first.
$form->postProcessHook();
}
$result = $payment->doPayment($paymentParams);
$form->_params = array_merge($form->_params, $result);
$form->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $result));
if (!empty($result['trxn_id'])) {
$contribution->trxn_id = $result['trxn_id'];
}
if (!empty($result['payment_status_id'])) {
$contribution->payment_status_id = $result['payment_status_id'];
}
$result['contribution'] = $contribution;
if ($result['payment_status_id'] == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'status_id', 'Pending') && $payment->isSendReceiptForPending()) {
//.........这里部分代码省略.........
示例12: postProcess
//.........这里部分代码省略.........
// also add location name to the array
$formValues["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_middle_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_last_name', $formValues);
$formValues["address_name-{$this->_bltID}"] = trim($formValues["address_name-{$this->_bltID}"]);
$fields["address_name-{$this->_bltID}"] = 1;
$fields["email-{$this->_bltID}"] = 1;
$ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactID, 'contact_type');
$nameFields = array('first_name', 'middle_name', 'last_name');
foreach ($nameFields as $name) {
$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));
// 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->_contributorEmail;
}
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, true);
$payment =& CRM_Core_Payment::singleton($this->_mode, 'Contribute', $this->_paymentProcessor, $this);
$result =& $payment->doDirectPayment($paymentParams);
if (is_a($result, 'CRM_Core_Error')) {
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'] = 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;
$membership =& CRM_Member_BAO_Membership::create($params, $ids);
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->trxn_id = $result['trxn_id'];
if ($contribution->find(true)) {
// next create the transaction record
示例13: postProcess
//.........这里部分代码省略.........
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $this->_contactID, null, null, $ctype);
// add all the additioanl payment params we need
$this->_params["state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
$this->_params["country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
if ($this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_CREDIT_CARD) {
$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'] = $this->_params['total_amount'];
$this->_params['amount_level'] = 0;
$this->_params['currencyID'] = $config->defaultCurrency;
$this->_params['payment_action'] = 'Sale';
if (CRM_Utils_Array::value('soft_credit_to', $params)) {
$this->_params['soft_credit_to'] = $params['soft_credit_to'];
$this->_params['pcp_made_through_id'] = $params['pcp_made_through_id'];
}
$this->_params['pcp_display_in_roll'] = $params['pcp_display_in_roll'];
$this->_params['pcp_roll_nickname'] = $params['pcp_roll_nickname'];
$this->_params['pcp_personal_note'] = $params['pcp_personal_note'];
//Add common data to formatted params
CRM_Contribute_Form_AdditionalInfo::postProcessCommon($params, $this->_params);
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;
require_once 'CRM/Core/Payment/Form.php';
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;
}
$payment =& CRM_Core_Payment::singleton($this->_mode, 'Contribute', $this->_paymentProcessor, $this);
$result =& $payment->doDirectPayment($paymentParams);
if (is_a($result, 'CRM_Core_Error')) {
//set the contribution mode.
$urlParams = "action=add&cid={$this->_contactID}";
if ($this->_mode) {
$urlParams .= "&mode={$this->_mode}";
}
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 {
if (!CRM_Utils_System::isNull($this->_params['receipt_date'])) {
示例14: submit
//.........这里部分代码省略.........
}
}
if ($this->_contributorContactID == $this->_contactID) {
//see CRM-12869 for discussion of why we don't do this for separate payee payments
CRM_Contact_BAO_Contact::createProfileContact($formValues, $fields, $this->_contributorContactID, NULL, NULL, CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactID, 'contact_type'));
}
// add all the additional payment params we need
$formValues["state_province-{$this->_bltID}"] = $formValues["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($formValues["billing_state_province_id-{$this->_bltID}"]);
$formValues["country-{$this->_bltID}"] = $formValues["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($formValues["billing_country_id-{$this->_bltID}"]);
$formValues['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($formValues);
$formValues['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($formValues);
$formValues['ip_address'] = CRM_Utils_System::ipAddress();
$formValues['amount'] = $params['total_amount'];
$formValues['currencyID'] = $config->defaultCurrency;
$formValues['description'] = ts("Contribution submitted by a staff person using member's credit card for signup");
$formValues['invoiceID'] = md5(uniqid(rand(), TRUE));
$formValues['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 = $formValues;
$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($formValues['soft_credit_type_id'])) {
$softParams['contact_id'] = $params['contact_id'];
$softParams['soft_credit_type_id'] = $formValues['soft_credit_type_id'];
}
}
if (!empty($formValues['send_receipt'])) {
$paymentParams['email'] = $this->_contributorEmail;
}
CRM_Core_Payment_Form::mapParams($this->_bltID, $formValues, $paymentParams, TRUE);
// CRM-7137 -for recurring membership,
// we do need contribution and recurring records.
$result = NULL;
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) {
示例15: postProcess
/**
* Function to process the renewal form
*
* @access public
* @return None
*/
public function postProcess()
{
require_once 'CRM/Member/BAO/Membership.php';
require_once 'CRM/Member/BAO/MembershipType.php';
require_once 'CRM/Member/BAO/MembershipStatus.php';
// get the submitted form values.
$this->_params = $formValues = $this->controller->exportValues($this->_name);
$params = array();
$ids = array();
$config =& CRM_Core_Config::singleton();
$params['contact_id'] = $this->_contactID;
if ($this->_mode) {
$formValues['total_amount'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'minimum_fee');
$formValues['contribution_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'contribution_type_id');
require_once 'CRM/Core/BAO/PaymentProcessor.php';
$this->_paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($formValues['payment_processor_id'], $this->_mode);
require_once "CRM/Contact/BAO/Contact.php";
$now = CRM_Utils_Date::getToday($now, 'YmdHis');
$fields = array();
// set email for primary location.
$fields["email-Primary"] = 1;
$formValues["email-5"] = $formValues["email-Primary"] = $this->_contributorEmail;
$formValues['register_date'] = $now;
// now set the values for the billing location.
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
// also add location name to the array
$formValues["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_middle_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_last_name', $formValues);
$formValues["address_name-{$this->_bltID}"] = trim($formValues["address_name-{$this->_bltID}"]);
$fields["address_name-{$this->_bltID}"] = 1;
$fields["email-{$this->_bltID}"] = 1;
$ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactID, 'contact_type');
$nameFields = array('first_name', 'middle_name', 'last_name');
foreach ($nameFields as $name) {
$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'] = $formValues['total_amount'];
$this->_params['currencyID'] = $config->defaultCurrency;
$this->_params['payment_action'] = 'Sale';
$this->_params['invoiceID'] = md5(uniqid(rand(), true));
// 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->_contributorEmail;
}
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, true);
$payment =& CRM_Core_Payment::singleton($this->_mode, 'Contribute', $this->_paymentProcessor, $this);
$result =& $payment->doDirectPayment($paymentParams);
if (is_a($result, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$this->_id}&context=membership&mode={$this->_mode}"));
}
if ($result) {
$this->_params = array_merge($this->_params, $result);
}
$formValues['contribution_status_id'] = 1;
$formValues['receive_date'] = $now;
$formValues['invoice_id'] = $this->_params['invoiceID'];
$formValues['trxn_id'] = $result['trxn_id'];
$formValues['payment_instrument_id'] = 1;
$formValues['is_test'] = $this->_mode == 'live' ? 0 : 1;
if (CRM_Utils_Array::value('send_receipt', $this->_params)) {
$formValues['receipt_date'] = $now;
} else {
$formValues['receipt_date'] = null;
}
$this->set('params', $this->_params);
$this->assign('trxn_id', $result['trxn_id']);
$this->assign('receive_date', CRM_Utils_Date::mysqlToIso($formValues['receive_date']));
}
$renewalDate = null;
if ($formValues['renewal_date']) {
$this->set('renewDate', CRM_Utils_Date::processDate($formValues['renewal_date']));
}
$this->_membershipId = $this->_id;
// check for test membership.
$isTestMembership = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_membershipId, 'is_test');
$renewMembership = CRM_Member_BAO_Membership::renewMembership($this->_contactID, $this->_memType, $isTestMembership, $this, null);
$endDate = CRM_Utils_Date::processDate($renewMembership->end_date);
//.........这里部分代码省略.........