Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Square Payments Plugin for osCommerce


shichemt

Recommended Posts

  • 2 weeks later...

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

Link to comment
Share on other sites

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".

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?"

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

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');
}

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 3115

Warning: 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 3115

Warning: 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

Link to comment
Share on other sites

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 3115

Warning: 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 3115

Warning: 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, '[email protected]', "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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 weeks later...

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!

 

 

 

 

 

Link to comment
Share on other sites

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", "[email protected]", "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 by shichemt
General Adjustment
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 4 weeks later...

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.

Link to comment
Share on other sites

  • 2 months later...

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 pixel_trans.gif

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 by Jan Zonjee

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

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 

Link to comment
Share on other sites

  • 4 months later...

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...