本文整理汇总了PHP中CRM_Contribute_BAO_Contribution::find方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_Contribution::find方法的具体用法?PHP CRM_Contribute_BAO_Contribution::find怎么用?PHP CRM_Contribute_BAO_Contribution::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_Contribution
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_Contribution::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: recur
/**
* @param $input
* @param $ids
* @param $objects
* @param $first
*
* @return bool
*/
public function recur(&$input, &$ids, &$objects, $first)
{
if (!isset($input['txnType'])) {
CRM_Core_Error::debug_log_message("Could not find txn_type in input request");
echo "Failure: Invalid parameters<p>";
return FALSE;
}
if ($input['txnType'] == 'subscr_payment' && $input['paymentStatus'] != 'Completed') {
CRM_Core_Error::debug_log_message("Ignore all IPN payments that are not completed");
echo "Failure: Invalid parameters<p>";
return FALSE;
}
$recur =& $objects['contributionRecur'];
// make sure the invoice ids match
// make sure the invoice is valid and matches what we have in the contribution record
if ($recur->invoice_id != $input['invoice']) {
CRM_Core_Error::debug_log_message("Invoice values dont match between database and IPN request");
echo "Failure: Invoice values dont match between database and IPN request<p>";
return FALSE;
}
$now = date('YmdHis');
// fix dates that already exist
$dates = array('create', 'start', 'end', 'cancel', 'modified');
foreach ($dates as $date) {
$name = "{$date}_date";
if ($recur->{$name}) {
$recur->{$name} = CRM_Utils_Date::isoToMysql($recur->{$name});
}
}
$sendNotification = FALSE;
$subscriptionPaymentStatus = NULL;
//set transaction type
$txnType = $_POST['txn_type'];
switch ($txnType) {
case 'subscr_signup':
$recur->create_date = $now;
//some times subscr_signup response come after the
//subscr_payment and set to pending mode.
$statusID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionRecur', $recur->id, 'contribution_status_id');
if ($statusID != 5) {
$recur->contribution_status_id = 2;
}
$recur->processor_id = $_POST['subscr_id'];
$recur->trxn_id = $recur->processor_id;
$sendNotification = TRUE;
$subscriptionPaymentStatus = CRM_Core_Payment::RECURRING_PAYMENT_START;
break;
case 'subscr_eot':
if ($recur->contribution_status_id != 3) {
$recur->contribution_status_id = 1;
}
$recur->end_date = $now;
$sendNotification = TRUE;
$subscriptionPaymentStatus = CRM_Core_Payment::RECURRING_PAYMENT_END;
break;
case 'subscr_cancel':
$recur->contribution_status_id = 3;
$recur->cancel_date = $now;
break;
case 'subscr_failed':
$recur->contribution_status_id = 4;
$recur->modified_date = $now;
break;
case 'subscr_modify':
CRM_Core_Error::debug_log_message("We do not handle modifications to subscriptions right now");
echo "Failure: We do not handle modifications to subscriptions right now<p>";
return FALSE;
case 'subscr_payment':
if ($first) {
$recur->start_date = $now;
} else {
$recur->modified_date = $now;
}
// make sure the contribution status is not done
// since order of ipn's is unknown
if ($recur->contribution_status_id != 1) {
$recur->contribution_status_id = 5;
}
break;
}
$recur->save();
if ($sendNotification) {
$autoRenewMembership = FALSE;
if ($recur->id && isset($ids['membership']) && $ids['membership']) {
$autoRenewMembership = TRUE;
}
//send recurring Notification email for user
CRM_Contribute_BAO_ContributionPage::recurringNotify($subscriptionPaymentStatus, $ids['contact'], $ids['contributionPage'], $recur, $autoRenewMembership);
}
if ($txnType != 'subscr_payment') {
return;
}
//.........这里部分代码省略.........
示例2: getValues
/**
* Given the list of params in the params array, fetch the object
* and store the values in the values array
*
* @param array $params
* Input parameters to find object.
* @param array $values
* Output values of the object.
* @param array $ids
* The array that holds all the db ids.
*
* @return CRM_Contribute_BAO_Contribution|null
* The found object or null
*/
public static function getValues($params, &$values, &$ids)
{
if (empty($params)) {
return NULL;
}
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->copyValues($params);
if ($contribution->find(TRUE)) {
$ids['contribution'] = $contribution->id;
CRM_Core_DAO::storeValues($contribution, $values);
return $contribution;
}
$null = NULL;
// return by reference
return $null;
}
示例3: processFailedTransaction
/**
* Process failed transaction - would be nice to do this through api too but for now lets put in
* here - this is a copy & paste of the completetransaction api
* @param unknown $contributionID
*/
function processFailedTransaction($contributionID)
{
$input = $ids = array();
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $contributionID;
$contribution->find(TRUE);
if (!$contribution->id == $contributionID) {
throw new Exception('A valid contribution ID is required', 'invalid_data');
}
try {
if (!$contribution->loadRelatedObjects($input, $ids, FALSE, TRUE)) {
throw new Exception('failed to load related objects');
}
$objects = $contribution->_relatedObjects;
$objects['contribution'] =& $contribution;
$input['component'] = $contribution->_component;
$input['is_test'] = $contribution->is_test;
$input['amount'] = $contribution->total_amount;
// @todo required for base ipn but problematic as api layer handles this
$transaction = new CRM_Core_Transaction();
$ipn = new CRM_Core_Payment_BaseIPN();
$ipn->failed($objects, $transaction, $input);
} catch (Exception $e) {
}
}
示例4: civicrm_api3_contribution_repeattransaction
/**
* Complete an existing (pending) transaction.
*
* This will update related entities (participant, membership, pledge etc)
* and take any complete actions from the contribution page (e.g. send receipt).
*
* @todo - most of this should live in the BAO layer but as we want it to be an addition
* to 4.3 which is already stable we should add it to the api layer & re-factor into the BAO layer later
*
* @param array $params
* Input parameters.
*
* @throws API_Exception
* Api result array.
*/
function civicrm_api3_contribution_repeattransaction(&$params)
{
$input = $ids = array();
civicrm_api3_verify_one_mandatory($params, NULL, array('contribution_recur_id', 'original_contribution_id'));
if (empty($params['original_contribution_id'])) {
$params['original_contribution_id'] = civicrm_api3('contribution', 'getvalue', array('return' => 'id', 'contribution_recur_id' => $params['contribution_recur_id'], 'options' => array('limit' => 1, 'sort' => 'id DESC')));
}
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $params['original_contribution_id'];
if (!$contribution->find(TRUE)) {
throw new API_Exception('A valid original contribution ID is required', 'invalid_data');
}
$original_contribution = clone $contribution;
try {
if (!$contribution->loadRelatedObjects($input, $ids, TRUE)) {
throw new API_Exception('failed to load related objects');
}
unset($contribution->id, $contribution->receive_date, $contribution->invoice_id);
$contribution->receive_date = $params['receive_date'];
$passThroughParams = array('trxn_id', 'total_amount', 'campaign_id', 'fee_amount', 'financial_type_id', 'contribution_status_id');
$input = array_intersect_key($params, array_fill_keys($passThroughParams, NULL));
$params = _ipn_process_transaction($params, $contribution, $input, $ids, $original_contribution);
} catch (Exception $e) {
throw new API_Exception('failed to load related objects' . $e->getMessage() . "\n" . $e->getTraceAsString());
}
}
示例5: orderStateChange
/**
* The function gets called when the state(CHARGED, CANCELLED..) changes for an order
*
* @param string $status status of the transaction send by google
* @param array $privateData contains the name value pair of <merchant-private-data>
*
* @return void
*
*/
function orderStateChange($status, $dataRoot, $privateData, $component)
{
$input = $objects = $ids = array();
$input['component'] = strtolower($component);
$ids['contributionRecur'] = self::retrieve('contributionRecurID', 'Integer', $privateData, FALSE);
$serial = $dataRoot['serial-number'];
$orderNo = $dataRoot['google-order-number']['VALUE'];
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->invoice_id = $orderNo;
if (!$contribution->find(TRUE)) {
CRM_Core_Error::debug_log_message("orderStateChange: Could not find contribution record with invoice id: {$serial}");
return;
}
// Google sends the charged notification twice.
// So to make sure, code is not executed again.
if ($contribution->contribution_status_id == 1) {
CRM_Core_Error::debug_log_message("Contribution already handled (ContributionID = {$contribution->id}).");
return;
}
// make sure invoice is set to serial no for recurring payments, to avoid violating uniqueness
$contribution->invoice_id = $ids['contributionRecur'] ? $serial : $orderNo;
$objects['contribution'] =& $contribution;
$ids['contribution'] = $contribution->id;
$ids['contact'] = $contribution->contact_id;
$ids['event'] = $ids['participant'] = $ids['membership'] = NULL;
$ids['contributionPage'] = NULL;
if ($input['component'] == "event") {
list($ids['event'], $ids['participant']) = explode(CRM_Core_DAO::VALUE_SEPARATOR, $contribution->trxn_id);
} else {
$ids['related_contact'] = NULL;
$ids['onbehalf_dupe_alert'] = NULL;
if ($contribution->trxn_id) {
list($ids['membership'], $ids['related_contact'], $ids['onbehalf_dupe_alert']) = explode(CRM_Core_DAO::VALUE_SEPARATOR, $contribution->trxn_id);
}
foreach (array('membership', 'related_contact', 'onbehalf_dupe_alert') as $fld) {
if (!is_numeric($ids[$fld])) {
unset($ids[$fld]);
}
}
}
$paymentProcessorID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_PaymentProcessorType', 'Google_Checkout', 'id', 'payment_processor_type');
$this->loadObjects($input, $ids, $objects, TRUE, $paymentProcessorID);
$transaction = new CRM_Core_Transaction();
// CRM_Core_Error::debug_var( 'c', $contribution );
if ($status == 'PAYMENT_DECLINED' || $status == 'CANCELLED_BY_GOOGLE' || $status == 'CANCELLED') {
return $this->failed($objects, $transaction);
}
$input['amount'] = $contribution->total_amount;
$input['fee_amount'] = NULL;
$input['net_amount'] = NULL;
$input['trxn_id'] = $ids['contributionRecur'] ? $serial : $dataRoot['google-order-number']['VALUE'];
$input['is_test'] = $contribution->is_test;
$recur = NULL;
if ($ids['contributionRecur']) {
$recur = $objects['contributionRecur'];
}
$this->completeTransaction($input, $ids, $objects, $transaction, $recur);
$this->completeRecur($input, $ids, $objects);
}
示例6: loadObjects
/**
* Load objects related to contribution.
*
* @input array information from Payment processor
* @param array $ids
* @param array $objects
* @param boolean $required
* @param integer $paymentProcessorID
* @param array $error_handling
* @return multitype:number NULL |boolean
*/
function loadObjects(&$input, &$ids, &$objects, $required, $paymentProcessorID, $error_handling = NULL)
{
if (empty($error_handling)) {
// default options are that we log an error & echo it out
// note that we should refactor this error handling into error code @ some point
// but for now setting up enough separation so we can do unit tests
$error_handling = array('log_error' => 1, 'echo_error' => 1);
}
$ids['paymentProcessor'] = $paymentProcessorID;
if (is_a($objects['contribution'], 'CRM_Contribute_BAO_Contribution')) {
$contribution =& $objects['contribution'];
} else {
//legacy support - functions are 'used' to be able to pass in a DAO
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = CRM_Utils_Array::value('contribution', $ids);
$contribution->find(TRUE);
$objects['contribution'] =& $contribution;
}
try {
$success = $contribution->loadRelatedObjects($input, $ids, $required);
} catch (Exception $e) {
$success = FALSE;
if (CRM_Utils_Array::value('log_error', $error_handling)) {
CRM_Core_Error::debug_log_message($e->getMessage());
}
if (CRM_Utils_Array::value('echo_error', $error_handling)) {
echo $e->getMessage();
}
if (CRM_Utils_Array::value('return_error', $error_handling)) {
return array('is_error' => 1, 'error_message' => $e->getMessage());
}
}
$objects = array_merge($objects, $contribution->_relatedObjects);
return $success;
}
示例7: handlePaymentNotification
public function handlePaymentNotification()
{
$errors = array("101" => "Tarjeta caducada", "102" => "Tarjeta en excepción transitoria o bajo sospecha de fraude", "106" => "Intentos de PIN excedidos", "125" => "Tarjeta no efectiva", "129" => "Código de seguridad (CVV2/CVC2) incorrecto", "180" => "Tarjeta ajena al servicio", "184" => "Error en la autenticación del titular", "190" => "Denegación del emisor sin especificar motivo", "191" => "Fecha de caducidad errónea", "202" => "Tarjeta en excepción transitoria o bajo sospecha de fraude con retirada de tarjeta", "904" => "Comercio no registrado en FUC", "909" => "Error de sistema", "913" => "Pedido repetido", "944" => "Sesión Incorrecta", "950" => "Operación de devolución no permitida", "912" => "Emisor no disponible", "9912" => "Emisor no disponible", "9064" => "Número de posiciones de la tarjeta incorrecto", "9078" => "Tipo de operación no permitida para esa tarjeta", "9093" => "Tarjeta no existente", "9094" => "Rechazo servidores internacionales", "9104" => "Comercio con “titular seguro” y titular sin clave de compra segura", "9218" => "El comercio no permite op. seguras por entrada /operaciones", "9253" => "Tarjeta no cumple el check-digit", "9256" => "El comercio no puede realizar preautorizaciones", "9257" => "Esta tarjeta no permite operativa de preautorizaciones", "9261" => "Operación detenida por superar el control de restricciones en la entrada al SIS", "9915" => "A petición del usuario se ha cancelado el pago", "9929" => "Anulación de autorización en diferido realizada por el comercio", "9997" => "Se está procesando otra transacción en SIS con la misma tarjeta", "9998" => "Operación en proceso de solicitud de datos de tarjeta", "9999" => "Operación que ha sido redirigida al emisor a autenticar");
$module = self::retrieve('md', 'String', 'GET', false);
$qfKey = self::retrieve('qfKey', 'String', 'GET', false);
$miObj = new RedsysAPI();
$response = array();
$response["version"] = $_POST["Ds_SignatureVersion"];
$response["parameters"] = $_POST["Ds_MerchantParameters"];
$response["signature"] = $_POST["Ds_Signature"];
$decodecResponseJson = $miObj->decodeMerchantParameters($response["parameters"]);
$decodecResponse = json_decode($decodecResponseJson);
$firma = $miObj->createMerchantSignatureNotif($this->_paymentProcessor["password"], $response["parameters"]);
// Validations
if ($decodecResponse->Ds_MerchantCode != $this->_paymentProcessor["user_name"]) {
CRM_Core_Error::debug_log_message("Redsys Response param Ds_MerchantCode incorrect");
return false;
}
// Contribution exists and is valid
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = self::trimAmount($decodecResponse->Ds_Order);
if (!$contribution->find(TRUE)) {
CRM_Core_Error::debug_log_message("Could not find contribution record: {$contribution->id} in IPN request: " . print_r($params, TRUE));
echo "Failure: Could not find contribution record for {$contribution->id}<p>";
return FALSE;
}
if ($firma === $response["signature"]) {
switch ($module) {
case 'contribute':
if ($decodecResponse->Ds_Response == self::REDSYS_RESPONSE_CODE_ACCEPTED) {
$query = "UPDATE civicrm_contribution SET trxn_id='" . $decodecResponse->Ds_AuthorisationCode . "', contribution_status_id=1 where id='" . self::trimAmount($decodecResponse->Ds_Order) . "'";
CRM_Core_DAO::executeQuery($query);
} else {
$error = self::trimAmount($decodecResponse->Ds_Response);
if (array_key_exists($error, $errors)) {
$error = $errors[$error];
}
$cancel_date = CRM_Utils_Date::currentDBDate();
$query = "UPDATE civicrm_contribution SET contribution_status_id=3, cancel_reason = '" . $error . "' , cancel_date = '" . $cancel_date . "' where id='" . self::trimAmount($decodecResponse->Ds_Order) . "'";
CRM_Core_DAO::executeQuery($query);
}
break;
case 'event':
if ($decodecResponse->Ds_Response == self::REDSYS_RESPONSE_CODE_ACCEPTED) {
$query = "UPDATE civicrm_contribution SET trxn_id='" . $decodecResponse->Ds_AuthorisationCode . "', contribution_status_id=1 where id='" . self::trimAmount($decodecResponse->Ds_Order) . "'";
CRM_Core_DAO::executeQuery($query);
} else {
$error = self::trimAmount($decodecResponse->Ds_Response);
if (array_key_exists($error, $errors)) {
$error = $errors[$error];
}
$cancel_date = CRM_Utils_Date::currentDBDate();
$query = "UPDATE civicrm_contribution SET contribution_status_id=3, cancel_reason = '" . $error . "' , cancel_date = '" . $cancel_date . "' where id='" . self::trimAmount($decodecResponse->Ds_Order) . "'";
CRM_Core_DAO::executeQuery($query);
}
break;
default:
require_once 'CRM/Core/Error.php';
CRM_Core_Error::debug_log_message("Could not get module name from request url");
}
}
}
示例8: update_recurring_contribution
/**
* Update the recurring contribution.
*
* @param object $current_recur
* The ID of the recurring contribution
*
* @return object
* The recurring contribution object.
*/
function update_recurring_contribution($current_recur)
{
/*
* Creating a new recurrence object as the DAO had problems saving unless all the dates were overwritten. Seems easier to create a new object and only update the fields that are needed @todo - switching to using the api would solve the DAO dates problem & api accepts 'In Progress' so no need to resolve it first.
*/
$updated_recur = $current_recur;
$updated_recur->id = $current_recur->id;
$updated_recur->modified_date = CRM_Utils_Date::isoToMysql(date('Y-m-d H:i:s'));
$updated_recur->failure_count = $current_recur->failure_count;
/*
* Update the next date to schedule a contribution. If all installments complete, mark the recurring contribution as complete
*/
if (_versionAtLeast(4.4)) {
$updated_recur->next_sched_contribution_date = CRM_Utils_Date::isoToMysql(date('Y-m-d 00:00:00', strtotime('+' . $current_recur->frequency_interval . ' ' . $current_recur->frequency_unit)));
} else {
$updated_recur->next_sched_contribution = CRM_Utils_Date::isoToMysql(date('Y-m-d 00:00:00', strtotime('+' . $current_recur->frequency_interval . ' ' . $current_recur->frequency_unit)));
}
if (isset($current_recur->installments) && $current_recur->installments > 0) {
$contributions = new CRM_Contribute_BAO_Contribution();
$contributions->whereAdd("`contribution_recur_id` = " . $current_recur->id);
$contributions->find();
if ($contributions->N >= $current_recur->installments) {
if (_versionAtLeast(4.4)) {
$updated_recur->next_sched_contribution_date = NULL;
} else {
$updated_recur->next_sched_contribution = NULL;
}
$updated_recur->contribution_status_id = _eway_recurring_get_contribution_status_id('Completed');
$updated_recur->end_date = CRM_Utils_Date::isoToMysql(date('Y-m-d 00:00:00'));
}
}
return $updated_recur->save();
}
示例9: validateValue
protected function validateValue($rec, $field, $validType, $exceptionCode = 0, $import_type = 'JG')
{
if (!array_key_exists($field, $rec)) {
throw new Exception("Not in record '{$field}'");
}
$value = $origValue = $rec[$field];
switch ($validType) {
//===== general types ====
case 'money':
//matusz: filter out all which does not make a money value invalid
$value = str_replace('£', '', $value);
$value = str_replace(',', '', $value);
$value = trim($value);
if (strlen($value) == 0) {
// Null entry
// throw new CRM_Finance_BAO_Import_ValidateException(
// "Can't be empty",
// $exceptionCode,
// $value);
$value = 0;
}
if (!is_numeric($value)) {
throw new CRM_Finance_BAO_Import_ValidateException("Invalid number", $exceptionCode, $value);
}
$value = floatval($value);
//mzeman: we take negative values also as per discussion with psaleh
// if ($value < 0) {
// throw new CRM_Finance_BAO_Import_ValidateException(
// "Value is zero or less",
// $exceptionCode,
// $value);
// }
break;
case 'contactId':
if (empty($value)) {
throw new CRM_Finance_BAO_Import_ValidateException("Contact id is empty", self::VALIDATE_ERR_NO_CONTACT, $value);
}
// Check if the contact exists
require_once 'CRM/Contact/DAO/Contact.php';
$contact = new CRM_Contact_DAO_Contact();
$contact->id = $value;
$contact->find();
if (!$contact->fetch()) {
throw new CRM_Finance_BAO_Import_ValidateException("Can't find contact for this id", self::VALIDATE_ERR_NO_CONTACT, $value);
}
break;
//===== specific types =====
//===== specific types =====
case 'VARef':
$value = trim($value);
if (empty($value)) {
throw new CRM_Finance_BAO_Import_ValidateException("VARef is empty", self::VALIDATE_ERR_REF_EMPTY, $value);
}
// Check if the contact exists
require_once 'CRM/Contact/DAO/Contact.php';
$contact = new CRM_Contact_DAO_Contact();
$contact->external_identifier = $value;
$contact->find();
if (!$contact->fetch()) {
throw new CRM_Finance_BAO_Import_ValidateException("Can't find contact for this VAReference", self::VALIDATE_ERR_REF_NO_CONTACT, $value);
}
return array($field => $value, 'contact_id' => $contact->id, 'contact_display_name' => $contact->display_name);
break;
case 'campaignCode':
$value = trim($value);
if (empty($value)) {
throw new CRM_Finance_BAO_Import_ValidateException("Code invalid", self::VALIDATE_ERR_CAMPAIGN_CODE, $value);
}
// Check if the contact exists
require_once 'CRM/Campaign/BAO/Campaign.php';
$ret = civicrm_api('Campaign', 'GET', array('external_identifier' => $value, 'version' => 3));
if ($ret['is_error'] || $ret['count'] == 0) {
throw new CRM_Finance_BAO_Import_ValidateException("Can't find campaign for this code", self::VALIDATE_ERR_CAMPAIGN_CODE, $value);
}
$id = $ret['id'];
$contId = $this->getContributionTypeIdByCampaignId($id);
//matusz: TODO check issue here also if its available and assigned to charity
return array($field => $value, 'campaign_id' => $id, 'contribution_type_id' => $contId);
break;
// PS 03/10/2012
// New case to deal with Campaign ID now being passed in by External Sources
// PS 03/10/2012
// New case to deal with Campaign ID now being passed in by External Sources
case 'campaignID':
$value = trim($value);
if (empty($value)) {
throw new CRM_Finance_BAO_Import_ValidateException("ID invalid", self::VALIDATE_ERR_CAMPAIGN_ID, $value);
}
// Check if the contact exists
require_once 'CRM/Campaign/BAO/Campaign.php';
$ret = civicrm_api('Campaign', 'GET', array('id' => $value, 'version' => 3));
if ($ret['is_error'] || $ret['count'] == 0) {
throw new CRM_Finance_BAO_Import_ValidateException("Can't find campaign for this id", self::VALIDATE_ERR_CAMPAIGN_ID, $value);
}
$id = $ret['id'];
$contId = $this->getContributionTypeIdByCampaignId($id);
//matusz: TODO check issue here also if its available and assigned to charity
return array($field => $value, 'campaign_id' => $id, 'contribution_type_id' => $contId);
break;
case 'grossAmount':
//.........这里部分代码省略.........
开发者ID:hoegrammer,项目名称:uk.co.vedaconsulting.module.justgivingImports,代码行数:101,代码来源:SourceAbstract.php
示例10: sendMail
/**
* Send receipt from contribution.
*
* Do not call this directly - it is being refactored. use contribution.sendmessage api call.
*
* Note that the compose message part has been moved to contribution
* In general LoadObjects is called first to get the objects but the composeMessageArray function now calls it.
*
* @param array $input
* Incoming data from Payment processor.
* @param array $ids
* Related object IDs.
* @param int $contributionID
* @param array $values
* Values related to objects that have already been loaded.
* @param bool $recur
* Is it part of a recurring contribution.
* @param bool $returnMessageText
* Should text be returned instead of sent. This.
* is because the function is also used to generate pdfs
*
* @return array
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public static function sendMail(&$input, &$ids, $contributionID, &$values, $recur = FALSE, $returnMessageText = FALSE)
{
$input['is_recur'] = $recur;
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $contributionID;
if (!$contribution->find(TRUE)) {
throw new CRM_Core_Exception('Contribution does not exist');
}
$contribution->loadRelatedObjects($input, $ids, TRUE);
// set receipt from e-mail and name in value
if (!$returnMessageText) {
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
if (!empty($userID)) {
list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
$values['receipt_from_email'] = CRM_Utils_Array::value('receipt_from_email', $input, $userEmail);
$values['receipt_from_name'] = CRM_Utils_Array::value('receipt_from_name', $input, $userName);
}
}
$return = $contribution->composeMessageArray($input, $ids, $values, $recur, $returnMessageText);
// Contribution ID should really always be set. But ?
if (!$returnMessageText && (!isset($input['receipt_update']) || $input['receipt_update']) && empty($contribution->receipt_date)) {
civicrm_api3('Contribution', 'create', array('receipt_date' => 'now', 'id' => $contribution->id));
}
return $return;
}
示例11: _setUpParticipantObjects
/**
* Set up participant requirements for test.
*/
public function _setUpParticipantObjects()
{
$event = $this->eventCreate(array('is_email_confirm' => 1));
$this->assertAPISuccess($event, 'line ' . __LINE__ . ' set-up of event');
$this->_eventId = $event['id'];
$this->_participantId = $this->participantCreate(array('event_id' => $this->_eventId, 'contact_id' => $this->_contactId));
//we'll create membership payment here because to make setup more re-usable
$participantPayment = civicrm_api('participant_payment', 'create', array('version' => 3, 'contribution_id' => $this->_contributionId, 'participant_id' => $this->_participantId));
$this->assertAPISuccess($participantPayment, 'line ' . __LINE__ . ' set-up of event');
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $this->_contributionId;
$contribution->find();
$this->objects['contribution'] = $contribution;
$this->input = array('component' => 'event', 'total_amount' => 150.0, 'invoiceID' => "c8acb91e080ad7bd8a2adc119c192885", 'contactID' => $this->_contactId, 'contributionID' => $contribution->id, 'participantID' => $this->_participantId);
$this->ids['participant'] = $this->_participantId;
$this->ids['event'] = $this->_eventId;
}
示例12: _setUpParticipantObjects
/**
* Set up participant requirements for test.
*/
public function _setUpParticipantObjects()
{
$event = $this->eventCreate(array('is_email_confirm' => 1));
$this->_eventId = $event['id'];
$this->_participantId = $this->participantCreate(array('event_id' => $this->_eventId, 'contact_id' => $this->_contactId));
$this->callAPISuccess('participant_payment', 'create', array('contribution_id' => $this->_contributionId, 'participant_id' => $this->_participantId));
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $this->_contributionId;
$contribution->find();
$this->objects['contribution'] = $contribution;
$this->input = array('component' => 'event', 'total_amount' => 150.0, 'invoiceID' => "c8acb91e080ad7bd8a2adc119c192885", 'contactID' => $this->_contactId, 'contributionID' => $contribution->id, 'participantID' => $this->_participantId);
$this->ids['participant'] = $this->_participantId;
$this->ids['event'] = $this->_eventId;
}
示例13: civicrm_api3_contribution_completetransaction
/**
* Complete an existing (pending) transaction, updating related entities (participant, membership, pledge etc)
* and taking any complete actions from the contribution page (e.g. send receipt)
*
* @todo - most of this should live in the BAO layer but as we want it to be an addition
* to 4.3 which is already stable we should add it to the api layer & re-factor into the BAO layer later
*
* @param array $params input parameters
* {@getfields Contribution_completetransaction}
* @return array Api result array
* @static void
* @access public
*
*/
function civicrm_api3_contribution_completetransaction(&$params)
{
$input = $ids = array();
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $params['id'];
$contribution->find(TRUE);
if (!$contribution->id == $params['id']) {
throw new API_Exception('A valid contribution ID is required', 'invalid_data');
}
try {
if (!$contribution->loadRelatedObjects($input, $ids, FALSE, TRUE)) {
throw new API_Exception('failed to load related objects');
}
$objects = $contribution->_relatedObjects;
$objects['contribution'] =& $contribution;
$input['component'] = $contribution->_component;
$input['is_test'] = $contribution->is_test;
$input['trxn_id'] = $contribution->trxn_id;
$input['amount'] = $contribution->total_amount;
if (isset($params['is_email_receipt'])) {
$input['is_email_receipt'] = $params['is_email_receipt'];
}
// @todo required for base ipn but problematic as api layer handles this
$transaction = new CRM_Core_Transaction();
$ipn = new CRM_Core_Payment_BaseIPN();
$ipn->completeTransaction($input, $ids, $objects, $transaction);
} catch (Exception $e) {
throw new API_Exception('failed to load related objects' . $e->getMessage() . "\n" . $e->getTraceAsString());
}
}
示例14: postProcess
//.........这里部分代码省略.........
}
require_once 'CRM/Core/Payment/Form.php';
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, true);
$payment =& CRM_Core_Payment::singleton($this->_mode, 'Contribute', $this->_paymentProcessor, $this);
$result =& $payment->doDirectPayment($paymentParams);
if (is_a($result, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=add&cid={$this->_contactID}&context=&mode={$this->_mode}"));
}
if ($result) {
$this->_params = array_merge($this->_params, $result);
}
$params['contribution_status_id'] = 1;
$params['receive_date'] = $now;
$params['invoice_id'] = $this->_params['invoiceID'];
$params['contribution_source'] = ts('Online Membership: Admin Interface');
$params['source'] = $formValues['source'] ? $formValues['source'] : $params['contribution_source'];
$params['trxn_id'] = $result['trxn_id'];
$params['payment_instrument_id'] = 1;
$params['is_test'] = $this->_mode == 'live' ? 0 : 1;
if (CRM_Utils_Array::value('send_receipt', $this->_params)) {
$params['receipt_date'] = $now;
} else {
$params['receipt_date'] = null;
}
$this->set('params', $this->_params);
$this->assign('trxn_id', $result['trxn_id']);
$this->assign('receive_date', CRM_Utils_Date::mysqlToIso($params['receive_date']));
// required for creating membership for related contacts
$params['action'] = $this->_action;
$membership =& CRM_Member_BAO_Membership::create($params, $ids);
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->trxn_id = $result['trxn_id'];
if ($contribution->find(true)) {
// next create the transaction record
$trxnParams = array('contribution_id' => $contribution->id, 'trxn_date' => $now, 'trxn_type' => 'Debit', 'total_amount' => $params['total_amount'], 'fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['total_amount']), 'currency' => $config->defaultCurrency, 'payment_processor' => $this->_paymentProcessor['payment_processor_type'], 'trxn_id' => $result['trxn_id']);
require_once 'CRM/Contribute/BAO/FinancialTrxn.php';
$trxn =& CRM_Contribute_BAO_FinancialTrxn::create($trxnParams);
}
} else {
$params['action'] = $this->_action;
if ($this->_onlinePendingContributionId && CRM_Utils_Array::value('record_contribution', $formValues)) {
// update membership as well as contribution object, CRM-4395
require_once 'CRM/Contribute/Form/Contribution.php';
$params['contribution_id'] = $this->_onlinePendingContributionId;
$params['componentId'] = $params['id'];
$params['componentName'] = 'contribute';
$result = CRM_Contribute_BAO_Contribution::transitionComponents($params, true);
//carry updated membership object.
$membership =& new CRM_Member_DAO_Membership();
$membership->id = $this->_id;
$membership->find(true);
$cancelled = true;
if ($membership->end_date) {
//display end date w/ status message.
$endDate = $membership->end_date;
require_once 'CRM/Member/PseudoConstant.php';
$membershipStatues = CRM_Member_PseudoConstant::membershipStatus();
if (!in_array($membership->status_id, array(array_search('Cancelled', $membershipStatues), array_search('Expired', $membershipStatues)))) {
$cancelled = false;
}
}
// suppress form values in template.
$this->assign('cancelled', $cancelled);
} else {
$membership =& CRM_Member_BAO_Membership::create($params, $ids);
示例15: postProcess
//.........这里部分代码省略.........
$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['total_amount'];
$this->_params['currencyID'] = $config->defaultCurrency;
$this->_params['description'] = ts('Office Credit Card Membership Signup Contribution');
$this->_params['payment_action'] = 'Sale';
$this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
$this->_params['financial_type_id'] = $params['financial_type_id'];
// at this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
$paymentParams['contactID'] = $this->_contributorContactID;
//CRM-10377 if payment is by an alternate contact then we need to set that person
// as the contact in the payment params
if ($this->_contributorContactID != $this->_contactID) {
if (!empty($this->_params['soft_credit_type_id'])) {
$softParams['contact_id'] = $params['contact_id'];
$softParams['soft_credit_type_id'] = $this->_params['soft_credit_type_id'];
}
}
if (!empty($this->_params['send_receipt'])) {
$paymentParams['email'] = $this->_contributorEmail;
}
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, TRUE);
// CRM-7137 -for recurring membership,
// we do need contribution and recuring records.
$result = NULL;
if (!empty($paymentParams['is_recur'])) {
$contributionType = new CRM_Financial_DAO_FinancialType();
$contributionType->id = $params['financial_type_id'];
if (!$contributionType->find(TRUE)) {
CRM_Core_Error::fatal('Could not find a system table');
}
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($this, $paymentParams, $result, $this->_contributorContactID, $contributionType, TRUE, FALSE, $isTest, $lineItems);
//create new soft-credit record, CRM-13981
if ($softParams) {
$softParams['contribution_id'] = $contribution->id;
$softParams['currency'] = $contribution->currency;
$softParams['amount'] = $contribution->total_amount;
CRM_Contribute_BAO_ContributionSoft::add($softParams);
}
$paymentParams['contactID'] = $this->_contactID;
$paymentParams['contributionID'] = $contribution->id;
$paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
$ids['contribution'] = $contribution->id;
$params['contribution_recur_id'] = $paymentParams['contributionRecurID'];
}
if ($params['total_amount'] > 0.0) {
$payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
$result = $payment->doDirectPayment($paymentParams);
}
if (is_a($result, 'CRM_Core_Error')) {
//make sure to cleanup db for recurring case.
if (!empty($paymentParams['contributionID'])) {
CRM_Contribute_BAO_Contribution::deleteContribution($paymentParams['contributionID']);
}
if (!empty($paymentParams['contributionRecurID'])) {
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=add&cid={$this->_contactID}&context=&mode={$this->_mode}"));