shichemt Posted January 16, 2019 Share Posted January 16, 2019 This add-on will allow to accept Visa, MasterCard, American Express, Discover, JCB, or UnionPay credit cards via Square Payment Gateway on your osCommerce website. Link to the contribution Please post any bugs, problems and suggestions about Square Payments Plugin for osCommerce in this topic. I will do my best to provide support. Quote Link to comment Share on other sites More sharing options...
Cory_C Posted January 25, 2019 Share Posted January 25, 2019 Thank you for creating this contribution! I had two issues that I've not been able to figure out after installing. 1) When inserting the required code into "catalog/includes/template_bottom.php", the left column and right column of my website disappears. I removed the code for now. maximuminternational.com 2) Also regarding the required code, I get a syntax error parse error unexpected '[' result from the last line of this code that is inserted into the template_bottom.php file (just above </body> at the end of the file). <?php // SQUARE INSTALLATION if (isset($payment) && $payment == MODULE_PAYMENT_SQUARE_TEXT_CODE) { $applicationID_query = tep_db_query("select configuration_value from configuration where configuration_key = 'MODULE_PAYMENT_SQUARE_APPLICATION_ID'"); $applicationID = tep_db_fetch_array($applicationID_query)['configuration_value']; I changed: $applicationID = tep_db_fetch_array($applicationID_query)['configuration_value']; To this: $applicationID = tep_db_fetch_array($applicationID_query['configuration_value']); Or this: $applicationID = tep_db_fetch_array($applicationID_query('configuration_value')); The error changes to syntax error parse error unexpected ';' for the same line of code. I don't write code, so I don't know where to go from here, but think I could follow instructions to get this working. I'm using osCommerce v2.3.3, PHP 5.3.29 Cory Quote Link to comment Share on other sites More sharing options...
♥Gyakutsuki Posted January 26, 2019 Share Posted January 26, 2019 Remove this request and use only MODULE_PAYMENT_SQUARE_APPLICATION_ID shichemt and Cory_C 1 1 Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum Link to comment Share on other sites More sharing options...
Cory_C Posted January 28, 2019 Share Posted January 28, 2019 On 1/25/2019 at 9:43 PM, Gyakutsuki said: Remove this request and use only MODULE_PAYMENT_SQUARE_APPLICATION_ID This resolved both of my errors. Thank you. Now I just need to track down a "/checkout_payment.php?payment_error=square&error=INVALID_REQUEST_ERROR". Quote Link to comment Share on other sites More sharing options...
shichemt Posted February 3, 2019 Author Share Posted February 3, 2019 On 1/28/2019 at 10:56 AM, Cory_C said: This resolved both of my errors. Thank you. Now I just need to track down a "/checkout_payment.php?payment_error=square&error=INVALID_REQUEST_ERROR". Let me know what you've done so far, and/or DM me a screenshot of the issue that you're encountering. Quote Link to comment Share on other sites More sharing options...
Cory_C Posted February 4, 2019 Share Posted February 4, 2019 We use Sucuri for malware prevention on our website. I have been back in forth with them and our site host as this is most likely because of the Sucuri firewall protection where the requests I receive at the hosting server is from firewall range of IP's (USER -->>> FIREWALL -->>> SERVER). Sucuri support is asking me: "Have you checked with the module developer yet to see if they are familiar with working with reverse proxy systems in regards to seeing the correct user IP address?" Quote Link to comment Share on other sites More sharing options...
shichemt Posted February 7, 2019 Author Share Posted February 7, 2019 On 2/4/2019 at 12:44 PM, Cory_C said: We use Sucuri for malware prevention on our website. I have been back in forth with them and our site host as this is most likely because of the Sucuri firewall protection where the requests I receive at the hosting server is from firewall range of IP's (USER -->>> FIREWALL -->>> SERVER). Sucuri support is asking me: "Have you checked with the module developer yet to see if they are familiar with working with reverse proxy systems in regards to seeing the correct user IP address?" That's a really good question you can ask to Square because I only brought their payment gateway to osCommerce. AFAIK, the IP address that submits the order is what it gets submitted to the order page in the admin side, but I am not sure how Square handles that from their side. Quote Link to comment Share on other sites More sharing options...
djppimp Posted February 16, 2019 Share Posted February 16, 2019 I am also having the same error INVALID_REQUEST_ERROR after attempting a transaction, is there anything special i have to do to make my installation compatible with the composer / autoload vendor stuff? Quote Link to comment Share on other sites More sharing options...
djppimp Posted February 16, 2019 Share Posted February 16, 2019 Here are the changes I had to make to get this addon to work. Thanks for your contribution, Square is a great asset! //////////////// on template_bottom.php Step 1: change $applicationID_query = tep_db_query("select configuration_value from configuration where configuration_key = 'MODULE_PAYMENT_SQUARE_APPLICATION_ID'"); $applicationID = tep_db_fetch_array($applicationID_query)['configuration_value']; to $applicationID_query = tep_db_query("select configuration_value from configuration where configuration_key = 'MODULE_PAYMENT_SQUARE_APPLICATION_ID'"); $application_array = tep_db_fetch_array($applicationID_query); $applicationID = $application_array['configuration_value']; Step 2: change document.getElementById("form").submit(); to document.getElementById("checkout_confirmation").submit(); //////////////// on checkout_confirmation.php Step 1: change echo tep_draw_form('checkout_confirmation', $form_action_url, 'post'); to echo tep_draw_form('checkout_confirmation', $form_action_url, 'post', 'id="checkout_confirmation"'); Step 2: after if (is_array($payment_modules->modules)) { echo $payment_modules->process_button(); } add if ($payment_modules->selected_module != 'square') { echo tep_draw_button(IMAGE_BUTTON_CONFIRM_ORDER, 'check', null, 'primary'); } Quote Link to comment Share on other sites More sharing options...
j0ec00l2k Posted February 16, 2019 Share Posted February 16, 2019 7 hours ago, djppimp said: Here are the changes I had to make to get this addon to work. Thanks for your contribution, Square is a great asset! //////////////// on template_bottom.php Step 1: change $applicationID_query = tep_db_query("select configuration_value from configuration where configuration_key = 'MODULE_PAYMENT_SQUARE_APPLICATION_ID'"); $applicationID = tep_db_fetch_array($applicationID_query)['configuration_value']; to $applicationID_query = tep_db_query("select configuration_value from configuration where configuration_key = 'MODULE_PAYMENT_SQUARE_APPLICATION_ID'"); $application_array = tep_db_fetch_array($applicationID_query); $applicationID = $application_array['configuration_value']; Step 2: change document.getElementById("form").submit(); to document.getElementById("checkout_confirmation").submit(); //////////////// on checkout_confirmation.php Step 1: change echo tep_draw_form('checkout_confirmation', $form_action_url, 'post'); to echo tep_draw_form('checkout_confirmation', $form_action_url, 'post', 'id="checkout_confirmation"'); Step 2: after if (is_array($payment_modules->modules)) { echo $payment_modules->process_button(); } add if ($payment_modules->selected_module != 'square') { echo tep_draw_button(IMAGE_BUTTON_CONFIRM_ORDER, 'check', null, 'primary'); } Thank you much, My install worked perfect but had 2 confirm order buttons one would post the sale through Square and the other would give php errors. I made your modifications and now have one perfectly functioning confirm order button. Thanks, Joe Quote Link to comment Share on other sites More sharing options...
j0ec00l2k Posted February 16, 2019 Share Posted February 16, 2019 I spoke too soon. Ok, Everything works but I thought I would try a card that was valid but would get declined as its a out of money prepaid card. To see what the error message would be for a declined card. And I got a php error of: Warning: Missing argument 5 for tep_mail(), called in /home/connecto/public_html/catalog/includes/modules/payment/square.php on line 370 and defined in /home/connecto/public_html/catalog/includes/functions/general.php on line 3115Warning: Missing argument 6 for tep_mail(), called in /home/connecto/public_html/catalog/includes/modules/payment/square.php on line 370 and defined in /home/connecto/public_html/catalog/includes/functions/general.php on line 3115Warning: Cannot modify header information - headers already sent by (output started at /home/connecto/public_html/catalog/includes/functions/general.php:3115) in /home/connecto/public_html/catalog/includes/functions/general.php on line 148 Any clues what I should do??? I am no programmer but can follow PHP somewhat since I have setup my Oscommerce store 15yrs ago and have added modules that come with instructions. Thank you for your help. Joe Quote Link to comment Share on other sites More sharing options...
j0ec00l2k Posted February 17, 2019 Share Posted February 17, 2019 I temporarily commented out the tep_mail so it just displays the CC error message to the customer and does not email it. If anyone can help me get the email function working that would be great. Thanks, Joe Quote Link to comment Share on other sites More sharing options...
j0ec00l2k Posted February 17, 2019 Share Posted February 17, 2019 22 hours ago, j0ec00l2k said: I spoke too soon. Ok, Everything works but I thought I would try a card that was valid but would get declined as its a out of money prepaid card. To see what the error message would be for a declined card. And I got a php error of: Warning: Missing argument 5 for tep_mail(), called in /home/connecto/public_html/catalog/includes/modules/payment/square.php on line 370 and defined in /home/connecto/public_html/catalog/includes/functions/general.php on line 3115Warning: Missing argument 6 for tep_mail(), called in /home/connecto/public_html/catalog/includes/modules/payment/square.php on line 370 and defined in /home/connecto/public_html/catalog/includes/functions/general.php on line 3115Warning: Cannot modify header information - headers already sent by (output started at /home/connecto/public_html/catalog/includes/functions/general.php:3115) in /home/connecto/public_html/catalog/includes/functions/general.php on line 148 Any clues what I should do??? I am no programmer but can follow PHP somewhat since I have setup my Oscommerce store 15yrs ago and have added modules that come with instructions. Thank you for your help. Joe tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, "Square Debug Error", "Square has encountered some errors:\n\n".var_export($e, true)."n\n\n". "Customer ID: ".$customer_id . "r\n\r\n\r\n".var_export($order, true)); Well from what I make of it the 2 variables that its looking for Store_Owner and Store_owner_Email_Address are not defined in the general.php file So I tried this.. tep_mail(STORE_OWNER, 'My Name', STORE_OWNER_EMAIL_ADDRESS, 'myemailaddress@gmail.com', "Square Debug Error", "Square has encountered some errors:\n\n".var_export($e, true)."n\n\n". "Customer ID: ".$customer_id . "r\n\r\n\r\n".var_export($order, true)); I did not get the email but it did not cause any php errors and it returned the customer to the payment page with the CC error. Anyone? Quote Link to comment Share on other sites More sharing options...
cmcdanel Posted February 22, 2019 Share Posted February 22, 2019 I resolved the namespace error. I made the changes recommended by Joe, but now have 2 buttons when not a square payment. Also get the invalid request error. Any other suggestions? Quote Link to comment Share on other sites More sharing options...
cmcdanel Posted February 22, 2019 Share Posted February 22, 2019 After much digging I found that $HTTP_POST_VARS['nonce'] is not getting set, therefore no card data. HTTP_POST_VARS in general is working, as it is used extensively in osCommerce. HELP please! Quote Link to comment Share on other sites More sharing options...
cmcdanel Posted February 23, 2019 Share Posted February 23, 2019 The problem with the calls to tep_mail is that the last 2 arguments are missing. They are the From Name and the From Email. In modules/payment/square.php at about line 370 You can change : true)) to true), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS) to fix the error. These can also be set to any name, email you choose. Carl Quote Link to comment Share on other sites More sharing options...
EmpOphelia Posted March 3, 2019 Share Posted March 3, 2019 Thank you so much for creating this module. I am excited to put it to work, but I need a hand with a couple of errors. I'm afraid I do not code PHP and this is the first module I've tried to install. osCommerce Online Merchant v2.2 RC2a PHP Version 4.4.9 As the website administrator, I go to the module to install square. Square is not there and I see: Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/username/public_html/includes/modules/payment/square.php on line 320 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/username/public_html/includes/modules/payment/square.php on line 320 Parse error: syntax error, unexpected T_STRING in /home/username/public_html/includes/modules/payment/square.php on line 320 I go to the file and I find line 320: $transaction_api = new \SquareConnect\Api\TransactionApi(); It's in this function block: function before_process() { global $order, $HTTP_POST_VARS, $customer_id; require(DIR_WS_CLASSES . "square" . DIRECTORY_SEPARATOR . "vendor" . DIRECTORY_SEPARATOR . 'autoload.php'); $requirement_query = tep_db_query("select f.configuration_value as access_token, s.configuration_value AS locationId from configuration f, configuration s where f.configuration_key = 'MODULE_PAYMENT_SQUARE_ACCESS_TOKEN' AND s.configuration_key = 'MODULE_PAYMENT_SQUARE_LOCATION_ID';"); $requirement_array = tep_db_fetch_array($requirement_query); $access_token = $requirement_array['access_token']; $locationID = $requirement_array['locationId']; $transaction_api = new \SquareConnect\Api\TransactionApi(); $request_body = array ( "card_nonce" => $HTTP_POST_VARS['nonce'], # Monetary amounts are specified in the smallest unit of the applicable currency. # This amount is in cents. It's also hard-coded for $1.00, which isn't very useful. "amount_money" => array ( "amount" => (round($order->info['total'], 2) * 100 ), # Amount explanation: # 100 is 1.00 USD # 10000 is 100.00 USD "currency" => "USD" ), I tried a couple of syntax changes to line 320. Original: $transaction_api = new \SquareConnect\Api\TransactionApi(); Syntax Change 1: $transaction_api = new ['\SquareConnect\Api\TransactionApi'](); Result: The other warnings disappear and I'm left with the following error. Parse error: syntax error, unexpected '[', expecting T_STRING or T_VARIABLE or '$' in /home/username/public_html/includes/modules/payment/square.php on line 320 I couldn't find the \SquareConnect\Api\TransactionApi path in my file system. I look forward to any thoughts you have. I'd love to start using Square. Thanks! Quote Link to comment Share on other sites More sharing options...
shichemt Posted March 4, 2019 Author Share Posted March 4, 2019 (edited) On 2/17/2019 at 6:21 AM, j0ec00l2k said: .... tep_mail function only has 4 arguments (unless it is modified), and the line of code below is only for debug if there's any issues with a transaction. STORE_OWNER/STORE_OWNER_EMAIL_ADDRESS are not defined in your system. Therefore, change : tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, "Square Debug Error", "Square has encountered some errors:\n\n".var_export($e, true)."n\n\n". "Customer ID: ".$customer_id . "r\n\r\n\r\n".var_export($order, true)); to tep_mail("STORE_OWNER", "youremail@yourdomain.com", "Square Debug Error", "Square has encountered some errors:\n\n".var_export($e, true)."n\n\n". "Customer ID: ".$customer_id . "r\n\r\n\r\n".var_export($order, true)); and let us know if the issue was resolved. ** EDIT: if the issue is not resolved, can you pastebin your tep_mail function? Thank you. Edited March 4, 2019 by shichemt General Adjustment Quote Link to comment Share on other sites More sharing options...
shichemt Posted March 4, 2019 Author Share Posted March 4, 2019 4 hours ago, EmpOphelia said: ... Unfortunately PHP 5.2 and below are not supported as namespaces are being used in this plug-in and those versions do not support that. Please try upgrading to PHP 5.3 or later, and let us know if the issue was resolved. Quote Link to comment Share on other sites More sharing options...
shichemt Posted March 4, 2019 Author Share Posted March 4, 2019 On 2/22/2019 at 5:33 PM, cmcdanel said: ... nonce should be set through Square JS. Make sure that you've added the <script> tag in template_bottom.php and you're placing the order through HTTPS. Quote Link to comment Share on other sites More sharing options...
EmpOphelia Posted March 9, 2019 Share Posted March 9, 2019 Shichemt, Thank you for your replies! I'll see what I can do with a more current version of PHP. I'll let you know how it goes. shichemt 1 Quote Link to comment Share on other sites More sharing options...
balon Posted April 5, 2019 Share Posted April 5, 2019 Hello, We are attempting to use this module. On the checkout_payment.php page, we end up with https://i.gyazo.com/de89d794624ee52ecd6baa5e7dc4e529.png We cannot enter any CC details, nor select a credit card type. Upon hitting continue we will get "error_message=Please+select+a+payment+method+for+your+order." We followed the original installation, then also tried j0ec00l2k's suggestions for making it compatible. Using PHP 5.6. Any help would be appreciated greatly. Quote Link to comment Share on other sites More sharing options...
tkeats Posted June 18, 2019 Share Posted June 18, 2019 (edited) I'm oooh so excited to see this module option and got all the steps taken care of. However it's still not showing up i my 'module' list. Version Checker Installed Version: osCommerce Online Merchant v2.3.3.4 PHP Version 5.4.45 After I uploaded the code, made the change in template_bottom "Install Module (43)" didnt change. it was '43' before, and remained the same. It's not in the list either. Advice? Edited July 31, 2020 by Jan Zonjee Quote A signature is something that reflects its user. - The dictionary The question is not, 'to code, or not to code' the question is, 'if we do not code, are we really alive?' -- anonymous Link to comment Share on other sites More sharing options...
herbsandhelpers Posted June 24, 2019 Share Posted June 24, 2019 Hello, Been trying to make this work on Frozen CE php 7.2 with Raiwa modular checkout. No problem installing and getting responses e.g. missing values etc. However running as sandbox with the test card nothing happens pressing confirm button. Pressing finalise button just seems to bypass, confirming order but no payment. Tried the recommended solutions above again nothing don’t seem to get a working button, no call to Square made. I am wondering what people have as the callback url in square? Couldn’t really work out what to put? Any help appreciated just so frustrating getting no where and not knowing why. Lorraine Quote Link to comment Share on other sites More sharing options...
dtrisker Posted October 29, 2019 Share Posted October 29, 2019 I am trying to get this working in BS. I created a clone of my store as a test store. I get a message: Request not authorized. when trying to complete my payment. I also notice that Square has changed from Transaction to 3 separate APIs: Payments, Refunds & Orders. Has anybody changed this and gotten it to work yet? thx Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.