* @throws \Civi\Payment\Exception\PaymentProcessorException
*/
protected function processCreditCard($submittedValues, $lineItem, $contactID) {
- $contribution = FALSE;
$isTest = ($this->_mode == 'test') ? 1 : 0;
// CRM-12680 set $_lineItem if its not set
* with a delayed start)
* 3) the payment succeeded with an immediate payment.
*
- * The doPayment function ensures that contribution_status_id is always set
+ * The doPayment function ensures that payment_status_id is always set
* as historically we have had to guess from the context - ie doDirectPayment
* = error or success, unless it is a recurring contribution in which case it is pending.
*/
- if (!isset($result['contribution_status_id']) || $result['contribution_status_id'] ==
- array_search('Completed', $statuses)) {
+ if ($result['payment_status_id'] == array_search('Completed', $statuses)) {
civicrm_api3('contribution', 'completetransaction', array('id' => $contribution->id, 'trxn_id' => $result['trxn_id']));
}
else {
$statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id');
if ($this->_paymentProcessor['billing_mode'] == 4) {
$result = $this->doTransferCheckout($params, $component);
- if (is_array($result) && !isset($result['contribution_status_id'])) {
- $result['contribution_status_id'] = array_search('Pending', $statuses);
+ if (is_array($result) && !isset($result['payment_status_id'])) {
+ $result['payment_status_id'] = array_search('Pending', $statuses);
}
}
else {
$result = $this->doDirectPayment($params, $component);
- if (is_array($result) && !isset($result['contribution_status_id'])) {
+ if (is_array($result) && !isset($result['payment_status_id'])) {
if (!empty($params['is_recur'])) {
// See comment block.
- $paymentParams['contribution_status_id'] = array_search('Pending', $statuses);
+ $paymentParams['payment_status_id'] = array_search('Pending', $statuses);
}
else {
- $result['contribution_status_id'] = array_search('Completed', $statuses);
+ $result['payment_status_id'] = array_search('Completed', $statuses);
}
}
}
$form->_values['contribution_id'] = $membershipContributionID;
}
- // Refer to CRM-16737. Payment processors 'should' return payment_status_id
- // to denote the outcome of the transaction.
- //
- // In 4.7 trxn_id will no longer denote the outcome & all processor transactions must return an array
- // containing payment_status_id.
- // In 4.6 support (such as there was) for other ways of denoting payment outcome is retained but the use
- // of payment_status_id is strongly encouraged.
- if (!empty($form->_params['is_recur']) && $form->_contributeMode == 'direct') {
- if (!isset($membershipContribution->payment_status_id) && $membershipContribution->payment_status_id == 1) {
+ if ($form->_contributeMode == 'direct') {
+ if (CRM_Utils_Array::value('payment_status_id', $paymentResult) == 1) {
+ // Refer to CRM-16737. Payment processors 'should' return payment_status_id
+ // to denote the outcome of the transaction.
try {
civicrm_api3('contribution', 'completetransaction', array(
'id' => $paymentResult['contribution']->id,
$this->assign('amount', $params['total_amount']);
}
- // if the payment processor returns a contribution_status_id -> use it!
- if (isset($result['contribution_status_id'])) {
- $params['contribution_status_id'] = $result['contribution_status_id'];
- }
- elseif (isset($result['payment_status_id'])) {
+ // if the payment processor returns a payment_status_id -we assume this
+ // applies to the whole contribution.
+ // At this stage this form is not processing separate payments.
+ if (isset($result['payment_status_id'])) {
// CRM-16737 $result['contribution_status_id'] is deprecated in favour
// of payment_status_id as the payment processor only knows whether the payment is complete
// not whether payment completes the contribution
*/
public function testSubmitMembershipPriceSetPaymentPaymentProcessorRecurInstantPayment() {
$this->params['is_recur'] = 1;
- $var = array();
$this->params['recur_frequency_unit'] = 'month';
$this->setUpMembershipContributionPage();
- $dummyPP = CRM_Core_Payment::singleton('live', $this->_paymentProcessor);
+ $dummyPP = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
$dummyPP->setDoDirectPaymentResult(array('payment_status_id' => 1, 'trxn_id' => 'create_first_success'));
$submitParams = array(