Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 09:59

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Paypal Donate Script / Buy Now Button

Discussion on Paypal Donate Script / Buy Now Button within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Dec 2012
Posts: 36
Received Thanks: 4
Paypal Donate Script / Buy Now Button

hi epvpers,

ich habe mir aus den released homepages die DamnedRev3_Shadow HP runtergeladen. Dort ist ein fertiges Paypal-Script bereits integriert.
Das Paypal-Button-Script (Buy-Now-Button) habe ich natürlich angepasst.
Es funktioniert insofern, dass ich die Zahlung auf meinem Paypal-Konto erhalte. Aber es wird kein Datenbankeintrag erstellt.

Nach der Zahlung soll ja eine IPN an meine homepage geschickt werden (an die payed.php). Diese php datei soll dann die daten von paypal überprüfen und in die mssql datenbank die donatepoints eintragen.

Also entweder ist mein paypalbutton falsch konfiguriert, oder das script ist falsch, oder das was paypal als bestätigung des kaufs schickt wird blockiert (ports..).

Habe die ports 80, 443 tcp freigegeben auf meinem Root.

payed.php:

Code:
<?php
	include('inc/config.inc.php');
	
	// 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";
	
		//If testing on Sandbox use:
	  $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
	//$fp = fsockopen ('ssl://www.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) {
				// check the payment_status is Completed DONE
				// check that txn_id has not been previously processed DONE
				// check that receiver_email is your Primary PayPal email DONE
				// check that payment_amount/payment_currency are correct DONE
				// process payment DONE
				
				//$checktxn = mysql_query('SELECT COUNT(*) as count FROM `'.TABLE_PREFIX.'donationlogs` WHERE `txn_id`=\''.mysql_real_escape_string($_POST['txn_id']).'\'');
				odbc_exec($mssql, 'USE [WEBSITE_REV3]');
				$result = odbc_exec($mssql, 'SELECT * FROM [rev3_pplogs] WHERE txn_id=\''.mysql_real_escape_string($_POST['txn_id']).'\'');
				$total_rows = odbc_num_rows($result);
				if($_POST['payment_status'] == 'Completed') {
					$status = true;
				} else {
					$status = false;
				}
				if($total_rows == 0) {
					$txn = true;
				} else {
					$txn = false;
				}
				
				if($_POST['receiver_email'] == $_CONFIG['ppemail']) {
					$receiver = true;
				} else {
					$receiver = false;
				}
				if($_POST['mc_currency'] == 'EUR') {
					$eur = true;
				} else {
					$eur = false;
				}
				$dp = $_POST['option_selection1'];
				switch($dp) {
					case '1200': if($_POST['mc_gross'] == '10.00') { $amount = true; }; break;
					case '2500': if($_POST['mc_gross'] == '20.00') { $amount = true; }; break;
					case '6500': if($_POST['mc_gross'] == '50.00') { $amount = true; }; break;
					case '13000': if($_POST['mc_gross'] == '100.00') { $amount = true; }; break;
					/* NORMAL
					case '1000': if($_POST['mc_gross'] == '10.00') { $amount = true; }; break;
					case '2000': if($_POST['mc_gross'] == '20.00') { $amount = true; }; break;
					case '5250': if($_POST['mc_gross'] == '50.00') { $amount = true; }; break;
					case '11000': if($_POST['mc_gross'] == '100.00') { $amount = true; }; break;
					*/
					default: $amount = false; break;
				}
				if(($status == true) && ($txn == true) && ($receiver == true) && ($eur == true) && ($amount == true)) {
					$worth = $_POST['mc_gross'];
					$worth = str_replace('.', ',', $_POST['mc_gross']);
					odbc_exec($mssql, 'USE [WEBSITE_REV3]');
					odbc_exec($mssql, 'INSERT INTO [rev3_pplogs] (txn_id, account, worth, email, datetime) VALUES(\''.mssql_escape_string($_POST['txn_id']).'\', \''.mssql_escape_string($_POST['option_selection2']).'\', \''.mssql_escape_string($worth).'\', \''.mssql_escape_string($_POST['payer_email']).'\', \''.date('d.m.Y H:i:s').'\')');
					odbc_exec($mssql, 'USE [ACCOUNT_DBF]');
					odbc_exec($mssql, 'UPDATE [ACCOUNT_TBL] SET cash=cash+\''.mssql_escape_string($dp).'\' WHERE account=\''.mssql_escape_string($_POST['option_selection2']).'\'');
				}
				
				// echo the response
				echo "The response from IPN was: <b>" .$res ."</b><br><br>";
				
				//loop through the $_POST array and print all vars to the screen.
	
				foreach($_POST as $key => $value){
						echo $key." = ". $value."<br>";
				}
			} else if (strcmp ($res, "INVALID") == 0) {
				// log for manual investigationk
				// echo the response
				echo "The response from IPN was: <b>" .$res ."</b>";
			}
		}
		fclose ($fp);
	}
?>

Hier ist noch ein anderes Paypal Script, welches einfach nur die Daten, die paypal sendet, ausgeben soll. Dies hat auch nicht ganz funktioniert.

Code:
<?php
 
$pp_hostname = "www.paypal.com"; // Change to [url]www.sandbox.paypal.com[/url] to test against sandbox
 
 
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';
 
$tx_token = $_GET['tx'];
$auth_token = "uz14k8H0gpDXY_Xhjc2j_b_c8pwNajYmbWc4pcRDrBrb31kezIz-YpNUdi";
$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 ("<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
    }
}
 
?>
 
 
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>
takischa is offline  
Old 05/05/2013, 13:11   #2
 
elite*gold: 0
Join Date: Dec 2012
Posts: 36
Received Thanks: 4
hat echt keiner ne ahnung davon? ich mein das script wurd ja released. sollte ja richtig sein. frage is nur was muss man sonst noch alles einstellen bei seinem paypal konto, damit das läuft?
takischa is offline  
Old 05/05/2013, 17:24   #3
 
elite*gold: 0
Join Date: Apr 2009
Posts: 243
Received Thanks: 32
Ich denke mal nicht das du die Sandboxversion von Paypal verwendest also:

Quote:
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
//$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
zu

Quote:
//$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
ändern. Ansonsten probier es erstmal aus, sonst helfe ich dir mal per Skype...
lanzelord996 is offline  
Old 05/05/2013, 18:12   #4
 
elite*gold: 0
Join Date: Dec 2012
Posts: 36
Received Thanks: 4
ja das ist richtig, hatte es mal mit sandbox versucht. jez stehts wieder auf normal. sandbox suckt, krieg keinen account mit bankverbindung eingerichtet. deswegen muss ich warten bis jemand donated.
ok, ich schreib dir meinen skype-namen. danke
takischa is offline  
Old 05/06/2013, 12:30   #5


 
Reavern's Avatar
 
elite*gold: 15
Join Date: May 2010
Posts: 5,996
Received Thanks: 2,283
Arrow Flyff PServer - Discussions / Questions -> Web Development

#moved
Reavern is offline  
Old 05/06/2013, 13:37   #6
 
KoKsPfLaNzE's Avatar
 
elite*gold: 0
Join Date: Jan 2009
Posts: 731
Received Thanks: 233
kann mir das auf wunsch auch angucken, und das mit meinen eigenen scripts bissel abstimmen.

skype: olli.coder
KoKsPfLaNzE is offline  
Old 05/07/2013, 10:18   #7


 
elite*gold: 0
Join Date: Feb 2010
Posts: 7,220
Received Thanks: 6,758
Hast du dir den Paypalbutton direkt von der Paypal API geholt? Wenn nicht, tu das ;-)
#SoNiice is offline  
Reply


Similar Threads Similar Threads
[Hilfe]Donate Script
01/21/2013 - Web Development - 6 Replies
Hallo Community, ich habe noch nicht so viel erfahrung was php angeht und brauche da mal etwas hilfe. Es sind viele funkten und sachen doppelt oder unnütz das weis ich auch :) Wo ich hilfe bei brauch einen dump schutz dort einzufügen damit man die DB nicht voll spammt so einfach. Und vielleicht eine eine vereinfachte version währe auch hilfreich. Funktionen: <?php
[S]Psc Donate Script [B]85 E*Gold
10/16/2012 - Coders Trading - 3 Replies
Heyho Leute :D , Ich komme mal auf den Punkt und suche ein PSC Donate Script für meinen Server :) Ich würde euch mit 85 E*Gold bezahlen :) Mfg , Weekend.
Moneybookers/Skrill donate button gesucht
09/11/2012 - elite*gold Trading - 0 Replies
hab jemanden gefunden :) *closed*
Paypal Donate Script?
03/12/2012 - Flyff Private Server - 22 Replies
Guten Tag e*Pvper's Ich wollte mal Fragen ob es ein Donation Script über Paypal gibt. Wo man aber auch natürlich auswählen muss wieviele Points und dann Spenden muss in Logs gespeichert wird und dann bekommt man die Coins. Habe bei Google nichts gefunden. Danke aber schonmal im Vorraus! Mit freundlichen Grüßen RyukTheShinigami
[Release] Donate Script
10/20/2011 - Flyff PServer Guides & Releases - 29 Replies
Hi, da mir aufgefallen ist das es noch garnicht so ein donate script gibt. Dachte ich mir ich release mal meins. PHP Code : <?php $server = "DEINSERVER\SQLEXPRESS"; $user = ""; $pass= ""; $username = $_POST; $password = $_POST;



All times are GMT +1. The time now is 09:59.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.