Zen Cart Logo
Forums / Addon Payment Modules / Square Payment Module for Zen Cart [Support Thread]

Square Payment Module for Zen Cart [Support Thread]

Sticky

Views: 366,772

Results 381 to 400 of 835
5 Mar 2020, 12:27 AM
#381
twitchtoo avatar

twitchtoo

Totally Zenned

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

Square Payment Module for Zen Cart [Support Thread]

Fjolsvith

If the fileset is the newest from the Zen Plugins, you may need to** re-key** your store to My Apps in Square.

5 Mar 2020, 2:48 AM
#382
fjolsvith avatar

fjolsvith

New Zenner

Join Date:
Mar 2016
Location:
Norcatur, Kansas, USA
Posts:
88
Plugin Contributions:
2

Re: Square Payment Module for Zen Cart [Support Thread]

DrByte:

Um ... The error suggests that you've changed the PHP files associated with this module. If it was something Square did only on their end, the error would be different.

What's the back-story of changes to the PHP files?

Which set of files are you using? v0.9xxx? or 1.0-beta? Or a hybrid of files that you've changed independently?

Ah, you are correct. I modified modules\payment\square.php around line 318 to add extra information about the order to the description passed to square:

	if (sizeof($order->products) < 100) {
	    $p = '';
            for ($i = 0; $i < sizeof($order->products); $i++) {
                $p2 = $order->products[$i];
				if (!$p == '') {
					$p .= ', ';
				}
				$p .= '(' . $p2['qty'] . ') ' . $p2['name'] ;
            }
        }
		$p = 'Item(s) Ordered:' . $p;
		
		$d = 'Delivery Address: ' . $order->delivery['street_address'] . ', ' . $order->delivery['city'] . ', ' . $order->delivery['state'] . '  ' . $order->delivery['postcode'] . '  tel:' . $order->customer['telephone'];
		$p .= '; ' . $d;

        $note = htmlentities(trim($order->billing['firstname'] . ' ' . $order->billing['lastname'] . ' ' . $p . ' ' . STORE_NAME));

I had done this for the Stripe module and it worked great there because it basically duplicated the order information on the email that Stripe sent out to customers, which helped reassure them. The average order at my store is $3.5k, and some people are apprehensive about making such big purchases on the internet.

I recently switched from Stripe to Square, and that is the reason for the module change. I will go read up how long the note field can be and modify the code to fit.

Edit: So I reverted the payment module files back to the 1.0-beta (which is the version I'm using) and I still have the OAuthApi.php line 134 error.

5 Mar 2020, 3:02 AM
#383
fjolsvith avatar

fjolsvith

New Zenner

Join Date:
Mar 2016
Location:
Norcatur, Kansas, USA
Posts:
88
Plugin Contributions:
2

Re: Square Payment Module for Zen Cart [Support Thread]

I did receive an email from the Square Developer Team about new API updates and deprications yesterday, so I am pretty sure it is something to do with their API changes. I can forward it to you if you like, just send me a private message.

5 Mar 2020, 3:07 AM
#384
fjolsvith avatar

fjolsvith

New Zenner

Join Date:
Mar 2016
Location:
Norcatur, Kansas, USA
Posts:
88
Plugin Contributions:
2

Re: Square Payment Module for Zen Cart [Support Thread]

twitchtoo:

Fjolsvith

If the fileset is the newest from the Zen Plugins, you may need to** re-key** your store to My Apps in Square.

I did that and had two successful orders at the end of February. Last night was the most recent attempt by a customer to place an order, and it failed. And then, today I had two more try to order and they complained about getting the HTTP 500 error and not getting the order placed.

I was able to use the MySql console to disable the Square module by setting the status to false. That allowed me to enable the Stripe module so those orders could be placed this evening.

5 Mar 2020, 3:20 AM
#385
twitchtoo avatar

twitchtoo

Totally Zenned

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

Re: Square Payment Module for Zen Cart [Support Thread]

I would pull the files, manually pull the SQL entries and start over installing the stock module. Then sync it with new credentials in your Square account.

That forces everything to be new replaced and working.

Alternately, check to see there were no changes with your provider. Recently a customer lost module function due to the 'new - upgrade' server having cloud Php settings that shut important functions off the site was using.

6 Mar 2020, 2:08 AM
#386
fjolsvith avatar

fjolsvith

New Zenner

Join Date:
Mar 2016
Location:
Norcatur, Kansas, USA
Posts:
88
Plugin Contributions:
2

Re: Square Payment Module for Zen Cart [Support Thread]

twitchtoo:

I would pull the files, manually pull the SQL entries and start over installing the stock module. Then sync it with new credentials in your Square account.

That forces everything to be new replaced and working.

That fixed it. I tested it. Thanks!

Running the 1.0 beta version.

9 Mar 2020, 8:56 PM
#387
adolgin avatar

adolgin

New Zenner

Join Date:
Jul 2007
Posts:
63
Plugin Contributions:
0

Re: Square Payment Module for Zen Cart [Support Thread]

Looking to switch to Square from 2checkout. Any advice? Pro vs. Cons? 2checkout worked well for us for a while until we run into a stolen Credit Card problem, and lost over $500. It turns out that 2checkout stopped providing phone support just recently, which adds salt to the wounds. Are there any other good processors similar to them besides Square to look at? TIA.

10 Mar 2020, 4:11 AM
#388
royaldave avatar

royaldave

Zen Follower

Join Date:
Aug 2013
Location:
Perth, WA, AU
Posts:
284
Plugin Contributions:
1

Re: Square Payment Module for Zen Cart [Support Thread]

Hi

Using 156c.

I've just had a complaint about a payment going through twice on the same order.

Sure enough there are two payments.

In my logs I found the following -

"Card nonce already used; please request new nonce."

Based on my brief research of this error,

some can be found here - https://www.sellercommunity.com/t5/Developer-Discussions/Creating-Customer-Card/td-p/27378

can I assume perhaps that the customer managed to refresh the screen (or go back) and trigger the payment twice?

11 Mar 2020, 2:46 PM
#389
adolgin avatar

adolgin

New Zenner

Join Date:
Jul 2007
Posts:
63
Plugin Contributions:
0

Re: Square Payment Module for Zen Cart [Support Thread]

Anyone?

11 Mar 2020, 6:46 PM
#390
twitchtoo avatar

twitchtoo

Totally Zenned

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

Re: Square Payment Module for Zen Cart [Support Thread]

royaldave:

Hi

Using 156c.

I've just had a complaint about a payment going through twice on the same order.

Sure enough there are two payments.

In my logs I found the following -

"Card nonce already used; please request new nonce."

Based on my brief research of this error,

some can be found here - https://www.sellercommunity.com/t5/Developer-Discussions/Creating-Customer-Card/td-p/27378

can I assume perhaps that the customer managed to refresh the screen (or go back) and trigger the payment twice?

I wonder if we need to add a script to disable the button after one click. Historically on sites where this has been enabled, folks still find a way to refresh or go back and forward (because they are impatient or have super high speed connections) and the problem repeats of 'double clicking the send request'.

Also, this error will display when there is a javascript interfering as mentioned previously - see post #364 in this thread:
https://www.zen-cart.com/showthread.php?222449-Square-Payment-Module-for-Zen-Cart-Support-Thread&p=1366255#post1366255

12 Mar 2020, 1:19 AM
#391
carlwhat avatar

carlwhat

zennedOut

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

Re: Square Payment Module for Zen Cart [Support Thread]

DrByte:

At this time the module doesn't report any AVS response details. But, more importantly, if the customer's bank chooses to reject the transaction (for any reason, including avs) then Square will tell your store that the payment was rejected. It's the cardholder's bank that does the determination of AVS adequacy, since they're the ones assuming the risk. Square (or any card processor) is just the middle-man.

DrB,
i'm sorry. this is just not correct.

with the exception of card present transactions using an EMV chip card and reader, it is the MERCHANT who assumes all risk for the credit card transaction. one could get an AVS response of EXACT match, and the card holder could still report the transaction as fraudulent and it is the merchant who would suffer the loss for the transaction. in addition, AVS is primarily for US addresses although there seems to be some work getting done on some international addresses.

i have not used square (or the square module for ZC), but in my experience in credit card transactions, the response is a single character code, that corresponds to zip match, zip street number match, etc. the MERCHANT could choose to reject transactions that do not meet their criteria for the transaction. issuing banks can reject transactions for any number of reasons. but getting an EXACT avs response does not transfer the liability for the transaction to the issuing bank. the liability for any card not present transaction rests with the merchant.

finally, considering that square does provide AVS verification, i find it odd that the API would not provide that information back to the merchant making the transaction. and apparently they do not. from their site:

avs_status
string
Status code returned from the Address Verification System (AVS) check. Can be AVS_ACCEPTED, AVS_REJECTED, AVS_NOT_CHECKED.

pretty lame that they do not provide the response code from the AVS system.

15 Mar 2020, 4:06 PM
#392
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Square Payment Module for Zen Cart [Support Thread]

The Square plugin v1.0 has been released.
https://www.zen-cart.com/downloads.php?do=file&id=156

The 1.0 module now uses Square's latest 2020 API SDK version 3.20200226.0

Also, transaction "notes" now include not just the customer name but also abbreviated order details, up to 500 characters.

NOTE: IF YOU WERE USING THE 1.00-BETA version, this is DIFFERENT, so you will want to upgrade from 1.00-beta to actual 1.0 using the posted zip linked herein.

Upgrade instructions:
Delete the server's /includes/classes/vendors/square directory
and the /includes/modules/payment/square_support directory
(You will replace these in a moment, but this deletes older obsolete files first).
Then upload all the files from the files_to_upload directory, putting them into the same directory on the server as you find them in the zip.
And if you'd copied the jscript_square.php file to an alternate checkout flow, do that copy again.

NOTE: Upgraders will be required to re-authorize to your Square account manually within 30 days after installing this module.
(You can force it sooner by Removing and Re-Installing the module in your Admin, re-adding your credentials, etc.)

15 Mar 2020, 4:07 PM
#393
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Square Payment Module for Zen Cart [Support Thread]

Fjolsvith:

Ah, you are correct. I modified modules\payment\square.php around line 318 to add extra information about the order to the description passed to square:

if (sizeof($order->products) < 100) {
    $p = '';
        for ($i = 0; $i < sizeof($order->products); $i++) {
            $p2 = $order->products[$i];
            if (!$p == '') {
                $p .= ', ';
            }
            $p .= '(' . $p2['qty'] . ') ' . $p2['name'] ;
        }
    }
    $p = 'Item(s) Ordered:' . $p;
    
    $d = 'Delivery Address: ' . $order->delivery['street_address'] . ', ' . $order->delivery['city'] . ', ' . $order->delivery['state'] . '  ' . $order->delivery['postcode'] . '  tel:' . $order->customer['telephone'];
    $p .= '; ' . $d;

    $note = htmlentities(trim($order->billing['firstname'] . ' ' . $order->billing['lastname'] . ' ' . $p . ' ' . STORE_NAME));

After reviewing it, I figured it makes sense to incorporate this too, so (a modified form of) this is now in v1.0.
16 Mar 2020, 2:24 AM
#394
fjolsvith avatar

fjolsvith

New Zenner

Join Date:
Mar 2016
Location:
Norcatur, Kansas, USA
Posts:
88
Plugin Contributions:
2

Re: Square Payment Module for Zen Cart [Support Thread]

Okay, I found a bug in the 1.0 beta. It is in includes\modules\payments\square.php line 664:

        $oauthApi = new SquareConnect\Api\OAuthApi($this->_sqConfig);

The OAuthApi class initializes NOT with SquareConfiguration, but rather with ApiClient. See lines 34-45 of includes\classes\vendors\square\connect\lib\Api\OAuthApi.php:

    /**
     * Constructor
     * @param \SquareConnect\ApiClient|null $apiClient The api client to use
     */
    function __construct($apiClient = null)
    {
        if ($apiClient == null) {
            $apiClient = new ApiClient();
            $apiClient->getConfig()->setHost('https://connect.squareup.com');
        }
  
        $this->apiClient = $apiClient;
    }

So this is the error that is being thrown by this bug. This is the problem I have been experiencing:

[15-Mar-2020 20:47:11 America/Chicago] PHP Fatal error:  Uncaught Error: Call to undefined method SquareConnect\Configuration::callApi() in C:\wamp\www\store\includes\classes\vendors\square\connect\lib\Api\OAuthApi.php:134
Stack trace:
#0 C:\wamp\www\store\includes\classes\vendors\square\connect\lib\Api\OAuthApi.php(78): SquareConnect\Api\OAuthApi->obtainTokenWithHttpInfo(Object(SquareConnect\Model\ObtainTokenRequest))
#1 C:\wamp\www\store\includes\modules\payment\square.php(676): SquareConnect\Api\OAuthApi->obtainToken(Object(SquareConnect\Model\ObtainTokenRequest))
#2 C:\wamp\www\store\includes\modules\payment\square.php(541): square->renewOAuthToken()
#3 C:\wamp\www\store\includes\modules\payment\square.php(476): square->token_refresh_check()
#4 C:\wamp\www\store\includes\modules\payment\square.php(718): square->getAccessToken()
#5 C:\wamp\www\store\includes\modules\payment\square.php(733): square->getLocationsList()
#6 C:\wamp\www\store\includes\modules\payment\square.php(1264): square->getLocationsPulldownArray()
#7 C:\wamp\www\store\wEn-nImda4eman\modules.php(307) : eval()'d code(1): zen_cfg_pull_down_square_locations('', 'MODULE_PAYMENT_...')
#8 C:\wamp\www\store\wEn-nImda4eman\modules.php(307): eval()
#9 {main}
  thrown in C:\wamp\www\store\includes\classes\vendors\square\connect\lib\Api\OAuthApi.php on line 134

I believe I fixed it by modifying line 664 to:

        $oauthApi = new SquareConnect\Api\OAuthApi($this->_apiConnection);
16 Mar 2020, 2:59 AM
#395
fjolsvith avatar

fjolsvith

New Zenner

Join Date:
Mar 2016
Location:
Norcatur, Kansas, USA
Posts:
88
Plugin Contributions:
2

Re: Square Payment Module for Zen Cart [Support Thread]

Ah, good. I see you fixed the above bug in the 1.0 release. And, I'm proud of myself for devising the correct fix!

16 Mar 2020, 7:12 AM
#396
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Square Payment Module for Zen Cart [Support Thread]

Hmmm. I wonder if the same issue exists on line 677 (of the 1.0 file, not the beta).
And if it does, I think the "fix" requires also calling setApiClient instead of setSquareConfig:

        $this->setApiClient();
        $oauthApi = new SquareConnect\Api\OAuthApi($this->_apiConnection);
30 Mar 2020, 8:13 AM
#397
royaldave avatar

royaldave

Zen Follower

Join Date:
Aug 2013
Location:
Perth, WA, AU
Posts:
284
Plugin Contributions:
1

Re: Square Payment Module for Zen Cart [Support Thread]

twitchtoo:

I wonder if we need to add a script to disable the button after one click. Historically on sites where this has been enabled, folks still find a way to refresh or go back and forward (because they are impatient or have super high speed connections) and the problem repeats of 'double clicking the send request'.

Also, this error will display when there is a javascript interfering as mentioned previously - see post #364 in this thread:
https://www.zen-cart.com/showthread.php?222449-Square-Payment-Module-for-Zen-Cart-Support-Thread&p=1366255#post1366255

I've had a couple more "double payments" since originally posting. Does anyone else experience this ?

1 Apr 2020, 4:24 PM
#398
haredo avatar

haredo

Totally Zenned

Join Date:
Apr 2006
Location:
Texas
Posts:
6,176
Plugin Contributions:
0

Re: Square Payment Module for Zen Cart [Support Thread]

156c
PHP Version: 7.2.29
Upgraded from 155f

Last night I received a debug log file while accessing my Administration Panel.
I had to log into square for a Access Token request.
No biggie, but why am I not receiving an email when from the module itself when under the Log Mode I have this box checked? Log on Failures and Email on Failures
I do not see anywhere under the Edit of this module to submit my email address so upon this error last night I would have received an email.

6 Apr 2020, 11:22 PM
#399
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Re: Square Payment Module for Zen Cart [Support Thread]

Hello,
I'm running into this error log

[06-Apr-2020 12:42:49 America/Detroit] Request URI: /ADMIN/orders.php?selected_box=customers&status=1&page=1&oID=XXXXXXXXXXX&action=doCapture, IP address: XXXXXXXXXXX
#1 zen_update_orders_history() called at [/includes/modules/payment/square.php:1179]
#2 square->_doCapt() called at [/ADMIN/orders.php:308]
--> PHP Warning: Invalid argument supplied for foreach() in /includes/functions/functions_osh_update.php on line 207.

Any idea what's happening?

7 Apr 2020, 12:13 AM
#400
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Square Payment Module for Zen Cart [Support Thread]

mvstudio:

Hello,
I'm running into this error log

[06-Apr-2020 12:42:49 America/Detroit] Request URI: /ADMIN/orders.php?selected_box=customers&status=1&page=1&oID=XXXXXXXXXXX&action=doCapture, IP address: XXXXXXXXXXX
#1 zen_update_orders_history() called at [/includes/modules/payment/square.php:1179]
#2 square->_doCapt() called at [/ADMIN/orders.php:308]
--> PHP Warning: Invalid argument supplied for foreach() in /includes/functions/functions_osh_update.php on line 207.

Any idea what's happening?
Any idea what modified includes/functions/functions_osh_update.php away from the ZC installed version? There aren't even 200 lines in the original file...