cooldude832 Posted June 7, 2007 Share Posted June 7, 2007 This is my first attempting into e-commerce and I want to use paypal systems to gather my payments, but my issue is understanding what to do after the payment enters paypal and the customer has successful paid for the item. Is there a way paypal will tell me the payment passed and i can process the order? without manually doing it so i can get a return $_REQUEST or 2 from paypal saying yes order has passed. any one got any ideas I'm open to ideas but basically I need to get an okay back from paypl saying i can send a request to my distributor to send order #x to buyer y in location z. Quote Link to comment https://forums.phpfreaks.com/topic/54535-need-help-with-paypal-and-php/ Share on other sites More sharing options...
mmarif4u Posted June 7, 2007 Share Posted June 7, 2007 When the purchased is confirmed pay pal will email you, and also to your customer. But remember paypal will send emails after confirmation of payments,mean that the credit card is valid and everything related to that card is ok, and card is successfully processed. And then the amount will be transfered to ur account. Thats all, hope you get an idea from it. Quote Link to comment https://forums.phpfreaks.com/topic/54535-need-help-with-paypal-and-php/#findComment-269749 Share on other sites More sharing options...
cooldude832 Posted June 7, 2007 Author Share Posted June 7, 2007 well i've read paypals info and i found this PHP <?php // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-synch'; $tx_token = $_GET['tx']; $auth_token = "GX_sTf5bW3wxRfFEbgofs88nQxvMQ7nsI8m21rzNESnl_79ccFTWj2aPgQ0"; $req .= "&tx=$tx_token&at=$auth_token"; // post back to PayPal system to validate $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30); // If possible, securely post back to paypal using HTTPS // Your PHP server will need to be SSL enabled // $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); // read the body data $res = ''; $headerdone = false; while (!feof($fp)) { $line = fgets ($fp, 1024); if (strcmp($line, "\r\n") == 0) { // read the header $headerdone = true; } else if ($headerdone) { // header has been read. now read the contents $res .= $line; } } // 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 ("<p><h3>Thank you for your purchase!</h3></p>"); echo ("<b>Payment Details</b><br>\n"); echo ("<li>Name: $firstname $lastname</li>\n"); echo ("<li>Item: $itemname</li>\n"); echo ("<li>Amount: $amount</li>\n"); echo (""); } else if (strcmp ($lines[0], "FAIL") == 0) { // log for manual investigation } } fclose ($fp); ?> 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> that array $keyarray seems to be what i'm looking for my question is can i generate a random keyphrase on my end (take a 12 digit random code and md5 it, store it in mysql then send the 12 digit code to paypal to return to me on successs). and then check the db for that code and then send off a email/xml request to my supplier to send off an item? I think I can do it I want to know if its a good idea or bad? Quote Link to comment https://forums.phpfreaks.com/topic/54535-need-help-with-paypal-and-php/#findComment-269757 Share on other sites More sharing options...
cooldude832 Posted June 7, 2007 Author Share Posted June 7, 2007 I figured it out paypal is amazing Quote Link to comment https://forums.phpfreaks.com/topic/54535-need-help-with-paypal-and-php/#findComment-269765 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.