Kryptix Posted January 3, 2010 Share Posted January 3, 2010 I've tried everything I know to try and get this to work but I'm still stuck. Is there anyone out there who could possibly help me over MSN/TeamViewer? It's really simple what I'm trying to do, user clicks a button on my site to pay a fixed payment of £4 and then they're redirected back. If it's confirmed that it's paid it edits the database. I just can't get the PayPal API to tell my script that it's successful. I can pay if anyone fancies helping me. :-\ Send me a PM if you're interested. I don't expect this for free as I really need a walk through. Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted January 3, 2010 Share Posted January 3, 2010 if you wish to pay someone to do this you would have better luck posting in the freelance forums Quote Link to comment Share on other sites More sharing options...
Kryptix Posted January 3, 2010 Author Share Posted January 3, 2010 It's not a big paid job though, I don't really need any code, I just need walking through it and I'm sure there's many people here who know it like the back of their hand. Quote Link to comment Share on other sites More sharing options...
gizmola Posted January 3, 2010 Share Posted January 3, 2010 Which API are you using? Are you using the UK payflow pro 4 api? We have a number of Brits on the forum who might be able to help you if that's the case. I'm not sure if that's required in the UK, but since you mentioned pounds, I thought it might be pertinent. Quote Link to comment Share on other sites More sharing options...
monkeypaw201 Posted January 4, 2010 Share Posted January 4, 2010 I don't know what your database looks like, but here is a sample snippet I used on a website once. I'm sure with a bit of tweaking, you can get it to work the way you want. <?php $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } $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 ('ssl://www.paypal.com', 443, $errno, $errstr, 30); $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; $invoice_id = $_POST['custom']; if (!$fp) { echo "error connecting to paypal"; } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { $this->db->query("INSERT INTO `transactions` (`iid`,`gateway`,`gateway_id`,`amount`,`status`,`timestamp`) VALUES ('".$invoice_id."','paypal','".$txn_id."','$payment_amount','verified','".time()."')"); $this->db->query("UPDATE `invoices` SET `status` = 'paid' WHERE `iid` = '".$invoice_id."'"); } else if (strcmp ($res, "INVALID") == 0) { $this->db->query("INSERT INTO `transactions` (`iid`,`gateway`,`gateway_id`,`amount`,`status`,`timestamp`) VALUES ('".$invoice_id."','paypal','".$txn_id."','$payment_amount','invalid','".time()."')"); } } fclose ($fp); } ?> Quote Link to comment Share on other sites More sharing options...
Kryptix Posted January 6, 2010 Author Share Posted January 6, 2010 Thank-you, I'll give that a go. I'm just using the bog standard PayPal buttons, web payments standard, I believe? I'll try that tonight but I'm still open to help if anyone fancies earning some money. Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted January 6, 2010 Share Posted January 6, 2010 you need to use their IPN (Instant Payment Notification) option. PayPal has a huge reservoir of Developer information/help on their site .. that be a good place to start as it would be the most up-to-date information out there (i would assume). they also have developer forums i believe. IPN is feature that paypal has where their system will send a POSTBACK to your site upon a successful or declined payment. IPN works like this: 1. user clicks "Pay using PayPal", or something similar. 2. user is taken to PayPal payment page on paypal.com 3. user enters payment information and clicks to have payment processed. 4a. user's payment info is approved/successful, so paypal executes your IPN script (http://www.your-site.com/paypal/ipn.php) and your database is updated accordingly (as well as anything else you want your script to do). 4b. user's payment is declined by paypal. IPN is executed and no changes are made to your db. 5. user is sent to confirmation page. that's the jist of it. Quote Link to comment Share on other sites More sharing options...
Kryptix Posted January 7, 2010 Author Share Posted January 7, 2010 you need to use their IPN (Instant Payment Notification) option. PayPal has a huge reservoir of Developer information/help on their site .. that be a good place to start as it would be the most up-to-date information out there (i would assume). they also have developer forums i believe. IPN is feature that paypal has where their system will send a POSTBACK to your site upon a successful or declined payment. IPN works like this: 1. user clicks "Pay using PayPal", or something similar. 2. user is taken to PayPal payment page on paypal.com 3. user enters payment information and clicks to have payment processed. 4a. user's payment info is approved/successful, so paypal executes your IPN script (http://www.your-site.com/paypal/ipn.php) and your database is updated accordingly (as well as anything else you want your script to do). 4b. user's payment is declined by paypal. IPN is executed and no changes are made to your db. 5. user is sent to confirmation page. that's the jist of it. I understand how it works but it's getting it working that I'm struggling with. Will the script above work? Quote Link to comment 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.