Re: Square Payment Module for Zen Cart [Support Thread]
To get rid of that 'id' error, a temporary fix is this ...
In that file, on line 140 you'll see the first line below. Add the second line:
Code:
if (!isset($order->billing['country'])) return;
if (!isset($order->billing['country']['id'])) return;
I may use a different approach in the future, but for now that should suffice.
Re: Square Payment Module for Zen Cart [Support Thread]
Quote:
Originally Posted by
Spikenzie
Yes, all the captured amounts are now correct. Yay, thanks!
A side effect of this change that I noticed, but is no a big deal, on the admin side (and the note sent to Square) all transactions now say "Converted from: n.nn CAD" or "Converted from: n.nn USD" even when no conversion "math" is required (eg. CAD -> CAD).
Okay, looking again around line 274, let's test one more change, to get rid of the CAD->CAD message.
Add the extra condition, as shown, including the { } braces:
Code:
// force conversion to Square Account's currency:
if ($order->info['currency'] != $location->currency || $order->info['currency'] != DEFAULT_CURRENCY) {
global $currencies;
$payment_amount = round($order->info['total'] * $currencies->get_value($location->currency), 2);
$currency_code = $location->currency;
if ($order->info['currency'] != $location->currency) {
$this->currency_comment = '(Converted from: ' . round($order->info['total'] * $order->info['currency_value'], 2) . ' ' . $order->info['currency'] . ')';
}
// @TODO - if Square adds support for transmission of tax and shipping amounts, these may need recalculation here too
}
While you're at it, do you mind testing another optimization I'd like to use. Does this still give the same converted price correctly for the actual payment collected?
Code:
// force conversion to Square Account's currency:
if ($order->info['currency'] != $location->currency || $order->info['currency'] != DEFAULT_CURRENCY) {
global $currencies;
$payment_amount = $currencies->rateAdjusted($order->info['total'], true, $location->currency);
$currency_code = $location->currency;
if ($order->info['currency'] != $location->currency) {
$this->currency_comment = '(Converted from: ' . round($order->info['total'] * $order->info['currency_value'], 2) . ' ' . $order->info['currency'] . ')';
}
// @TODO - if Square adds support for transmission of tax and shipping amounts, these may need recalculation here too
}
Re: Square Payment Module for Zen Cart [Support Thread]
Hey DrByte, all of your suggestions worked!
Quote:
To get rid of that 'id' error, a temporary fix is this ...
No more id log warnings,
Quote:
Okay, looking again around line 274, let's test one more change, to get rid of the CAD->CAD message.
"Converted from:" text appears at correct time
and
Quote:
...do you mind testing another optimization...
the optimization you wanted me to test still calculates the correct converted amounts (or not converted amounts when that is the case) Note: my tests were under $5.00
Thanks!
Re: Square Payment Module for Zen Cart [Support Thread]
Great! I've posted a new v0.95 version of the module, including these fixes.
Re: Square Payment Module for Zen Cart [Support Thread]
All of a sudden, Square is bouncing with INVALID_ENUM_VALUE with the detail - "is not a valid enum value for 'billing_address.country' "
Is this something 0.95 might fix or do we need to come up with a country field to satisfy a new requirement.
[27-Nov-2018 17:04:48 UTC] Request URI: /index.php?main_page=checkout_process, IP address: 72.190.125.38
#1 trigger_error() called at [/home/spicdavi/public_html/includes/modules/payment/square.php:338]
#2 square->before_process() called at [/home/spicdavi/public_html/includes/classes/payment.php:245]
#3 payment->before_process() called at [/home/spicdavi/public_html/includes/modules/checkout_process.php:84]
#4 require(/home/spicdavi/public_html/includes/modules/checkout_process.php) called at [/home/spicdavi/public_html/includes/modules/pages/checkout_process/header_php.php:14]
#5 require(/home/spicdavi/public_html/includes/modules/pages/checkout_process/header_php.php) called at [/home/spicdavi/public_html/index.php:36]
[27-Nov-2018 17:04:48 UTC] PHP Notice: Square Connect [configuration] error.
Response Body:
stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[category] => INVALID_REQUEST_ERROR
Code:
=> INVALID_ENUM_VALUE
[code]
[detail] => `` is not a valid enum value for `billing_address.country`.
[field] => billing_address.country
)
)
)
Response Headers:
Array
(
[0] => HTTP/1.1 400 Bad Request
[Content-Type] => application/json
[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] => Tue, 27 Nov 2018 17:04:47 GMT
[keep-alive] => timeout=60
[Strict-Transport-Security] => max-age=631152000
[content-length] => 182
)
in /home/spicdavi/public_html/includes/modules/payment/square.php on line 338
Re: Square Payment Module for Zen Cart [Support Thread]
More info to the above. Both transaction attempts were American Express with Free Shipping. Both were finally successful in ordering, but neither has responded to requests for what difficulties they had when ordering.
1 Attachment(s)
Re: Square Payment Module for Zen Cart [Support Thread]
I have found a potential store user problem with this plug-in. It is not so much a bug but rather an issue that could cause financial problems for shop owners and unsatisfied customers.
This is the scenario, you let customers shop in multiple currencies but Square only takes payments in the currency in the country that the shop is based. We are in Canada but our store is set to a default currency of USD. If a Canadian customer checks out and their cart is set to USD their CC will be billed in CAD at about 30% more then their cart total. There is no warning from Square (or rather this plug-in) that they are going to do a currency conversion. See the potential problem?
I've been trying for a long time to create something I'm calling a clarity message that would appear at check-out, something like;
Square checkout only processes payments in (your square's currency), your order total is (your order total in some other currency), your CC will be billed (your order currency converted to your square's currency).
I had it working and nice looking from the user side; it would show the clear we will be charging your CC something else (if that was the case) or a generic "Secure check out with Square Payments" type message if no conversion was required.
I did this by using simon1066's post #126 to add an image, where he wrote:
Quote:
Here's one way to add an image:
,and the logic from DrByte's post # 232 where he wrote
Quote:
if ($order->info['currency'] != $location->currency) {
Problems where two fold, where I needed to insert the "if" logic into the code to get the payment title it caused errors on the admin side in modules payments menu and in places other than checkout the message would appear sort of like "your payment will be (nothing printed here) $."
I now have a static work around without amounts that look like this;
Attachment 18145
but, it does not appear correctly on the admin / customer orders pages or the order confirmation emailed to users. And, I don't think the message without amounts it is clear enough for some people.
Any ideas?
Re: Square Payment Module for Zen Cart [Support Thread]
Fresh install 155f
PHP: 7.1.24
Square Payment Module 0.95
One Page Checkout (OPC) 2.0.5
Dr. Bytes,
OPC turned on
Category set up as Document - General called Printable Brochure
Product enabled under it called Document - Product which I have the pdf & zip of the brochure to download
When clicking confirm to order when logged in to download pdf/zip the cursor just spins and does not complete the order
Also using guest check out the cursor just spin and does not complete the order
OPC turned off
I can successfully purchase the downloadable brochure pdf/zip sucessfully.
This is the error console below.
Attachment 18146
Re: Square Payment Module for Zen Cart [Support Thread]
Note that the jQuery issue that @haredo describes occurs when the cart contains only unpriced items, e.g. the demo product A Free Product - All (index.php?main_page=product_info&cPath=24&products_id=57), i.e. the payment method for the order is set to FreeOrder/freecharger.
This is similar in nature to the issue that was previously corrected when PayPal Express Checkout/Shortcut-Button was selected.
Re: Square Payment Module for Zen Cart [Support Thread]
FWIW, I was able to correct the integration issue by editing the /includes/modules/pages/checkout_payment/jscript_square.php (it's also copied to the /checkout_one/jscript_square.php for the OPC integration) and changing:
Code:
if ($payment_modules->in_special_checkout()) {
return false;
}
to
Code:
if ($payment_modules->in_special_checkout() || (isset($payment_modules->paymentClass) && $payment_modules->paymentClass->code != 'square')) {
return false;
}
The result is that Square's jQuery module doesn't load if the payment class is selected and it's not Square.