Skip to content
Snippets Groups Projects
Commit 8e427167 authored by mattwire's avatar mattwire
Browse files

Refactor passing of token parameters to use pre_approval_parameters

parent d888076d
No related branches found
No related tags found
No related merge requests found
......@@ -155,6 +155,15 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
return FALSE;
}
/**
* Is an authorize-capture flow supported.
*
* @return bool
*/
protected function supportsPreApproval() {
return TRUE;
}
/**
* Get the currency for the transaction.
*
......@@ -348,6 +357,39 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
]);
}
/**
* Function to action pre-approval if supported
*
* @param array $params
* Parameters from the form
*
* This function returns an array which should contain
* - pre_approval_parameters (this will be stored on the calling form & available later)
* - redirect_url (if set the browser will be redirected to this.
*
* @return array
*/
public function doPreApproval(&$params) {
$paymentIntentID = CRM_Utils_Request::retrieve('paymentIntentID', 'String');
if (!empty($paymentIntentID)) {
return ['pre_approval_parameters' => ['paymentIntentID' => $paymentIntentID]];
}
}
/**
* Get any details that may be available to the payment processor due to an approval process having happened.
*
* In some cases the browser is redirected to enter details on a processor site. Some details may be available as a
* result.
*
* @param array $storedDetails
*
* @return array
*/
public function getPreApprovalDetails($storedDetails) {
return $storedDetails;
}
/**
* Process payment
* Submit a payment using Stripe's PHP API:
......
......@@ -10,7 +10,7 @@ use CRM_Stripe_ExtensionUtil as E;
*/
class CRM_Stripe_Check {
const MIN_VERSION_MJWSHARED = '0.4.4';
const MIN_VERSION_MJWSHARED = '0.4.5';
public static function checkRequirements(&$messages) {
$extensions = civicrm_api3('Extension', 'get', [
......
......@@ -128,23 +128,6 @@ function stripe_civicrm_buildForm($formName, &$form) {
}
}
/**
* Implements hook_civicrm_postProcess().
*
* @param string $formName
* @param \CRM_Core_Form $form
*
* @throws \CRM_Core_Exception
*/
function stripe_civicrm_postProcess($formName, &$form) {
// We're only interested in forms that have a paymentprocessor
if (empty($form->get('paymentProcessor')) || ($form->get('paymentProcessor')['class_name'] !== 'Payment_Stripe')) {
return;
}
CRM_Core_Payment_Stripe::setTokenParameter('paymentMethodID', $form);
CRM_Core_Payment_Stripe::setTokenParameter('paymentIntentID', $form);
}
/**
* Implements hook_civicrm_check().
*
......
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