Prevent PayPal from double-encoding the IPN Notify URL
authorChristian Wach <needle@haystack.co.uk>
Mon, 16 Nov 2020 19:20:49 +0000 (19:20 +0000)
committerChristian Wach <needle@haystack.co.uk>
Mon, 16 Nov 2020 19:20:49 +0000 (19:20 +0000)
CRM/Core/Payment/PayPalImpl.php

index e2f8cb7596321bb05c778339884a509e88a805fe..57dd8cc633b19afe4fc5109e16e14d2d412d1575 100644 (file)
@@ -976,6 +976,14 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment {
     // Allow further manipulation of the arguments via custom hooks ..
     CRM_Utils_Hook::alterPaymentProcessorParams($this, $params, $paypalParams);
 
+    /*
+     * PayPal urlencodes the IPN Notify URL. For sites not using Clean URLs (or
+     * using Shortcodes in WordPress) this results in "%2F" becoming "%252F" and
+     * therefore incomplete transactions. We need to prevent that.
+     * @see https://lab.civicrm.org/dev/core/-/issues/1931
+     */
+    $paypalParams['notify_url'] = rawurldecode($paypalParams['notify_url']);
+
     $uri = '';
     foreach ($paypalParams as $key => $value) {
       if ($value === NULL) {