Hey cp,
Ik heb dus een Paysafecard betaal optie op mijn site waar de gebruiker zelf kiest hoeveel credits hij/zij wilt kopen. Als je dus 765 credits invult dan ga je deze kopen en het script berekent hierbij de prijs uit etc. Werkt 100% alleen ik maak me zorgen om de veiligheid van het script, als de betaling gelukt is word je namelijk naar het volgende gestuurd:
site.nl/wallie&aantal=765&trxid=13325047&ShoppingCartID=13325047
Niet echt veilig dus want bij de betaling kan je de trxid en shoppingcartid zien, je betaald dus, vult deze link even in met een aantal van bijvoorbeeld 10.000 en voila, voor 6 euro heb je 10.000 credits.
Hoe kan ik dit beveiligen zodat de gebruiker er niet mee kan klooien?
Deel van het script:
$aantal = $_POST['num_credits'];
# Set your rtlo ere
$iRtlo = ***;
if ( !isset ( $_GET['ShoppingCartID'] ) ) {
# To initiate a payment, initiate the class
$oWallie = new TargetPayWallie ( $iRtlo );
# Set wallie amount in cents so 500 cent will be 5 euro
$oWallie->setWallieAmount ( $am );
# Set wallie description
$oWallie->setWallieDescription ( 'site.nl '.$am.' credits kopen via Paysafecard!');
# Set return url, wich should return on succes
$oWallie->setWallieReturnUrl ( 'http://www.site.nl/ingame.php?p=wallie&aantal='.$aantal.'' );
/**
* OPTIONAL PARAMETERS FOR WALLIE
* UNCOMMENT IF YOU WANT TO USE
*/
$oWallie->setWallieCountry ( '31' ); // Set the country (optional)
$oWallie->setWallieLang ( 'NL' ); // Set wallie language (optional)
$oWallie->setWallieCurrency ( 'EUR'); // Set wallie currency ( optional )
# Now we can initiate the payment
$aReturn = $oWallie->startPayment();
# This is the transaction id
$intTrxId = $aReturn[0];
# this will be the bank url that will rederect to the bank.
$strURL = $aReturn[1];
# For check we can echo it here. (uncomment if you want to see. )
echo '<center>Je wordt binnen enkele seconden naar de betaalscherm gebracht. Gebeurt dit niet binnen 5 seconden, klik dan <strong><a href="'.$strURL.'">hier</a></strong>!</center>';
# Rederect your user now to:
?>
<meta http-equiv="refresh" content="3;URL=<?php echo $strURL; ?>" />
<?php
}
}
/**
* This function will validate the payment
*
*/
# ?action=vtrxid= 'trxid'
if ( isset ( $_GET['ShoppingCartID'] ) ) {
# Init the class
$oWallie = new TargetPayWallie ( $iRtlo );
# Test mode? 1 = test mode, 0 = normal
$iTest = 0;
# Once, only validate the payment once?
$iOnce = 1;
if ( $oWallie->validatePayment ( $_GET['ShoppingCartID'], $iOnce, $iTest ) == true ) {
mysql_query("UPDATE `users` SET `credits`=`credits`+".$aantal." WHERE `id`=".ID) or die(mysql_error());
Toon Meer
De $aantal var kan ik niet gebruiken want na deze var wordt de betaalscherm geopend en daarna kom je weer terug bij het script, de $_POST is dan niet meer geldig en daarom zit de $_GET er nu in verwerkt maar hoe kan ik dit beveiligen?
Alvast bedankt!