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
Branches
Tags
No related merge requests found
......@@ -357,6 +357,10 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
if(!empty(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 {
CRM_Core_Error::statusBounce(E::ts('Unable to complete payment! Missing paymentIntent ID.'));
Civi::log()->debug('paymentIntentID not found. $params: ' . print_r($params, TRUE));
......
......@@ -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
// This allows multi-page checkout to work (eg. register->confirm->thankyou)
$params = $form->get('params');
if (isset($params[0])) {
$paymentIntentID = CRM_Utils_Request::retrieveValue('paymentIntentID', 'String');
if ($paymentIntentID) {
$params[0]['paymentIntentID'] = $paymentIntentID;
$form->set('params', $params);
if (!$params) {
// @fixme Hack for contributionpages - see https://github.com/civicrm/civicrm-core/pull/15252
$params = $form->getVar('_params');
$hackForContributionPages = TRUE;
}
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.
Please register or to comment