eileenmcnaughton / nz.co.fuzion.omnipaymultiprocessor

Omnipay Multi Processor Payment Processor For CiviCRM
Other
13 stars 44 forks source link

Error: Call to undefined method Omnipay\PayPal\RestGateway::set() #103

Open hoegrammer opened 5 years ago

hoegrammer commented 5 years ago

Hi, I'm getting that error when using a webform. The processor is set to "Paypal Checkout"

hoegrammer commented 5 years ago

Actually I get the same error when using the contribution page directly:

  | Error: Call to undefined method Omnipay\PayPal\RestGateway::set() in CRM_Core_Payment_OmnipayMultiProcessor->setProcessorFields() (line 318 of /var/www/mysite/sites/default/files/civicrm/ext/nz.co.fuzion.omnipaymultiprocessor/CRM/Core/Payment/OmnipayMultiProcessor.php).

hoegrammer commented 5 years ago

I thought it might be because I was using PHP 7.0 but I am now using 7.2 and getting the same error.

Using the contribution page, I see a nice Paypal button, click it, I get the popup briefly and the popup tries to load, then disappears replaced by an alert saying "the site is not configured correctly to take payments". In watchdog I see the above error.

eileenmcnaughton commented 5 years ago

It implies that you have a field filed in in civicrm_payment_processor without a matching value in civicrm_payment_processor_type

hoegrammer commented 5 years ago

Hello! The fields array is Array ( [Clientid] => myemail+ikm_api1.gmail.com [Secret] => FBM93XJTWAsdfsdZSAB [] => AWkT50gtrA0iXnhXXlAFYAOXzvynv8B4pJTYjDdt44TAJwrSD )

So one of the array keys is blank

hoegrammer commented 5 years ago

hence $fn = "set{$name}" ending up as "set"

hoegrammer commented 5 years ago

I've wrapped that bit of code in an if statement checking that $name is not empty.

Now I'm getting this error:

Array
(
    [0] => Authentication failed due to invalid authentication credentials or a missing Authorization header.10,Paypal,46,1,omnipay_PayPal_Rest
)

Which I'm wondering might be due to that thing with the blank array key not being passed?

eileenmcnaughton commented 5 years ago

@hoegrammer so the cilentId is not an email in this instance - mine looks like AWzymvrczbgFT9CuhILzNXnXFyLXsxa8lacr_TJbOT4ytdRuaKnr73t1kOIdwbSTmnjTuajgKaiZCjqR

eileenmcnaughton commented 5 years ago

& only 2 keys should be set in the payment_processor table username & password

hoegrammer commented 5 years ago

I generated a client id and secret which are in the right format (using paypal apps section rather than API) and I made a new payment processor and just filled in these fields. Then I made a contribution page and assigned the new processor. The contribution page won't load - I get the error "CRM_Core_Exception: A payment processor configured for this page might be disabled (contact the site administrator for assistance). in /var/www/usdfsdft.crm-dev/sites/all/modules/civicrm/CRM/Contribute/Form/ContributionBase.php on line 349"

It's passing "0" as the processor id I think:

CRM_Core_Form->assignPaymentProcessor('0')

but the id is 2. When I set the payment processor field of the contribution page back to the original processor this doesn't happen

eileenmcnaughton commented 5 years ago

0 is the pay later processor -

so you have 2 new entries in civicrm_payment_processor and when you look at the values for processor_id in civicrm_contribution_page it has the id of the live one of those 2?

hoegrammer commented 5 years ago

Yes

hoegrammer commented 5 years ago

select * from civicrm_payment_processor where id = 11; +----+-----------+----------+-------------+---------------------------+-----------+------------+---------+----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+-----------+-------------------+-------------------+-------------------+------------+---------+-------------------------------+--------------+----------+--------------+-----------------------+-----------------------+ | id | domain_id | name | description | payment_processor_type_id | is_active | is_default | is_test | user_name | password | signature | url_site | url_api | url_recur | url_button | subject | class_name | billing_mode | is_recur | payment_type | payment_instrument_id | accepted_credit_cards | +----+-----------+----------+-------------+---------------------------+-----------+------------+---------+----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+-----------+-------------------+-------------------+-------------------+------------+---------+-------------------------------+--------------+----------+--------------+-----------------------+-----------------------+ | 11 | 1 | Paypal 2 | NULL | 46 | 1 | 1 | 0 | AWg9iMcYVCN-3VltTHKcgYYYU9gip9wGEv1BwABB4-irwLSdk79VfUXrnsIxXZD9Vig7qA305k9h8Q0 | EKqbOM3UpMKeG8nDaXtLB6JBAURPZ2AvQevS60UpZTBoAKDHudzL1z8xjAsRf89-7fuiV_wJ23nD1th | NULL | http://unused.com | http://unused.com | http://unused.com | NULL | NULL | Payment_OmnipayMultiProcessor | 4 | 1 | 1 | 1 | {"Visa":"Visa"} | +----+-----------+----------+-------------+---------------------------+-----------+------------+---------+----------------------------------------------------------------------------------+----------------------------------------------------------------------------------+-----------+-------------------+-------------------+-------------------+------------+---------+-------------------------------+--------------+----------+--------------+-----------------------+-----------------------+ 1 row in set (0.00 sec)

select payment_processor from civicrm_contribution_page where id = 2; +-------------------+ | payment_processor | +-------------------+ | 11 | +-------------------+

eileenmcnaughton commented 5 years ago

OK - so that looks wrong - the processor id 11 is the test mode processor - the LIVE one should be the one saved into civicrm_contribution_page - presumably number 10? (it then picks up the test one when you are in test mode)

eileenmcnaughton commented 5 years ago

Also this patch is required https://github.com/civicrm/civicrm-core/pull/13798