Great work on the Square module! Thank you!
When Square is updating their API (which they did quite often in 2019), can I usually update without worrying or is there a good chance that the Zen Cart module will not work anymore?
Printable View
Great work on the Square module! Thank you!
When Square is updating their API (which they did quite often in 2019), can I usually update without worrying or is there a good chance that the Zen Cart module will not work anymore?
Would it be possible to display a field in the form instead? that way we store owners could also verify that information when processing the order. We had some quite serious problems in the past 2 years where a few of our customers were using their spouses/ex-spouses/boyfriends credit cards without their authorization (or so the credit card owners claimed) to place orders on our website, which we had to refund as they ended up being unauthorized. We lost the products and the funds, so not cool. Having a field in the form to verify the name on the card would at least provide a certain level of security for merchants (somewhat).
I looked into the square developer and I found (not that I even pretend to know anything about it) a the cardholder_name parameter https://developer.squareup.com/refer...-customer-card
Could this be incorporated?
Thank you for all you do, and for looking into this.
ZC 1.5.5f
PHP 7.1.33
MySQL 5.7.23-23
Square 0.97
I've got a cron job that runs on odd numbered days to refresh OAuth. It's been running quietly for months. A bit over a week ago, it's been triggering the following error:
I've verified that the cron is running PHP 7.1.33.Code:[19-Dec-2019 00:00:02 America/Los_Angeles] PHP Fatal error: Uncaught Error: Class 'square' not found in /*****/********/public_html/mystoredomain/square_handler.php:21
Stack trace:
#0 {main}
thrown in /*****/********/public_html/mystoredomain/square_handler.php on line 21
My host changed how they serve up PHP on December 17 that bumped the PHP version my cart used to 7.3, which triggered numerous errors/warnings. I went into the control panel and backed PHP down to 7.1.33. I've been getting the cron triggered errors since then.
I haven't done any significant changes to the cart in this time frame. Square payments are being processed normally.
I would appreciate any thoughts and suggestions on how to fix this.
I've tracked down the reason that the cron job triggers the error reported in my last post.
It appears that with the latest host changes that $PHP_SELF and (most?) $_SERVER variables are empty when the script is run from cron. The code in includes/classes/payment.php failed to find the square payment module because it extracts the script type (.php) from the $PHP_SELF variable.
My patch to get around this problem was to set $PHP_SELF to __FILE__ if $PHP_SELF was empty in square_handler.php near line 13:
All seems well now.Code:require 'includes/application_top.php';
if (empty($PHP_SELF)) $PHP_SELF = __FILE__; // ensure that $PHP_SELF is not empty
require DIR_WS_CLASSES . 'payment.php';
ZC 1.5.4
PHP 5.6.40
MySQL 5.7.28
Square 0.97
Hoping for some help troubleshooting SQ-NONCE-FAILURE. Understand it is probably in my template's tpl_checkout_payment_default.php file. I have done some coding in the past, but this is beyond my current understanding of ZC. To me, line 22 below (not numbered, sorry)
<?php echo zen_draw_form('checkout_payment', zen_href_lin
looks to me to fulfill the "<form> element with a name="checkout_payment" in it" requirement, but there is much I don't understand. :)
Console errors:
Uncaught ReferenceError: $ is not defined at index.php?main_page=checkout_payment:100Uncaught ReferenceError: $ is not defined at index.php?main_page=checkout_payment:188
Using a Template named Cold_Steel
Please?
tpl_checkout_payment_default.php
Code:<?php
/**
* Page Template
*
* Loaded automatically by index.php?main_page=checkout_payment.<br />
* Displays the allowed payment modules, for selection by customer.
*
* @package templateSystem
* @copyright Copyright 2003-2011 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
**********************************************************************
*This program is distributed in the hope that it will be useful, but
*WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************
* @version $Id: tpl_checkout_payment_default.php 19358 2011-08-24 17:36:50Z drbyte $
*/
?>
<?php echo $payment_modules->javascript_validation(); ?>
<div class="centerColumn" id="checkoutPayment">
<?php echo zen_draw_form('checkout_payment', zen_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'), 'post', ($flagOnSubmit ? 'onsubmit="return check_form();"' : '')); ?>
<?php echo zen_draw_hidden_field('action', 'submit'); ?>
<h1 id="checkoutPaymentHeading"><?php echo HEADING_TITLE; ?></h1>
<!-- bof Order Steps (tableless) -->
<div class="progressmeter">
<?php echo TEXT_ORDER_STEPS_INFO; ?>
<ol>
<li class="one"><span><?php echo DONE_TEXT_ORDER_STEPS; ?></span><?php echo TEXT_ORDER_STEPS_1; ?></li>
<li class="two current"><span><?php echo CURRENT_TEXT_ORDER_STEPS; ?></span><?php echo TEXT_ORDER_STEPS_2; ?></li>
<li class="three"><span><?php echo NEXT_TEXT_ORDER_STEPS_3; ?></span><?php echo TEXT_ORDER_STEPS_3; ?></li>
<li class="four"><span><?php echo NEXT_TEXT_ORDER_STEPS_4; ?></span><?php echo TEXT_ORDER_STEPS_4; ?></li>
</ol>
</div>
<!-- eof Order Steps (tableless) -->
<?php if ($messageStack->size('redemptions') > 0) echo $messageStack->output('redemptions'); ?>
<?php if ($messageStack->size('checkout') > 0) echo $messageStack->output('checkout'); ?>
<?php if ($messageStack->size('checkout_payment') > 0) echo $messageStack->output('checkout_payment'); ?>
<?php
if (DISPLAY_CONDITIONS_ON_CHECKOUT == 'true') {
?>
<fieldset>
<legend><?php echo TABLE_HEADING_CONDITIONS; ?></legend>
<div><?php echo TEXT_CONDITIONS_DESCRIPTION;?></div>
<?php echo zen_draw_checkbox_field('conditions', '1', false, 'id="conditions"');?>
<label class="checkboxLabel" for="conditions"><?php echo TEXT_CONDITIONS_CONFIRM; ?></label>
</fieldset>
<?php
}
?>
<?php // ** BEGIN PAYPAL EXPRESS CHECKOUT **
if (!$payment_modules->in_special_checkout()) {
// ** END PAYPAL EXPRESS CHECKOUT ** ?>
<h2 id="checkoutPaymentHeadingAddress"><?php echo TITLE_BILLING_ADDRESS; ?></h2>
<div id="checkoutBillto" class="floatingBox back">
<?php if (MAX_ADDRESS_BOOK_ENTRIES >= 2) { ?>
<div class="buttonRow forward"><?php echo '<a href="' . zen_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, '', 'SSL') . '">' . zen_image_button(BUTTON_IMAGE_CHANGE_ADDRESS, BUTTON_CHANGE_ADDRESS_ALT) . '</a>'; ?></div>
<?php } ?>
<address><?php echo zen_address_label($_SESSION['customer_id'], $_SESSION['billto'], true, ' ', '<br />'); ?></address>
</div>
<div class="floatingBox important forward"><?php echo TEXT_SELECTED_BILLING_DESTINATION; ?></div>
<br class="clearBoth" />
<?php // ** BEGIN PAYPAL EXPRESS CHECKOUT **
}
// ** END PAYPAL EXPRESS CHECKOUT ** ?>
<fieldset id="checkoutOrderTotals">
<legend id="checkoutPaymentHeadingTotal"><?php echo TEXT_YOUR_TOTAL; ?></legend>
<?php
if (MODULE_ORDER_TOTAL_INSTALLED) {
$order_totals = $order_total_modules->process();
?>
<?php $order_total_modules->output(); ?>
<?php
}
?>
</fieldset>
<?php
$selection = $order_total_modules->credit_selection();
if (sizeof($selection)>0) {
for ($i=0, $n=sizeof($selection); $i<$n; $i++) {
if ($_GET['credit_class_error_code'] == $selection[$i]['id']) {
?>
<div class="messageStackError"><?php echo zen_output_string_protected($_GET['credit_class_error']); ?></div>
<?php
}
for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) {
?>
<fieldset>
<legend><?php echo $selection[$i]['module']; ?></legend>
<?php echo $selection[$i]['redeem_instructions']; ?>
<div class="gvBal larger"><?php echo $selection[$i]['checkbox']; ?></div>
<label class="inputLabel"<?php echo ($selection[$i]['fields'][$j]['tag']) ? ' for="'.$selection[$i]['fields'][$j]['tag'].'"': ''; ?>><?php echo $selection[$i]['fields'][$j]['title']; ?></label>
<?php echo $selection[$i]['fields'][$j]['field']; ?>
</fieldset>
<?php
}
}
?>
<?php
}
?>
<?php // ** BEGIN PAYPAL EXPRESS CHECKOUT **
if (!$payment_modules->in_special_checkout()) {
// ** END PAYPAL EXPRESS CHECKOUT ** ?>
<fieldset>
<legend><?php echo TABLE_HEADING_PAYMENT_METHOD; ?></legend>
<?php
if (SHOW_ACCEPTED_CREDIT_CARDS != '0') {
?>
<?php
if (SHOW_ACCEPTED_CREDIT_CARDS == '1') {
echo TEXT_ACCEPTED_CREDIT_CARDS . zen_get_cc_enabled();
}
if (SHOW_ACCEPTED_CREDIT_CARDS == '2') {
echo TEXT_ACCEPTED_CREDIT_CARDS . zen_get_cc_enabled('IMAGE_');
}
?>
<br class="clearBoth" />
<?php } ?>
<?php
$selection = $payment_modules->selection();
if (sizeof($selection) > 1) {
?>
<p class="important"><?php echo TEXT_SELECT_PAYMENT_METHOD; ?></p>
<?php
} elseif (sizeof($selection) == 0) {
?>
<p class="important"><?php echo TEXT_NO_PAYMENT_OPTIONS_AVAILABLE; ?></p>
<?php
}
?>
<?php
$radio_buttons = 0;
for ($i=0, $n=sizeof($selection); $i<$n; $i++) {
?>
<?php
if (sizeof($selection) > 1) {
if (empty($selection[$i]['noradio'])) {
?>
<?php echo zen_draw_radio_field('payment', $selection[$i]['id'], ($selection[$i]['id'] == $_SESSION['payment'] ? true : false), 'id="pmt-'.$selection[$i]['id'].'"'); ?>
<?php } ?>
<?php
} else {
?>
<?php echo zen_draw_hidden_field('payment', $selection[$i]['id'], 'id="pmt-'.$selection[$i]['id'].'"'); ?>
<?php
}
?>
<label for="pmt-<?php echo $selection[$i]['id']; ?>" class="radioButtonLabel"><?php echo $selection[$i]['module']; ?></label>
<?php
if (defined('MODULE_ORDER_TOTAL_COD_STATUS') && MODULE_ORDER_TOTAL_COD_STATUS == 'true' and $selection[$i]['id'] == 'cod') {
?>
<div class="alert"><?php echo TEXT_INFO_COD_FEES; ?></div>
<?php
} else {
// echo 'WRONG ' . $selection[$i]['id'];
?>
<?php
}
?>
<br class="clearBoth" />
<?php
if (isset($selection[$i]['error'])) {
?>
<div><?php echo $selection[$i]['error']; ?></div>
<?php
} elseif (isset($selection[$i]['fields']) && is_array($selection[$i]['fields'])) {
?>
<div class="ccinfo">
<?php
for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) {
?>
<label <?php echo (isset($selection[$i]['fields'][$j]['tag']) ? 'for="'.$selection[$i]['fields'][$j]['tag'] . '" ' : ''); ?>class="inputLabelPayment"><?php echo $selection[$i]['fields'][$j]['title']; ?></label><?php echo $selection[$i]['fields'][$j]['field']; ?>
<br class="clearBoth" />
<?php
}
?>
</div>
<br class="clearBoth" />
<?php
}
$radio_buttons++;
?>
<br class="clearBoth" />
<?php
}
?>
</fieldset>
<?php // ** BEGIN PAYPAL EXPRESS CHECKOUT **
} else {
?><input type="hidden" name="payment" value="<?php echo $_SESSION['payment']; ?>" /><?php
}
// ** END PAYPAL EXPRESS CHECKOUT ** ?>
<fieldset>
<legend><?php echo TABLE_HEADING_COMMENTS; ?></legend>
<?php echo zen_draw_textarea_field('comments', '45', '3'); ?>
</fieldset>
<div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_CONTINUE_CHECKOUT, BUTTON_CONTINUE_ALT, 'onclick="submitFunction('.zen_user_has_gv_account($_SESSION['customer_id']).','.$order->info['total'].')"'); ?></div>
<div class="buttonRow back"><?php echo TITLE_CONTINUE_CHECKOUT_PROCEDURE . '<br />' . TEXT_CONTINUE_CHECKOUT_PROCEDURE; ?></div>
</form>
</div>
The console error that you noted above:
implies to me that your template's /common/html_header.php isn't loading jQuery (or loading a woefully old version). Make sure, too, that your template includes /jscript/jscript_framework.php (that's the AJAX support interface).Code:Console errors:
Uncaught ReferenceError: $ is not defined at index.php?main_page=checkout_payment:100Uncaught ReferenceError: $ is not defined at index.php?main_page=checkout_payment:188
What is the postal code input in the Square module needed for? Normally postal code is not needed for payment by credit card.
Square looks for a match between the billing zip and the zip presented in the form. Not unlike many gas stations that ask for a zip to verify the card.
We've had several instances where corporate or charitable zip codes do not match the billing as they often confuse the zip of the holder with the zip of the institution.
Just another way for Square to better verify the transaction.
Ah, yes, that cold_steel template far out-dates the introduction of the Zen Cart AJAX framework. If you want to continue using cold_steel, just copy the zc156c's responsive_classic/jscript/jscript_framework.php to cold_steel/jscript. That version of the file simply brings in the common, template_default, version of the framework.
Note, though, that there will be a significant number of changes needed for that template to continue operation under current versions of PHP.