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,712

Results 781 to 800 of 835
23 Mar 2025, 9:56 AM
#781
daxtheman avatar

daxtheman

New Zenner

Join Date:
Jun 2023
Location:
UK
Posts:
21
Plugin Contributions:
0

Square Payment Module for Zen Cart [Support Thread]

Hi
Using ZC 1.5.8a and OPC with PHP8.2 and Square module 2.0.2. Basic responsive_classic template.

Not sure where the issue I have originates - maybe the group pricing code or maybe something being picked up in the Square module. I'm sure those with a far greater knowledge of how these things integrate can advise. Here's the issue:

1/When the cart user qualifies for a group pricing discount (or when a discount code is used) the cart total is showing the correct net figure that will be charged to their card.
2/When the cart sends off the amount to the bank for verification the bank pop-up asks for approval for the pre-discount amount - not the amount shown in the cart.
3/When the cart verification is declined the resulting log shows the correct discounted amount in the audit trail!
4/If the user accepts the larger amount at the verification stage the transaction goes through at the discounted amount.

This screenshot shows better what I am trying to detail:
Attachment 20934

The error log:

 [amountMoney:Square\Models\CreatePaymentRequest:private] => Square\Models\Money Object
       (
           [amount:Square\Models\Money:private] => Array
               (
                   [value] => 41324
               )

           [currency:Square\Models\Money:private] => GBP

I'd appreciate any guidance here on a resolution. Where did the bank get the wrong amount data from in the initial pop-up screen (that isn't used for the transaction)?

Thanks for reading this.

24 Mar 2025, 1:30 AM
#782
carlwhat avatar

carlwhat

zennedOut

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

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

DaxtheMan:

Hi
Using ZC 1.5.8a and OPC with PHP8.2 and Square module 2.0.2. Basic responsive_classic template.

Not sure where the issue I have originates - maybe the group pricing code or maybe something being picked up in the Square module. I'm sure those with a far greater knowledge of how these things integrate can advise. Here's the issue:

1/When the cart user qualifies for a group pricing discount (or when a discount code is used) the cart total is showing the correct net figure that will be charged to their card.
2/When the cart sends off the amount to the bank for verification the bank pop-up asks for approval for the pre-discount amount - not the amount shown in the cart.
3/When the cart verification is declined the resulting log shows the correct discounted amount in the audit trail!
4/If the user accepts the larger amount at the verification stage the transaction goes through at the discounted amount.

This screenshot shows better what I am trying to detail:
Attachment 20934

The error log:

[amountMoney:Square\Models\CreatePaymentRequest:private] => Square\Models\Money Object
(
[amount:Square\Models\Money:private] => Array
(
[value] => 41324
)

        [currency:Square\Models\Money:private] => GBP
> 
> I'd appreciate any guidance here on a resolution. Where did the bank get the wrong amount data from in the initial pop-up screen (that isn't used for the transaction)?
> 
> Thanks for reading this.

i won’t be in front of my computer until wednesday. at that point i can boot up 1 of my 137 different zc installs and track down what the problem may be. 

that said, i think the paypal rest app may have encountered a similar problem. it seems that the order total is not reflective of these discounts at the time of payment. 

but i will look at it closer when i’m in front of my computer. 

best.
24 Mar 2025, 7:19 PM
#783
daxtheman avatar

daxtheman

New Zenner

Join Date:
Jun 2023
Location:
UK
Posts:
21
Plugin Contributions:
0

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

Thanks carlwhat - I do appreciate the help.

25 Mar 2025, 4:24 PM
#784
swguy avatar

swguy

Administrator

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

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

Would it make sense to do a check for Safari before enabling Apple Pay? If you're using Chrome, you get this console error:

square.js:3 Initializing Apple Pay failed PaymentMethodUnsupportedError: Method unsupported: Apple Pay is only available on Safari.
at new Wf (square.js:3:375247)
at Yf (square.js:3:383212)
at square.js:3:386948
at Generator.next (<anonymous>)
at Jf (square.js:3:383366)
at a (square.js:3:383570)

26 Mar 2025, 2:03 PM
#785
carlwhat avatar

carlwhat

zennedOut

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

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

DaxtheMan:

Hi
Using ZC 1.5.8a and OPC with PHP8.2 and Square module 2.0.2. Basic responsive_classic template.

Not sure where the issue I have originates - maybe the group pricing code or maybe something being picked up in the Square module. I'm sure those with a far greater knowledge of how these things integrate can advise. Here's the issue:

1/When the cart user qualifies for a group pricing discount (or when a discount code is used) the cart total is showing the correct net figure that will be charged to their card.
2/When the cart sends off the amount to the bank for verification the bank pop-up asks for approval for the pre-discount amount - not the amount shown in the cart.
3/When the cart verification is declined the resulting log shows the correct discounted amount in the audit trail!
4/If the user accepts the larger amount at the verification stage the transaction goes through at the discounted amount.

This screenshot shows better what I am trying to detail:
Attachment 20934

The error log:

[amountMoney:Square\Models\CreatePaymentRequest:private] => Square\Models\Money Object
(
[amount:Square\Models\Money:private] => Array
(
[value] => 41324
)

        [currency:Square\Models\Money:private] => GBP
> 
> I'd appreciate any guidance here on a resolution. Where did the bank get the wrong amount data from in the initial pop-up screen (that isn't used for the transaction)?
> 
> Thanks for reading this.

dax,
i have looked at this issue.  i will have a solution for you soon.

i have started a discussion about [this issue here](https://github.com/zencart/zencart/discussions/7038).

IMO, this is a design flaw inherent in ZC with which i will be forced to handle.

thanks for your patience.
26 Mar 2025, 2:07 PM
#786
carlwhat avatar

carlwhat

zennedOut

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

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

swguy:

Would it make sense to do a check for Safari before enabling Apple Pay? If you're using Chrome, you get this console error:

square.js:3 Initializing Apple Pay failed PaymentMethodUnsupportedError: Method unsupported: Apple Pay is only available on Safari.
at new Wf (square.js:3:375247)
at Yf (square.js:3:383212)
at square.js:3:386948
at Generator.next (<anonymous>)
at Jf (square.js:3:383366)
at a (square.js:3:383570)

i'll add it to my list, but truly very low priority.

wrong totals getting sent to the payment processor because the $order->info object is incorrect at the time the data should be handled is far greater priority and something that really makes little sense to me.

why is there a checkout payment page if the base ZC can not provide the correct totals?

27 Mar 2025, 1:31 AM
#787
carlwhat avatar

carlwhat

zennedOut

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

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

DaxtheMan:

...Using ZC 1.5.8a and OPC with PHP8.2 and Square module 2.0.2. Basic responsive_classic template....

Thanks carlwhat - I do appreciate the help.

dax,
there are 5 files that i think you need to change.

3 of the files involve commenting out 1 line. the other 2 files require adding 3 lines.

you can review the file changes here:

https://github.com/zencart/zencart/compare/master...proseLA:zencart:orderTotal

you need to do everything in green.

considering you are using v158a, the line numbers may be different. but the changes should be the same and in about the same place.

please let me know if you have any questions.

and MOST importantly, let us know if it works and does what you expect!

best.

28 Mar 2025, 7:24 AM
#788
daxtheman avatar

daxtheman

New Zenner

Join Date:
Jun 2023
Location:
UK
Posts:
21
Plugin Contributions:
0

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

carlwhat:

dax,
there are 5 files that i think you need to change.

3 of the files involve commenting out 1 line. the other 2 files require adding 3 lines.

you can review the file changes here:

https://github.com/zencart/zencart/compare/master...proseLA:zencart:orderTotal

you need to do everything in green.

considering you are using v158a, the line numbers may be different. but the changes should be the same and in about the same place.

please let me know if you have any questions.

and MOST importantly, let us know if it works and does what you expect!

best.

Thank you for looking at this issue. I have added the 5 amendments and double checked them but the pop-up bank response still includes the same result as before - namely the pre-discount amount is requested to be approved.

dax

28 Mar 2025, 8:05 AM
#789
daxtheman avatar

daxtheman

New Zenner

Join Date:
Jun 2023
Location:
UK
Posts:
21
Plugin Contributions:
0

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

carlwhat:

dax,
i have looked at this issue. i will have a solution for you soon.

i have started a discussion about this issue here.

IMO, this is a design flaw inherent in ZC with which i will be forced to handle.

thanks for your patience.

Thank you for this information. It is interesting that ZC leaves totalling of the order (in part) to the payment module... I can, I think, now comprehend the scale of the issue!

What is strange to me is that the bank actually processes the discounted amount despite the original request for the customer to approve (via the 3D pop-up screen) being the pre-discount amount. Where does the information for that initial bank response originate? - that is not used subsequently.

Probably over simplifying the issue.

dax

28 Mar 2025, 2:57 PM
#790
carlwhat avatar

carlwhat

zennedOut

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

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

DaxtheMan:

Thank you for this information. It is interesting that ZC leaves totalling of the order (in part) to the payment module... I can, I think, now comprehend the scale of the issue!

What is strange to me is that the bank actually processes the discounted amount despite the original request for the customer to approve (via the 3D pop-up screen) being the pre-discount amount. Where does the information for that initial bank response originate? - that is not used subsequently.

Probably over simplifying the issue.

dax

dax,
i think you have done something wrong. or you have some other modifications going on.

i have replicated your issue exactly using the low order fee, which is similar to group pricing, except it is adding and not subtracting the order_total amount.

in the following screencasts (in ogg format) which demonstrates the problem as you have described it, and then enacts my fixes to address it.

as to whether these changes will get merged into the base ZC, we will see.

base zen-cart square webPay SCA with wrong amount in SCA.

fixes zen-cart square webPay SCA with correct amount in SCA.

best.

28 Mar 2025, 8:05 PM
#791
daxtheman avatar

daxtheman

New Zenner

Join Date:
Jun 2023
Location:
UK
Posts:
21
Plugin Contributions:
0

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

Hi carlwhat

Very many thanks.

I reviewed the ogg files and noticed that you used the standard zc checkout. I mentioned, in the beginning, that I was using OPC. So I thought, what if...I switch off OPC?

It works. Proper amount used in the bank pop-up matching the discounted amount etc.

So, I guess I now need to see what OPC is doing. So your suggestion that a modification is at play was correct. It would appear that One Page Checkout doesn't quite link to the Square Webpay payment module in the same way as the standard 3 page checkout!

Is this one for the OPC forum?

dax

28 Mar 2025, 10:38 PM
#792
carlwhat avatar

carlwhat

zennedOut

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

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

dax,
while i would love to blame OPC, it is not one for that forum. and sorry i missed that part!

i have a new and simpler solution that will not break other things in the way that my previous modification of core code might.

you said square webPay 2.0.2? assuming that is correct, here are my proposed changes:

in this file:

includes/modules/pages/checkout_payment/jscript_square_webPay.php

make the following few changes:

// starting at line 41 from:
    $values = json_encode([
                              'orderInfo' => $order->info,
                              'orderBilling' => $order->billing,
                              'orderCustomer' => $order->customer,
                              'appId' => MODULE_PAYMENT_SQ_WEBPAY_APPLICATION_ID,
                              'locationId' => $square_webPay->getLocationDetails()->getId(),
                              'handler' => DIR_WS_HTTPS_CATALOG . 'squareWebPay_handler.php',
                              'textTotal' => TEXT_YOUR_TOTAL ?? 'Total:',
                              'orderTotal' => zen_round($order->info['total'], 2),
                              'locale' => $locale,
                              'google' => $google,
                              'apple' => $applePay,
                              'creditCards' => $creditCards,
                          ]);

// to:

    $calculatedTotal = $order_total_modules->pre_confirmation_check(true);
    $values = json_encode([
                              'orderInfo' => $order->info,
                              'orderBilling' => $order->billing,
                              'orderCustomer' => $order->customer,
                              'appId' => MODULE_PAYMENT_SQ_WEBPAY_APPLICATION_ID,
                              'locationId' => $square_webPay->getLocationDetails()->getId(),
                              'handler' => DIR_WS_HTTPS_CATALOG . 'squareWebPay_handler.php',
                              'textTotal' => TEXT_YOUR_TOTAL ?? 'Total:',
                              'orderTotal' => zen_round($calculatedTotal, 2),
                              'locale' => $locale,
                              'google' => $google,
                              'apple' => $applePay,
                              'creditCards' => $creditCards,
                          ]);

// on line 157 (now line 158... or thereabouts), from:

async function verifyBuyer(payments, token) {
            const verificationDetails = {
                amount: squareOrderValues.orderInfo.total.toFixed(2),

//to: 
async function verifyBuyer(payments, token) {
            const verificationDetails = {
                amount: squareOrderValues.orderTotal.toFixed(2),

all of the changes are in red.

please let us know how that goes!

best.

31 Mar 2025, 5:33 PM
#793
daxtheman avatar

daxtheman

New Zenner

Join Date:
Jun 2023
Location:
UK
Posts:
21
Plugin Contributions:
0

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

Hi carlwhat,

Brilliant! That cured it. Thank you and kindest regards.

P.S. Sorry for delay in responding but had a long weekend off...

dax

7 Apr 2025, 12:45 AM
#794
wmorris avatar

wmorris

Totally Zenned

Join Date:
Aug 2007
Location:
Amarillo, Tx
Posts:
1,675
Plugin Contributions:
0

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

Is this compatible to ZC version 2.0.0 yet?

14 Jun 2025, 3:03 PM
#796
dml73 avatar

dml73

Zen Follower

Join Date:
Oct 2007
Posts:
413
Plugin Contributions:
0

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

In Zencart admin under the Square Pay plugin it says: "Make sure the OAuth Redirect URL in your Square Account "app" is set to".

So my question is, where in my Square Pay account do I find this "app" setting?? I can't seem to find anywhere to enter my URL.

Attachment 20990

14 Jun 2025, 3:52 PM
#797
gernot avatar

gernot

Zen Follower

Join Date:
Feb 2017
Location:
Tokyo, Japan
Posts:
334
Plugin Contributions:
0

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

Hi DML73
See the OAuth section of your apps page:
https://developer.squareup.com/apps/

14 Jun 2025, 4:23 PM
#798
swguy avatar

swguy

Administrator

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

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

Go to the OAuth tab, and paste it in the “Redirect URL” field.

15 Jun 2025, 7:07 AM
#799
dml73 avatar

dml73

Zen Follower

Join Date:
Oct 2007
Posts:
413
Plugin Contributions:
0

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

Ah ok, I found it. However in Zencart the plugin still shows '(Access Token needed)' and 'ALERT: Access Token not set:'. Even I entered my URL in 'Production Redirect URL' on the Square OAuth page and 'Application ID' and 'Application Secret (OAuth)' in Zencart.
Am I missing something?

15 Jun 2025, 10:55 AM
#800
mprough avatar

mprough

Totally Zenned

Join Date:
Nov 2007
Location:
Woodbine, Georgia, United States
Posts:
4,278
Plugin Contributions:
37

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

DML73:

Ah ok, I found it. However in Zencart the plugin still shows '(Access Token needed)' and 'ALERT: Access Token not set:'. Even I entered my URL in 'Production Redirect URL' on the Square OAuth page and 'Application ID' and 'Application Secret (OAuth)' in Zencart.
Am I missing something?

Clear your cookies