From 3105efd2f63576c08014c4ef753e8ed594259ef7 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sun, 12 Jul 2015 18:44:15 +1200 Subject: [PATCH] CRM-16808 make functions called by paypal express more generic --- CRM/Contribute/Form/Contribution/Confirm.php | 2 +- CRM/Core/Payment.php | 14 ++++++++++++++ CRM/Core/Payment/PayPalImpl.php | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 6506549f7a..bcc80a2b3d 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -219,7 +219,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr ); if ($rfp) { $payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this); - $expressParams = $payment->getExpressCheckoutDetails($this->get('token')); + $expressParams = $payment->getPreApprovalDetails($this->get('pre_approval_parameters')); $this->_params['payer'] = CRM_Utils_Array::value('payer', $expressParams); $this->_params['payer_id'] = $expressParams['payer_id']; diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index 8499202b38..7a753b296d 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -251,6 +251,20 @@ abstract class CRM_Core_Payment { */ public function doPreApproval($params) {} + /** + * 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 array(); + } + /** * Default payment instrument validation. * diff --git a/CRM/Core/Payment/PayPalImpl.php b/CRM/Core/Payment/PayPalImpl.php index ee6b4adbcc..600ec5c544 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -190,6 +190,20 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { return $result['token']; } + /** + * 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 $this->getExpressCheckoutDetails($storedDetails['token']); + } + /** * Get details from paypal. Check PayPal documentation for more information * -- 2.25.1