Commit d8de1376 authored by mattwire's avatar mattwire
Browse files

Throw exception on payment failure. Always update the paymentintent status in CiviCRM database

parent 32b6b814
......@@ -880,23 +880,29 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
}
}
catch (Exception $e) {
$this->handleError($e->getCode(), $e->getMessage(), $params['error_url']);
$errorMessage = $e->getMessage();
$this->handleError($e->getCode(), $errorMessage, $params['error_url']);
if ($e instanceof \Stripe\Exception\CardException) {
throw new PaymentProcessorException($errorMessage);
}
}
// Update the paymentIntent in the CiviCRM database for later tracking
$intentParams = [
'stripe_intent_id' => $intent->id,
'payment_processor_id' => $this->_paymentProcessor['id'],
'status' => $intent->status,
'contribution_id' => $params['contributionID'] ?? NULL,
'description' => $this->getDescription($params, 'description'),
'identifier' => $params['qfKey'] ?? NULL,
'contact_id' => $params['contactID'],
];
if (empty($intentParams['contribution_id'])) {
$intentParams['flags'][] = 'NC';
finally {
// Always update the paymentIntent in the CiviCRM database for later tracking
$intentParams = [
'stripe_intent_id' => $intent->id,
'payment_processor_id' => $this->_paymentProcessor['id'],
'status' => $intent->status,
'contribution_id' => $params['contributionID'] ?? NULL,
'description' => $this->getDescription($params, 'description'),
'identifier' => $params['qfKey'] ?? NULL,
'contact_id' => $params['contactID'],
'extra_data' => ($errorMessage ?? '') . ';' . ($email ?? ''),
];
if (empty($intentParams['contribution_id'])) {
$intentParams['flags'][] = 'NC';
}
CRM_Stripe_BAO_StripePaymentintent::create($intentParams);
}
CRM_Stripe_BAO_StripePaymentintent::create($intentParams);
return $params;
}
......
......@@ -15,7 +15,7 @@
<author>Matthew Wire (MJW Consulting)</author>
<email>mjw@mjwconsult.co.uk</email>
</maintainer>
<releaseDate>2022-01-18</releaseDate>
<releaseDate>2022-01-24</releaseDate>
<version>6.7-dev</version>
<develStage>alpha</develStage>
<compatibility>
......
Supports Markdown
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