Connecting Tech Pros Worldwide Forums | Help | Site Map

Paypal return

Member
 
Join Date: May 2007
Posts: 64
#1: Jul 1 '07
Hi there,

I am working on paypal payment gateway using php.
How can I set return url with some arguments

Thanks,
Yogesh

volectricity's Avatar
Expert
 
Join Date: Jun 2007
Location: Baltimore
Posts: 587
#2: Jul 1 '07

re: Paypal return


Quote:

Originally Posted by ykhamitkar

Hi there,

I am working on paypal payment gateway using php.
How can I set return url with some arguments

Thanks,
Yogesh

What?

You mean how to make a query string?

"?var1=value1&var2=value2"


Be more specific.
Member
 
Join Date: May 2007
Posts: 64
#3: Jul 2 '07

re: Paypal return


Quote:

Originally Posted by volectricity

What?

You mean how to make a query string?

"?var1=value1&var2=value2"


Be more specific.

Hi,

I am sorry, May be I was not clear.
Yes I want a query string.

Thanks,
Yogesh
luke14free's Avatar
Member
 
Join Date: Apr 2007
Location: Italy, Milan
Posts: 88
#4: Jul 2 '07

re: Paypal return


Maybe when he wanted more infos he meant to specify in which part of the code you need to put that and things like that...It would be great for us to help you with your code if you could post a pseudo code.
However as he said this is the sintax for GET
www.somesite.com?var1=2 and so on...
ak1dnar's Avatar
Moderator
 
Join Date: Jan 2007
Location: Colombo
Posts: 1,440
#5: Jul 2 '07

re: Paypal return


Quote:

Originally Posted by ykhamitkar

Hi there,

I am working on paypal payment gateway using php.
How can I set return url with some arguments

Thanks,
Yogesh

Hi Yogesh,
You can Send a hidden form field named return with theOther form elements

[PHP]
$paypal_site_url='http://www.thescripts.com/thanks.php';
<input type="hidden" name="return" value="<?=$paypal_site_url?>">


[/PHP]

If you need further details about Paypal IPG integration, you are welcome here.

Thanks,
-Ajaxrand
Member
 
Join Date: May 2007
Posts: 64
#6: Jul 2 '07

re: Paypal return


Quote:

Originally Posted by ajaxrand

Hi Yogesh,
You can Send a hidden form field named return with theOther form elements

[PHP]
$paypal_site_url='http://www.thescripts.com/thanks.php';
<input type="hidden" name="return" value="<?=$paypal_site_url?>">


[/PHP]

If you need further details about Paypal IPG integration, you are welcome here.

Thanks,
-Ajaxrand


Thanks for your input Ajaxrand,
Let me explain the scenario.
I a working on a site where user updates details in a form and data gets updated in the database.

1. User Updates form with his unique UserID
|
2. Data goes in database
|
3. Column Payment_status from database is marked as "Not Done"
|
4. User is redirected to Paypal site
|
5. User makes the payment
|
6. Paypal redirects to my site on payment completion
|
7. Payment_Status column is marked as "Done" for that particular UserID

Now what I want to do is when I redirect(step 3) the site to paypal I also want to set Return parameter with parameter UserID.

So when user comes back to my site I can use the UserID to change value in database.

I read somewhere about rm parameter. But not sure how to use that.

I am new to payment gateway. so please help.

Thanks,
Yogesh
ak1dnar's Avatar
Moderator
 
Join Date: Jan 2007
Location: Colombo
Posts: 1,440
#7: Jul 3 '07

re: Paypal return


rm is stands for Return Method

Expand|Select|Wrap|Line Numbers
  1. $paypal_return_method="2"; //1=GET 2=POST
  2. <input type="hidden" name="rm" value="<?=$paypal_return_method?>">
  3.  
You can set either GET or POST method. Then once user press the complete button from Paypal side you can retrieve the Completed transaction info back to your site.

To the page that I mentioned in my ealier post.

Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="return" value="Complete_URL_to_the Success_page.php">
  2.  
  3.  
Here at success.php (IF rm is POST), You can print back the completed transaction details to the customer.
Expand|Select|Wrap|Line Numbers
  1.  
  2. <?=$_POST['txn_id']?>
  3. // This is only the transaction ID
  4. // There are Lots like this refer to Paypal web site for more
  5.  
But issue is here,some times user might NOT press the button to merchant web site.
In that case you can use IPN functionality.
This is set by
Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="notify_url" value="complete_URL_to_IPN.php">
  2.  
Sending this form field to paypal. Then once payment made this url will fire without pressing return back to your site.

When you send this notify_url you can send the User ID to Paypal and get it back by GET request.
Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="notify_url" value=" http://www.site.com/ipn.php?userid=1001">
  2.  
Thanks
-Ajaxrand
Member
 
Join Date: May 2007
Posts: 64
#8: Jul 8 '07

re: Paypal return


Quote:

Originally Posted by ajaxrand

rm is stands for Return Method

Expand|Select|Wrap|Line Numbers
  1. $paypal_return_method="2"; //1=GET 2=POST
  2. <input type="hidden" name="rm" value="<?=$paypal_return_method?>">
  3.  
You can set either GET or POST method. Then once user press the complete button from Paypal side you can retrieve the Completed transaction info back to your site.

To the page that I mentioned in my ealier post.

Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="return" value="Complete_URL_to_the Success_page.php">
  2.  
  3.  
Here at success.php (IF rm is POST), You can print back the completed transaction details to the customer.
Expand|Select|Wrap|Line Numbers
  1.  
  2. <?=$_POST['txn_id']?>
  3. // This is only the transaction ID
  4. // There are Lots like this refer to Paypal web site for more
  5.  
But issue is here,some times user might NOT press the button to merchant web site.
In that case you can use IPN functionality.
This is set by
Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="notify_url" value="complete_URL_to_IPN.php">
  2.  
Sending this form field to paypal. Then once payment made this url will fire without pressing return back to your site.

When you send this notify_url you can send the User ID to Paypal and get it back by GET request.
Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="notify_url" value=" http://www.site.com/ipn.php?userid=1001">
  2.  
Thanks
-Ajaxrand


Thank you so much Ajaxrand. Nice information
Member
 
Join Date: May 2007
Posts: 64
#9: Jul 8 '07

re: Paypal return


Quote:

Originally Posted by ykhamitkar

Thank you so much Ajaxrand. Nice information


Hi I tried the notify_url but it didnt work can you see if I am doing any error.
or do i need to change any any setting in paypal site to activate notify_url


Here is my html code for the form
================================================
Expand|Select|Wrap|Line Numbers
  1. <input type="Hidden" name="cmd" value="_xclick">
  2. <input type="Hidden" name="business" value="username@hotmail.com">
  3. <!-- Allow customer to enter desired quantity -->
  4. <input type="Hidden" name="undefined_quantity" value="1">
  5. <input type="Hidden" name="item_name" value="Registraion">
  6. <input type="Hidden" name="item_number" value="">
  7. <!-- No currency_code variable has been specified, so monetary amount is assumed to be USD -->
  8. <input type="Hidden" name="amount" value="10">
  9. <! Passthrough variables for order tracking or other purpose -->
  10. <input type="Hidden" name="custom" value="">
  11. <input type="Hidden" name="invoice" value="">
  12. <input type="Hidden" name="charset" value="">
  13. <input type="Hidden" name="no_shipping" value="1">
  14. <input type="Hidden" name="return" value="">
  15. <input type="Hidden" name="cancel_return" value="">
  16. <!-- Do not prompt customer to include a note with the purchase -->
  17. <input type="Hidden" name="no_note" value="1">
  18. <input type="Hidden" name="rm" value="2">
  19. <input type="Hidden" name="notify_url" value="">
  20. <input id=UserName style="WIDTH: 165px" tabindex=1 maxlength=16 name="Name">
  21. <input id=PasswordVerify style="WIDTH: 165px" tabindex=3 type=text maxlength=15 name="Phone">
  22. <input id=EMail style="WIDTH: 165px" tabindex=4 name="Email">
  23. <input type=submit value=Submit Now name=Authorize onClick="updatevaluesonsubmit()">
  24.  
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="text/JavaScript">
  2. function updatevaluesonsubmit() 
  3.  
  4. notify_url = "http://mysite.com/Payment-Complete.php?";
  5. notify_url = notify_url + "Name=" + frm.Name.value;
  6. notify_url = notify_url + "&Phone=" + frm.Phone.value;
  7. notify_url = notify_url + "&Email=" + frm.Email.value;
  8. notify_url = notify_url + "&Country=" + frm.Country.value;
  9. notify_url = notify_url + "&Product=" + frm.Registraion.value;
  10. notify_url = notify_url + "&Amount=" + frm.amount.value;
  11. frm.notify_url.value = notify_url;
  12. </Script>
  13.  
****

When user clicks on submit I am running updatevaluesonsubmit javascript to update notify_url field (I checked this and it works fine)
then it opens paypal site but when user makes payment it does not run Payment-Complete.php.

here is the code of Payment-Complete.php to send email. but it does not send email
================================================== ====
Payment-Complete.php:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // multiple recipients
  3. $to = 'ykhamitkar@gmail.com'; //
  4. $companyname = 'My comany';
  5.  
  6. //Put name of cc. put " $cc = '' " if not required
  7. $cc = 'yogesh@teamags.com';
  8.  
  9. //Put name of bcc. put " $bcc = '' " if not required
  10. $bcc = '';
  11.  
  12. // subject
  13. $subject = 'Payment Complete';
  14.  
  15. // message
  16. $mailBody = '';
  17. $mailBody = $mailBody . '
  18. <table border="0" bordercolor="#000000" rowheight="30" width="400" cellspacing="1" celpadding="1">
  19. <tr>
  20. <td align="center" bgcolor="#CCCCCC" colspan="2" height="30"><b>
  21. <font face="Arial" size="2">Personal Details</font></b></td></tr>';
  22.  
  23. $mailBody = $mailBody . '<tr>
  24. <td align="right" bgcolor="#CCCCCC" height="30"><font face="Arial" size="2">Name : </td>
  25. <td bgcolor="#EAEAEA"><font face="Arial" size="2">';
  26. $mailBody = $mailBody . $_REQUEST['Name']."</td></tr>";
  27. $mailBody = $mailBody . '<tr>
  28. <td align="right" bgcolor="#CCCCCC" height="30"><font face="Arial" size="2">Email : </td>
  29. <td bgcolor="#EAEAEA"><font face="Arial" size="2">';
  30. $mailBody = $mailBody . $_REQUEST['Email']."</td></tr>";
  31.  
  32. $mailBody = $mailBody . '<tr>
  33. <td align="right" bgcolor="#CCCCCC" height="30"><font face="Arial" size="2">Phone : </td>
  34. <td bgcolor="#EAEAEA"><font face="Arial" size="2">';
  35. $mailBody = $mailBody . $_REQUEST['Phone']."</td></tr>";
  36.  
  37. $mailBody = $mailBody . '<tr>
  38. <td align="right" bgcolor="#CCCCCC" height="30"><font face="Arial" size="2">Product : </td>
  39. <td bgcolor="#EAEAEA"><font face="Arial" size="2">';
  40. $mailBody = $mailBody . $_REQUEST['Product']."</td></tr>";
  41.  
  42. $mailBody = $mailBody . '<tr>
  43. <td align="right" bgcolor="#CCCCCC" height="30"><font face="Arial" size="2">Amount : </td>
  44. <td bgcolor="#EAEAEA"><font face="Arial" size="2">';
  45. $mailBody = $mailBody . $_REQUEST['Amount']."</td></tr>";
  46.  
  47. $mailBody = $mailBody . '<tr> 
  48. <td align="right" bgcolor="#CCCCCC" height="30"><font face="Arial" size="2">Country : </td>
  49. <td bgcolor="#EAEAEA"><font face="Arial" size="2">';
  50. $mailBody = $mailBody . $_REQUEST['Country'].'</td></tr></table><BR><BR>';
  51.  
  52. $mailBody = $mailBody .'<font face="Arial" size="2">Thank you, <br><br>';
  53. $mailBody = $mailBody .'from<b> ' . 'ABC.com' . '</b><br><br><br></font>';
  54.  
  55.  
  56. $headers = '';
  57. // To send HTML mail, the Content-type header must be set
  58. //$headers = 'MIME-Version: 1.0' . "\r\n";
  59. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  60.  
  61. // Additional headers
  62. $headers .= 'To: ' . $companyname . '<' . $to . '>' . "\r\n";
  63. $headers .= 'From: '.$_REQUEST['Name'].' <'.$_REQUEST['Email'].'>' . "\r\n";
  64.  
  65. if ($cc!='')
  66. {
  67. $headers .= 'Cc:' . trim($cc) ."\r\n";
  68. }
  69.  
  70. if ($bcc!='')
  71. {
  72. $headers .= 'Bcc: ' . trim($bcc) . "\r\n";
  73. }
  74.  
  75. // Mail it
  76. mail($to, $subject, $mailBody, $headers);
  77.  
  78. //Open thank you page
  79. //include("thank-you.htm");
  80. ?>
  81.  
===================


Please help!!

Thanks,
Yogesh

PLEASE USE [code] Tags - Ajaxrand
ak1dnar's Avatar
Moderator
 
Join Date: Jan 2007
Location: Colombo
Posts: 1,440
#10: Jul 9 '07

re: Paypal return


Quote:
when user makes payment it does not run Payment-Complete.php.
If you not getting a mail the problem is with your mail script. but note that you cant see the page(s) anyway (payment_complete page, Thankyou page ).Its Completly hapening on the server side.
Server-Server Comunication
when Calling from client to server only you can see the page.

Read my previuos post to find out the diferences between
return
notify_url
Read it here
Link 1
Link 2

Thanks Thread is still open for you.come back any time.
Member
 
Join Date: May 2007
Posts: 64
#11: Jul 18 '07

re: Paypal return


Quote:

Originally Posted by ajaxrand

If you not getting a mail the problem is with your mail script. but note that you cant see the page(s) anyway (payment_complete page, Thankyou page ).Its Completly hapening on the server side.
Server-Server Comunication
when Calling from client to server only you can see the page.

Read my previuos post to find out the diferences between
return
notify_url
Read it here
Link 1
Link 2

Thanks Thread is still open for you.come back any time.


======

Hi Ajaxrand,

I tried the notify url and it works well.

Thanks for your help

Yogesh
ak1dnar's Avatar
Moderator
 
Join Date: Jan 2007
Location: Colombo
Posts: 1,440
#12: Jul 19 '07

re: Paypal return


Quote:

Originally Posted by ykhamitkar

======

Hi Ajaxrand,

I tried the notify url and it works well.

Thanks for your help

Yogesh



Its a pleasure to hear that Yogesh. good luck with your project.
Hope to see you again here @ TSDN.
Thanks!
-ajaxrand
Newbie
 
Join Date: Jul 2009
Posts: 13
#13: Jul 6 '09

re: Paypal return


please help me to integrate the paypal direct method.

how i can integrate paypal with my shopping cart.
Member
 
Join Date: Feb 2009
Location: Romania/London
Posts: 88
#14: Jul 7 '09

re: Paypal return


Have you even attempted to find out how?

There is a ton of documention at Paypal detailing this example code, etc. Also thousands of tutorials on Google.
Reply