Forums

PASSING AN ARRAY TO PAYPAL REDIRECT

dariegler 28 Sep, 2016
i am trying to pass an array to paypal direct.
the following is the custom code to define the array.
THIS IS THE FIRST MODULE
<?php

$favcolor = $form->data['MealM'];

switch ($favcolor) {
    case "penne":
        echo "Your meal choice  is penne";
       $form->data['amt'] = 20;
        break;
    case "chicken":
        echo "Your meal choice  is chicken!";
$form->data['amt'] = 25;
        break;
    case "pork":
        echo "Your meal choice  is pork!";
$form->data['amt'] = 27;
        break;
    default:
echo "No Match";
}
?>


THIS IS THE SECOND
<?php
$menu = Array();
$amtm = Array();
$num = Array();
$amtm[0] =   $form->data['amt'];
$menu[0]  =   $form->data['MealM'];
$num[0] = 1;

If  ($form->data['FNAMEG']  >  ' ') { 
$form->data['NUMBER'] = 2;

  $favcolor = $form->data['MealG'];
  switch ($favcolor) {
      case "penne":
        echo "Guest Your meal choice  is penne";
       $form->data['amt1'] = 20;
$amtm[1]=$form->data['amt1'] ;
        break;
    case "chicken":
        echo "Guest Your meal choice  is Chicken";
       $form->data['amt1'] = 25;
        break;
$amtm[1]=$form->data['amt1'];
     case "pork":
        echo "Guest Your meal choice  is pork!";
       $form->data['amt1'] = 27;
$amtm[1]=$form->data['amt1'];
        break;
     default:
         echo "Your favorite color is neither red, blue, nor green!";
}
}
?>

<?php

$num[1] = 1;

$menu[1] = $form->data['MealG'];

echo "meals are".$menu[0] ."," . $menu[1] . ".";
echo " meal costs are". $amtm[0] . ", " . $amtm[1]  . ".";
echo " No of meals are". $num[0] . ", " . $num[1]  . ".";

$form->data['cost'] = $form->data['amt'] + $form->data['amt1'];
?>

I pass the following to paypal
$menu
$amtm
$num
i set the upload to 1 and command os _cart
when i get to paypal, there is no data loaded.

what am i missing?
GreyHead 28 Sep, 2016
Hi dariegler,

I can't see how this is supposed to work :-(

How exactly do you pass $menu, $amtm, and $num to PayPal? There is nothing shown here to do that.

Does PayPal accept array values for these parameters?

Are you using the ReDirect or the PayPal ReDirect action or some other code?

Bob
dariegler 28 Sep, 2016
here is what it says for the item field in the paypal direct _ful plugin.
i put @menu array and corresponding $num and $amtm in the quantity and amt fields.

The field name holding the item's title, if the field value is an array then multiple items will be shown on the PayPal page, and both the amount and quantity fields should be of type array too. also for this to work, the Command should be set to '_cart' and you should add upload="1" to the extra params box.
GreyHead 28 Sep, 2016
Hi dariegler,

You can't use $xxx in the PayPal action boxes - you need to add the data to the $form->data array and then add the array name to the box, For example add $form->data['menu'] = $menu; to your custom code and then use just menu in the action.

Bob
dariegler 28 Sep, 2016
I added the three arrays to data and pointed to each like this:
$form->data['menu'] 
$form->data['amtm'] 
$form->data['num'] 

Still not data passed to pay pal.

_________________________________________________
Following is the display of the array in debug.
Array
(
    [option] => com_chronoforms5
    [chronoform] => NOVEMBERtest
    [event] => submit
    [NUMBER] => 2
    [email] => dariegler@gmail.com
    [FNAME] => david
    [LNAMEM] => Riegler
    [MealM] => pork
    [FNAMEG] => Jean
    [LNAMEG] => Riegler
    [MealG] => penne
    [Payment] => mail
    [input_submit_8] => Submit
    [amt] => 27
    [amt1] => 20
    [cost] => 47
    [dinner] => dinner
    [5de973f7b738a75e292184bcb42ca8b3eda32aeb] => 1
    [menu] => Array
        (
            [0] => pork
            [1] => penne
        )

    [amtm] => Array
        (
            [0] => 27
            [1] => 20
        )

    [num] => Array
        (
            [0] => 1
            [1] => 1
        )

    [id] => 39
)
dariegler 01 Oct, 2016
any ideas on this problem?
GreyHead 01 Oct, 2016
Hi dariegler,

If you turn the Debugger on in the PayPal ReDirect action can you see the data items? If not then can you capture the URL that is being used to connect to PayPal. Hopefully one of these will let you see what data is being passed.

Bob
dariegler 01 Oct, 2016
Bob.
thanks for the effort in looking at this, but im stumped.
The following is the url going to PayPal. it appears to be truncated. i tried a couple of times and it is the same.

https://www.paypal.com/cgi-bin/webscr?cmd=_cart&business=owrcmoaa%40owrc.net&no_shipping=1&no_note=1&return=www.owrc.net¤cy_code=USD&amount=0&upload=1&

this is what a normal one looks like that is working with out arrays.

https://www.paypal.com/webapps/hermes?token=4WP68689NV6042521&useraction=commit&xclick_params=bG9naW5fZW1haWwlM0Rvd3JjbW9hYSUyNTQwb3dyYy5uZXQlMjZidXNpbmVzcyUzRG93cmNtb2FhJTI1NDBvd3JjLm5ldCUyNm5vX3NoaXBwaW5nJTNEMSUyNm5vX25vdGUlM0QxJTI2cmV0dXJuJTNEb3dyYy5uZXQlMjZjdXJyZW5jeV9jb2RlJTNEVVNEJTI2aXRlbV9uYW1lJTNEZGlubmVyJTI2YW1vdW50JTNEMjUlMjYlMjZ3YV90eXBlJTNEQnV5Tm93JTI2#/checkout/login

i have previously listed the debug output and the arrays are there.
This topic is locked and no more replies can be posted.