Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <style type="text/css">
- #bold {
- color:#05924b;
- font-family:Gisha, Verdana, Sans-Serif;
- font-size:25px;
- font-weight:700;
- margin-left:100px;
- margin-right:100px;
- text-align:left;
- text-align:center;
- margin-bottom:-10px;
- }
- #welcomeText {
- color:#05924b;
- font-family:Gisha, Verdana, Sans-Serif;
- font-size:36px;
- margin-top:30px;
- margin-bottom:15px;
- text-align:center;
- }
- .abouttext {
- color:#05924b;
- font-family:Gisha, Verdana, Sans-Serif;
- font-size:22px;
- margin-left:100px;
- margin-right:100px;
- margin-top:0px;
- text-align:left;
- text-align:center;
- }
- #undertext {
- margin-top:20px;
- text-align:center;
- }
- </style>
- <?php
- /*
- update: 06/27/2011
- - updated to use cURL for better security, assumes PHP version 5.3
- */
- // read the post from PayPal system and add 'cmd'
- $req = 'cmd=_notify-synch';
- $tx_token = $_GET['tx'];
- $pp_hostname = "www.sandbox.paypal.com";
- // read the post from PayPal system and add 'cmd'
- $req = 'cmd=_notify-synch';
- $tx_token = $_GET['tx'];
- $auth_token = "FBO_RlnSKMrFCJlPOvghIonpJx2uiXH_ICIeh8-VMIUWtVjM5vhPJV0LCUW";
- $req .= "&tx=$tx_token&at=$auth_token";
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "https://$pp_hostname/cgi-bin/webscr");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
- //set cacert.pem verisign certificate path in curl using 'CURLOPT_CAINFO' field here,
- //if your server does not bundled with default verisign certificates.
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: $pp_hostname"));
- $res = curl_exec($ch);
- curl_close($ch);
- if(!$res){
- //HTTP ERROR
- }else{
- // parse the data
- $lines = explode("\n", $res);
- $keyarray = array();
- if (strcmp ($lines[0], "SUCCESS") == 0) {
- for ($i=1; $i<count($lines);$i++){
- list($key,$val) = explode("=", $lines[$i]);
- $keyarray[urldecode($key)] = urldecode($val);
- }
- // check the payment_status is Completed
- // check that txn_id has not been previously processed
- // check that receiver_email is your Primary PayPal email
- // check that payment_amount/payment_currency are correct
- // process payment
- $firstname = $keyarray['first_name'];
- $lastname = $keyarray['last_name'];
- $itemname = $keyarray['item_name'];
- $amount = $keyarray['payment_gross'];
- echo ("<div id='welcomeText'>Thank you for your purchase!</div>");
- echo ("<p><div id='bold'>Payment Details</div></p><br>\n");
- echo ("<div class='abouttext'>Name: $firstname $lastname</div>\n");
- echo ("<div class='abouttext'>Item: $itemname</div>\n");
- echo ("<div class='abouttext'>Amount: $amount</div>\n");
- echo ("");
- }
- else if (strcmp ($lines[0], "FAIL") == 0) {
- // log for manual investigation
- }
- }
- ?>
- <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>
- Back to: <a href='http://www.energyshop.se'>energyshop.se</a></div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement