$this->_component = strtolower(CRM_Utils_Array::value('component', $input, 'contribute'));
}
}
- $paymentProcessorID = CRM_Utils_Array::value('paymentProcessor', $ids);
+
+ $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'
+ );
+ $intentionalEnotice = $CRM16923AnUnreliableMethodHasBeenUserToDeterminePaymentProcessorFromContributionPage;
+ }
+
+ if (!empty($ids['contributionRecur'])) {
+ $recur = new CRM_Contribute_BAO_ContributionRecur();
+ $recur->id = $ids['contributionRecur'];
+ if (!$recur->find(TRUE)) {
+ throw new Exception("Could not find recur record: " . $ids['contributionRecur']);
+ }
+ $this->_relatedObjects['contributionRecur'] = $recur;
+ $paymentProcessorID = $recur->payment_processor_id;
+ }
+
$contributionType = new CRM_Financial_BAO_FinancialType();
$contributionType->id = $this->financial_type_id;
$contributionType->find(TRUE);
}
$this->_relatedObjects['contributionType'] = $contributionType;
+ 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;
+ }
+ }
+
if ($this->_component == 'contribute') {
// retrieve the other optional objects first so
// stuff down the line can use this info and do things
}
}
- 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;
- }
- }
-
- if (!empty($ids['contributionRecur'])) {
- $recur = new CRM_Contribute_BAO_ContributionRecur();
- $recur->id = $ids['contributionRecur'];
- if (!$recur->find(TRUE)) {
- throw new Exception("Could not find recur record: " . $ids['contributionRecur']);
- }
- $this->_relatedObjects['contributionRecur'] = &$recur;
- //get payment processor id from recur object.
- $paymentProcessorID = $recur->payment_processor_id;
- }
- //for normal contribution get the payment processor id.
if (!$paymentProcessorID) {
- if ($this->contribution_page_id) {
- // get the payment processor id from contribution page
- $paymentProcessorID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage',
- $this->contribution_page_id,
- 'payment_processor'
- );
- }
//fail to load payment processor id.
- elseif (empty($ids['pledge_payment'])) {
+ // this seems a bit dubious....
+ if (empty($ids['pledge_payment'])) {
$loadObjectSuccess = TRUE;
if ($required) {
throw new Exception("Could not find contribution page for contribution record: " . $this->id);
$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;
+ $intentionalEnotice = $CRM16923AnUnreliableMethodHasBeenUserToDeterminePaymentProcessorFromEvent;
}
}