Forums

Redirect plugin and paypal

giupi 14 May, 2010
Hello to everybody.

I searched all the forum to try to solve my problem but I didn't find the answer.

My first problem was to use redirect plugin to get paypal payment; I solved it after a long search and many trials by chance. I did not understand wich parameters putting in the Extra fields Data of the plugin. Finally I discovered that you have to put these:

cmd=_xclick
business=your_paypal_email@whatever.com
item_name=blablabla
currency_code=EUR
amount=10.00 (or whatever amount)
return=http://www.yoursite.com

And the Target URL is: https://www.paypal.com/it/cgi-bin/webscr

(It seems to me that these parameters were not written in any post of the forum in a clear way... so hope this could help someone else...)

I then copied in "Field names from your form" all the field's names coming from the form.

But in paypal page after submitting the form and before confirming the payment I can only see the "item_name" wich is the same for all the transactions and I can't see the other fields coming from the form: infact the payment confirmation email that I receive from paypal does not contain any element (but the email address, name and item_name) that can help linking the submitted form data to the paypal record; someone infact could use one email/name to submit the data and other email/name to pay...

My questions now are:

1) how can I distinguish the transactions by using "item_name" (or other visible ID in paypal) as variable?

2) And how can I get people pay a different amount (coming from a form's field), so that also "amount" would be a variable?

I think I browsed all the forum finding some posts with similar question to mine but I did not understand the solutions

e.g. http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=9&t=15377
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=15873

I hope that someone could answer my questions possibly step by step 🙂 ... thank you in advance.
GreyHead 15 May, 2010
Hi giupi,

The Extra fields Data box is mainly used for Fixed data that is the same for every transaction.

Use the Field Names from Your Form boxes for variable data.
If you don't know the values when you create the form use hidden inputs as place-holders
<input type='hidden' name='amount' value='' />
<input type='hidden' name='item_number' value='' />

Then you can set these values in the the OnSubmit before box and they will be sent to PayPal
<?php
. . . // add calculation code here
$amount = 5.99;
$item_number = 'XXX_'.$user->id;
JRequest::setVar('amount', $amount);
JRequest::setVar('item_number', $item_number);
?>

Bob
giupi 15 May, 2010
Thank you Bob for your kind reply.

I managed, by using your suggestion, to pass to Paypal the variable "amount" that one can choose from the form, so now the fee isn't anymore fixed (I had first to remove amount=... from Extra fields Data); but I didn't manage to pass the item_number.

I did not understand completely how this code works:

<?php
. . . // add calculation code here
$amount = 5.99;
$item_number = 'XXX_'.$user->id;
JRequest::setVar('amount', $amount);
JRequest::setVar('item_number', $item_number);
?>


Particularly "$user" variable: people filling the form are not necessary registered users... could this be the reason why it does work only half way?

To me it would be enough to pass to paypal the "name"+"surname" fields (eventually also his/her position) coming from the form, so that in the paypal record (and in the email I receive) a certain payment is linked to certain data (name+position) coming from the form.

I'm sorry to bother you with this stupid thing, but I'm a beginner in using chronoform. Thank you...
GreyHead 15 May, 2010
Hi guipi,

The user part was just an example . . . Try
<?php
$name = JRequest::getString('name', '', 'post);
$surname = JRequest::getString('surname', 'unknown', 'post);
$item_number = $name.'_'.$surname;
. . .

Bob
giupi 16 May, 2010
Bob, I'm really really sorry to bother you, but I can't get this working...

Summing up here's what I did:

1) I added in the Form HTML code:
<input type='hidden' name='item_number' value='' />

(amount is coming from the form field - and is the only thing I got working)

2) in On Submit code - before sending email:
<?php
. . . // add calculation code here
$amount = 5.99;
$name = JRequest::getString('name', '', 'post);
$surname = JRequest::getString('surname', 'unknown', 'post);
$item_number = $name.'_'.$surname;
JRequest::setVar('amount', $amount);
?>


3) In the redirect plugin these are the settings:
[attachment=0]Immagine.jpg[/attachment]

When i'm redirect to paypal there is no "item_number" reference and no other reference but the item_name (the same every time) and the amount.

Would you be so kind to give me just a little more help? :-) Thank you!
GreyHead 16 May, 2010
Hi guipi,

You skipped this line:
JRequest::setVar('item_number', $item_number);

Bob
giupi 16 May, 2010
Ok now I know it! I'm too stupid to use this component! I've bought (because I payed the component validation on behalf of my working office) something that I'm not able to use! I still can't get it working...

Now my OnsubmitCode Before sending email is:

<?php
. . . // add calculation code here
$amount = 5.99;
$name = JRequest::getString('name', '', 'post);
$surname = JRequest::getString('surname', 'unknown', 'post);
$item_number = $name.'_'.$surname;
JRequest::setVar('amount', $amount);
JRequest::setVar('item_number', $item_number);
?>


But I still can't get the item_number passing through.

I think I will surrender; I will make do with the amount choose only, linking the form subscriptions to the payments using the date/time of the submission when the buyer's name is different...

Or maybe I will try to contact someone else on the professional paid service forum.

Thank you anyway!
GreyHead 19 Jul, 2010
Hi giupi,

That all looks OK.

Dou you have 'Send Emails' set to Yes on the Form general Tab? Otherwise the Onsubmit Before code will not be run.

Bob
tpkwan 23 Dec, 2010
After lots of debugging, thought this is a bug in the redirect plugin.

While there is a dropdown that allows you to select whether to run the redirect plugin before or after email on the backend, there is a hard coded hidden variable of the same name set to before_email. That means, there is no way to set the plugin to run after email.

As the logic goes, the redirect plugin will set the url parameters before running the onsubmitcodeb4. So any changes in the onsubmitcodeb4 have no effect on the parameters that sent to the paypal.

Can someone look into this? In the meantime, you can hack the redirect plugin to be able to change to run redirect after email: Change line 188 of cf_redirect.php to

    //~ $hidden_array['params[onsubmit]'] = 'before_email';


The cf_redirect.php is at components/com_chronocontact/plugins off your joomla root.
GreyHead 24 Dec, 2010
Hi tpkwan,

Well found - I've looked at that line many times and never realised what it was doing :-(

Bob
This topic is locked and no more replies can be posted.