Advertisement
Guest User

Untitled

a guest
Feb 26th, 2013
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.20 KB | None | 0 0
  1. <style type="text/css">
  2. #bold {
  3.     color:#05924b;
  4.     font-family:Gisha, Verdana, Sans-Serif;
  5.     font-size:25px;
  6.     font-weight:700;
  7.     margin-left:100px;
  8.     margin-right:100px;
  9.     text-align:left;
  10.     text-align:center;
  11.     margin-bottom:-10px;
  12. }
  13. #welcomeText {
  14.     color:#05924b;
  15.     font-family:Gisha, Verdana, Sans-Serif;
  16.     font-size:36px;
  17.     margin-top:30px;
  18.     margin-bottom:15px;
  19.     text-align:center;
  20. }
  21. .abouttext {
  22.     color:#05924b;
  23.     font-family:Gisha, Verdana, Sans-Serif;
  24.     font-size:22px;
  25.     margin-left:100px;
  26.     margin-right:100px;
  27.     margin-top:0px;
  28.     text-align:left;
  29.     text-align:center;
  30. }
  31. #undertext {
  32.     margin-top:20px;
  33.     text-align:center;
  34.     }
  35. </style>
  36. <?php
  37.  
  38. /*
  39.  update: 06/27/2011
  40.   - updated to use cURL for better security, assumes PHP version 5.3
  41. */
  42.  
  43. // read the post from PayPal system and add 'cmd'
  44. $req = 'cmd=_notify-synch';
  45.  
  46. $tx_token = $_GET['tx'];
  47.  
  48. $pp_hostname = "www.sandbox.paypal.com";
  49.  
  50. // read the post from PayPal system and add 'cmd'
  51. $req = 'cmd=_notify-synch';
  52.  
  53. $tx_token = $_GET['tx'];
  54. $auth_token = "FBO_RlnSKMrFCJlPOvghIonpJx2uiXH_ICIeh8-VMIUWtVjM5vhPJV0LCUW";
  55. $req .= "&tx=$tx_token&at=$auth_token";
  56.  
  57. $ch = curl_init();
  58. curl_setopt($ch, CURLOPT_URL, "https://$pp_hostname/cgi-bin/webscr");
  59. curl_setopt($ch, CURLOPT_POST, 1);
  60. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  61. curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
  62. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
  63. //set cacert.pem verisign certificate path in curl using 'CURLOPT_CAINFO' field here,
  64. //if your server does not bundled with default verisign certificates.
  65. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
  66. curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: $pp_hostname"));
  67. $res = curl_exec($ch);
  68. curl_close($ch);
  69.  
  70. if(!$res){
  71.     //HTTP ERROR
  72. }else{
  73.      // parse the data
  74.     $lines = explode("\n", $res);
  75.     $keyarray = array();
  76.     if (strcmp ($lines[0], "SUCCESS") == 0) {
  77.         for ($i=1; $i<count($lines);$i++){
  78.         list($key,$val) = explode("=", $lines[$i]);
  79.         $keyarray[urldecode($key)] = urldecode($val);
  80.     }
  81.     // check the payment_status is Completed
  82.     // check that txn_id has not been previously processed
  83.     // check that receiver_email is your Primary PayPal email
  84.     // check that payment_amount/payment_currency are correct
  85.     // process payment
  86.     $firstname = $keyarray['first_name'];
  87.     $lastname = $keyarray['last_name'];
  88.     $itemname = $keyarray['item_name'];
  89.     $amount = $keyarray['payment_gross'];
  90.  
  91.     echo ("<div id='welcomeText'>Thank you for your purchase!</div>");
  92.  
  93.     echo ("<p><div id='bold'>Payment Details</div></p><br>\n");
  94.     echo ("<div class='abouttext'>Name: $firstname $lastname</div>\n");
  95.     echo ("<div class='abouttext'>Item: $itemname</div>\n");
  96.     echo ("<div class='abouttext'>Amount: $amount</div>\n");
  97.     echo ("");
  98.     }
  99.     else if (strcmp ($lines[0], "FAIL") == 0) {
  100.         // log for manual investigation
  101.     }
  102. }
  103.  
  104. ?>
  105.  
  106.  
  107. <div id="undertext">Your transaction has been completed, and a receipt for your purchase has been emailed to you.<br> You may log into your account at <a href='https://www.paypal.com'>www.paypal.com</a> to view details of this transaction.<br>
  108. Back to: <a href='http://www.energyshop.se'>energyshop.se</a></div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement