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 = $this->prepareParamsForPaymentProcessor($this->_params);
$this->_params['amount'] = $params['fee_amount'];
$this->_params['amount_level'] = $params['amount_level'];
$this->_params['currencyID'] = $config->defaultCurrency;
// 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);
+ try {
+ $result = $payment->doPayment($paymentParams);
+ }
+ catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
+ // @todo un comment the following line out when we are creating a contribution before we get to this point
+ // see dev/financial#53 about ensuring we create a pending contribution before we try processing payment
+ // CRM_Contribute_BAO_Contribution::failPayment($contributionID);
+ CRM_Core_Session::singleton()->setStatus($e->getMessage());
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/participant',
"reset=1&action=add&cid={$this->_contactId}&context=participant&mode={$this->_mode}"
));
$participants[0]->id,
'Participant'
);
- //add participant payment
- $paymentParticipant = [
+
+ // Add participant payment
+ $participantPaymentParams = [
'participant_id' => $participants[0]->id,
'contribution_id' => $contribution->id,
];
+ civicrm_api3('ParticipantPayment', 'create', $participantPaymentParams);
- CRM_Event_BAO_ParticipantPayment::create($paymentParticipant);
$this->_contactIds[] = $this->_contactId;
}
else {
}
}
- //insert payment record for this participation
+ // Insert payment record for this participant
if (empty($ids['contribution'])) {
foreach ($this->_contactIds as $num => $contactID) {
- $ppDAO = new CRM_Event_DAO_ParticipantPayment();
- $ppDAO->participant_id = $participants[$num]->id;
- $ppDAO->contribution_id = $contributions[$num]->id;
- $ppDAO->save();
+ $participantPaymentParams = [
+ 'participant_id' => $participants[$num]->id,
+ 'contribution_id' => $contributions[$num]->id,
+ ];
+ civicrm_api3('ParticipantPayment', 'create', $participantPaymentParams);
}
}
- // next create the transaction record
- $transaction = new CRM_Core_Transaction();
// CRM-11124
if ($this->_params['discount_id']) {
CRM_Price_BAO_PriceSet::parseFirstPriceSetValueIDFromParams($this->_params)
);
}
- $transaction->commit();
}
}