Totally Zenned
- Join Date:
- Jan 2004
- Location:
- N of San Antonio TX
- Posts:
- 9,763
- Plugin Contributions:
- 9
Square WebPay support thread.
Just did a test order on the site with the fatal error. Got the same error BUT, the order processed.
Views: 128,171
Totally Zenned
Just did a test order on the site with the fatal error. Got the same error BUT, the order processed.
Zen Follower
Brent:
Have a look at post 131
It isn't strictly the correct way to do it as it doesn't fix the root cause but does solve the problem (if you don't need to keep track of which module was used to take the payment).
Thank you. Works fine.
Quick 'n dirty.
zennedOut
dbltoe:
Installed the new 1.0.2 on 1.5.7d with OPC.
Getting ```
[30-Oct-2022 13:30:25 America/New_York] PHP Fatal error: Uncaught TypeError: Argument 1 passed to square_webPay::saveAccessToken() must be an instance of Square\Models\ObtainTokenResponse, instance of Square\Http\ApiResponse given, called in /includes/modules/payment/square_webPay.php on line 779 and defined in /includes/modules/payment/square_webPay.php:678
Stack trace:
#0 /includes/modules/payment/square_webPay.php(779): square_webPay->saveAccessToken(Object(Square\Http\ApiResponse))
#1 /includes/modules/payment/square_webPay.php(622): square_webPay->renewOAuthToken()
#2 /squareWebPay_handler.php(45): square_webPay->token_refresh_check(false)
#3 {main}
thrown in /includes/modules/payment/square_webPay.php on line 678
[30-Oct-2022 13:30:25 America/New_York] Request URI: /squareWebPay_handler.php, IP address: 68.##.##.122
--> PHP Fatal error: Uncaught TypeError: Argument 1 passed to square_webPay::saveAccessToken() must be an instance of Square\Models\ObtainTokenResponse, instance of Square\Http\ApiResponse given, called in /includes/modules/payment/square_webPay.php on line 779 and defined in /includes/modules/payment/square_webPay.php:678
Stack trace:
#0 /includes/modules/payment/square_webPay.php(779): square_webPay->saveAccessToken(Object(Square\Http\ApiResponse))
#1 /includes/modules/payment/square_webPay.php(622): square_webPay->renewOAuthToken()
#2 /squareWebPay_handler.php(45): square_webPay->token_refresh_check(false)
#3 {main}
thrown in /includes/modules/payment/square_webPay.php on line 678.
line 779 of /includes/modules/payment/square_webPay.php needs to be changed.
```php
//from
$this->saveAccessToken($apiResponse);
//to
$this->saveAccessToken($response['results']);
zennedOut
dbltoe:
Another site with 1.0.2 and OPC gets a token warning when the customer has an autofill in Chrome for the CC and does not press enter on the CC Zip before clicking on the confirm order button.
Looks like we may have to work out a way for OPC to ensure the CC is fully active before the confirm order is clicked. You agree?
this is one of those comments that i have no idea what you are talking about and looks to be pure conjecture on your part.
so simply i will disagree.
zennedOut
i have just submitted version 1.0.3 for review.
i'm of the opinion that the small bug previously documented warranted a new release.
best.
Administrator
Approved.
Totally Zenned
Here's the scenario:
Thus the error received is```
[30-Oct-2022 12:54:58 America/Los_Angeles] PHP Notice: missing token result: check if card button is disabled on dev console using: document.getElementById('card-button'); else look for javascript error in console. in /includes/modules/payment/square_webPay.php on line 261
By not finishing the entry process on the CC form before clicking on the Confirm Order button, the customer is forcing OPC to submit an invalid CC form.
The answer may be totally in OPC's court but at least I can see why the token errors have been so random.
Totally Zenned
I don't use OPC and got the same warning so you may be able to rule that out.
[27-Oct-2022 14:38:53 Europe/London] PHP Notice: missing token result: check if card button is disabled on dev console using: document.getElementById('card-button'); else look for javascript error in console. in /includes/modules/payment/square_webPay.php on line 239
At the time I was not running V1.0.2 though but a test version carlwhat gave me that fixed the issues when the store is hosted in a subfolder. The only modified file was /includes/modules/pages/checkout_payment/jscript_square_webPay.php
Totally Zenned
Brent:
I don't use OPC and got the same warning so you may be able to rule that out.
I don't think there is an error with OPC. I think the problem is with the customer who enters the last bit off CC info without hitting enter or tabbing out of the CC form and clicking on the confirm order button.
My thought for a fix would work for either one. Make the confirm button disabled until the payment form is fully completed.
Just my WAG:P
I'll leave it up to Paul, Cindy and Scott et al to work it out. I stand ready to test any possible solutions.
Totally Zenned
In the past (and also these days), I have added written instructions to the payment selection area on the checkout page.
Generally, these are coloured RED and in BOLD text - so the idiots who do online shopping (that's me too), are instructed what to do before hit "Confirm Order".
EG: Above the option for CARD PAYMENTS I have;
Make sure to enter your card details manually! All fields are needed - CARD NUMBER, EXPIRY DATE, CVV
New Zenner
How to change the card entry form to dark mode? our website is black background and some section of the card input can not display clearly. Square told us that web pay SDK can Customize the Card Entry Form and they have as dark mode.
Thanks.
zennedOut
yellx3:
How to change the card entry form to dark mode? our website is black background and some section of the card input can not display clearly. Square told us that web pay SDK can Customize the Card Entry Form and they have as dark mode.
Thanks.
i have not implemented a dark mode, nor do i have plans to do so.
i certainly am available for hire to do so; feel free to PM me if interested.
best.
zennedOut
swguy:
includes/modules/payment/square_webPay.php line 846 creates the error log:
[15-Oct-2022 12:28:29 UTC] PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function Square\Models\Order::__construct(), 0 passed in /home/cust/public_html/shop/includes/modules/payment/square_webPay.php on line 846 and exactly 1 expected in /home/cust/public_html/shop/includes/modules/payment/square_webPay/square/square/src/Models/Order.php:172
Perhaps instead of
return new Models\Order;
it should be
return null;
(This can happen in abnormal situations where the creation of all parts of the error didn't complete successfully.)
@swguy, i am finally looking at this error.
i think the way to solve this problem is returning an empty array. corrected code for that 1 method:
protected function lookupOrderDetails($order_id)
{
global $db;
$sql = "SELECT * from " . TABLE_SQUARE_PAYMENTS . " WHERE order_id = " . (int)$order_id;
$order = $db->Execute($sql);
if ($order->EOF) {
return [];
}
$ids = [];
// foreach (['tender_id', 'transaction_id', 'payment_id', 'sq_order'] as $key) {
foreach (['tender_id', 'transaction_id', 'sq_order'] as $key) {
if (!empty($order->fields[$key])) {
$ids[] = $order->fields[$key];
}
}
$request = new Models\BatchRetrieveOrdersRequest($ids);
try {
$apiResponse = $this->client->getOrdersApi()->batchRetrieveOrders($request);
$response = $this->processResult($apiResponse, $request);
return $response['results']->getOrders();
} catch (\SquareConnect\ApiException $e) {
return [];
}
}
thanks for pointing it out.
Zen Follower
I have been using square_handler_cron.php from swguy to automatically refresh the Square token. Do I need to make any changes to it to work with Square_webPay? I can't find his code anymore to see if it has been updated. The key statements in his code are:
if (IS_CLI == 'VERBOSE') echo 'Starting token refresh... ' . "\n\n";
require DIR_WS_CLASSES . 'payment.php';
$module = new payment('square');
$square = new square;
$result = $square->token_refresh_check();
if ($result === 'failure') {
if (IS_CLI == 'VERBOSE') echo 'Square Token Refresh Failure. See logs.' . "\n";
if (IS_CLI == 'VERBOSE') echo 'Done.' . "\n\n";
exit(1);
} else {
if (IS_CLI == 'VERBOSE') echo $result . "\n";
if (IS_CLI == 'VERBOSE') echo 'Done.' . "\n\n";
exit(0); // returns 0 status code, which means successful
}
Thank you.
Administrator
i think the way to solve this problem is returning an empty array. corrected code for that 1 method ...
Much obliged, sir!
zennedOut
Dave224:
I have been using square_handler_cron.php from swguy to automatically refresh the Square token. Do I need to make any changes to it to work with Square_webPay? I can't find his code anymore to see if it has been updated. The key statements in his code are:
if (IS_CLI == 'VERBOSE') echo 'Starting token refresh... ' . "\n\n";
require DIR_WS_CLASSES . 'payment.php';
$module = new payment('square');
$square = new square;
$result = $square->token_refresh_check();
if ($result === 'failure') {
if (IS_CLI == 'VERBOSE') echo 'Square Token Refresh Failure. See logs.' . "\n";
if (IS_CLI == 'VERBOSE') echo 'Done.' . "\n\n";
exit(1);
} else {
if (IS_CLI == 'VERBOSE') echo $result . "\n";
if (IS_CLI == 'VERBOSE') echo 'Done.' . "\n\n";
exit(0); // returns 0 status code, which means successful
}
> Thank you.
dave,
i can not say whether this handler will work. i have a feeling it will not. but i can not say.
the latest version of my handler does verbose logging if you set $verbose to true in the handler. furthermore, i have improved the logging so that in the case of a failed refresh, the error message is much specific. in addition it can be set up as a cron job as well.
i would look at the docs on it.
best.
Totally Zenned
Should update the version when the version is updated...
public $moduleVersion = '1.0.2';
public $moduleVersion = '1.0.3';
modules/payment/square_webPay.php
zennedOut
twitchtoo:
Should update the version when the version is updated...
public $moduleVersion = '1.0.2';
public $moduleVersion = '1.0.3';
modules/payment/square_webPay.php
should?
everybody makes mistakes.
i'm reminded of your comment here:
https://www.zen-cart.com/showthread.php?226778-Inventory-Updater&p=1389299#post1389299
and lack of any real follow up.
so just go bugger off, unless you have anything of any real value to add.
best.
Administrator
Dave224:
I have been using square_handler_cron.php from swguy to automatically refresh the Square token. Do I need to make any changes to it to work with Square_webPay?
https://docs.zen-cart.com/user/payment/square_avoiding_token_expiry/
Like @carlwhat said - always check the docs!
Zen Follower
Thanks for the updated release... got an issue I can't resolve: I've installed and after I enter the Application Secret(OAuth) and save. When I click edit to go in and set the location. The drop down is blank
Any suggestions on what might be causing this? I do have 2 locations set in square. The one I need to use is the MAIN location set in square.
For domain needtoorder.com
Fields marked required must be completed.
Tell staff why this post should be reviewed.