Commit 520b5faf authored by mattwire's avatar mattwire

Tweaks to support Stripe 6.2

parent bda55b89
......@@ -130,8 +130,13 @@ trait CRM_Core_Payment_MJWTrait {
* 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)
*
* Following https://github.com/civicrm/civicrm-core/pull/15477 we are passing contribution_id via the
* PaymentProcessor.Pay API and this is the preferred format.
* Historically most places passed contributionID.
*/
return CRM_Utils_Array::value('contributionID', $params);
return CRM_Utils_Array::value('contribution_id', $params,
CRM_Utils_Array::value('contributionID', $params));
}
/**
......@@ -503,62 +508,16 @@ trait CRM_Core_Payment_MJWTrait {
* @throws \CRM_Core_Exception
*/
protected function getTokenParameter($parameterName, $params, $required = TRUE) {
// Get the passed in parameter
$parameterValue = NULL;
if(!empty(CRM_Utils_Array::value($parameterName, $params))) {
$parameterValue = CRM_Utils_Array::value($parameterName, $params);
// If we stored it via pre_approval_parameters it should already be in the params array
if (!empty($params[$parameterName])) {
return $params;
}
elseif (CRM_Core_Session::singleton()->get($parameterName)) {
// @fixme Hack for contributionpages - see https://github.com/civicrm/civicrm-core/pull/15252
$parameterValue = CRM_Core_Session::singleton()->get($parameterName);
CRM_Core_Session::singleton()->set($parameterName, NULL);
}
elseif(CRM_Utils_Request::retrieve($parameterName, 'String')) {
$parameterValue = CRM_Utils_Request::retrieve($parameterName, 'String');
}
if (empty($parameterValue) && $required) {
// If we're submitting without a confirmation page it should be in the $_POST array
$params[$parameterName] = CRM_Utils_Request::retrieve($parameterName, 'String');
if (empty($params[$parameterName]) && $required) {
Civi::log()->debug("{$parameterName} not found. \$params: " . print_r($params, TRUE));
CRM_Core_Error::statusBounce(E::ts('Unable to complete payment! Missing %1.', [1 => $parameterName]));
}
$params[$parameterName] = $parameterValue;
return $params;
}
/**
* Given a submitted form, retrieve a parameter that was added via (an input element added by) javascript.
* Save the parameter in the params array for the form so it's accessible at the end of a multi-page form.
*
* @param string $parameterName
* @param \CRM_Core_Form $form
*
* @throws \CRM_Core_Exception
*/
public static function setTokenParameter($parameterName, &$form) {
// Retrieve the parameterValue 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 (!$params) {
// @fixme Hack for contributionpages - see https://github.com/civicrm/civicrm-core/pull/15252
$params = $form->getVar('_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;
}
$parameterValue = CRM_Utils_Request::retrieveValue($parameterName, 'String');
if ($parameterValue) {
$paymentParams[$parameterName] = $parameterValue;
$form->set('params', $params);
// @fixme Hack for contributionpages - see https://github.com/civicrm/civicrm-core/pull/15252
CRM_Core_Session::singleton()->set($parameterName, $parameterValue);
}
}
}
......@@ -13,8 +13,8 @@
<url desc="Support">https://www.mjwconsult.co.uk</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2019-09-25</releaseDate>
<version>0.4.4</version>
<releaseDate>2019-10-14</releaseDate>
<version>0.4.5</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.13</ver>
......
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