Fix redirect to PayPal
authorPeter Haight <peterh@giantrabbit.com>
Thu, 19 Nov 2020 02:45:06 +0000 (18:45 -0800)
committerPeter Haight <peterh@giantrabbit.com>
Thu, 19 Nov 2020 02:45:06 +0000 (18:45 -0800)
If you put in double slashes in the path part of the PayPal URL and then
PayPal asks you to do their captcha, they have some sort of bug where
they do the wrong redirect after the captcha to https://cgi-bin/webscr.

Issue #153

CRM/Core/Payment/PayPalImpl.php

index e2f8cb7596321bb05c778339884a509e88a805fe..88ba727eca15ef32a3e5ea86be06ea7fd809c33d 100644 (file)
@@ -843,9 +843,10 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment {
     }
     $this->_component = $params['component'];
     $token = $this->setExpressCheckOut($params);
+    $siteUrl = rtrim($this->_paymentProcessor['url_site'], '/');
     return [
       'pre_approval_parameters' => ['token' => $token],
-      'redirect_url' => $this->_paymentProcessor['url_site'] . "/cgi-bin/webscr?cmd=_express-checkout&token=$token",
+      'redirect_url' => $siteUrl . "/cgi-bin/webscr?cmd=_express-checkout&token=$token",
     ];
   }