if (!$this->_mode) {
// payment_instrument isn't required in edit and will not be present when payment block is enabled.
$required = !$this->_id;
- $checkPaymentID = array_search('Check', CRM_Contribute_PseudoConstant::paymentInstrument('name'));
+ $checkPaymentID = array_search('Check', CRM_Contribute_BAO_Contribution::buildOptions('payment_instrument_id', 'validate'));
$paymentInstrument = $this->add('select', 'payment_instrument_id',
ts('Payment Method'),
- ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::paymentInstrument(),
+ ['' => ts('- select -')] + CRM_Contribute_BAO_Contribution::buildOptions('payment_instrument_id', 'create'),
$required, ['onChange' => "return showHideByValue('payment_instrument_id','{$checkPaymentID}','checkNumber','table-row','select',false);"]
);
}
$params['is_pay_later'] = 1;
}
elseif ($params['contribution_status_id'] == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed')) {
+ // @todo - if the contribution is new then it should be Pending status & then we use
+ // Payment.create to update to Completed.
$params['is_pay_later'] = 0;
}
// process associated membership / participant, CRM-4395
if ($contribution->id && $action & CRM_Core_Action::UPDATE) {
+ // @todo use Payment.create to do this, remove transitioncomponents function
+ // if contribution is being created with a completed status it should be
+ // created pending & then Payment.create adds the payment
CRM_Contribute_BAO_Contribution::transitionComponents([
'contribution_id' => $contribution->id,
'contribution_status_id' => $contribution->contribution_status_id,