0

I've recently copy pasted code from a tutorial on paypal adaptive payments, found here:

http://proggblo.blogspot.ca/2013/04/paypal-adaptive-payments-parallel.html

However, I've run across some apparent syntax errors. Perhaps deprecated due to newer versions of PHP? (currently using 7.0.5)

The first issue is this piece of code:

  $sum;

  foreach ($itemsArr as $key=>$value) {

    $sum+=$value["price"];

  }

if I leave this as is, I get the error

Undefined variable: sum

Alright. So change that to

sum = 1;

hoping the original code wanted an integer and not a string. But then I get a new error:

Illegal string offset 'price'

which is coming from

$sum+=$value["price"];

I'm not entirely sure what to replace this with.

Next up is

$payKey = $response['payKey'];

which is giving me the error:

Undefined index: payKey

Help?

Felix
  • 2,532
  • 5
  • 37
  • 75
  • what is in `$itemsArr`? – Thomas Oct 04 '16 at 03:30
  • you can look at the full code source linked in my post – Felix Oct 04 '16 at 03:33
  • 1
    I don't know if you are using the same `array`, can you paste the `addReceiver` calls – Thomas Oct 04 '16 at 03:38
  • http://paste.ofcode.org/uYvmeTh6YaDsRBpb6rUhiB Here is my entire file. I haven't really changed anything from the original so far. – Felix Oct 04 '16 at 03:40
  • 1
    The third parameter must be provided an array of arrays, try to test your code only using the first call to `addReceiver` on line 259. – Thomas Oct 04 '16 at 03:42
  • Err, ignore my last paste.http://paste.ofcode.org/y43kZqDXkEvFhBmaqvy2tF – Felix Oct 04 '16 at 03:43
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/124841/discussion-between-felix-maxime-and-thomas). – Felix Oct 04 '16 at 03:44

0 Answers0