Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Argument 1 passed to EED_SquareOnsiteOAuth::encryptString() must be of the type string #27

Closed
lorenzocaum opened this issue Jan 27, 2022 · 3 comments · Fixed by #28
Assignees

Comments

@lorenzocaum
Copy link
Contributor

lorenzocaum commented Jan 27, 2022

Notice: Trying to get property 'nonce' of non-object in /dom16100/wp-content/plugins/eea-square-gateway/modules/EED_SquareOnsiteOAuth.module.php on line 557

Notice: Trying to get property 'application_id' of non-object in /dom16100/wp-content/plugins/eea-square-gateway/modules/EED_SquareOnsiteOAuth.module.php on line 580

Notice: Trying to get property 'access_token' of non-object in /dom16100/wp-content/plugins/eea-square-gateway/modules/EED_SquareOnsiteOAuth.module.php on line 584

Fatal error: Uncaught TypeError: Argument 1 passed to EED_SquareOnsiteOAuth::encryptString() must be of the type string, null given, called in /dom16100/wp-content/plugins/eea-square-gateway/modules/EED_SquareOnsiteOAuth.module.php on line 584 and defined in /dom16100/wp-content/plugins/eea-square-gateway/modules/EED_SquareOnsiteOAuth.module.php:793 Stack trace: #0 /dom16100/wp-content/plugins/eea-square-gateway/modules/EED_SquareOnsiteOAuth.module.php(584): EED_SquareOnsiteOAuth::encryptString(NULL, false) #1 /dom16100/wp-content/plugins/eea-square-gateway/modules/EED_SquareOnsiteOAuth.module.php(743): EED_SquareOnsiteOAuth::refreshToken(Object(EE_Payment_Method)) #2 /dom16100/wp-content/plugins/eea-square-gateway/payment_methods/SquareOnsite/forms/SettingsForm.php(113): EED_SquareOnsiteOAuth::checkAndRefreshToken(Object(EE_Payment_Method)) #3 /dom16100/wp-content/plugins/eea-square-gateway/payment_methods/SquareOnsite/forms/SettingsForm.php(64): EventEspresso\Square\payment_methods\SquareOnsite\forms\SettingsForm->valid in /dom16100/wp-content/plugins/eea-square-gateway/modules/EED_SquareOnsiteOAuth.module.php on line 793

‹ lorenzochrome21 — Event Smart 2022-01-27 at 3 09 44 PM

Steps to reproduce

Not sure. However, I do remember what I did on the site.

In this issue (https://github.com/eventespresso/eventsmart.com-website/issues/886#issuecomment-1018780369), I noticed that two sites deactivated the Square payment method. On this new site where I reported this issue, I followed these steps:

  • Last Friday, Jan 21, I set up a new testing site through Chrome.
  • I purchased the Square payment gateway to get access to the upgrade.
  • I activated the Square in the payment methods screen.
  • Then connected it in live mode.
  • After, I set a Slack reminder to check to see if it was deactivated the following Monday.
  • On Monday's check, the Square payment method was not deactivated.
  • Today is Thursday so almost a week later, I went back to the site to check on the deactivated issue again. This time, I noticed a fatal error.

Reported or seen on

https://lorenzochrome21.makeeventsnotwar.com/wp-admin/admin.php?page=espresso_payment_settings#espresso_squareonsite_payment_settings

Other notes

I saw the same error on one of my testing sites (https://enzo12staging.wpengine.com/wp-admin/admin.php?page=espresso_payment_settings#espresso_squareonsite_payment_settings):

An error of type E_ERROR was caused in line 793 of the file /nas/content/live/enzo12staging/wp-content/plugins/eea-square-gateway/modules/EED_SquareOnsiteOAuth.module.php. Error message: Uncaught TypeError: Argument 1 passed to EED_SquareOnsiteOAuth::encryptString() must be of the type string, null given, called in /nas/content/live/enzo12staging/wp-content/plugins/eea-square-gateway/modules/EED_SquareOnsiteOAuth.module.php on line 584 and defined in /nas/content/live/enzo12staging/wp-content/plugins/eea-square-gateway/modules/EED_SquareOnsiteOAuth.module.php:793
Stack trace:
#0 /nas/content/live/enzo12staging/wp-content/plugins/eea-square-gateway/modules/EED_SquareOnsiteOAuth.module.php(584): EED_SquareOnsiteOAuth::encryptString(NULL, false)
#1 /nas/content/live/enzo12staging/wp-content/plugins/eea-square-gateway/modules/EED_SquareOnsiteOAuth.module.php(743): EED_SquareOnsiteOAuth::refreshToken(Object(EE_Payment_Method))
#2 /nas/content/live/enzo12staging/wp-content/plugins/eea-square-gateway/payment_methods/SquareOnsite/forms/SettingsForm.php(113): EED_SquareOnsiteOAuth::checkAndRefreshToken(Object(EE_Payment_Method))
#3 /nas/content/live/enzo12staging/wp-content/plugins/eea-square-gateway/

‹ Lorenzo Caum Site — WordPress 2022-01-27 at 3 30 06 PM

Tony shared this feedback in Slack support-desk:

It means the keys have been set nothing and the pm is trying to use them. So the problem is not the fatal itself.... its that the keys are being blanked

@lorenzocaum
Copy link
Contributor Author

lorenzocaum commented Jan 27, 2022

Hey there @knazart I saw Square had a fatal on a testing site on a subsite on MakeEventsNotWar. Tony mentioned it is from the keys for Square being blanked as he has seen this with some Event Espresso customers.

In another conversation, you mentioned issues like this can be tough to debug. I wrote out the steps that I followed to get set up with Square here:

#27 (comment)

I don't understand how the keys are stored but a couple of ideas popped into my head:

  • Does Square interact with a transient (temporary storage)?
  • Does Square use a cron to check the keys are valid on a schedule? Or when someone browses to the Square payment method screen?
  • Does Square use one set of API credentials when connecting? (I'm wondering if connecting one site and then connecting to a different site would cause a conflict.)

Is there any additional information that you need that would be help to debug this issue?

@Pebblo
Copy link
Member

Pebblo commented Jan 28, 2022

This is essentially the same issue from #16

The error is different but the cause is pretty much the same, so we need to find out how the keys are being saved null.

@knazart
Copy link
Member

knazart commented Jan 28, 2022

This happens on refreshToken which should occur every 2 days, triggered by a cron.

I did patch up the fatal and notices just now. This is not null being saved, this is null being returned from the API as a response on the refresh request. And that's because somehow we are ending up without a refresh_token while being connected (authenticated). And refreshToken shouldn't run if the client is not connected...

I did check the logs on lorenzochrome21 and yes, I do see a "Could not find the refresh token.", and the refresh_token is really missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants