Answers.Body: <p>This usually happens when you have</p>
  <ol>
  <li>Browser cookies disabled</li>
  <li>CiviCRM cache cleared when users is on payment processor gateway and doing payment.</li>
  <li>User is created at the time of submitting contribution and causes session to clear.</li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-23T11:12:51.007Z
Answers.Text: Yes it appears that number 3 is my issue, is there any way to fix this though?
Answers.UserDisplayName: Scott Neville
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-21T23:35:58.223Z
Answers.LastActivityDate: 2021-03-21T23:35:58.223Z
Answers.UserDisplayName: Pradeep Nayak
Answers.Body: <p>I have had a similar problem, but it involves existing users not created users. See <a href="https://civicrm.stackexchange.com/questions/39156/payments-fail-with-paypal-standard-and-could-not-find-a-valid-session-key">my question</a> for a description and solution.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-28T23:23:55.963Z
Answers.LastActivityDate: 2021-03-28T23:23:55.963Z
Answers.UserDisplayName: Ken West
Answers.Body: <p>Issue Description:</p>
  <p>The issue is related to the getReturnSuccessUrl() function in the Payment.php file of CiviCRM. The original code is causing a problem where the query parameter _qf_ThankYou_display is not properly appended to the $qfKey. As a result, the success URL is not being generated correctly.</p>
  <p>Solution:
  To fix this issue, we need to modify the getReturnSuccessUrl() function by appending the _qf_ThankYou_display=1 parameter to the $qfKey. This will ensure that the success URL is generated with the correct parameters.</p>
  <p>Original Code:</p>
  <p>protected function getReturnSuccessUrl($qfKey) {
  if (isset($this-&gt;successUrl)) {
  return $this-&gt;successUrl;
  }</p>
  <p>return CRM_Utils_System::url($this-&gt;getBaseReturnUrl(), [
  '_qf_ThankYou_display' =&gt; 1,
  'qfKey' =&gt; $qfKey,
  ],
  TRUE, NULL, FALSE
  );
  }</p>
  <p>Updated Code:</p>
  <p>protected function getReturnSuccessUrl($qfKey) {
  if (isset($this-&gt;successUrl)) {
  return $this-&gt;successUrl;
  }</p>
  <p>// Append the '_qf_ThankYou_display=1' parameter to the $qfKey.
  $qfKey .= '&amp;_qf_ThankYou_display=1';</p>
  <p>return CRM_Utils_System::url($this-&gt;getBaseReturnUrl(), [
  'qfKey' =&gt; $qfKey,
  ],
  TRUE, NULL, FALSE
  );
  }</p>
  <p>With this modification, the success URL will be generated correctly, and the issue should be resolved. Remember to apply the change in the Payment.php file as described in the solution above.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-21T05:53:41.640Z
Answers.LastActivityDate: 2023-07-21T05:54:51.590Z
Answers.LastEditDate: 2023-07-21T05:54:51.590Z
Answers.UserDisplayName: Dheeraj Jhamtani
Body: <p>I have a site which has been running for some time.  Recently whenever anyone makes a contribution (via PayPal).  When they click return to merchant they get the following error:</p>
  <p><a href="https://i.sstatic.net/Z1vt1.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Z1vt1.png" alt="Error" /></a></p>
  <p>This is caused by the qfKey coming back in the URL being invalid.  The error starts on line 308 of civicrm/CRM/Core/Controller.php and is caused by CRM_Core_Key::validate($key, $name, $addSequence) returning null.</p>
  <p>I have disabling all my custom templates and the issue persists.  Looking at the code it should get the qfKey from the request, so what is causing it to be invalid?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-03-20T10:37:37.137Z
Comments.Text: Do you have cookies enabled? Are you creating any user while submitting the contribution?
Comments.UserDisplayName: Pradeep Nayak
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-03-20T10:58:22.977Z
Comments.Text: Cookies are enabled, I can see a PHPSESSID being set.  Yes a user is being created when the submission is taking place.
Comments.UserDisplayName: Scott Neville
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-03-20T12:37:15.470Z
Comments.Text: You have an interesting point disabling the account creation is enough to fix the problem.  Although not ideal
Comments.UserDisplayName: Scott Neville
Tags: <civicontribute>
Title: qfKey are always invalid when returning from payment processor in contribution
ThreadText: # qfKey are always invalid when returning from payment processor in contribution
  
  (Asked by: username_0 on 2021-03-20)
  
  I have a site which has been running for some time. Recently whenever anyone makes a contribution (via PayPal). When they click return to merchant they get the following error:
  
  [![Error](https://i.sstatic.net/Z1vt1.png)](https://i.sstatic.net/Z1vt1.png)
  
  This is caused by the qfKey coming back in the URL being invalid. The error starts on line 308 of civicrm/CRM/Core/Controller.php and is caused by CRM\_Core\_Key::validate($key, $name, $addSequence) returning null.
  
  I have disabling all my custom templates and the issue persists. Looking at the code it should get the qfKey from the request, so what is causing it to be invalid?
  
  **Tags:** civicontribute
  
  > **Comments:**
  > **username_1**: Do you have cookies enabled? Are you creating any user while submitting the contribution?  
  > **username_0**: Cookies are enabled, I can see a PHPSESSID being set.  Yes a user is being created when the submission is taking place.  
  > **username_0**: You have an interesting point disabling the account creation is enough to fix the problem.  Although not ideal  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2021-03-21. Score: 3
  
  This usually happens when you have
  
  1. Browser cookies disabled
  2. CiviCRM cache cleared when users is on payment processor gateway and doing payment.
  3. User is created at the time of submitting contribution and causes session to clear.
  
  > **Comments:**
  > **username_0**: Yes it appears that number 3 is my issue, is there any way to fix this though?  
  
  ---
  
  ### Answer by username_2 on 2021-03-28. Score: 0
  
  I have had a similar problem, but it involves existing users not created users. See [my question](https://civicrm.stackexchange.com/questions/39156/payments-fail-with-paypal-standard-and-could-not-find-a-valid-session-key) for a description and solution.
  
  
  ---
  
  ### Answer by username_3 on 2023-07-21. Score: 0
  
  Issue Description:
  
  The issue is related to the getReturnSuccessUrl() function in the Payment.php file of CiviCRM. The original code is causing a problem where the query parameter \_qf\_ThankYou\_display is not properly appended to the $qfKey. As a result, the success URL is not being generated correctly.
  
  Solution:
  To fix this issue, we need to modify the getReturnSuccessUrl() function by appending the \_qf\_ThankYou\_display=1 parameter to the $qfKey. This will ensure that the success URL is generated with the correct parameters.
  
  Original Code:
  
  protected function getReturnSuccessUrl($qfKey) {
  if (isset($this->successUrl)) {
  return $this->successUrl;
  }
  
  return CRM\_Utils\_System::url($this->getBaseReturnUrl(), [
  '\_qf\_ThankYou\_display' => 1,
  'qfKey' => $qfKey,
  ],
  TRUE, NULL, FALSE
  );
  }
  
  Updated Code:
  
  protected function getReturnSuccessUrl($qfKey) {
  if (isset($this->successUrl)) {
  return $this->successUrl;
  }
  
  // Append the '\_qf\_ThankYou\_display=1' parameter to the $qfKey.
  $qfKey .= '&\_qf\_ThankYou\_display=1';
  
  return CRM\_Utils\_System::url($this->getBaseReturnUrl(), [
  'qfKey' => $qfKey,
  ],
  TRUE, NULL, FALSE
  );
  }
  
  With this modification, the success URL will be generated correctly, and the issue should be resolved. Remember to apply the change in the Payment.php file as described in the solution above.
  
  
  ---
  
  