Skip to content
Snippets Groups Projects
Commit 81b0e0ad authored by mattwire's avatar mattwire
Browse files

Fix issue with event/membership payments failing to record in CiviCRM (introduced in 5.3).

parent fe9c3fa1
No related branches found
Tags 5.3.1
No related merge requests found
......@@ -542,11 +542,6 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
throw new \Civi\Payment\Exception\PaymentProcessorException('Failed to create Stripe Charge: ' . $errorMessage);
}
// Success! Return some values for CiviCRM.
$newParams['id'] = $this->getContributionId($params);
$newParams['trxn_id'] = $stripeCharge->id;
$newParams['payment_status_id'] = $completedStatusId;
// Return fees & net amount for Civi reporting.
try {
$stripeBalanceTransaction = \Stripe\BalanceTransaction::retrieve($stripeCharge->balance_transaction);
......@@ -556,11 +551,20 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
$errorMessage = self::handleErrorNotification($err, $params['stripe_error_url']);
throw new \Civi\Payment\Exception\PaymentProcessorException('Failed to retrieve Stripe Balance Transaction: ' . $errorMessage);
}
// Success!
// For contribution workflow we have a contributionId so we can set parameters directly.
// For events/membership workflow we have to return the parameters and they might get set...
$newParams['trxn_id'] = $stripeCharge->id;
$newParams['payment_status_id'] = $completedStatusId;
$newParams['fee_amount'] = $stripeBalanceTransaction->fee / 100;
$newParams['net_amount'] = $stripeBalanceTransaction->net / 100;
civicrm_api3('Contribution', 'create', $newParams);
unset($newParams['id']);
if ($this->getContributionId($params)) {
$newParams['id'] = $this->getContributionId($params);
civicrm_api3('Contribution', 'create', $newParams);
unset($newParams['id']);
}
$params = array_merge($params, $newParams);
return $params;
......
<?php
/**
* Shared payment functions that should one day be migrated to CiviCRM core
* Version 1.0
* Version 20190311
*/
trait CRM_Core_Payment_StripeTrait {
......@@ -68,7 +68,12 @@ trait CRM_Core_Payment_StripeTrait {
* @return mixed
*/
protected function getContributionId($params) {
return $params['contributionID'];
/*
* contributionID is set in the contribution workflow
* We do NOT have a contribution ID for event and membership payments as they are created after payment!
* See: https://github.com/civicrm/civicrm-core/pull/13763 (for events)
*/
return CRM_Utils_Array::value('contributionID', $params);
}
/**
......
## Releae 5.3.1
* Fix issue with event/membership payments failing to record in CiviCRM (introduced in 5.3).
## Release 5.3
**All users should upgrade to 5.3.1 due to an issue with event/membership payments**
There are no database changes in this release but you should update your Stripe webhook API version to 2019-02-19.
### Changes
......
......@@ -12,8 +12,8 @@
<author>Matthew Wire (MJW Consulting)</author>
<email>mjw@mjwconsult.co.uk</email>
</maintainer>
<releaseDate>2019-03-08</releaseDate>
<version>5.3</version>
<releaseDate>2019-03-12</releaseDate>
<version>5.3.1</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.10</ver>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment