Commit 97b5e77a authored by mattwire's avatar mattwire Committed by mattwire
Browse files

Set the 'payment_status' and add helper functions on doPayment()

parent 87476831
......@@ -500,9 +500,11 @@ trait CRM_Core_Payment_MJWTrait {
* @throws \CiviCRM_API3_Exception
*/
protected function endDoPayment($params, $contributionParams = []) {
$contributionParams['trxn_id'] = $this->getPaymentProcessorOrderID();
if ($this->getPaymentProcessorOrderID()) {
$contributionParams['trxn_id'] = $this->getPaymentProcessorOrderID();
}
if (isset($params['contributionID'])) {
if (isset($params['contributionID']) && !empty($contributionParams)) {
$contributionParams['id'] = $params['contributionID'];
$contributionParams['skipCleanMoney'] = TRUE;
$contributionParams['skipRecentView'] = TRUE;
......@@ -516,11 +518,38 @@ trait CRM_Core_Payment_MJWTrait {
// We need to set this to ensure that contributions are set to the correct status
// It should have already been set to "Completed" if we made a successful payment
if (empty($params['payment_status_id'])) {
$params['payment_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
$this->setStatusPaymentPending($params);
}
return $params;
}
/**
* Set the payment status to Pending
* @param array $params
*
* @return array
*/
protected function setStatusPaymentPending(array $params) {
$params['payment_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
$params['payment_status'] = 'Pending';
return $params;
}
/**
* Set the payment status to Completed
* @param $params
*
* @return array
*/
protected function setStatusPaymentCompleted(array $params) {
$returnParams['payment_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
$returnParams['payment_status'] = 'Completed';
return $params;
}
/**
* Get a "token" parameter that was inserted via javascript on the payment form (eg. paymentIntentID).
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment