Answers.Body: <p>Is there a reason you're using Omnipay rather than the inbuilt Paypal processor? (I think I read on Mastodon you saying you were just wanting to integrate Paypal?)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-09-13T04:57:03.257Z
Answers.Text: The reason is that I want to be able to use PayPal Checkout so that people can use a credit card without a Paypal account. As far as I can tell, that isn't possible with the inbuild processor.
Answers.UserDisplayName: Nick Perkins
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-29T10:26:08.890Z
Answers.LastActivityDate: 2023-08-29T10:26:08.890Z
Answers.UserDisplayName: Nic
Answers.Body: <p>The line in question (line 294 of <code>&lt;civiroot&gt;/CRM/Contribute/Form/Contribution/Confirm.php</code> looks like this:</p>
  <pre><code>$this-&gt;_params = array_merge($this-&gt;_params, $preApprovalParams);
  </code></pre>
  <p>You can fix this error by changing it to this:</p>
  <pre><code>$this-&gt;_params = array_merge($this-&gt;_params, $preApprovalParams ?? []);
  </code></pre>
  <p>Now this isn't an ideal solution, because that won't survive a Civi upgrade. The root problem appears to be in the OmniPay extension, <a href="https://github.com/eileenmcnaughton/nz.co.fuzion.omnipaymultiprocessor/blob/a020f42f19fd67c4523ad123585fb9490808dfcf/CRM/Core/Payment/OmnipayMultiProcessor.php#L1112C26-L1112C26" rel="nofollow noreferrer">in the doPreApproval function</a>.</p>
  <p>I don't use OmniPay so can't check myself - but looking at that function, it seems like the only way it wouldn't return a value would be if an error occurred, and that would be in your CiviCRM logs.  See if your <a href="https://civicrm.stackexchange.com/a/15932/12">log files</a> show any errors that have a matching timestamp?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-26T16:53:05.607Z
Answers.LastActivityDate: 2023-08-26T16:53:05.607Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I'm setting up a membership form using a contribution page. I've installed the &quot;Omnipay multiprocessor support&quot; and have it set up for sandbox payments. When I complete the process and I'm returned to the site, I get a critical error page.</p>
  <p>The php error logs show the following error:</p>
  <pre><code>[25-Aug-2023 19:51:19 Australia/Brisbane] PHP Fatal error:  Uncaught TypeError: array_merge(): Argument #2 must be of type array, null given in /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/Contribution/Confirm.php:294
  Stack trace:
  #0 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/Contribution/Confirm.php(294): array_merge(Array, NULL)
  #1 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/Contribution/Main.php(1345): CRM_Contribute_Form_Contribution_Confirm-&gt;preProcess()
  #2 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/Contribution/Main.php(1102): CRM_Contribute_Form_Contribution_Main-&gt;skipToThankYouPage()
  #3 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(617): CRM_Contribute_Form_Contribution_Main-&gt;postProcess()
  #4 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php(153): CRM_Core_Form-&gt;mainProcess()
  #5 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php(120): CRM_Core_QuickForm_Action_Upload-&gt;realPerform(Object(CRM_Contribute_Form_Contribution_Main), 'upload')
  #6 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Upload-&gt;perform(Object(CRM_Contribute_Form_Contribution_Main), 'upload')
  #7 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller-&gt;handle(Object(CRM_Contribute_Form_Contribution_Main), 'upload')
  #8 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(355): HTML_QuickForm_Page-&gt;handle('upload')
  #9 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(319): CRM_Core_Controller-&gt;run(Array, NULL)
  #10 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(69): CRM_Core_Invoke::runItem(Array)
  #11 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke(Array)
  #12 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm.php(1199): CRM_Core_Invoke::invoke(Array)
  #13 /home/xxx/public_html/wp-content/plugins/civicrm/includes/civicrm.basepage.php(380): CiviCRM_For_WordPress-&gt;invoke()
  #14 /home/xxx/public_html/wp-includes/class-wp-hook.php(310): CiviCRM_For_WordPress_Basepage-&gt;basepage_handler(Object(WP))
  #15 /home/xxx/public_html/wp-includes/class-wp-hook.php(334): WP_Hook-&gt;apply_filters(NULL, Array)
  #16 /home/xxx/public_html/wp-includes/plugin.php(565): WP_Hook-&gt;do_action(Array)
  #17 /home/xxx/public_html/wp-includes/class-wp.php(796): do_action_ref_array('wp', Array)
  #18 /home/xxx/public_html/wp-includes/functions.php(1335): WP-&gt;main('')
  #19 /home/xxx/public_html/wp-blog-header.php(16): wp()
  #20 /home/xxx/public_html/index.php(17): require('/home/xxx/pub...')
  #21 {main}
    thrown in /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/Contribution/Confirm.php on line 294
  </code></pre>
  <p>This is the first time I've tried to set up civicrm, so I'm a little lost on this one.</p>
  <p>Edit: running Civicrm 5.64.1</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-25T20:26:35.167Z
Comments.Text: Please post your CiviCRM version?  Also, if you have the option to run PHP 7, that's a quick way to work around this, TypeErrors aren't fatal in PHP < 8.
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-26T03:53:37.203Z
Comments.Text: I've added that I'm using 5.64.1. I tried to downgrade to v7.4 but I get new errors, so have switched back for now.
Comments.UserDisplayName: Nick Perkins
Tags: <wordpress><civicontribute><paypal><omnipay>
Title: Error when Paypal Checkout payment is processed
ThreadText: # Error when Paypal Checkout payment is processed
  
  (Asked by: username_0 on 2023-08-25)
  
  I'm setting up a membership form using a contribution page. I've installed the "Omnipay multiprocessor support" and have it set up for sandbox payments. When I complete the process and I'm returned to the site, I get a critical error page.
  
  The php error logs show the following error:
  
  ```
  [25-Aug-2023 19:51:19 Australia/Brisbane] PHP Fatal error:  Uncaught TypeError: array_merge(): Argument #2 must be of type array, null given in /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/Contribution/Confirm.php:294
  Stack trace:
  #0 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/Contribution/Confirm.php(294): array_merge(Array, NULL)
  #1 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/Contribution/Main.php(1345): CRM_Contribute_Form_Contribution_Confirm->preProcess()
  #2 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/Contribution/Main.php(1102): CRM_Contribute_Form_Contribution_Main->skipToThankYouPage()
  #3 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(617): CRM_Contribute_Form_Contribution_Main->postProcess()
  #4 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php(153): CRM_Core_Form->mainProcess()
  #5 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php(120): CRM_Core_QuickForm_Action_Upload->realPerform(Object(CRM_Contribute_Form_Contribution_Main), 'upload')
  #6 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Upload->perform(Object(CRM_Contribute_Form_Contribution_Main), 'upload')
  #7 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Contribute_Form_Contribution_Main), 'upload')
  #8 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(355): HTML_QuickForm_Page->handle('upload')
  #9 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(319): CRM_Core_Controller->run(Array, NULL)
  #10 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(69): CRM_Core_Invoke::runItem(Array)
  #11 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke(Array)
  #12 /home/xxx/public_html/wp-content/plugins/civicrm/civicrm.php(1199): CRM_Core_Invoke::invoke(Array)
  #13 /home/xxx/public_html/wp-content/plugins/civicrm/includes/civicrm.basepage.php(380): CiviCRM_For_WordPress->invoke()
  #14 /home/xxx/public_html/wp-includes/class-wp-hook.php(310): CiviCRM_For_WordPress_Basepage->basepage_handler(Object(WP))
  #15 /home/xxx/public_html/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters(NULL, Array)
  #16 /home/xxx/public_html/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
  #17 /home/xxx/public_html/wp-includes/class-wp.php(796): do_action_ref_array('wp', Array)
  #18 /home/xxx/public_html/wp-includes/functions.php(1335): WP->main('')
  #19 /home/xxx/public_html/wp-blog-header.php(16): wp()
  #20 /home/xxx/public_html/index.php(17): require('/home/xxx/pub...')
  #21 {main}
    thrown in /home/xxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/Contribution/Confirm.php on line 294
  
  ```
  
  This is the first time I've tried to set up civicrm, so I'm a little lost on this one.
  
  Edit: running Civicrm 5.64.1
  
  **Tags:** wordpress, civicontribute, paypal, omnipay
  
  > **Comments:**
  > **username_1**: Please post your CiviCRM version?  Also, if you have the option to run PHP 7, that's a quick way to work around this, TypeErrors aren't fatal in PHP < 8.  
  > **username_0**: I've added that I'm using 5.64.1. I tried to downgrade to v7.4 but I get new errors, so have switched back for now.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2023-08-29. Score: 0
  
  Is there a reason you're using Omnipay rather than the inbuilt Paypal processor? (I think I read on Mastodon you saying you were just wanting to integrate Paypal?)
  
  > **Comments:**
  > **username_0**: The reason is that I want to be able to use PayPal Checkout so that people can use a credit card without a Paypal account. As far as I can tell, that isn't possible with the inbuild processor.  
  
  ---
  
  ### Answer by username_1 on 2023-08-26. Score: 0
  
  The line in question (line 294 of `<civiroot>/CRM/Contribute/Form/Contribution/Confirm.php` looks like this:
  
  ```
  $this->_params = array_merge($this->_params, $preApprovalParams);
  
  ```
  
  You can fix this error by changing it to this:
  
  ```
  $this->_params = array_merge($this->_params, $preApprovalParams ?? []);
  
  ```
  
  Now this isn't an ideal solution, because that won't survive a Civi upgrade. The root problem appears to be in the OmniPay extension, [in the doPreApproval function](https://github.com/eileenmcnaughton/nz.co.fuzion.omnipaymultiprocessor/blob/a020f42f19fd67c4523ad123585fb9490808dfcf/CRM/Core/Payment/OmnipayMultiProcessor.php#L1112C26-L1112C26).
  
  I don't use OmniPay so can't check myself - but looking at that function, it seems like the only way it wouldn't return a value would be if an error occurred, and that would be in your CiviCRM logs. See if your [log files](https://civicrm.stackexchange.com/a/15932/12) show any errors that have a matching timestamp?
  
  
  ---
  
  