1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Fixed PayPal.php - works now!!!

Discussion in 'Optigold ISP' started by Mia, Aug 2, 2007.

  1. #1
    I am guessing that this paypal.php never worked.. I don't see how it could. If anyone wants to get it to work, we have fixed the file. The receiver and sender emails were mixed up, which was causing the file not to send the correct email address to OG, hence the file never worked.


    <?php
    	
    	// Settings
    	
    	$paypal_key = "yourkeyhere";						// *** CHANGE THIS!!! ***   This should match what you have set under Maintenance & Preferences -> General Preferences -> Billing
    	$paypal_email = "your-email@here.com";		// This should be your PayPal email address (used for verification purposes)
    	$email_success = TRUE;							// Do you want to email the above address when it was inserted into Optigold successfully?
    	$email_failure = TRUE;							// Do you want to email the above address when the transaction failed to be inserted into Optigold?
    	$optigold_url = "http://your-web-server-IP-here:591";	// Your machine running FileMaker Unlimited or WSC (no trailing slash needed).
    
    
    
    
    
    
    	// 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 ('www.paypal.com', 80, $errno, $errstr, 30);
    
    	// assign posted variables to local variables
    	$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'];
    
    	if (!$fp) {
    		// HTTP ERROR
    	} else {
    		fputs ($fp, $header . $req);
    		while (!feof($fp) && $fp) {
    			$res = fgets ($fp, 1024);
    		}
    		if (strcmp ($res, "VERIFIED") == 0) {
    			// 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
    			
    			$fp = fopen ($optigold_url . "/FMPro?-db=MainMenu.fp5&-lay=Web&-max=1&-script=PayPal&-format=paypal.txt&Miscellaneous+1=" . urlencode ($paypal_key) . "&Miscellaneous+2=" . urlencode ($payer_email) . "&Identification=" . urlencode ($payment_amount) . "&Miscellaneous+3=" . urlencode ($txn_id) . "&-Find", "r");
    			while (!feof ($fp) && $fp) {
    				$result .= fgets ($fp, 1024);
    			}
    			fclose($handle);
    			
    			if ($result == "success" && $email_success) {
    				mail($paypal_email, "PayPal Transaction Complete", "A PayPal payment was successfully entered into Optigold.\n\nFrom: " . $payer_email . "\nAmount: " . $payment_amount . "\nTransaction ID: " . $txn_id);
    			} elseif ($email_failure) {
    				mail($paypal_email, "PayPal Transaction Failed", "A PayPal payment failed to be inserted into Optigold.\n\nFrom: " . $payer_email . "\nAmount: " . $payment_amount . "\nTransaction ID: " . $txn_id . "\n\n\n" . $result);
    			}			
    			
    		} elseif (strcmp ($res, "INVALID") == 0) {
    			// log for manual investigation
    			mail($paypal_email, "PayPal Transaction Failed", "A request to insert a PayPal transaction into Optigold ISP failed because it could not be validated by PayPal.\n\nRequest was from: " . $_SERVER['REMOTE_ADDR']);
    		}
    	fclose ($fp);
    	}
    ?>
    
    Code (markup):
    We also fixed the grammar errors in some of the error responses as well...
     
    Mia, Aug 2, 2007 IP
    GTech, bordello and Will.Spencer like this.
  2. uditbhargava_2001

    uditbhargava_2001 Banned

    Messages:
    185
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    thx for providing , really needed it
     
    uditbhargava_2001, Aug 3, 2007 IP
  3. Mia

    Mia R.I.P. STEVE JOBS

    Messages:
    23,694
    Likes Received:
    1,167
    Best Answers:
    0
    Trophy Points:
    440
    #3
    Not a problem... Now to try to integrate this into our ordering sytem/pages... Fun, fun....
     
    Mia, Aug 4, 2007 IP
  4. pifko

    pifko Active Member

    Messages:
    510
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    60
    #4
    what is this for? proxys?
     
    pifko, Aug 24, 2007 IP
  5. neelesh

    neelesh Peon

    Messages:
    141
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    That's a cute little, handy script. Thanks dude
     
    neelesh, Aug 25, 2007 IP
  6. MazaWood.com

    MazaWood.com Peon

    Messages:
    524
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Can I know what this script is??? I mean for what it is used????
     
    MazaWood.com, Aug 26, 2007 IP
  7. Mia

    Mia R.I.P. STEVE JOBS

    Messages:
    23,694
    Likes Received:
    1,167
    Best Answers:
    0
    Trophy Points:
    440
    #7
    No.

    The script is for accepting paypal payments using Optigold.

    Well, someone else wrote it, but it did not work.. Not sure if they just half assed it or what.. We just fixed it so it worked was all.

    For accepting paypal payments using Optigold.
     
    Mia, Aug 27, 2007 IP
  8. bfblackjack

    bfblackjack Peon

    Messages:
    134
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Awesome! Thank you very much for this! Good work! ;)
     
    bfblackjack, Aug 28, 2007 IP
  9. Mia

    Mia R.I.P. STEVE JOBS

    Messages:
    23,694
    Likes Received:
    1,167
    Best Answers:
    0
    Trophy Points:
    440
    #9
    No problem...
     
    Mia, Aug 29, 2007 IP
  10. serge20

    serge20 Banned

    Messages:
    321
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #10
    i got one for www.sanitywars.com , when someone donates to the paypal specified it registers the username that payed , the date , and the amount
     
    serge20, Aug 30, 2007 IP
  11. Mia

    Mia R.I.P. STEVE JOBS

    Messages:
    23,694
    Likes Received:
    1,167
    Best Answers:
    0
    Trophy Points:
    440
    #11

    And you're using OG?
     
    Mia, Aug 30, 2007 IP
  12. rewindd

    rewindd Guest

    Messages:
    69
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    thanks, I have been looking for this everywhere. this one finally works.
     
    rewindd, Sep 1, 2007 IP
  13. Gnet

    Gnet Peon

    Messages:
    5,340
    Likes Received:
    529
    Best Answers:
    0
    Trophy Points:
    0
    #13
    I'm just wondering, how come there are so many bugs in this product when its owned and controlled by such a big software programmer?
     
    Gnet, Sep 2, 2007 IP
    Mia likes this.
  14. Mia

    Mia R.I.P. STEVE JOBS

    Messages:
    23,694
    Likes Received:
    1,167
    Best Answers:
    0
    Trophy Points:
    440
    #14
    Not a problem...

    :p
     
    Mia, Sep 4, 2007 IP
    Gnet and SecureWebDev like this.
  15. weiqi

    weiqi Peon

    Messages:
    136
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #15
    thanks, I have been looking for this everywhere. this one finally works.
     
    weiqi, Sep 16, 2007 IP
  16. bugmenot

    bugmenot Banned

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Nice script! I'll try it out :D
     
    bugmenot, Sep 17, 2007 IP
  17. n3o_the_on3

    n3o_the_on3 Well-Known Member

    Messages:
    1,422
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    165
    #17
    Very handy script and thanks to Mia for his excellency.
     
    n3o_the_on3, Sep 23, 2007 IP
  18. Univ

    Univ Peon

    Messages:
    161
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #18
    You guys must be an expert to write this script! Thanks a lot!
     
    Univ, Nov 16, 2007 IP
  19. Mia

    Mia R.I.P. STEVE JOBS

    Messages:
    23,694
    Likes Received:
    1,167
    Best Answers:
    0
    Trophy Points:
    440
    #19
    Someone else wrote it, we just fixed it..
     
    Mia, Nov 16, 2007 IP
  20. providerman

    providerman Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    thanx u i was lookin for it
     
    providerman, Nov 17, 2007 IP