Re: Square Payment Module for Zen Cart [Support Thread]
Quote:
Originally Posted by
DrByte
The fact that your 2nd echo does not appear means the code before it is failing with fatal errors. Your server's PHP error-logs will contain more information. Clearly something's unusual about your server config which is preventing this from operating normally.
Thanks, Dr Byte - appreciate the advice on the way forward. I've started investigating how to access those PHP error logs. Will report back after speaking with my ISP (need their intervention to enable PHP error tracking, which is currently turned off) and when I know more. Fingers crossed.
Re: Square Payment Module for Zen Cart [Support Thread]
Quote:
Originally Posted by
dbltoe
Anyone had a go with the addition of Apple Pay? https://medium.com/square-corner-blo...s-1f85cb6fe433
It appears that the two javascript files used are combined into jscript_square.php file. My attempt at adding the required info resulted in messing up the form.
I changed jscript_square.php to
Code:
<?php/**
* Javascript to prep functionality for Square payment module
*
* @package square
* @copyright Copyright 2003-2017 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: Author: Chris Brown <[email protected]> New in v1.5.6 $
*/
if (!defined(MODULE_PAYMENT_SQUARE_STATUS) || MODULE_PAYMENT_SQUARE_STATUS != 'True' || (!defined('MODULE_PAYMENT_SQUARE_APPLICATION_ID') || MODULE_PAYMENT_SQUARE_ACCESS_TOKEN == '')) {
return false;
}
?>
<script type="text/javascript" src="https://js.squareup.com/v2/paymentform"></script>
<script type="text/javascript">
var cardNonce;
var paymentForm = new SqPaymentForm({
//
locationId: locationId
//
applicationId: '<?php echo MODULE_PAYMENT_SQUARE_APPLICATION_ID; ?>',
inputClass: 'paymentInput',
inputStyles: [
{
fontSize: '14px',
padding: '7px 12px',
backgroundColor: "white"
}
],
cardNumber: {
elementId: 'square_cc-number',
placeholder: '•••• •••• •••• ••••'
},
cvv: {
elementId: 'square_cc-cvv',
placeholder: 'CVV'
},
expirationDate: {
elementId: 'square_cc-expires',
placeholder: 'MM/YY'
},
postalCode: {
elementId: 'square_cc-postcode',
placeholder: '11111'
},
callbacks: {
cardNonceResponseReceived: function (errors, nonce, cardData) {
if (errors) {
console.error("Encountered errors:");
var error_html = ""
errors.forEach(function (error) {
console.error(' ' + error.message);
error_html += "<li> " + error.message + " </li>";
});
document.getElementById('card-errors').innerHTML = '<ul>' + error_html + '</ul>';
$('#paymentSubmitButton').disabled = false;
} else {
// success
$('#paymentSubmitButton').disabled = true;
$("#card-errors").empty()
document.getElementById('card-nonce').value = nonce;
document.getElementById('card-type').value = cardData.card_brand;
document.getElementById('card-four').value = cardData.last_4;
document.getElementById('card-exp').value = ('0'+cardData.exp_month.toString()).substr(-2) + cardData.exp_year.toString().substr(-2);
document.getElementsByName('checkout_payment')[0].submit();
}
},
unsupportedBrowserDetected: function () {
document.getElementById('card-errors').innerHTML = '<p class="error alert">This browser is not supported for Square Payments. Please contact us to let us know! Meanwhile, please pay using an alternate method; or shop using a different browser such as FireFox or Chrome.</p>';
paymentForm.destroy();
},
inputEventReceived: function (inputEvent) {
switch (inputEvent.eventType) {
case 'focusClassAdded':
methodSelect('pmt-square');
break;
case 'cardBrandChanged':
document.getElementById('sq-card-brand').innerHTML = inputEvent.cardBrand;
break;
}
},
methodsSupported: function (methods) {
if (methods.applePay === true) {
// Show apple pay button
var element = document.getElementById('sq-apple-pay');
element.style.display = 'inline-block';
}
}
paymentFormLoaded: function () {
paymentForm.setPostalCode('<?php echo $order->billing['postcode']; ?>');
}
}
});
createPaymentRequest: function () {
return {
requestShippingAddress: true,
currencyCode: "USD",
countryCode: "US",
total: {
label: "{{ MERCHANT NAME }}",
amount: "100.00",
pending: false,
},
lineItems: [
{
label: "Subtotal",
amount: "80.00",
pending: false,
},
{
label: "Shipping",
amount: "0.00",
pending: true,
},
{
label: "Tax",
amount: "10.00",
pending: false,
}
]
};
};
// ...
$(function () {
$.ajaxSetup({
headers: {"X-CSRFToken": "<?php echo $_SESSION['securityToken']; ?>"}
});
$('form[name="checkout_payment"]').submit(function(e) {
if($('#pmt-square').is(':checked') || this['payment'].value == 'square' || document.getElementById('pmt-square').checked == true) {
e.preventDefault();
paymentForm.requestCardNonce();
}
});
});
</script>
<style>
.paymentInput {display:inline;font-size:1em;margin:0 0.1em 10px 0;height:35px;padding-left:5px;width:50%;}
.paymentInput {background-color: white;border:3px solid #ccc;}
.paymentInput--error {color: red; border-color: red;}
</style>
Done this way, the form is not properly set with input blocks and preset Zip.
Has anyone being able to figure out the Apple Pay? I've tried similar approaches as this with no good results. :( :no:
Re: Square Payment Module for Zen Cart [Support Thread]
Any chance we'll be getting their hosted pages checkout?
https://squareup.com/townsquare/host...e-payment-form
Re: Square Payment Module for Zen Cart [Support Thread]
My set-up:
ZC 1.5.5f
PHP 7.1.23
mySQL 5.5.60
Template: BusinessSet_res Black for ZC 1.5.5
Plugins: Sales report 3.2.0, Group price per item 155, InstantSearch 1.0.2, CEON URI Mapping 4.5.5 and Optional payment method 1.2
We are running a web store from Canada. We have our default currency set to USD and allow customers to check out in USD, CAD and Euro. Works great with PayPal and payments go into the same respective currency in PayPal.
Since we where doing upgrades we decided to add Square Payments. Our Square account is in CAD (this is Square's rule - since our business is located in Canada). The installation went smoothly, Square payments show up at checkout, all looks good.
When we checkout using Square and the order total is in USD the amount captured by Square is correct (as seen both in the Square dashboard and on the Admin Orders details page). That is, the order total in USD times the exchange rate into CAD. Eg. rate is 1:1.3, sale for a $1.00 USD order gets captured by Square as $1.30 CAD.
Problem: But if the checkout is done in CAD the amount captured by Square is wrong. It only captures the value amount in USD but in CAD. Eg. customers checks out with a product priced in the admin at $1.00 USD but they have their log in currency set to CAD, so they see it as $1.30 CAD, OK so far. At check out, Square then captures the sale as $1.00 CAD. Essentially shorting us by 30% (the current exchange rate) rather then just capturing the $1.30 CAD displayed to the customer and matching the currency used by Square. Afterwords, when logged in as a customers (or admin side) the order details, amounts and currencies display correctly, just not the amount captured by Square (as seen both in the Square dashboard and on the Admin Orders details page).
There is one warning created in the log file: Illegal string offset 'id' in /homepage/.…./Store/includes/modules/payments/square.php on line 143
Update: For a test I installed a fresh 1.5.5f with only Square Payment 0.94 and a fresh database with only example products no other plug-in or mods and I get the same results (but without the log warning).
Any ideas?
Re: Square Payment Module for Zen Cart [Support Thread]
Quote:
Originally Posted by
mprough
Undecided. What's the business reason behind the request? (it helps for understanding the scope)
Re: Square Payment Module for Zen Cart [Support Thread]
Quote:
Originally Posted by
Spikenzie
We are running a web store from Canada. We have our default currency set to USD ...
Our Square account is in CAD (this is Square's rule - since our business is located in Canada).
Right now the module can handle currency conversions based on when the Square account's currency is different from the customer's checkout currency.
But it doesn't also consider that your store's "default" currency (upon which all your pricing is based) is different from the Square account's currency.
I'll try to work out that logic this week and post back. Hmmmm....
Re: Square Payment Module for Zen Cart [Support Thread]
Thanks DrByte, that would be great.
An update on the log file warning,
Quote:
There is one warning created in the log file: Illegal string offset 'id' in /homepage/.…./Store/includes/modules/payments/square.php on line 143
This was because I had the Square Payments Payment Zone set to Canada but in my Zone Definitions for Canada I had no sub-zones (provinces) set.
Re: Square Payment Module for Zen Cart [Support Thread]
Quote:
Originally Posted by
Spikenzie
We are running a web store from Canada. We have our default currency set to USD ...
Our Square account is in CAD (this is Square's rule - since our business is located in Canada).
I'm between afternoon events right now so have limited time to test, but I'm wondering if making the following edit may solve the issue for you?
Line 274 of /includes/modules/payments/square.php
change:
if ($order->info['currency'] != $location->currency) {
to
if ($order->info['currency'] != $location->currency || $order->info['currency'] != DEFAULT_CURRENCY) {
Does that sort it out for all the combinations you posted about?
Re: Square Payment Module for Zen Cart [Support Thread]
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).
Re: Square Payment Module for Zen Cart [Support Thread]
My mistake, log files warnings are still being generated but not when the sale transaction happens but rather when an order is opened "edited" in the admin side.
If an order is opened to look at and then you navigate elsewhere one error log file is created (action=edit). If you open an order update it status then three error log files are created (one with action=edit, then action=update_order and finally another action=edit).
Here are the two types of log warnings in full;
Quote:
[18-Nov-2018 22:13:36 America/New_York] Request URI: /testadmin/orders.php?page=1&oID=8&action=edit, IP address: xxx.xxx.xxx.xxx
#1 square->update_status() called at [/yadayada/myTestSite/includes/modules/payment/square.php:130]
#2 square->__construct() called at [/yadayada/myTestSite/testadmin/orders.php:441]
[18-Nov-2018 22:13:36 America/New_York] PHP Warning: Illegal string offset 'id' in /yadayada/myTestSite/includes/modules/payment/square.php on line 143
and
Quote:
[18-Nov-2018 22:13:36 America/New_York] Request URI: /testadmin/orders.php?page=1&oID=8&action=update_order, IP address: xxx.xxx.xxx.xxx
#1 square->update_status() called at [/yadayada/myTestSite/includes/modules/payment/square.php:130]
#2 square->__construct() called at [/yadayada/myTestSite/testadmin/orders.php:194]
[18-Nov-2018 22:13:36 America/New_York] PHP Warning: Illegal string offset 'id' in /yadayada/myTestSite/includes/modules/payment/square.php on line 143
Everything seems to be working, but at this rate the logs folder will get pretty full.
Any ideas on how to tame the warnings?