Forums / PayPal Website Payments Pro support / Payflow module for v139 won't run under php 7

Payflow module for v139 won't run under php 7

Views: 25,052

Results 1 to 14 of 14
22 Mar 2016, 5:06 PM
#1
badarac avatar

badarac

Totally Zenned

Join Date:
Aug 2009
Location:
Longs, SC
Posts:
635
Plugin Contributions:
0

Payflow module for v139 won't run under php 7

The current downloadable Payflow module was written for 1.3.9. It's worked fine in more recent releases though. I installed this on 1.5.5 running with php 7 and it receives the following error ```
PHP Parse error: syntax error, unexpected '[', expecting ',' or ';' in /home/eclyonsc/public_html/includes/modules/payment/payflow.php on line 1195

22 Mar 2016, 5:17 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Payflow module for v139 won't run under php 7

badarac:

The current downloadable Payflow module was written for 1.3.9. It's worked fine in more recent releases though. I installed this on 1.5.5 running with php 7 and it receives the following error ```
PHP Parse error: syntax error, unexpected '[', expecting ',' or ';' in /home/eclyonsc/public_html/includes/modules/payment/payflow.php on line 1195


More than likely the code contains a function as the same name as the class just above it. Typical action to bring the code to PHP 7.0 level of operation is to change the function's name to __construct. That has been something compatible with PHP 5 for some time now... 

There could be other code that casts the result of a variable to become a variable ie: $$var where $var ="me" would previously create a variable $me. In PHP 7.0 this should become ${$var} to generate $me...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

22 Mar 2016, 5:21 PM
#3
badarac avatar

badarac

Totally Zenned

Join Date:
Aug 2009
Location:
Longs, SC
Posts:
635
Plugin Contributions:
0

Re: Payflow module for v139 won't run under php 7

mc12345678:

More than likely the code contains a function as the same name as the class just above it. Typical action to bring the code to PHP 7.0 level of operation is to change the function's name to __construct. That has been something compatible with PHP 5 for some time now...

There could be other code that casts the result of a variable to become a variable ie: $$var where $var ="me" would previously create a variable $me. In PHP 7.0 this should become ${$var} to generate $me...
Thanks, I'll have a look at that and see if it's an easy fix.

22 Mar 2016, 5:26 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Payflow module for v139 won't run under php 7

Does this match your line 1195? If so, I'm struggling to see any PHP7 issue with that. Hmmm...

          if ($order_totals[$i]['code'] == 'ot_total')    $optionsST['AMT']         = round($order_totals[$i]['value'],2);

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Mar 2016, 5:38 PM
#5
badarac avatar

badarac

Totally Zenned

Join Date:
Aug 2009
Location:
Longs, SC
Posts:
635
Plugin Contributions:
0

Re: Payflow module for v139 won't run under php 7

DrByte:

Does this match your line 1195? If so, I'm struggling to see any PHP7 issue with that. Hmmm...

      if ($order_totals[$i]['code'] == 'ot_total')    $optionsST['AMT']         = round($order_totals[$i]['value'],2);
The mod downloaded from <https://www.zen-cart.com/downloads.php?do=file&id=212> contains the following around 1195
      // handle other order totals:
      global $$order_totals[$i]['code'];
      if ((substr($order_totals[$i]['text'], 0, 1) == '-') || (isset($$order_totals[$i]['code']->credit_class) && $$order_totals[$i]['code']->credit_class == true)) {
        // handle credits
        $creditsApplied += round($order_totals[$i]['value'], 2);
      } else {
        // treat all other OT's as if they're related to handling fees or other extra charges to be added/included
        $surcharges += $order_totals[$i]['value'];
      }
I've made the following changes and it seems to have solved the problem
      // handle other order totals:
      global ${$order_totals[$i]['code']};
      if ((substr($order_totals[$i]['text'], 0, 1) == '-') || (isset($$order_totals[$i]['code']->credit_class) && ${$order_totals[$i]['code']->credit_class} == true)) {
        // handle credits
        $creditsApplied += round($order_totals[$i]['value'], 2);
      } else {
        // treat all other OT's as if they're related to handling fees or other extra charges to be added/included
        $surcharges += $order_totals[$i]['value'];
      }
22 Mar 2016, 5:47 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Payflow module for v139 won't run under php 7

There are a couple places to change on that line.
Here's what v155 does in the main paypal module:```
if ((substr($order_totals[$i]['text'], 0, 1) == '-') || (isset(${$order_totals[$i]['code']}->credit_class) && ${$order_totals[$i]['code']}->credit_class == true)) {

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Mar 2016, 6:10 PM
#7
badarac avatar

badarac

Totally Zenned

Join Date:
Aug 2009
Location:
Longs, SC
Posts:
635
Plugin Contributions:
0

Re: Payflow module for v139 won't run under php 7

DrByte:

There are a couple places to change on that line.
Here's what v155 does in the main paypal module:```
if ((substr($order_totals[$i]['text'], 0, 1) == '-') || (isset(${$order_totals[$i]['code']}->credit_class) && ${$order_totals[$i]['code']}->credit_class == true)) {

OOPS! Missed one. Thanks Dr B
23 Mar 2016, 11:45 AM
#8
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Payflow module for v139 won't run under php 7

badarac:

OOPS! Missed one. Thanks Dr B

So submitting your 2nd plugin to ZC? :)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

23 Mar 2016, 11:55 AM
#9
badarac avatar

badarac

Totally Zenned

Join Date:
Aug 2009
Location:
Longs, SC
Posts:
635
Plugin Contributions:
0

Re: Payflow module for v139 won't run under php 7

mc12345678:

So submitting your 2nd plugin to ZC? :)
Oh a wise guy huh? :shocking:

You mean Dr B hasn't already done that? I suppose I could pack it up and send it in.

23 Mar 2016, 12:51 PM
#10
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Payflow module for v139 won't run under php 7

badarac:

Oh a wise guy huh? :shocking:

You mean Dr B hasn't already done that? I suppose I could pack it up and send it in.
Who me?! :lookaroun

He does a lot, but can't do everything. :smile:

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

23 Mar 2016, 2:17 PM
#11
badarac avatar

badarac

Totally Zenned

Join Date:
Aug 2009
Location:
Longs, SC
Posts:
635
Plugin Contributions:
0

Re: Payflow module for v139 won't run under php 7

mc12345678:

Who me?! :lookaroun

He does a lot, but can't do everything. :smile:
Dr B you can kick off your shoes and sip a tall cool one. I submitted the updates. :cool:

6 Jul 2016, 4:11 PM
#12
envisionocity avatar

envisionocity

New Zenner

Join Date:
Sep 2009
Posts:
4
Plugin Contributions:
0

Re: Payflow module for v139 won't run under php 7

badarac:

Dr B you can kick off your shoes and sip a tall cool one. I submitted the updates. :cool:

I'd definitely be interested in an updated PFp mod, as I've been encountering random issues since updating Zen to 1.55, including the troublesome "An Error has Occurred (0 <!-- Approved -->)" which results in payment being taken from customers, but no order getting recorded in Zen... and then customers calling a week or so later saying they never got their order, because we never received notification of one being placed. Ugh!!

But I looked and the PayFlow mod still shows as last updated in 2010. /sigh

--Tim

6 Jul 2016, 8:47 PM
#13
badarac avatar

badarac

Totally Zenned

Join Date:
Aug 2009
Location:
Longs, SC
Posts:
635
Plugin Contributions:
0

Re: Payflow module for v139 won't run under php 7

envisionocity:

I'd definitely be interested in an updated PFp mod, as I've been encountering random issues since updating Zen to 1.55, including the troublesome "An Error has Occurred (0 <!-- Approved -->)" which results in payment being taken from customers, but no order getting recorded in Zen... and then customers calling a week or so later saying they never got their order, because we never received notification of one being placed. Ugh!!

But I looked and the PayFlow mod still shows as last updated in 2010. /sigh

--Tim

I submitted it in March but you're correct that it does not appear in the downloads. I'll see if I still have what was submitted and you're welcome to it. It may not address any issues other than the ph 7 errors described in this thread though. I send you a PM if I find it.

23 Dec 2019, 12:37 AM
#14
johns4y avatar

johns4y

New Zenner

Join Date:
Jan 2009
Posts:
93
Plugin Contributions:
0

Re: Payflow module for v139 won't run under php 7

Hi Badarac, its been 3 1/2 years since you started this thread and I just wanted thank you because it solved blank page issues with Checkout and PayPal Express. Adding those brackets to the paypalwpp.php file fixed things right up. Awesome. Happy Now. Best regards.