Forums

Redirect Plugin with Paypal

wimprovoost 01 Aug, 2009
Hello,

As this is my first post, let me start with a big THANK YOU for making Chronoforms available to the world. I've tried various form solutions and for me this is by far the best!

My question is on the Redirect Plugin that I use to get to PayPal. Most of it works fine, I get to the sandbox and can complete transactions and all. The one thing I can't get my head around is how to insert a variable in the plugin fields.
My site (transportation service) calculates a price based on the distance customers want to travel. So basically every order has a different price. When I put a fixed number at the amount field, everything works fine. But the business model is not flat fee🙂

I tried:
- in the Redirect plugin, extra fields, amount=$price.
- in the Redirect plugin, extra fields, amount=$_POST[price] as it does show up in the POST array of this form.
- in the Redirect plugin, extra fields, amount = <?php $price ?>.
- in the Redirect plugin, extra fields, amount = <?php $_POST[price] ?>
- in the form code as php, put a hidden field with name = "amount" and value = "$price"
- in the form code as plain html, put a hidden field with name = "amount" and value = "$price"
this last try worked, i.e. the Redirect plugin showed the 'amount' field in the list of form fields. However this is not very useful as in this mode I cannot use variables
- AS I read in a recent post here, tried playing with the order of things, before email and after email.

I'm probably overseeing something terribly obvious, but at this point a hint in the right direction would be very much appreciated!

Thanks in advance,

Wim
GreyHead 01 Aug, 2009
Hi Wim,

Where do you calculate the price?
In the form using JavaScript? or afterwards using PHP?

Bob
wimprovoost 01 Aug, 2009
Hi Bob,

Wow didn't expect a reply on a Saturday afternoon, great!

In the first form I collect customer's address and destination details; in the second form I calculate coordinates, distance and price with PHP form code. This is shown as a sort of confirmation page. If ok the customer goes to the third page, which asks for acceptance of terms and conditions. Submitting this leads to the fourth form, which has the PayPal button as submit.
The forms are chained by a motherform with Multiform plugin. I tried redirecting from the last child form as well as from the mother form.

My line of thought is that hidden fields in either the child form or the mother form should do the trick ?

Thanks, Wim
GreyHead 01 Aug, 2009
Hi Wim,

When you calculate the total add it to a hidden field in the confirmation page as well as displaying it. Then you can use this field as a variable in the ReDirect plugin. You may need to carry it through the terms and conditions page the same way - though actually ChronoForms stores all the data from previous steps and makes it available in the $posted array.

The other solution again to use a hidden field to create a variable in the ReDirect plugin but to calculate and set the value in the Extra Code Before box in the Plugin setup.

Bob
wimprovoost 01 Aug, 2009
Hi Bob, thanks for that, maybe I'm not totally stupid after all . .

What you describe is just what I did, and what a wonderful feature of the Multipage plugin that collects all fields and carry them via the $_POST array !
I get stuck on the last form . In the form main code I put some PHP:

echo "<input type=\"hidden\" name=\"price\" value=\"$_POST[price]\" />";

I would expect to see 'price' in the Redirect plugin form field list. It doesnt show however.

Funny thing is, when I put the same line in plain html it does show up in the plugin field list:

<input type="hidden" name="price" value="10.95" />

Any idea what goes wrong here?

Thanks, Wim
GreyHead 01 Aug, 2009
Hi Wim,

Please try
<input type="hidden" name="price" value="<?php echo $_POST['price']; ?>" />
or
echo "<input type='hidden' name='price' value='".$_POST['price']."' />";
I suspect that the escaped quotes are confusing the ChronoForms name field parser.

Bob

Later: corrected second example
wimprovoost 01 Aug, 2009
Hi Bob,

You saved my day! Now I see the price field back in the plugin !

Thank you so much! Saves me hours and hours if not more.

Bye for now, and if I wasn't convinced to buy the license, now I m even more so !

Cheers,
Wim
This topic is locked and no more replies can be posted.