Jump to content

Search the Community

Showing results for tags 'ipn'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 5 results

  1. Hello everyone, I have been searching on internet about using paypal payment for a minicab booking form I havebut I couldnt find anything that I could use. What I have; The visitor comes to website and start completing the form. They get a price on the second page and the third page is the process page. The data goes to database and customer gets an email and the website admin gets the booking form in email. What I want to do; I want to enable paypal payment so visitor can pay for the minicab journey online. I need the get this working in a way that visitor gets the second page and sees the price, clicks Book & Pay by paypal button and visitor is redirected to paypal for payment, after payment, all the data enters the database (The variables are about 10-15) and customer gets the email and also lands on the success page. If the payment is not successfull then nothing goes to data base and visitor does not get email and visitor then is redirected to cancellation page. I hope I could explained, Could anyone help me how to do it or where I can find the information I needed. Regards
  2. <?php // Database variables $host = "localhost"; //database location $user = ""; //database username $pass = ""; //database password $db_name = ""; //database name // PayPal settings $paypal_email = 'paypal@example.com'; $return_url = 'http://example.com/payment-successful.htm'; $cancel_url = 'http://example.com/payment-cancelled.htm'; $notify_url = 'http://example.com/paypal/payments.php'; $item_name = 'Test Item'; //<----- this is my problem These are static variables set in the code I want to pass them from whatever the user selects in their shopping cart. $item_amount = 5.00; //<----- this is my problem // Include Functions include("functions.php"); //Database Connection $link = mysql_connect($host, $user, $pass); mysql_select_db($db_name); // Check if paypal request or response if (!isset($_POST["txn_id"]) && !isset($_POST["txn_type"])){ // Firstly Append paypal account to querystring $querystring .= "?business=".urlencode($paypal_email)."&"; // Append amount& currency (£) to quersytring so it cannot be edited in html //The item name and amount can be brought in dynamically by querying the $_POST['item_number'] variable. $querystring .= "item_name=".urlencode($item_name)."&"; $querystring .= "amount=".urlencode($item_amount)."&"; //loop for posted values and append to querystring foreach($_POST as $key => $value){ $value = urlencode(stripslashes($value)); $querystring .= "$key=$value&"; } // Append paypal return addresses $querystring .= "return=".urlencode(stripslashes($return_url))."&"; $querystring .= "cancel_return=".urlencode(stripslashes($cancel_url))."&"; $querystring .= "notify_url=".urlencode($notify_url); // Append querystring with custom field //$querystring .= "&custom=".USERID; // Redirect to paypal IPN header('location:https://www.sandbox.paypal.com/cgi-bin/webscr'.$querystring); exit(); }else{ // Response from Paypal // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $value = preg_replace('/(.*[^%^0^D])(%0A)(.*)/i','${1}%0D%0A${3}',$value);// IPN fix $req .= "&$key=$value"; } // assign posted variables to local variables $data['item_name'] = $_POST['item_name']; $data['item_number'] = $_POST['item_number']; $data['payment_status'] = $_POST['payment_status']; $data['payment_amount'] = $_POST['mc_gross']; $data['payment_currency'] = $_POST['mc_currency']; $data['txn_id'] = $_POST['txn_id']; $data['receiver_email'] = $_POST['receiver_email']; $data['payer_email'] = $_POST['payer_email']; $data['custom'] = $_POST['custom']; // 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 ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp($res, "VERIFIED") == 0) { // Used for debugging //@mail("you@youremail.com", "PAYPAL DEBUGGING", "Verified Response<br />data = <pre>".print_r($post, true)."</pre>"); // Validate payment (Check unique txnid & correct price) $valid_txnid = check_txnid($data['txn_id']); $valid_price = check_price($data['payment_amount'], $data['item_number']); // PAYMENT VALIDATED & VERIFIED! if($valid_txnid && $valid_price){ $orderid = updatePayments($data); if($orderid){ // Payment has been made & successfully inserted into the Database }else{ // Error inserting into DB // E-mail admin or alert user } }else{ // Payment made but data has been changed // E-mail admin or alert user } }else if (strcmp ($res, "INVALID") == 0) { // PAYMENT INVALID & INVESTIGATE MANUALY! // E-mail admin or alert user // Used for debugging //@mail("you@youremail.com", "PAYPAL DEBUGGING", "Invalid Response<br />data = <pre>".print_r($post, true)."</pre>"); } } fclose ($fp); } } ?>
  3. I successfully implemented paypal ipn on my website, I tested it on the paypal sandbox and everything worked. Then I changed the url from https://www.sandbox..../cgi-bin/webscr to https://www.paypal.com/cgi-bin/webscr. This should be standard procedure and everything should work fine. Once again, when using the sandbox provided by paypal, there are no problems. Now a few of my customers tried to buy things and nobody got there items. In my database I log everything and I logged this error: http error=Unknown SSL protocol error in connection to www.paypal.com:443 I use paypal ipn for the payment, underneath will be the ipn.php (ipn call back script that paypal will post variables to when a payment has been done) //Original source: https://cms.paypal.com/cms_content/US/en_US/files/developer/IPN_PHP_41.txt //Modified sample code by Codex-m: http://www.php-developer.org //WORKING DEMO HERE: http://www.php-developer.org/paypal_ipn_demo/ //Use your Paypal Sandbox buyer account to test. $req = 'cmd=' . urlencode('_notify-validate'); foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } //NEW CODE: using Curl instead of fsockopen $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://www.paypal.com/cgi-bin/webscr'); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); //curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: www.sandbox.paypal.com')); $res = curl_exec($ch); //assign posted variables to PHP variables $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']; $account=$_POST['custom']; $productname=$_POST['item_name']; $txn_type=$_POST['txn_type']; $trans_id=$_POST['transaction[0].id']; $trans_id_2=$_POST['transaction[0].id_for_sender']; //Check if any error occured if(curl_errno($ch)) { //HTTP ERROR occurred //Log error to database for troubleshooting $log='http error='.curl_error($ch); //Here the error message gets build db_write($log); //Here it gets written to the database } else { //NO HTTP ERROR OCCURRED, CLEAN //CHECK IF VERIFIED if (strcmp ($res, "VERIFIED") == 0) { I hope somebody knows what the problem is. Additional information about my webserver: ###### ApacheFriends XAMPP version 1.7.1 ###### + Apache 2.2.11 + MySQL 5.1.33 (Community Server) + PHP 5.2.9 + PEAR (Support for PHP 4 has been discontinued) + XAMPP Control Version 2.5 from www.nat32.com + XAMPP CLI Bundle 1.3 from Carsten Wiedmann + XAMPP Security 1.0 + SQLite 2.8.15 + OpenSSL 0.9.8i + phpMyAdmin 3.1.3.1 + ADOdb 5.06a + Mercury Mail Transport System v4.62 + FileZilla FTP Server 0.9.31 + Webalizer 2.01-10 + Zend Optimizer 3.3.0 + eAccelerator 0.9.5.3 for PHP 5.2.9 (but not activated in the php.ini)
  4. I found these scripts here: http://net.tutsplus....ation-with-php/ and they doesn't seem to be working anymore. Seems a bit more then I can figure out how to correct. The broken script is the last one of the three it appears. If anyone knows what is wrong with the IPN please let me know, I am searching for a means to accept payment on a membership based website and I am not having any luck. Seems all the paid membership tutorials available that I have found are all broken or out of date. The IPN when tested live with the correct settings doesn't do anything when paypal calls it. It doesn't create a user in the mysql database and it does not send any email. These are of course just the default codes from the link above. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""[url="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd[/url]"> <html xmlns="[url="http://www.w3.org/1999/xhtml"]http://www.w3.org/1999/xhtml[/url]"> <head> <title>Nettuts.com | Purchase access to download area</title> <link rel="stylesheet" type="text/css" media="All" href="css/style.css" /> </head> <body> <div id="wrap"> <h2>Purchase Access</h2> <p>Please click the button below to receive login details for the download area. <br /> Already have an account? <a href="login.php">Login</a> here.</p> Your PayPal Button Coder Here.... </div> </body> </html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""[url="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd[/url]"> <html xmlns="[url="http://www.w3.org/1999/xhtml"]http://www.w3.org/1999/xhtml[/url]"> <head> <title>Nettuts.com | Login</title> <link rel="stylesheet" type="text/css" media="All" href="css/style.css" /> </head> <body> <div id="wrap"> <?php mysql_connect("localhost", "user", "password") or die(mysql_error()); mysql_select_db("DBName") or die(mysql_error()); if(isset($_POST['email']) && isset($_POST['password'])){ // Verify $email = mysql_escape_string($_POST['email']); $password = md5($_POST['password']); $gUser = mysql_query("SELECT * FROM users WHERE email='".$email."' AND password='".$password."' LIMIT 1") or die(mysql_error()); $verify = mysql_num_rows($gUser); if($verify > 0){ echo '<h2>Login Complete</h2> <p>Click here to download our program</p>'; }else{ echo '<h2>Login Failed</h2> <p>Sorry your login credentials are incorrect.'; } }else{ ?> <h2>Login</h2> <p>Please enter your login credentials to get access to the download area</p> <form method="post" action=""> <fieldset> <label for="email">Email:</label><input type="text" name="email" value="" /> <label for="password">Password:</label><input type="text" name="password" value="" /> <input type="submit" value="Login" /> </fieldset> </form> <?php } ?> </div> </body> </html> IPN.php <?php mysql_connect("localhost", "user", "password") or die(mysql_error()); mysql_select_db("DBName") or die(mysql_error()); // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } // 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 ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { // PAYMENT VALIDATED & VERIFIED! $email = $_POST['payer_email']; $password = mt_rand(1000, 9999); mysql_query("INSERT INTO users (email, password) VALUES('". mysql_escape_string($email) ."', '".md5($password)."' ) ") or die(mysql_error()); $to = $email; $subject = 'Download Area | Login credentials'; $message = ' Thank you for your purchase Your account information ------------------------- Email: '.$email.' Password: '.$password.' ------------------------- You can now login at [url="http://yourwebsite.com/PayPal/'"]http://yourwebsite.com/PayPal/'[/url]; $headers = 'From:noreply@downloadarea.com' . "\r\n"; mail($to, $subject, $message, $headers); } else if (strcmp ($res, "INVALID") == 0) { // PAYMENT INVALID & INVESTIGATE MANUALY! $to = [email="'admin@yourwebsite.com'"]'admin@yourwebsite.com'[/email]; $subject = 'Download Area | Invalid Payment'; $message = ' Dear Administrator, A payment has been made but is flagged as INVALID. Please verify the payment manualy and contact the buyer. Buyer Email: '.$email.' '; $headers = 'From:noreply@yourwebsite.com' . "\r\n"; mail($to, $subject, $message, $headers); } } fclose ($fp); } ?> Thanks for taking a look. It's a really simple layout and would work perfectly for what I am doing... if it worked.
  5. We have a small Wordpress based site and we're using the WP E-commerce plugin to sell digital downloads. Everything is working, except the PayPal IPN function so when the customer pays he never receives the download e-mail until we change the transaction's status manually. Unfortunately it's not an option here because it's a digital download store so we have to fix the IPN somehow. My PHP knowledge is almost zero, so i'm here to ask some help from you guys. Store URL: http://brainwaveentrainment.eu WordPress version: 3.6.1 WP e-Commerce version: 3.8.12.1 Theme: Xyloto by Storefrontthemes I did this: Enabled IPN in Paypal with the store URL (http://brainwaveentrainment.eu) Enabled IPN in the PayPal Standard module. Send shipping details: No, Allow owerride: No. Currently i'm testing with a Sandbox account but it's not working with a live account either. I set up paypal to accept payments automatically also. I expected WP e-Commerce to do this: Modify the "Incomplete sale" status to "Accepted payment" Instead it did this: It's not changing the orders' status. It's pretty annoying. I tried everything, changed every setting, currency, IPN URL, etc but nothing helps. We want to start the store but we can't until it's not working. We purchased this theme and it's only working with this shopping cart so i can't just simply switch to a different e-commerce plugin. One IPN log from paypal: Notification URL http://brainwaveentrainment.eu/?wpsc...aypal_standard HTTP response code What's this? 200 Delivery status Sent No. of retries 0 Transaction ID 7W214573HJ105310Y IPN type Transaction made mc_gross=7.00&invoice=4151379432588&protection_eligibility=Eligible&address_status=confirmed&item_number1=531&tax=0.00&item_number2=568&payer_id=LYXHGVEQ4ASFN&address_street=1 Main St&payment_date=08:42:47 Sep 17, 2013 PDT&payment_status=Completed&charset=windows-1252&address_zip=95131&mc_shipping=0.00&mc_handling=0.00&first_name=Ferenc&mc_fee=0.50&address_country_code=US&address_name=Ferenc Szepesi's Test Store&notify_version=3.7&custom=&payer_status=verified&business=beatofficial@gmail.com&address_country=United States&num_cart_items=2&mc_handling1=0.00&mc_handling2=0.00&address_city=San Jose&verify_sign=AiPC9BjkCyDFQXbSkoZcgqH3hpacA.v.7UClmMzrTiiKgIJVSBufA1UT&payer_email=ferenc@szepesiweb.com&mc_shipping1=0.00&mc_shipping2=0.00&tax1=0.00&tax2=0.00&txn_id=7W214573HJ105310Y&payment_type=instant&payer_business_name=Ferenc Szepesi's Test Store&last_name=Szepesi&address_state=CA&item_name1=Gamma Energizer (Wind background), 45 minutes&receiver_email=beatofficial@gmail.com&item_name2=15 minutes relaxation Break (Wind chimes background)&payment_fee=0.50&quantity1=1&quantity2=1&receiver_id=5YKCMZKL6G46G&txn_type=cart&mc_gross_1=3.50&mc_currency=USD&mc_gross_2=3.50&residence_country=US&test_ipn=1&transaction_subject=&payment_gross=7.00&ipn_track_id=8542bf47e444e So it seems everything is working fine on the PayPal's side. I didn't gave up so i found this: The Paypal IPN log shows this URL in my case: http://brainwaveentrainment.eu/?wpsc...aypal_standard I tried to open this and i got this error message: "Fatal error: Cannot use object of type WP_Error as array in C:\xampp\htdocs\brainwaveentrainment.eu\wp-content\plugins\wp-e-commerce\wpsc-merchants\paypal-standard.merchant.php on line 400" On line 400 i found this: if ( 'VERIFIED' == $response['body'] ) { I googled for the error message and i found this fix: https://getsatisfaction.com/tweet_bl...error_as_array So i changed that line to look like this: if ( 'VERIFIED' == $response->body ) { Result: The error message is gone when i open that page! But... the IPN is still not working. I don't have PHP skills so i'm sure this single modification is not enough. Maybe somebody can help me with this here. I uploaded the original "paypal-standard.merchant.php" file's content to pastebin so you can check what's wrong with it: http://pastebin.com/9Dcd75LM Please help me if you can. I'm clueless and we really have to make this work somehow. I asked in the plugin's support forum too, but it's abandoned as a desert.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.