本文整理汇总了PHP中CRM_Financial_BAO_PaymentProcessor::getPayment方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Financial_BAO_PaymentProcessor::getPayment方法的具体用法?PHP CRM_Financial_BAO_PaymentProcessor::getPayment怎么用?PHP CRM_Financial_BAO_PaymentProcessor::getPayment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Financial_BAO_PaymentProcessor
的用法示例。
在下文中一共展示了CRM_Financial_BAO_PaymentProcessor::getPayment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* @param CRM_Core_Form $form
* @param null $type
* @param null $mode
*
* @throws Exception
*/
public static function preProcess(&$form, $type = NULL, $mode = NULL)
{
if ($type) {
$form->_type = $type;
} else {
$form->_type = CRM_Utils_Request::retrieve('type', 'String', $form);
}
if ($form->_type) {
$form->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($form->_type, $form->_mode);
}
$form->set('paymentProcessor', $form->_paymentProcessor);
// also set cancel subscription url
if (!empty($form->_paymentProcessor['is_recur']) && !empty($form->_values['is_recur'])) {
$form->_paymentObject = CRM_Core_Payment::singleton($mode, $form->_paymentProcessor, $form);
$form->_values['cancelSubscriptionUrl'] = $form->_paymentObject->subscriptionURL();
}
//checks after setting $form->_paymentProcessor
// we do this outside of the above conditional to avoid
// saving the country/state list in the session (which could be huge)
CRM_Core_Payment_Form::setPaymentFieldsByProcessor($form, $form->_paymentProcessor);
$form->assign_by_ref('paymentProcessor', $form->_paymentProcessor);
// check if this is a paypal auto return and redirect accordingly
//@todo - determine if this is legacy and remove
if (CRM_Core_Payment::paypalRedirect($form->_paymentProcessor)) {
$url = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_ThankYou_display=1&qfKey={$form->controller->_key}");
CRM_Utils_System::redirect($url);
}
// make sure we have a valid payment class, else abort
if (!empty($form->_values['is_monetary']) && !$form->_paymentProcessor['class_name'] && empty($form->_values['is_pay_later'])) {
CRM_Core_Error::fatal(ts('Payment processor is not set for this page'));
}
if (!empty($form->_membershipBlock) && !empty($form->_membershipBlock['is_separate_payment']) && (!empty($form->_paymentProcessor['class_name']) && !(CRM_Utils_Array::value('billing_mode', $form->_paymentProcessor) & CRM_Core_Payment::BILLING_MODE_FORM))) {
CRM_Core_Error::fatal(ts('This contribution page is configured to support separate contribution and membership payments. This %1 plugin does not currently support multiple simultaneous payments, or the option to "Execute real-time monetary transactions" is disabled. Please contact the site administrator and notify them of this error', array(1 => $form->_paymentProcessor['payment_processor_type'])));
}
}
示例2: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
parent::preProcess();
$this->_paymentProcessorID = CRM_Utils_Request::retrieve('processor_id', 'Integer', CRM_Core_DAO::$_nullObject, TRUE);
$this->assignBillingType();
// @todo - round about way to load it - just load as an object using civi\payment\system::getByProcessor
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_paymentProcessorID, 'unused');
CRM_Core_Payment_ProcessorForm::preProcess($this);
self::addCreditCardJs();
$this->assign('paymentProcessorID', $this->_paymentProcessorID);
}
示例3: preProcess
/**
* Set variables up before form is built.
*/
public function preProcess()
{
parent::preProcess();
$this->_paymentProcessorID = CRM_Utils_Request::retrieve('processor_id', 'Integer', CRM_Core_DAO::$_nullObject, TRUE);
$this->assignBillingType();
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_paymentProcessorID);
CRM_Core_Payment_ProcessorForm::preProcess($this);
self::addCreditCardJs();
$this->assign('paymentProcessorID', $this->_paymentProcessorID);
$this->assign('suppressForm', TRUE);
}
示例4: preProcess
/**
* @param CRM_Contribute_Form_Contribution_Main|CRM_Event_Form_Registration_Register|CRM_Financial_Form_Payment $form
* @param null $type
* @param null $mode
*
* @throws Exception
*/
public static function preProcess(&$form, $type = NULL, $mode = NULL)
{
if ($type) {
$form->_type = $type;
} else {
$form->_type = CRM_Utils_Request::retrieve('type', 'String', $form);
}
if ($form->_type) {
$form->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($form->_type, $form->_mode);
}
if (empty($form->_paymentProcessor)) {
// This would happen when hitting the back-button on a multi-page form with a $0 selection in play.
return;
}
$form->set('paymentProcessor', $form->_paymentProcessor);
$form->_paymentObject = System::singleton()->getByProcessor($form->_paymentProcessor);
$form->assign('suppressSubmitButton', $form->_paymentObject->isSuppressSubmitButtons());
$form->assign('currency', CRM_Utils_Array::value('currency', $form->_values));
// also set cancel subscription url
if (!empty($form->_paymentProcessor['is_recur']) && !empty($form->_values['is_recur'])) {
$form->_values['cancelSubscriptionUrl'] = $form->_paymentObject->subscriptionURL(NULL, NULL, 'cancel');
}
if (!empty($form->_values['custom_pre_id'])) {
$profileAddressFields = array();
$fields = CRM_Core_BAO_UFGroup::getFields($form->_values['custom_pre_id'], FALSE, CRM_Core_Action::ADD, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL);
foreach ((array) $fields as $key => $value) {
CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields, array('uf_group_id' => $form->_values['custom_pre_id']));
}
if (count($profileAddressFields)) {
$form->set('profileAddressFields', $profileAddressFields);
}
}
//checks after setting $form->_paymentProcessor
// we do this outside of the above conditional to avoid
// saving the country/state list in the session (which could be huge)
CRM_Core_Payment_Form::setPaymentFieldsByProcessor($form, $form->_paymentProcessor, CRM_Utils_Request::retrieve('billing_profile_id', 'String'));
$form->assign_by_ref('paymentProcessor', $form->_paymentProcessor);
// check if this is a paypal auto return and redirect accordingly
//@todo - determine if this is legacy and remove
if (CRM_Core_Payment::paypalRedirect($form->_paymentProcessor)) {
$url = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_ThankYou_display=1&qfKey={$form->controller->_key}");
CRM_Utils_System::redirect($url);
}
// make sure we have a valid payment class, else abort
if (!empty($form->_values['is_monetary']) && !$form->_paymentProcessor['class_name'] && empty($form->_values['is_pay_later'])) {
CRM_Core_Error::fatal(ts('Payment processor is not set for this page'));
}
if (!empty($form->_membershipBlock) && !empty($form->_membershipBlock['is_separate_payment']) && (!empty($form->_paymentProcessor['class_name']) && !$form->_paymentObject->supports('MultipleConcurrentPayments'))) {
CRM_Core_Error::fatal(ts('This contribution page is configured to support separate contribution and membership payments. This %1 plugin does not currently support multiple simultaneous payments, or the option to "Execute real-time monetary transactions" is disabled. Please contact the site administrator and notify them of this error', array(1 => $form->_paymentProcessor['payment_processor_type'])));
}
}
示例5: preProcess
/**
* Set variables up before form is built.
*/
public function preProcess()
{
parent::preProcess();
$this->_values['custom_pre_id'] = CRM_Utils_Request::retrieve('pre_profile_id', 'Integer', $this);
$this->_paymentProcessorID = CRM_Utils_Request::retrieve('processor_id', 'Integer', CRM_Core_DAO::$_nullObject, TRUE);
$this->currency = CRM_Utils_Request::retrieve('currency', 'String', CRM_Core_DAO::$_nullObject, TRUE);
$this->assignBillingType();
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_paymentProcessorID);
CRM_Core_Payment_ProcessorForm::preProcess($this);
self::addCreditCardJs();
$this->assign('paymentProcessorID', $this->_paymentProcessorID);
$this->assign('currency', $this->currency);
$this->assign('suppressForm', TRUE);
$this->controller->_generateQFKey = FALSE;
}
示例6: 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 int $billing_profile_id
* Display billing fields even for pay later.
* @param bool $isBackOffice
* Is this a back office function? If so the option to suppress the cvn needs to be evaluated.
*/
public static function setPaymentFieldsByProcessor(&$form, $processor, $billing_profile_id = NULL, $isBackOffice = FALSE)
{
$form->billingFieldSets = array();
// Load the pay-later processor
// @todo load this right up where the other processors are loaded initially.
if (empty($processor)) {
$processor = CRM_Financial_BAO_PaymentProcessor::getPayment(0);
}
$processor['object']->setBillingProfile($billing_profile_id);
$paymentTypeName = self::getPaymentTypeName($processor);
$paymentTypeLabel = self::getPaymentTypeLabel($processor);
$form->assign('paymentTypeName', $paymentTypeName);
$form->assign('paymentTypeLabel', $paymentTypeLabel);
$form->_paymentFields = $form->billingFieldSets[$paymentTypeName]['fields'] = self::getPaymentFieldMetadata($processor);
$form->_paymentFields = array_merge($form->_paymentFields, self::getBillingAddressMetadata($processor, $form->_bltID));
$form->assign('paymentFields', self::getPaymentFields($processor));
self::setBillingAddressFields($form, $processor);
// @todo - this may be obsolete - although potentially it could be used to re-order things in the form.
$form->billingFieldSets['billing_name_address-group']['fields'] = array();
}
示例7: civicrm_api3_contribution_transact
/**
* Process a transaction and record it against the contact.
*
* @param array $params
* Input parameters.
*
* @return array
* contribution of created or updated record (or a civicrm error)
*/
function civicrm_api3_contribution_transact($params)
{
// Set some params specific to payment processing
// @todo - fix this function - none of the results checked by civicrm_error would ever be an array with
// 'is_error' set
// also trxn_id is not saved.
// but since there is no test it's not desirable to jump in & make the obvious changes.
$params['payment_processor_mode'] = empty($params['is_test']) ? 'live' : 'test';
$params['amount'] = $params['total_amount'];
if (!isset($params['net_amount'])) {
$params['net_amount'] = $params['amount'];
}
if (!isset($params['invoiceID']) && isset($params['invoice_id'])) {
$params['invoiceID'] = $params['invoice_id'];
}
// Some payment processors expect a unique invoice_id - generate one if not supplied
$params['invoice_id'] = CRM_Utils_Array::value('invoice_id', $params, md5(uniqid(rand(), TRUE)));
$paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($params['payment_processor'], $params['payment_processor_mode']);
$paymentProcessor['object']->doPayment($params);
$params['payment_instrument_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessorType', $paymentProcessor['payment_processor_type_id'], 'payment_type') == 1 ? 'Credit Card' : 'Debit Card';
return civicrm_api('Contribution', 'create', $params);
}
示例8: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$session = CRM_Core_Session::singleton();
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$contributionParams = $requestParams = $_REQUEST;
$contactID = $session->get('userID');
if ($contactID && empty($contributionParams['email'])) {
$emailDetails = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
if (!empty($emailDetails)) {
$contributionParams['email'] = $emailDetails[1];
// for email to be prefilled
$this->assign('email', $emailDetails[1]);
}
}
$pageConfig = civicrm_api3('ContributionPage', 'getsingle', array('id' => $this->_id));
if (is_array($pageConfig['payment_processor'])) {
CRM_Core_Error::fatal(ts('Multiple payment processors not supported with quick donate.'));
}
$processorDetails = CRM_Financial_BAO_PaymentProcessor::getPayment($pageConfig['payment_processor'], 'live');
//MV: get amount details if other amount enabled for contribution page.
if ($pageConfig['amount_block_is_active']) {
$sql = "SELECT cpfv.amount, cpfv.is_default, cpfv.weight \n FROM civicrm_price_field_value cpfv \n INNER JOIN civicrm_price_field cpf ON (cpf.id = cpfv.price_field_id)\n INNER JOIN civicrm_price_set_entity cpse ON (cpse.price_set_id = cpf.price_set_id)\n WHERE cpse.entity_id = %1 AND cpf.name = 'contribution_amount'\n ";
$dao = CRM_Core_DAO::executeQuery($sql, array(1 => array($pageConfig['id'], 'Integer')));
$amount = 0;
while ($dao->fetch()) {
if ($dao->weight == 1 || $dao->is_default == 1) {
$amount = $dao->amount;
}
}
}
$pageConfig['default_amount'] = $amount ? $amount : $pageConfig['min_amount'];
$pageConfig['currency_symbol'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_Currency', $pageConfig['currency'], 'symbol', 'name');
$this->assign('pageConfig', $pageConfig);
$this->assign('key', $processorDetails['password']);
$this->assign('currency', strtolower($pageConfig['currency']));
if (!empty($requestParams['stripe_token'])) {
//FIXME: could go in post process
if (!$contributionParams['email']) {
CRM_Core_Error::fatal(ts('Email address is required'));
}
$contributionParams['financial_type_id'] = $pageConfig['financial_type_id'];
if (!$contactID) {
$contactParams = array('email' => $contributionParams['email'], 'contact_type' => 'Individual');
$dedupeParams = CRM_Dedupe_Finder::formatParams($contactParams, '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);
if (!$contactID) {
$cont = civicrm_api3('Contact', 'create', $contactParams);
$contactID = $cont['id'];
}
}
$contributionParams['contact_id'] = $contactID;
$contributionParams['payment_processor_id'] = $pageConfig['payment_processor'];
$contributionParams['currencyID'] = $pageConfig['currency'];
//gift aid
//get gift aid custom field id
$sqlCF = "SELECT cf.id \n FROM civicrm_custom_field cf \n INNER JOIN civicrm_custom_group cg ON (cg.id = cf.custom_group_id) \n WHERE cg.name = %1 AND cf.name = %2";
$sqlCFParams = array(1 => array(self::C_CUSTOM_GROUP_GIFT_AID, 'String'), 2 => array(self::C_CUSTOM_FIELD_GIFT_AID, 'String'));
$cfId = CRM_Core_DAO::singleValueQuery($sqlCF, $sqlCFParams);
if ($cfId && $contributionParams['donation_form']['gift_aid']) {
$contributionParams["custom_{$cfId}"] = 1;
}
//gift aid end
//campaign
if ($pageConfig['campaign_id']) {
$contributionParams['campaign_id'] = $pageConfig['campaign_id'];
}
try {
$result = civicrm_api3('Contribution', 'transact', $contributionParams);
} catch (CiviCRM_API3_Exception $e) {
$error = $e->getMessage();
$this->assign('error', $error);
CRM_Utils_System::setTitle(ts('Oops! There was a problem'));
}
if (!empty($result['error'])) {
$this->assign('error', $result['error']);
CRM_Utils_System::setTitle(ts('Oops! There was a problem'));
} else {
if ($result) {
$contributionID = $result['id'];
$contactID = $result['values'][$contributionID]['contact_id'];
// Send receipt
civicrm_api3('contribution', 'sendconfirmation', array('id' => $contributionID) + $pageConfig);
CRM_Utils_System::setTitle(ts('Thank you'));
$this->assign('status', 'thankyou');
$profileID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'Supporter Profile', 'id', 'title');
// Link (button) for users to create their own Personal Campaign page
if ($profileID && !$session->get('userID')) {
$ufId = CRM_Core_BAO_UFMatch::getUFId($contactID);
if ($ufId) {
$config = CRM_Core_Config::singleton();
$loginURL = $config->userSystem->getLoginURL();
$this->assign('loginURL', $loginURL);
//.........这里部分代码省略.........
示例9: main
/**
* This method is handles the response that will be invoked (from extern/googleNotify) every time
* a notification or request is sent by the Google Server.
*
*/
static function main($xml_response)
{
require_once 'Google/library/googleresponse.php';
require_once 'Google/library/googlerequest.php';
require_once 'Google/library/googlemerchantcalculations.php';
require_once 'Google/library/googleresult.php';
require_once 'Google/library/xml-processing/gc_xmlparser.php';
$config = CRM_Core_Config::singleton();
// Retrieve the XML sent in the HTTP POST request to the ResponseHandler
if (get_magic_quotes_gpc()) {
$xml_response = stripslashes($xml_response);
}
$headers = CRM_Utils_System::getAllHeaders();
if (GOOGLE_DEBUG_PP) {
CRM_Core_Error::debug_var('RESPONSE', $xml_response, TRUE, TRUE, 'Google');
}
// Retrieve the root and data from the xml response
$response = new GoogleResponse();
list($root, $data) = $response->GetParsedXML($xml_response);
// lets retrieve the private-data & order-no
$privateData = NULL;
if (array_key_exists('shopping-cart', $data[$root])) {
$privateData = $data[$root]['shopping-cart']['merchant-private-data']['VALUE'];
}
if (empty($privateData) && array_key_exists('order-summary', $data[$root]) && array_key_exists('shopping-cart', $data[$root]['order-summary'])) {
$privateData = $data[$root]['order-summary']['shopping-cart']['merchant-private-data']['VALUE'];
}
$privateData = $privateData ? self::stringToArray($privateData) : '';
$orderNo = $data[$root]['google-order-number']['VALUE'];
$serial = $data[$root]['serial-number'];
// a dummy object to call get context and a parent function inside it.
$ipn = new CRM_Core_Payment_GoogleIPN('live', $dummyProcessor);
list($mode, $module, $paymentProcessorID) = $ipn->getContext($privateData, $orderNo, $root, $response, $serial);
$mode = $mode ? 'test' : 'live';
$paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($paymentProcessorID, $mode);
$merchant_id = $paymentProcessor['user_name'];
$merchant_key = $paymentProcessor['password'];
$response->SetMerchantAuthentication($merchant_id, $merchant_key);
$server_type = $mode == 'test' ? 'sandbox' : 'production';
$request = new GoogleRequest($merchant_id, $merchant_key, $server_type);
$ipn = self::singleton($mode, $module, $paymentProcessor);
if (GOOGLE_DEBUG_PP) {
CRM_Core_Error::debug_var('RESPONSE-ROOT', $response->root, TRUE, TRUE, 'Google');
}
//Check status and take appropriate action
$status = $response->HttpAuthentication($headers);
switch ($root) {
case "request-received":
case "error":
case "diagnosis":
case "checkout-redirect":
case "merchant-calculation-callback":
break;
case "new-order-notification":
$response->SendAck($serial, FALSE);
$ipn->newOrderNotify($data[$root], $privateData, $module);
break;
case "order-state-change-notification":
$response->SendAck($serial, FALSE);
$new_financial_state = $data[$root]['new-financial-order-state']['VALUE'];
$new_fulfillment_order = $data[$root]['new-fulfillment-order-state']['VALUE'];
switch ($new_financial_state) {
case 'CHARGEABLE':
break;
case 'CHARGED':
case 'PAYMENT_DECLINED':
case 'CANCELLED':
case 'CANCELLED_BY_GOOGLE':
$ipn->orderStateChange($new_financial_state, $data[$root], $privateData, $module);
break;
case 'REVIEWING':
case 'CHARGING':
break;
default:
break;
}
break;
case "authorization-amount-notification":
$response->SendAck($serial, FALSE);
$new_financial_state = $data[$root]['order-summary']['financial-order-state']['VALUE'];
$new_fulfillment_order = $data[$root]['order-summary']['fulfillment-order-state']['VALUE'];
switch ($new_financial_state) {
case 'CHARGEABLE':
// For google-handled subscriptions chargeorder needn't be initiated,
// assuming auto-charging is turned on.
//$request->SendProcessOrder($data[$root]['google-order-number']['VALUE']);
//$request->SendChargeOrder($data[$root]['google-order-number']['VALUE'],'');
break;
case 'CHARGED':
case 'PAYMENT_DECLINED':
case 'CANCELLED':
break;
case 'REVIEWING':
case 'CHARGING':
case 'CANCELLED_BY_GOOGLE':
//.........这里部分代码省略.........
示例10: postProcess
//.........这里部分代码省略.........
$params['contribution_source'] = $formValues['source'];
}
}
if (empty($params['is_override']) && CRM_Utils_Array::value('contribution_status_id', $params) == array_search('Pending', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'))) {
$params['status_id'] = array_search('Pending', $allMemberStatus);
$params['skipStatusCal'] = TRUE;
$params['is_pay_later'] = 1;
$this->assign('is_pay_later', 1);
}
if (!empty($formValues['send_receipt'])) {
$params['receipt_date'] = CRM_Utils_Array::value('receive_date', $formValues);
}
//insert financial type name in receipt.
$formValues['contributionType_name'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $formValues['financial_type_id']);
}
// process line items, until no previous line items.
if (!empty($lineItem)) {
$params['lineItems'] = $lineItem;
$params['processPriceSet'] = TRUE;
}
$createdMemberships = array();
if ($this->_mode) {
if (empty($formValues['total_amount']) && !$priceSetId) {
// if total amount not provided minimum for membership type is used
$params['total_amount'] = $formValues['total_amount'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $formValues['membership_type_id'][1], 'minimum_fee');
} else {
$params['total_amount'] = CRM_Utils_Array::value('total_amount', $formValues, 0);
}
if ($priceSetId && !$isQuickConfig) {
$params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'financial_type_id');
} else {
$params['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $formValues);
}
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($formValues['payment_processor_id'], $this->_mode);
//get the payment processor id as per mode.
$params['payment_processor_id'] = $this->_params['payment_processor_id'] = $formValues['payment_processor_id'] = $this->_paymentProcessor['id'];
$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;
}
$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;
}
}
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, $ctype);
示例11: submit
/**
* Process form submission.
*
* This function is also accessed by a unit test.
*/
protected function submit()
{
$this->storeContactFields($this->_params);
$now = CRM_Utils_Date::getToday(NULL, 'YmdHis');
$this->convertDateFieldsToMySQL($this->_params);
$this->assign('receive_date', $this->_params['receive_date']);
$this->processBillingAddress($now);
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');
}
$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->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_params['payment_processor_id']);
$this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
$this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
$this->assign('credit_card_exp_date', CRM_Utils_Date::mysqlToIso(CRM_Utils_Date::format($this->_params['credit_card_exp_date'])));
$this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($this->_params['credit_card_number']));
$this->assign('credit_card_type', $this->_params['credit_card_type']);
$this->_params['description'] = ts("Contribution submitted by a staff person using member's credit card for renewal");
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$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);
$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.
$contributionRecurID = isset($this->_params['contributionRecurID']) ? $this->_params['contributionRecurID'] : NULL;
$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();
$priceSetId = CRM_Member_BAO_Membership::createLineItems($this, $this->_params['membership_type_id']);
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $this->_params, $lineItem[$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)) {
//.........这里部分代码省略.........
示例12: main
/**
* This method is handles the response that will be invoked (from extern/googleNotify) every time
* a notification or request is sent by the Google Server.
*
*/
static function main($xml_response)
{
require_once 'Google/library/googleresponse.php';
require_once 'Google/library/googlemerchantcalculations.php';
require_once 'Google/library/googleresult.php';
require_once 'Google/library/xml-processing/xmlparser.php';
$config = CRM_Core_Config::singleton();
// Retrieve the XML sent in the HTTP POST request to the ResponseHandler
if (get_magic_quotes_gpc()) {
$xml_response = stripslashes($xml_response);
}
require_once 'CRM/Utils/System.php';
$headers = CRM_Utils_System::getAllHeaders();
if (GOOGLE_DEBUG_PP) {
CRM_Core_Error::debug_var('RESPONSE', $xml_response, TRUE, TRUE, 'Google');
}
// Retrieve the root and data from the xml response
$xmlParser = new XmlParser($xml_response);
$root = $xmlParser->GetRoot();
$data = $xmlParser->GetData();
$orderNo = $data[$root]['google-order-number']['VALUE'];
// lets retrieve the private-data
$privateData = $data[$root]['shopping-cart']['merchant-private-data']['VALUE'];
$privateData = $privateData ? self::stringToArray($privateData) : '';
list($mode, $module, $paymentProcessorID) = self::getContext($xml_response, $privateData, $orderNo, $root);
$mode = $mode ? 'test' : 'live';
require_once 'CRM/Financial/BAO/PaymentProcessor.php';
$paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($paymentProcessorID, $mode);
$ipn =& self::singleton($mode, $module, $paymentProcessor);
// Create new response object
$merchant_id = $paymentProcessor['user_name'];
$merchant_key = $paymentProcessor['password'];
$server_type = $mode == 'test' ? "sandbox" : '';
$response = new GoogleResponse($merchant_id, $merchant_key, $xml_response, $server_type);
if (GOOGLE_DEBUG_PP) {
CRM_Core_Error::debug_var('RESPONSE-ROOT', $response->root, TRUE, TRUE, 'Google');
}
//Check status and take appropriate action
$status = $response->HttpAuthentication($headers);
switch ($root) {
case "request-received":
case "error":
case "diagnosis":
case "checkout-redirect":
case "merchant-calculation-callback":
break;
case "new-order-notification":
$response->SendAck();
$ipn->newOrderNotify($data[$root], $privateData, $module);
break;
case "order-state-change-notification":
$response->SendAck();
$new_financial_state = $data[$root]['new-financial-order-state']['VALUE'];
$new_fulfillment_order = $data[$root]['new-fulfillment-order-state']['VALUE'];
switch ($new_financial_state) {
case 'CHARGEABLE':
$amount = $ipn->getAmount($orderNo);
if ($amount) {
$response->SendChargeOrder($data[$root]['google-order-number']['VALUE'], $amount, $message_log);
$response->SendProcessOrder($data[$root]['google-order-number']['VALUE'], $message_log);
}
break;
case 'CHARGED':
case 'PAYMENT_DECLINED':
case 'CANCELLED':
$ipn->orderStateChange($new_financial_state, $data[$root], $module);
break;
case 'REVIEWING':
case 'CHARGING':
case 'CANCELLED_BY_GOOGLE':
break;
default:
break;
}
case "charge-amount-notification":
case "chargeback-amount-notification":
case "refund-amount-notification":
case "risk-information-notification":
$response->SendAck();
break;
default:
break;
}
}
示例13: postProcess
//.........这里部分代码省略.........
$amountOwed = $params['amount'];
unset($params['amount']);
}
$params['register_date'] = CRM_Utils_Date::processDate($params['register_date'], $params['register_date_time']);
$params['receive_date'] = CRM_Utils_Date::processDate(CRM_Utils_Array::value('receive_date', $params), CRM_Utils_Array::value('receive_date_time', $params));
$params['contact_id'] = $this->_contactId;
// overwrite actual payment amount if entered
if (!empty($params['total_amount'])) {
$contributionParams['total_amount'] = CRM_Utils_Array::value('total_amount', $params);
}
// Retrieve the name and email of the current user - this will be the FROM for the receipt email
$userName = CRM_Core_Session::singleton()->getLoggedInContactDisplayName();
if ($this->_contactId) {
list($this->_contributorDisplayName, $this->_contributorEmail, $this->_toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_contactId);
}
//modify params according to parameter used in create
//participant method (addParticipant)
$this->_params['participant_status_id'] = $params['status_id'];
$this->_params['participant_role_id'] = is_array($params['role_id']) ? $params['role_id'] : explode(',', $params['role_id']);
$this->_params['participant_register_date'] = $params['register_date'];
$roleIdWithSeparator = implode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_params['participant_role_id']);
if ($this->_mode) {
if (!$this->_isPaidEvent) {
CRM_Core_Error::fatal(ts('Selected Event is not Paid Event '));
}
$eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['event_id'], 'title');
// set source if not set
if (empty($params['source'])) {
$this->_params['participant_source'] = ts('Offline Registration for Event: %2 by: %1', array(1 => $userName, 2 => $eventTitle));
} else {
$this->_params['participant_source'] = $params['source'];
}
$this->_params['description'] = $this->_params['participant_source'];
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_params['payment_processor_id'], $this->_mode);
$now = date('YmdHis');
$fields = array();
// set email for primary location.
$fields['email-Primary'] = 1;
$params['email-Primary'] = $params["email-{$this->_bltID}"] = $this->_contributorEmail;
$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
$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;
$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);
示例14: handlePaymentMethod
/**
* Payment callback handler. The processor_name or processor_id is passed in.
* Note that processor_id is more reliable as one site may have more than one instance of a
* processor & ideally the processor will be validating the results
* Load requested payment processor and call that processor's handle<$method> method
*
* @public
* @param $method
* @param array $params
*/
static function handlePaymentMethod($method, $params = array())
{
if (!isset($params['processor_id']) && !isset($params['processor_name'])) {
CRM_Core_Error::fatal("Either 'processor_id' or 'processor_name' param is required for payment callback");
}
self::logPaymentNotification($params);
// Query db for processor ..
$mode = @$params['mode'];
$sql = "SELECT ppt.class_name, ppt.name as processor_name, pp.id AS processor_id\n FROM civicrm_payment_processor_type ppt\n INNER JOIN civicrm_payment_processor pp\n ON pp.payment_processor_type_id = ppt.id\n AND pp.is_active\n AND pp.is_test = %1";
$args[1] = array($mode == 'test' ? 1 : 0, 'Integer');
if (isset($params['processor_id'])) {
$sql .= " WHERE pp.id = %2";
$args[2] = array($params['processor_id'], 'Integer');
$notfound = "No active instances of payment processor ID#'{$params['processor_id']}' were found.";
} else {
$sql .= " WHERE ppt.name = %2";
$args[2] = array($params['processor_name'], 'String');
$notfound = "No active instances of the '{$params['processor_name']}' payment processor were found.";
}
$dao = CRM_Core_DAO::executeQuery($sql, $args);
// Check whether we found anything at all ..
if (!$dao->N) {
CRM_Core_Error::fatal($notfound);
}
$method = 'handle' . $method;
$extension_instance_found = FALSE;
// In all likelihood, we'll just end up with the one instance returned here. But it's
// possible we may get more. Hence, iterate through all instances ..
while ($dao->fetch()) {
// Check pp is extension
$ext = CRM_Extension_System::singleton()->getMapper();
if ($ext->isExtensionKey($dao->class_name)) {
$paymentClass = $ext->keyToClass($dao->class_name, 'payment');
require_once $ext->classToPath($paymentClass);
} else {
// Legacy or extension as module instance
if (empty($paymentClass)) {
$paymentClass = 'CRM_Core_' . $dao->class_name;
}
}
$paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($dao->processor_id, $mode);
// Should never be empty - we already established this processor_id exists and is active.
if (empty($paymentProcessor)) {
continue;
}
// Instantiate PP
$processorInstance = $paymentClass::singleton($mode, $paymentProcessor);
// Does PP implement this method, and can we call it?
if (!method_exists($processorInstance, $method) || !is_callable(array($processorInstance, $method))) {
// on the off chance there is a double implementation of this processor we should keep looking for another
// note that passing processor_id is more reliable & we should work to deprecate processor_name
continue;
}
// Everything, it seems, is ok - execute pp callback handler
$processorInstance->{$method}();
$extension_instance_found = TRUE;
}
if (!$extension_instance_found) {
CRM_Core_Error::fatal("No extension instances of the '{$params['processor_name']}' payment processor were found.<br />" . "{$method} method is unsupported in legacy payment processors.");
}
// Exit here on web requests, allowing just the plain text response to be echoed
if ($method == 'handlePaymentNotification') {
CRM_Utils_System::civiExit();
}
}
示例15: loadRelatedObjects
//.........这里部分代码省略.........
* Note that the unit test for the BaseIPN class tests this function
*
* @param array $input
* Input as delivered from Payment Processor.
* @param array $ids
* Ids as Loaded by Payment Processor.
* @param bool $loadAll
* Load all related objects - even where id not passed in? (allows API to call this).
*
* @return bool
* @throws Exception
*/
public function loadRelatedObjects(&$input, &$ids, $loadAll = FALSE)
{
if ($loadAll) {
$ids = array_merge($this->getComponentDetails($this->id), $ids);
if (empty($ids['contact']) && isset($this->contact_id)) {
$ids['contact'] = $this->contact_id;
}
}
if (empty($this->_component)) {
if (!empty($ids['event'])) {
$this->_component = 'event';
} else {
$this->_component = strtolower(CRM_Utils_Array::value('component', $input, 'contribute'));
}
}
// If the object is not fully populated then make sure it is - this is a more about legacy paths & cautious
// refactoring than anything else, and has unit test coverage.
if (empty($this->financial_type_id)) {
$this->find(TRUE);
}
$paymentProcessorID = CRM_Utils_Array::value('payment_processor_id', $input, CRM_Utils_Array::value('paymentProcessor', $ids));
if (!$paymentProcessorID && $this->contribution_page_id) {
$paymentProcessorID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->contribution_page_id, 'payment_processor');
if ($paymentProcessorID) {
$intentionalEnotice = $CRM16923AnUnreliableMethodHasBeenUserToDeterminePaymentProcessorFromContributionPage;
}
}
$ids['contributionType'] = $this->financial_type_id;
$ids['financialType'] = $this->financial_type_id;
$entities = array('contact' => 'CRM_Contact_BAO_Contact', 'contributionRecur' => 'CRM_Contribute_BAO_ContributionRecur', 'contributionType' => 'CRM_Financial_BAO_FinancialType', 'financialType' => 'CRM_Financial_BAO_FinancialType');
foreach ($entities as $entity => $bao) {
if (!empty($ids[$entity])) {
$this->_relatedObjects[$entity] = new $bao();
$this->_relatedObjects[$entity]->id = $ids[$entity];
if (!$this->_relatedObjects[$entity]->find(TRUE)) {
throw new CRM_Core_Exception($entity . ' could not be loaded');
}
}
}
if (!empty($ids['contributionRecur']) && !$paymentProcessorID) {
$paymentProcessorID = $this->_relatedObjects['contributionRecur']->payment_processor_id;
}
if (!empty($ids['pledge_payment'])) {
foreach ($ids['pledge_payment'] as $key => $paymentID) {
if (empty($paymentID)) {
continue;
}
$payment = new CRM_Pledge_BAO_PledgePayment();
$payment->id = $paymentID;
if (!$payment->find(TRUE)) {
throw new Exception("Could not find pledge payment record: " . $paymentID);
}
$this->_relatedObjects['pledge_payment'][] = $payment;
}
}
$this->loadRelatedMembershipObjects($ids);
if ($this->_component != 'contribute') {
// we are in event mode
// make sure event exists and is valid
$event = new CRM_Event_BAO_Event();
$event->id = $ids['event'];
if ($ids['event'] && !$event->find(TRUE)) {
throw new Exception("Could not find event: " . $ids['event']);
}
$this->_relatedObjects['event'] =& $event;
$participant = new CRM_Event_BAO_Participant();
$participant->id = $ids['participant'];
if ($ids['participant'] && !$participant->find(TRUE)) {
throw new Exception("Could not find participant: " . $ids['participant']);
}
$participant->register_date = CRM_Utils_Date::isoToMysql($participant->register_date);
$this->_relatedObjects['participant'] =& $participant;
// get the payment processor id from event - this is inaccurate see CRM-16923
// in future we should look at throwing an exception here rather than an dubious guess.
if (!$paymentProcessorID) {
$paymentProcessorID = $this->_relatedObjects['event']->payment_processor;
if ($paymentProcessorID) {
$intentionalEnotice = $CRM16923AnUnreliableMethodHasBeenUserToDeterminePaymentProcessorFromEvent;
}
}
}
if ($paymentProcessorID) {
$paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($paymentProcessorID, $this->is_test ? 'test' : 'live');
$ids['paymentProcessor'] = $paymentProcessorID;
$this->_relatedObjects['paymentProcessor'] = $paymentProcessor;
}
return TRUE;
}