本文整理汇总了PHP中CRM_Core_Payment_Form类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Payment_Form类的具体用法?PHP CRM_Core_Payment_Form怎么用?PHP CRM_Core_Payment_Form使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_Payment_Form类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setPaymentFieldsByProcessor
/**
* Add payment fields depending on payment processor. The payment processor can implement the following functions to override the built in fields.
*
* - getPaymentFormFields()
* - getPaymentFormFieldsMetadata()
* (planned - getBillingDetailsFormFields(), getBillingDetailsFormFieldsMetadata()
*
* Note that this code is written to accommodate the possibility CiviCRM will switch to implementing pay later as a manual processor in future
*
* @param CRM_Contribute_Form_AbstractEditPayment|CRM_Contribute_Form_Contribution_Main $form
* @param array $processor
* Array of properties including 'object' as loaded from CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors.
* @param bool $forceBillingFieldsForPayLater
* Display billing fields even for pay later.
*/
public static function setPaymentFieldsByProcessor(&$form, $processor, $forceBillingFieldsForPayLater = FALSE)
{
$form->billingFieldSets = array();
if ($processor != NULL) {
// ie it is pay later
$paymentFields = self::getPaymentFields($processor);
$paymentTypeName = self::getPaymentTypeName($processor);
$paymentTypeLabel = self::getPaymentTypeLabel($processor);
//@todo if we switch to iterating through $form->billingFieldSets we won't need to assign these directly
$form->assign('paymentTypeName', $paymentTypeName);
$form->assign('paymentTypeLabel', $paymentTypeLabel);
$form->billingFieldSets[$paymentTypeName]['fields'] = $form->_paymentFields = array_intersect_key(self::getPaymentFieldMetadata($processor), array_flip($paymentFields));
$form->billingPane = array($paymentTypeName => $paymentTypeLabel);
$form->assign('paymentFields', $paymentFields);
}
// @todo - replace this section with one similar to above per discussion - probably use a manual processor shell class to stand in for that capability
//return without adding billing fields if billing_mode = 4 (@todo - more the ability to set that to the payment processor)
// or payment processor is NULL (pay later)
if ($processor == NULL && !$forceBillingFieldsForPayLater || CRM_Utils_Array::value('billing_mode', $processor) == 4) {
return;
}
//@todo setPaymentFields defines the billing fields - this should be moved to the processor class & renamed getBillingFields
// potentially pay later would also be a payment processor
//also set the billingFieldSet to hold all the details required to render the fieldset so we can iterate through the fieldset - making
// it easier to re-order in hooks etc. The billingFieldSets param is used to determine whether to show the billing pane
CRM_Core_Payment_Form::setBillingDetailsFields($form);
$form->billingFieldSets['billing_name_address-group']['fields'] = array();
}
示例2: setDirectDebitFields
/** create all fields needed for direct debit transaction
*
* @return void
* @access public
*/
function setDirectDebitFields(&$form)
{
CRM_Core_Payment_Form::_setPaymentFields($form);
$form->_fields['account_holder'] = array('htmlType' => 'text', 'name' => 'account_holder', 'title' => ts('Account Holder'), 'cc_field' => true, 'attributes' => array('size' => 20, 'maxlength' => 34, 'autocomplete' => 'on'), 'is_required' => true);
//e.g. IBAN can have maxlength of 34 digits
$form->_fields['bank_account_number'] = array('htmlType' => 'text', 'name' => 'bank_account_number', 'title' => ts('Bank Account Number'), 'cc_field' => true, 'attributes' => array('size' => 20, 'maxlength' => 34, 'autocomplete' => 'off'), 'is_required' => true);
//e.g. SWIFT-BIC can have maxlength of 11 digits
$form->_fields['bank_identification_number'] = array('htmlType' => 'text', 'name' => 'bank_identification_number', 'title' => ts('Bank Identification Number'), 'cc_field' => true, 'attributes' => array('size' => 20, 'maxlength' => 11, 'autocomplete' => 'off'), 'is_required' => true);
$form->_fields['bank_name'] = array('htmlType' => 'text', 'name' => 'bank_name', 'title' => ts('Bank Name'), 'cc_field' => true, 'attributes' => array('size' => 20, 'maxlength' => 64, 'autocomplete' => 'off'), 'is_required' => true);
}
示例3: testCreditCardCSSName
public function testCreditCardCSSName()
{
$params = array('name' => 'API_Test_PP_Type', 'title' => 'API Test Payment Processor Type', 'class_name' => 'CRM_Core_Payment_APITest', 'billing_mode' => 'form', 'payment_processor_type_id' => 1, 'is_recur' => 0, 'domain_id' => 1, 'accepted_credit_cards' => json_encode(array('Visa' => 'Visa', 'Mastercard' => 'Mastercard', 'Amex' => 'Amex')));
$paymentProcessor = CRM_Financial_BAO_PaymentProcessor::create($params);
$cards = CRM_Financial_BAO_PaymentProcessor::getCreditCards($paymentProcessor->id);
$CSSCards = CRM_Core_Payment_Form::getCreditCardCSSNames($cards);
$expectedCSSCards = array('visa' => 'Visa', 'mastercard' => 'Mastercard', 'amex' => 'Amex');
$this->assertEquals($CSSCards, $expectedCSSCards, 'Verify correct credit card types are returned');
$CSSCards2 = CRM_Core_Payment_Form::getCreditCardCSSNames(array());
$allCards = array('visa' => 'Visa', 'mastercard' => 'MasterCard', 'amex' => 'Amex', 'discover' => 'Discover');
$this->assertEquals($CSSCards2, $allCards, 'Verify correct credit card types are returned');
}
示例4: doDirectPayment
/**
* Submit a payment using Advanced Integration Method.
*
* @param array $params
* Assoc array of input parameters for this transaction.
*
* @return array
* the result in a nice formatted array (or an error object)
*/
public function doDirectPayment(&$params)
{
// Invoke hook_civicrm_paymentProcessor
// In Dummy's case, there is no translation of parameters into
// the back-end's canonical set of parameters. But if a processor
// does this, it needs to invoke this hook after it has done translation,
// but before it actually starts talking to its proprietary back-end.
// no translation in Dummy processor
$cookedParams = $params;
CRM_Utils_Hook::alterPaymentProcessorParams($this, $params, $cookedParams);
// This means we can test failing transactions by setting a past year in expiry. A full expiry check would
// be more complete.
if (!empty($params['credit_card_exp_date']['Y']) && date('Y') > CRM_Core_Payment_Form::getCreditCardExpirationYear($params)) {
$error = new CRM_Core_Error(ts('transaction failed'));
return $error;
}
//end of hook invocation
if (!empty($this->_doDirectPaymentResult)) {
$result = $this->_doDirectPaymentResult;
$result['trxn_id'] = array_shift($this->_doDirectPaymentResult['trxn_id']);
return $result;
}
if ($this->_mode == 'test') {
$query = "SELECT MAX(trxn_id) FROM civicrm_contribution WHERE trxn_id LIKE 'test\\_%'";
$p = array();
$trxn_id = strval(CRM_Core_Dao::singleValueQuery($query, $p));
$trxn_id = str_replace('test_', '', $trxn_id);
$trxn_id = intval($trxn_id) + 1;
$params['trxn_id'] = 'test_' . $trxn_id . '_' . uniqid();
} else {
$query = "SELECT MAX(trxn_id) FROM civicrm_contribution WHERE trxn_id LIKE 'live_%'";
$p = array();
$trxn_id = strval(CRM_Core_Dao::singleValueQuery($query, $p));
$trxn_id = str_replace('live_', '', $trxn_id);
$trxn_id = intval($trxn_id) + 1;
$params['trxn_id'] = 'live_' . $trxn_id . '_' . uniqid();
}
$params['gross_amount'] = $params['amount'];
// Add a fee_amount so we can make sure fees are handled properly in underlying classes.
$params['fee_amount'] = 1.5;
$params['net_amount'] = $params['gross_amount'] - $params['fee_amount'];
return $params;
}
示例5: 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;
示例6: postProcess
//.........这里部分代码省略.........
if (array_key_exists("billing_{$name}", $params)) {
$params[$name] = $params["billing_{$name}"];
$params['preserveDBName'] = true;
}
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $this->_contactID, null, null, $ctype);
}
// build custom data getFields array
$customFieldsRole = CRM_Core_BAO_CustomField::getFields('Participant', false, false, CRM_Utils_Array::value('role_id', $params), $this->_roleCustomDataTypeID);
$customFieldsEvent = CRM_Core_BAO_CustomField::getFields('Participant', false, false, CRM_Utils_Array::value('event_id', $params), $this->_eventNameCustomDataTypeID);
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsRole, CRM_Core_BAO_CustomField::getFields('Participant', false, false, null, null, true));
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsEvent, $customFields);
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_participantId, 'Participant');
if ($this->_mode) {
// 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['fee_amount'];
$this->_params['amount_level'] = $params['amount_level'];
$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, 'Event', $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/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 (CRM_Utils_Array::value('send_receipt', $this->_params)) {
$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']));
// set source if not set
$this->_params['description'] = ts('Submit Credit Card for Event Registration by: %1', array(1 => $userName));
require_once 'CRM/Event/Form/Registration/Confirm.php';
require_once 'CRM/Event/Form/Registration.php';
//add contribution record
$this->_params['contribution_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['event_id'], 'contribution_type_id');
$this->_params['mode'] = $this->_mode;
//add contribution reocord
$contribution = CRM_Event_Form_Registration_Confirm::processContribution($this, $this->_params, $result, $contactID, false);
// add participant record
$participants = array();
$participants[] = CRM_Event_Form_Registration::addParticipant($this->_params, $contactID);
//add custom data for participant
require_once 'CRM/Core/BAO/CustomValueTable.php';
示例7: submit
//.........这里部分代码省略.........
$now = date('YmdHis');
$fields = array();
// set email for primary location.
$fields['email-Primary'] = 1;
$formValues['email-5'] = $formValues['email-Primary'] = $this->_memberEmail;
$params['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;
//ensure we don't over-write the payer's email with the member's email
if ($this->_contributorContactID == $this->_contactID) {
$fields["email-{$this->_bltID}"] = 1;
}
$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;
}
}
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;
示例8: postProcess
//.........这里部分代码省略.........
$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}", $params)) {
$params[$name] = $params["billing_{$name}"];
$params['preserveDBName'] = TRUE;
}
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $this->_contactId, NULL, NULL, $ctype);
}
if (!empty($this->_params['participant_role_id'])) {
$customFieldsRole = array();
foreach ($this->_params['participant_role_id'] as $roleKey) {
$customFieldsRole = CRM_Utils_Array::crmArrayMerge(CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, $roleKey, $this->_roleCustomDataTypeID), $customFieldsRole);
}
$customFieldsEvent = CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, CRM_Utils_Array::value('event_id', $params), $this->_eventNameCustomDataTypeID);
$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;
示例9: formRule
//.........这里部分代码省略.........
}
}
if (!empty($priceFieldIDS)) {
$ids = implode(',', $priceFieldIDS);
$priceFieldIDS['id'] = $fields['priceSetId'];
$self->set('memberPriceFieldIDS', $priceFieldIDS);
$count = CRM_Price_BAO_PriceSet::getMembershipCount($ids);
foreach ($count as $id => $occurrence) {
if ($occurrence > 1) {
$errors['_qf_default'] = ts('You have selected multiple memberships for the same organization or entity. Please review your selections and choose only one membership per entity. Contact the site administrator if you need assistance.');
}
}
}
if (empty($priceFieldMemTypes) && $self->_membershipBlock['is_required'] == 1) {
$errors['_qf_default'] = ts('Please select at least one membership option.');
}
}
CRM_Price_BAO_PriceSet::processAmount($self->_values['fee'], $fields, $lineItem);
if ($fields['amount'] < 0) {
$errors['_qf_default'] = ts('Contribution can not be less than zero. Please select the options accordingly');
}
$amount = $fields['amount'];
}
if (isset($fields['selectProduct']) && $fields['selectProduct'] != 'no_thanks') {
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $fields['selectProduct'];
$productDAO->find(TRUE);
$min_amount = $productDAO->min_contribution;
if ($amount < $min_amount) {
$errors['selectProduct'] = ts('The premium you have selected requires a minimum contribution of %1', array(1 => CRM_Utils_Money::format($min_amount)));
CRM_Core_Session::setStatus($errors['selectProduct']);
}
}
//CRM-16285 - Function to handle validation errors on form, for recurring contribution field.
CRM_Contribute_BAO_ContributionRecur::validateRecurContribution($fields, $files, $self, $errors);
if (!empty($fields['is_recur']) && CRM_Utils_Array::value('payment_processor_id', $fields) == 0) {
$errors['_qf_default'] = ts('You cannot set up a recurring contribution if you are not paying online by credit card.');
}
// validate PCP fields - if not anonymous, we need a nick name value
if ($self->_pcpId && !empty($fields['pcp_display_in_roll']) && CRM_Utils_Array::value('pcp_is_anonymous', $fields) == 0 && CRM_Utils_Array::value('pcp_roll_nickname', $fields) == '') {
$errors['pcp_roll_nickname'] = ts('Please enter a name to include in the Honor Roll, or select \'contribute anonymously\'.');
}
// return if this is express mode
$config = CRM_Core_Config::singleton();
if ($self->_paymentProcessor && $self->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) {
if (!empty($fields[$self->_expressButtonName . '_x']) || !empty($fields[$self->_expressButtonName . '_y']) || CRM_Utils_Array::value($self->_expressButtonName, $fields)) {
return $errors;
}
}
//validate the pledge fields.
if (!empty($self->_values['pledge_block_id'])) {
//validation for pledge payment.
if (!empty($self->_values['pledge_id'])) {
if (empty($fields['pledge_amount'])) {
$errors['pledge_amount'] = ts('At least one payment option needs to be checked.');
}
} elseif (!empty($fields['is_pledge'])) {
if (CRM_Utils_Rule::positiveInteger(CRM_Utils_Array::value('pledge_installments', $fields)) == FALSE) {
$errors['pledge_installments'] = ts('Please enter a valid number of pledge installments.');
} else {
if (CRM_Utils_Array::value('pledge_installments', $fields) == NULL) {
$errors['pledge_installments'] = ts('Pledge Installments is required field.');
} elseif (CRM_Utils_Array::value('pledge_installments', $fields) == 1) {
$errors['pledge_installments'] = ts('Pledges consist of multiple scheduled payments. Select one-time contribution if you want to make your gift in a single payment.');
} elseif (CRM_Utils_Array::value('pledge_installments', $fields) == 0) {
$errors['pledge_installments'] = ts('Pledge Installments field must be > 1.');
}
}
//validation for Pledge Frequency Interval.
if (CRM_Utils_Rule::positiveInteger(CRM_Utils_Array::value('pledge_frequency_interval', $fields)) == FALSE) {
$errors['pledge_frequency_interval'] = ts('Please enter a valid Pledge Frequency Interval.');
} else {
if (CRM_Utils_Array::value('pledge_frequency_interval', $fields) == NULL) {
$errors['pledge_frequency_interval'] = ts('Pledge Frequency Interval. is required field.');
} elseif (CRM_Utils_Array::value('pledge_frequency_interval', $fields) == 0) {
$errors['pledge_frequency_interval'] = ts('Pledge frequency interval field must be > 0');
}
}
}
}
// if the user has chosen a free membership or the amount is less than zero
// i.e. we don't need to validate payment related fields or profiles.
if ((double) $amount <= 0.0) {
return $errors;
}
if (CRM_Utils_Array::value('payment_processor_id', $fields) == NULL) {
$errors['payment_processor_id'] = ts('Payment Method is a required field.');
} else {
CRM_Core_Payment_Form::validatePaymentInstrument($fields['payment_processor_id'], $fields, $errors, !$self->_isBillingAddressRequiredForPayLater ? NULL : 'billing');
}
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
if ($greetingType = CRM_Utils_Array::value($greeting, $fields)) {
$customizedValue = CRM_Core_OptionGroup::getValue($greeting, 'Customized', 'name');
if ($customizedValue == $greetingType && empty($fielse[$greeting . '_custom'])) {
$errors[$greeting . '_custom'] = ts('Custom %1 is a required field if %1 is of type Customized.', array(1 => ucwords(str_replace('_', " ", $greeting))));
}
}
}
return empty($errors) ? TRUE : $errors;
}
示例10: processCreditCard
/**
* Process credit card payment.
*
* @param array $submittedValues
* @param array $lineItem
*
* @param int $contactID
* Contact ID
*
* @return bool|\CRM_Contribute_DAO_Contribution
* @throws \CRM_Core_Exception
* @throws \Civi\Payment\Exception\PaymentProcessorException
*/
protected function processCreditCard($submittedValues, $lineItem, $contactID)
{
$isTest = $this->_mode == 'test' ? 1 : 0;
// CRM-12680 set $_lineItem if its not set
// @todo - I don't believe this would ever BE set. I can't find anywhere in the code.
// It would be better to pass line item out to functions than $this->_lineItem as
// we don't know what is being changed where.
if (empty($this->_lineItem) && !empty($lineItem)) {
$this->_lineItem = $lineItem;
}
$this->_paymentObject = Civi\Payment\System::singleton()->getById($submittedValues['payment_processor_id']);
$this->_paymentProcessor = $this->_paymentObject->getPaymentProcessor();
// Set source if not set
if (empty($submittedValues['source'])) {
$userID = CRM_Core_Session::singleton()->get('userID');
$userSortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $userID, 'sort_name');
$submittedValues['source'] = ts('Submit Credit Card Payment by: %1', array(1 => $userSortName));
}
$params = $submittedValues;
$this->_params = array_merge($this->_params, $submittedValues);
// Mapping requiring documentation.
$this->_params['payment_processor'] = $submittedValues['payment_processor_id'];
$now = date('YmdHis');
// we need to retrieve email address
if ($this->_context == 'standalone' && !empty($submittedValues['is_email_receipt'])) {
list($this->userDisplayName, $this->userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
$this->assign('displayName', $this->userDisplayName);
}
$this->_contributorEmail = $this->userEmail;
$this->_contributorContactID = $contactID;
$this->processBillingAddress();
if (!empty($params['source'])) {
unset($params['source']);
}
$this->_params['amount'] = $this->_params['total_amount'];
// @todo - stop setting amount level in this function & call the CRM_Price_BAO_PriceSet::getAmountLevel
// function to get correct amount level consistently. Remove setting of the amount level in
// CRM_Price_BAO_PriceSet::processAmount. Extend the unit tests in CRM_Price_BAO_PriceSetTest
// to cover all variants.
$this->_params['amount_level'] = 0;
$this->_params['description'] = ts("Contribution submitted by a staff person using contributor's credit card");
$this->_params['currencyID'] = CRM_Utils_Array::value('currency', $this->_params, CRM_Core_Config::singleton()->defaultCurrency);
if (!empty($this->_params['receive_date'])) {
$this->_params['receive_date'] = CRM_Utils_Date::processDate($this->_params['receive_date'], $this->_params['receive_date_time']);
}
$this->_params['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $params);
$this->_params['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $params);
$this->_params['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $params);
//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'] = $contactID;
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, TRUE);
$financialType = new CRM_Financial_DAO_FinancialType();
$financialType->id = $params['financial_type_id'];
$financialType->find(TRUE);
// Add some financial type details to the params list
// if folks need to use it.
$paymentParams['contributionType_name'] = $this->_params['contributionType_name'] = $financialType->name;
$paymentParams['contributionPageID'] = NULL;
if (!empty($this->_params['is_email_receipt'])) {
$paymentParams['email'] = $this->userEmail;
$paymentParams['is_email_receipt'] = 1;
} else {
$paymentParams['is_email_receipt'] = 0;
$this->_params['is_email_receipt'] = 0;
}
if (!empty($this->_params['receive_date'])) {
$paymentParams['receive_date'] = $this->_params['receive_date'];
}
$this->_params['receive_date'] = $now;
if (!empty($this->_params['is_email_receipt'])) {
$this->_params['receipt_date'] = $now;
} else {
$this->_params['receipt_date'] = CRM_Utils_Date::processDate($this->_params['receipt_date'], $params['receipt_date_time'], TRUE);
}
$this->set('params', $this->_params);
$this->assign('receive_date', $this->_params['receive_date']);
// Result has all the stuff we need
//.........这里部分代码省略.........
示例11: 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 {
//.........这里部分代码省略.........
示例12: buildQuickform
/**
* @param $form
*/
static function buildQuickform(&$form)
{
$form->addElement('hidden', 'hidden_processor', 1);
$profileAddressFields = $form->get('profileAddressFields');
if (!empty($profileAddressFields)) {
$form->assign('profileAddressFields', $profileAddressFields);
}
// before we do this lets see if the payment processor has implemented a buildForm method
if (method_exists($form->_paymentProcessor['instance'], 'buildForm') && is_callable(array($form->_paymentProcessor['instance'], 'buildForm'))) {
// the payment processor implements the buildForm function, let the payment
// processor do the work
$form->_paymentProcessor['instance']->buildForm($form);
return;
}
if ($form->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
CRM_Core_Payment_Form::buildDirectDebit($form);
} elseif ($form->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_CREDIT_CARD) {
CRM_Core_Payment_Form::buildCreditCard($form);
}
}
示例13: buildQuickForm
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm()
{
if ($this->_mode) {
$this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE, array('onChange' => "buildAutoRenew( null, this.value );"));
CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE);
}
if ($this->_action & CRM_Core_Action::RENEW) {
$this->addButtons(array(array('type' => 'upload', 'name' => ts('Renew'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
} elseif ($this->_action & CRM_Core_Action::DELETE) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
} else {
$this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
}
示例14: postProcess
//.........这里部分代码省略.........
}
$config = CRM_Core_Config::singleton();
$params['currencyID'] = $config->defaultCurrency;
if ($this->_values['event']['is_monetary']) {
// we first reset the confirm page so it accepts new values
$this->controller->resetPage('Confirm');
//added for discount
$discountId = CRM_Core_BAO_Discount::findSet($this->_eventId, 'civicrm_event');
if (!empty($this->_values['discount'][$discountId])) {
$params['discount_id'] = $discountId;
$params['amount_level'] = $this->_values['discount'][$discountId][$params['amount']]['label'];
$params['amount'] = $this->_values['discount'][$discountId][$params['amount']]['value'];
} elseif (empty($params['priceSetId'])) {
if (!empty($params['amount'])) {
$params['amount_level'] = $this->_values['fee'][$params['amount']]['label'];
$params['amount'] = $this->_values['fee'][$params['amount']]['value'];
} else {
$params['amount_level'] = $params['amount'] = '';
}
} else {
$lineItem = array();
CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'], $params, $lineItem);
$this->set('lineItem', array($lineItem));
$this->set('lineItemParticipantsCount', array($primaryParticipantCount));
}
$this->set('amount', $params['amount']);
$this->set('amount_level', $params['amount_level']);
// generate and set an invoiceID for this transaction
$invoiceID = md5(uniqid(rand(), TRUE));
$this->set('invoiceID', $invoiceID);
if (is_array($this->_paymentProcessor)) {
$payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
}
// default mode is direct
$this->set('contributeMode', 'direct');
if (isset($params["state_province_id-{$this->_bltID}"]) && $params["state_province_id-{$this->_bltID}"]) {
$params["state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($params["state_province_id-{$this->_bltID}"]);
}
if (isset($params["country_id-{$this->_bltID}"]) && $params["country_id-{$this->_bltID}"]) {
$params["country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($params["country_id-{$this->_bltID}"]);
}
if (isset($params['credit_card_exp_date'])) {
$params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($params);
$params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($params);
}
if ($this->_values['event']['is_monetary']) {
$params['ip_address'] = CRM_Utils_System::ipAddress();
$params['currencyID'] = $config->defaultCurrency;
$params['payment_action'] = 'Sale';
$params['invoiceID'] = $invoiceID;
}
$this->_params = array();
$this->_params[] = $params;
$this->set('params', $this->_params);
if ($this->_paymentProcessor && $this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) {
//get the button name
$buttonName = $this->controller->getButtonName();
if (in_array($buttonName, array($this->_expressButtonName, $this->_expressButtonName . '_x', $this->_expressButtonName . '_y')) && !CRM_Utils_Array::value('is_pay_later', $params) && !$this->_allowWaitlist && !$this->_requireApproval) {
$this->set('contributeMode', 'express');
// Send Event Name & Id in Params
$params['eventName'] = $this->_values['event']['title'];
$params['eventId'] = $this->_values['event']['id'];
$params['cancelURL'] = CRM_Utils_System::url('civicrm/event/register', "_qf_Register_display=1&qfKey={$this->controller->_key}", TRUE, NULL, FALSE);
if (CRM_Utils_Array::value('additional_participants', $params, FALSE)) {
$urlArgs = "_qf_Participant_1_display=1&rfp=1&qfKey={$this->controller->_key}";
} else {
$urlArgs = "_qf_Confirm_display=1&rfp=1&qfKey={$this->controller->_key}";
}
$params['returnURL'] = CRM_Utils_System::url('civicrm/event/register', $urlArgs, TRUE, NULL, FALSE);
$params['invoiceID'] = $invoiceID;
//default action is Sale
$params['payment_action'] = 'Sale';
$token = $payment->setExpressCheckout($params);
if (is_a($token, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($token);
CRM_Utils_System::redirect($params['cancelURL']);
}
$this->set('token', $token);
$paymentURL = $this->_paymentProcessor['url_site'] . "/cgi-bin/webscr?cmd=_express-checkout&token={$token}";
CRM_Utils_System::redirect($paymentURL);
}
} elseif ($this->_paymentProcessor && $this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_NOTIFY) {
$this->set('contributeMode', 'notify');
}
} else {
$session = CRM_Core_Session::singleton();
$params['description'] = ts('Online Event Registration') . ' ' . $this->_values['event']['title'];
$this->_params = array();
$this->_params[] = $params;
$this->set('params', $this->_params);
if (!CRM_Utils_Array::value('additional_participants', $params)) {
self::processRegistration($this->_params);
}
}
// If registering > 1 participant, give status message
if (CRM_Utils_Array::value('additional_participants', $params, FALSE)) {
$statusMsg = ts('Registration information for participant 1 has been saved.');
CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
}
}
示例15: processCreditCard
/**
* @param $submittedValues
*/
public function processCreditCard($submittedValues)
{
$config = CRM_Core_Config::singleton();
$session = CRM_Core_Session::singleton();
$unsetParams = array('trxn_id', 'payment_instrument_id', 'contribution_status_id');
foreach ($unsetParams as $key) {
if (isset($submittedValues[$key])) {
unset($submittedValues[$key]);
}
}
// Get the required fields value only.
$params = $this->_params = $submittedValues;
//get the payment processor id as per mode.
//@todo unclear relevance of mode - seems like a lot of duplicated params here!
$this->_params['payment_processor'] = $params['payment_processor_id'] = $this->_params['payment_processor_id'] = $submittedValues['payment_processor_id'] = $this->_paymentProcessor['id'];
$now = date('YmdHis');
$fields = array();
// we need to retrieve email address
if ($this->_context == 'standalone' && !empty($submittedValues['is_email_receipt'])) {
list($this->userDisplayName, $this->userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactId);
$this->assign('displayName', $this->userDisplayName);
}
//set email for primary location.
$fields['email-Primary'] = 1;
$params['email-Primary'] = $this->_contributorEmail;
// now set the values for the billing location.
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
// also add location name to the array
$params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params);
$params["address_name-{$this->_bltID}"] = trim($params["address_name-{$this->_bltID}"]);
$fields["address_name-{$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}", $params)) {
$params[$name] = $params["billing_{$name}"];
$params['preserveDBName'] = TRUE;
}
}
if (!empty($params['source'])) {
unset($params['source']);
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $this->_contactId, NULL, NULL, $ctype);
// 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}"]);
if ($this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_CREDIT_CARD) {
$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'] = $this->_params['total_amount'];
// @todo - stop setting amount level in this function & call the CRM_Price_BAO_PriceSet::getAmountLevel
// function to get correct amount level consistently. Remove setting of the amount level in
// CRM_Price_BAO_PriceSet::processAmount. Extend the unit tests in CRM_Price_BAO_PriceSetTest
// to cover all variants.
$this->_params['amount_level'] = 0;
$this->_params['currencyID'] = CRM_Utils_Array::value('currency', $this->_params, $config->defaultCurrency);
if (!empty($this->_params['trxn_date'])) {
$this->_params['receive_date'] = CRM_Utils_Date::processDate($this->_params['trxn_date'], $this->_params['trxn_date_time']);
}
if (empty($this->_params['invoice_id'])) {
$this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
} else {
$this->_params['invoiceID'] = $this->_params['invoice_id'];
}
$this->assignBillingName($params);
$this->assign('address', CRM_Utils_Address::getFormattedBillingAddressFieldsFromParameters($params, $this->_bltID));
$date = CRM_Utils_Date::format($params['credit_card_exp_date']);
$date = CRM_Utils_Date::mysqlToIso($date);
$this->assign('credit_card_type', CRM_Utils_Array::value('credit_card_type', $params));
$this->assign('credit_card_exp_date', $date);
$this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($params['credit_card_number']));
//Add common data to formatted params
CRM_Contribute_Form_AdditionalInfo::postProcessCommon($params, $this->_params, $this);
// 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);
// 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->_contributorEmail;
$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'];
//.........这里部分代码省略.........