And now I had a payment go through with no issues. I'm not sure what's going on here...
And now I had a payment go through with no issues. I'm not sure what's going on here...
You may need to set up a CRON job on your server to renew the token every three days or so. There's instructions in the README.html file in the mod package
Automatic Token Refreshing via cron
This is optional. For low-traffic stores, this is recommended.
In the initial setup, you clicked that "green button" to activate the module by setting what's called a Refresh Token. This token will expire in 45 days if no transactions are made. (30 days expiration, plus 15 days grace period.) After the 30 days you will see the green "Get Access Token" button again in your store Admin, and will need to click it to reactivate the module as you did during initial setup.
With regular transaction activity the token will refresh itself, but this can come at the expense of a brief delay for random customers. To avoid the possibility of such delays, or expiration due to inactivity, we recommend that you set up a "cron job" on your server to automatically handle token refreshes without interfering with customer checkout activity.
To set up the cron job, go to the cron settings in your website hosting company's control panel, and create a new task to run every 3 days at 1am. The command for the task will be:
php /home/user/your/path/to/wherever/is/square_handler.php
Again, if your token expires, Square will no longer show up during checkout for your customers. But you can fix it manually by clicking the green button to "login and authorize your account" as described in the Configuration section above.
Thank you for this module, Dr. Byte. We've been using Paypal for card payments for years but some people seem to run a mile as soon as they see the Paypal brand. I set up a Square account a few days ago along with this module. It took me about half an hour from not having an account to running a test transaction in Zen Cart.
Anyway, I see that Square has just updated their API to handle the European PSD2/SCA (Strong Customer Authentication) regulations that come into force in a couple of months. I'm assuming this module will need an update to handle that?
I looked around but couldn't locate the similar occurrence I'm experiencing with one of my stores.
This is what I'm getting all of the sudden in the log files after everything was working just fine.
The payment module isn't giving me any error on the admin side for which I assumed the installation was done correctly (?). I've removed the module and installed it again, no error messages, but it isn't working as it should. Some credit card payments do go through just fine though, which is strange.
ZC Version 1.5.6a
Square version 0.97
[05-Aug-2019 03:55:55 America/Detroit] Request URI: /index.php?main_page=checkout_process, IP address:XXXXXXXXX
#1 trigger_error() called at [/includes/modules/payment/square.php:340]
#2 square->before_process() called at [/includes/classes/payment.php:245]
#3 payment->before_process() called at [/includes/modules/checkout_process.php:85]
#4 require(/includes/modules/checkout_process.php) called at [/includes/modules/pages/checkout_process/header_php.php:14]
#5 require(/includes/modules/pages/checkout_process/header_php.php) called at [/home/koolwedd/public_html/index.php:36]
--> PHP Notice: Square Connect [configuration] error.
Response Body:
stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[category] => INVALID_REQUEST_ERROR
[code] => NOT_FOUND
[detail] => Card nonce not found in this application environment. Please ensure an application ID belonging to the same environment is used to generate the nonce.
)
)
)
Response Headers:
Array
(
[0] => HTTP/1.1 404 Not Found
[Content-Type] => application/json
[Square-Version] => 2018-12-05
[Vary] => Origin, Accept-Encoding
[X-Content-Type-Options] => nosniff
[X-Download-Options] => noopen
[X-Frame-Options] => SAMEORIGIN
[X-Permitted-Cross-Domain-Policies] => none
[X-Xss-Protection] => 1; mode=block
[Date] => Mon, 05 Aug 2019 07:55:41 GMT
[keep-alive] => timeout=60
[Strict-Transport-Security] => max-age=631152000
[content-length] => 230
)
in /includes/modules/payment/square.php on line 340.
Any idea what could be happening?
Thank you.
all of the sudden ... after everything was working just fine.
reinstalled ... no error messages, but it isn't working as it should. Some credit card payments do go through just fine though, which is strange.
That sort of message usually means you've generated an app token for one store but are using it on another. But that wouldn't happen on already-running stores like yours unless someone is in your admin and messing with your own configuration settings, which is unlikely.
Due to the intermittent nature of the problem, I'd suggest reaching out to Square Support. It feels like maybe something amuck on their servers.
If you can get a tech person on their end to look into their logs (on their end) for those specific rejections (or new ones you can trigger in real time) then they can probably tell you what's causing it, or identify whether something's operating oddly on their end.
For context, you can tell them that you're using Square-Connect-PHP/2.20181205.0 (and passing 'Square-Version: 2018-12-05' with each transaction).
(In case they ask: I haven't upgraded it to a newer one yet for 2 reasons: you're not using any of the newer features they've added, and upgrading it requires a huge rewrite to the token infrastructure that I had to create long before they built one in. They've advised me that passing the API version number as described above is exactly the right approach in this case.)
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
Thank you DrByte for the quick reply.
I would think something else is happening since nothing has changed in the square account, just updated ZC to 1.5.6a and installed the module with the exact same information it's had. Also weird the event seems to be intermittent.
I'll post whatever solution square provides me with in case someone else here has a similar issue.
ZC v1.5.6c
PHP v7.2.10
Square v0.97
Successfully captured funds within Admin (Square) but received this warning when doing so
Lines 1017 - 1022 of square.phpCode:[22-Aug-2019 16:51:02 Europe/London] Request URI: /myadmin/orders.php?page=1&oID=1271&action=doCapture, IP address: my.ip.123.456 #1 square->_doCapt() called at [/home/mydomain/public_html/myadmin/orders.php:285] --> PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/mydomain/public_html/includes/modules/payment/square.php on line 1017.
Code:if (count($errors_object)) { $error = $this->parse_error_response($errors_object); $messageStack->add_session(MODULE_PAYMENT_SQUARE_TEXT_UPDATE_FAILED . ' [' . $error['detail'] . ']', 'error'); return false; }
Simon
Also, just noticed this warning, at time of above order
Lines 355 - 359 of square.phpCode:[17-Aug-2019 11:22:25 Europe/London] Request URI: /index.php?main_page=checkout_process, IP address: my.customersip.123.456 #1 square->before_process() called at [/home/mydomain/public_html/includes/classes/payment.php:246] #2 payment->before_process() called at [/home/mydomain/public_html/includes/modules/checkout_process.php:92] #3 require(/home/mydomain/public_html/includes/modules/checkout_process.php) called at [/home/mydomain/public_html/includes/modules/pages/checkout_process/header_php.php:14] #4 require(/home/mydomain/public_html/includes/modules/pages/checkout_process/header_php.php) called at [/home/mydomain/public_html/index.php:36] --> PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/mydomain/public_html/includes/modules/payment/square.php on line 355.
Code:if (count($errors_object)) { $error = $this->parse_error_response($errors_object); $messageStack->add_session('checkout_payment', MODULE_PAYMENT_SQUARE_TEXT_ERROR . ' [' . $error['detail'] . ']', 'error'); zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false)); }
Simon