Skip to content
Snippets Groups Projects
Commit 15fcc555 authored by mattwire's avatar mattwire
Browse files

Handle confirmation pages properly for contribution pages (make sure we pass...

Handle confirmation pages properly for contribution pages (make sure we pass through paymentIntentID
parent 7ce16a27
No related branches found
No related tags found
No related merge requests found
...@@ -357,6 +357,10 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment { ...@@ -357,6 +357,10 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
if(!empty(CRM_Utils_Array::value('paymentIntentID', $params))) { if(!empty(CRM_Utils_Array::value('paymentIntentID', $params))) {
$paymentIntentID = CRM_Utils_Array::value('paymentIntentID', $params); $paymentIntentID = CRM_Utils_Array::value('paymentIntentID', $params);
} }
elseif (CRM_Core_Session::singleton()->get('stripePaymentIntent')) {
// @fixme Hack for contributionpages - see https://github.com/civicrm/civicrm-core/pull/15252
$paymentIntentID = CRM_Core_Session::singleton()->get('stripePaymentIntent');
}
else { else {
CRM_Core_Error::statusBounce(E::ts('Unable to complete payment! Missing paymentIntent ID.')); CRM_Core_Error::statusBounce(E::ts('Unable to complete payment! Missing paymentIntent ID.'));
Civi::log()->debug('paymentIntentID not found. $params: ' . print_r($params, TRUE)); Civi::log()->debug('paymentIntentID not found. $params: ' . print_r($params, TRUE));
......
...@@ -179,11 +179,29 @@ function stripe_civicrm_postProcess($formName, &$form) { ...@@ -179,11 +179,29 @@ function stripe_civicrm_postProcess($formName, &$form) {
// Retrieve the paymentIntentID that was posted along with the form and add it to the form params // Retrieve the paymentIntentID that was posted along with the form and add it to the form params
// This allows multi-page checkout to work (eg. register->confirm->thankyou) // This allows multi-page checkout to work (eg. register->confirm->thankyou)
$params = $form->get('params'); $params = $form->get('params');
if (isset($params[0])) { if (!$params) {
$paymentIntentID = CRM_Utils_Request::retrieveValue('paymentIntentID', 'String'); // @fixme Hack for contributionpages - see https://github.com/civicrm/civicrm-core/pull/15252
if ($paymentIntentID) { $params = $form->getVar('_params');
$params[0]['paymentIntentID'] = $paymentIntentID; $hackForContributionPages = TRUE;
$form->set('params', $params); }
if (isset($params['amount'])) {
// Contribution pages have params directly in the main array
$paymentParams = &$params;
}
elseif (isset($params[0]['amount'])) {
// Event registration pages have params in a sub-array
$paymentParams = &$params[0];
}
else {
return;
}
$paymentIntentID = CRM_Utils_Request::retrieveValue('paymentIntentID', 'String');
if ($paymentIntentID) {
$paymentParams['paymentIntentID'] = $paymentIntentID;
$form->set('params', $params);
if (isset($hackForContributionPages)) {
// @fixme Hack for contributionpages - see https://github.com/civicrm/civicrm-core/pull/15252
CRM_Core_Session::singleton()->set('stripePaymentIntent', $paymentIntentID);
} }
} }
} }
......
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