Zen Cart Logo
Forums / Addon Payment Modules / Square WebPay support thread.

Square WebPay support thread.

Views: 128,171

Results 301 to 320 of 800
30 Oct 2022, 8:50 PM
#301
dbltoe avatar

dbltoe

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.

31 Oct 2022, 8:00 AM
#302
todoonada avatar

todoonada

Zen Follower

Join Date:
Nov 2006
Posts:
127
Plugin Contributions:
0

Re: Square WebPay support thread.

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.

31 Oct 2022, 4:00 PM
#303
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,953
Plugin Contributions:
8

Re: Square WebPay support thread.

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']);
31 Oct 2022, 4:08 PM
#304
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,953
Plugin Contributions:
8

Re: Square WebPay support thread.

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.

31 Oct 2022, 4:18 PM
#305
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,953
Plugin Contributions:
8

Re: Square WebPay support thread.

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.

31 Oct 2022, 6:25 PM
#306
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,682
Plugin Contributions:
56

Re: Square WebPay support thread.

Approved.

31 Oct 2022, 6:32 PM
#307
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,763
Plugin Contributions:
9

Re: Square WebPay support thread.

Here's the scenario:

  1. Site uses One Page Checkout and Square WebPay
  2. Customer selects product, adds to cart, and selects Guest Checkout
  3. If the customer's browser offers them a remembered card for use, they select that card
  4. Most systems ask the customer for their CVV to verify and add the card to the form.
  5. Often the Zip Code is left to be filled in by the customer.
  6. If the customer does not click on enter or tab to the next box but, instead, scrolls down and clicks on Confirm Order, they will get the invalid token notice.
  7. What has happened is that the customer has asked the cart to submit the order BEFORE the CC form is completed correctly. Essentially transmitting the transaction without a Zip Code.
  8. So, anytime a customer is using Square and clicks on the Confirm Order button without the CC form properly filled out will get the Token error.

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.
31 Oct 2022, 7:58 PM
#308
brent avatar

brent

Totally Zenned

Join Date:
Mar 2005
Location:
United Kingdom
Posts:
606
Plugin Contributions:
0

Re: Square WebPay support thread.

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

31 Oct 2022, 8:06 PM
#309
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,763
Plugin Contributions:
9

Re: Square WebPay support thread.

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.

1 Nov 2022, 8:03 PM
#310
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Square WebPay support thread.

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

4 Nov 2022, 8:32 PM
#311
yellx3 avatar

yellx3

New Zenner

Join Date:
Nov 2022
Location:
Ontario, Canada
Posts:
1
Plugin Contributions:
0

Re: Square WebPay support thread.

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.

4 Nov 2022, 10:31 PM
#312
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,953
Plugin Contributions:
8

Re: Square WebPay support thread.

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.

8 Nov 2022, 8:06 PM
#313
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,953
Plugin Contributions:
8

Re: Square WebPay support thread.

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.

12 Nov 2022, 5:43 PM
#314
dave224 avatar

dave224

Zen Follower

Join Date:
Jun 2012
Posts:
481
Plugin Contributions:
0

Re: Square WebPay support thread.

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.

12 Nov 2022, 6:50 PM
#315
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,682
Plugin Contributions:
56

Re: Square WebPay support thread.

i think the way to solve this problem is returning an empty array. corrected code for that 1 method ...

Much obliged, sir!

13 Nov 2022, 2:04 AM
#316
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,953
Plugin Contributions:
8

Re: Square WebPay support thread.

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.
13 Nov 2022, 3:51 AM
#317
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,732
Plugin Contributions:
14

Re: Square WebPay support thread.

Should update the version when the version is updated...

public $moduleVersion = '1.0.2';

public $moduleVersion = '1.0.3';

modules/payment/square_webPay.php

13 Nov 2022, 5:05 AM
#318
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,953
Plugin Contributions:
8

Re: Square WebPay support thread.

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.

13 Nov 2022, 10:57 AM
#319
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,682
Plugin Contributions:
56

Re: Square WebPay support thread.

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!

13 Nov 2022, 9:10 PM
#320
carbonless avatar

carbonless

Zen Follower

Join Date:
Jan 2007
Location:
Illinois, USA
Posts:
329
Plugin Contributions:
0

Re: Square WebPay support thread.

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 blankAttachment 20153

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