Forums

Send to paypal then (if verified) save form data

wmena 11 Jun, 2010
Hi,

Just trying to find the best way to do this...

I have a request form that included a $$$ amount. What I want to do is send the $$ amount to paypal and if the payment is actually made, take all of the fields from the form and save it. But, how do I get the form fields after the redirect back from paypal?

I've got the code to do the saving, I'm just not sure what plugins I should be using so that paypal returns back to me all of the form data that I collected prior to redirecting to it.

Make sense? Any clues?

Thanks
GreyHead 11 Jun, 2010
Hi wmena,

You could possibly do this with IPN but I wouldn't even try to do things this way round.

Save the data when the form is submitted marked as 'unpaid'. When payment is confirmed switch the status to 'paid'; you can do the housekeeping every week or so and delete the old 'unpaid' entries if you need to.

Bob
wmena 11 Jun, 2010
Yea, that's certainly one way... but I'm actually saving the data to a phpBB3 post.

Maybe I can save the data somewhere temporarily, then read it and write it out to phpBB3 when it's verified. I just need a way to add an ID to match the form data with the paypal info.

Ideas?
GreyHead 11 Jun, 2010
Hi wmena,

OK, that makes sense.

You could create a ChronoForms table for the form to save the data temporarily and create a unique identifier to pass to PayPal in the return_url. I'd probably use a random string.

Bob
wmena 11 Jun, 2010
OK... this is starting to sound promising. I can save the data.

I'm just trying to work out the flow of control.

I assume I use the redirect plugin to send info to paypal... but how do I send the random id to paypal... somehow using the Target URL field?

Do I have to use any additional plugins after flow comes back from paypal?

Thanks!
GreyHead 11 Jun, 2010
Hi wmena,

Not quite, add it as a variable in the return_url parameter then read the value when control is returned to you.

Bob
wmena 17 Jul, 2010
OK. Got all the code written.

I call a php program which does the following:

Save data to database (creating a unique ID)
Call paypal sending it unique ID.
paypal comes back, says verified (or not)
If verified, I read the record from database and stamp it verified
I do some post processing (add data to a phbb3 forum)

All this works fine when I put it in the Submit URL field.

But what doesn't happen is the email getting sent. I guess control never comes back to chronoforms.

Is there a better place to put this code?
GreyHead 17 Jul, 2010
Hi wmena,

You really want to do the ReDirect as the las thing so it will be important to manage the run-order. Some code may need to go into the OnSubmit After box.

The easiest way to manage a reDirection is to use the ReDirect Plugin which will set the ChronoForms ReDirect URL which is executed after everything else.

Bob
wmena 18 Jul, 2010
Well, I've got most things working. The only thing not working is sending email... because I'm not using the redirect. I'll try it.

But I want the email to only send if the paypal transaction comes back verified. IS that possible to do??
mike11 23 Jun, 2012
GreyHead,

You could possibly do this with IPN but I wouldn't even try to do things this way round.

Save the data when the form is submitted marked as 'unpaid'. When payment is confirmed switch the status to 'paid'; you can do the housekeeping every week or so and delete the old 'unpaid' entries if you need to.


Can you please explain a bit more how I can implement this? Meaning, how my users can submit my form and have it be automatically marked as "unpaid" and then when the IPN returns a Verified for that transaction, it will automatically turn to "paid"... I am thinking of using your Unique ID action to track the submittion of the form between Paypal and my site.

I guess the workflow would be as follows: User submits the form which includes a Unique ID (which would get transferred to Paypal via the Extra Field section of the Redirect), after successful payment, Paypal returns a Verified status to the Listener and the transaction with that specific Unique ID will turn from Unpaid to Paid.
GreyHead 24 Jun, 2012
Hi Mike 11,

You've more or less described it yourself.

Store the data in a database table when the form is submitted including (a) a column for the unique ID and (b) a status column set to 'waiting'.

Add the unique ID to the information passed to PayPal, I usually set it as the invoice number but be sure that it is included in the IPN Notify URL.

When the IPN request is received look up the saved data using the unique ID and update the status depending on the info from PayPal.

Remember that there can be several IPN notices - if the user is paying by e-cheque then they can happen several days later so your IPN code has to be able to complete the transaction.

Bob
mike11 24 Jun, 2012
Great... Thank you for your reply...

Is there anyone that could show me the code that would implement this?? I am not a programmer by any means (but with these amazing forums and tutorials, somehow I am able to do most everything)...

Thanks to all... 😀
This topic is locked and no more replies can be posted.