Hallo,
ik ben bezig met Paypal te implenteren op mijn site maar het werkt.
Na betaling wilt hij niet echt naar de success pagina gaan (wil het graag in 1 script houden).
Script is nog rommelig e.d. maar is om te testen, wie-o-wie kan me helpen?
Ik ontvang de betaling e.d. maar het wordt gewoon niet doorgevoerd naar de DB.
PHP
<?php
// PayPal instellingen
$paypal_url = 'https://www.paypal.com/cgi-bin/webscr'; //Test PayPal API URL
$paypal_id = '[email protected]'; //Business Email
if($_GET['id'] == '1'){
$pp_naam = '15 credits';
$pp_id = $_GET['id'];
$pp_prijs = '0.10';
}
elseif($_GET['id'] == '2'){
$pp_naam = '40 credits';
$pp_id = $_GET['id'];
$pp_prijs = '2.00';
}
elseif($_GET['id'] == '3'){
$pp_naam = '100 credits';
$pp_id = $_GET['id'];
$pp_prijs = '5.00';
}
elseif($_GET['id'] == '4'){
$pp_naam = '275 credits';
$pp_id = $_GET['id'];
$pp_prijs = '10.00';
}
?>
<div class="contentupper">
<h1>Credits kopen</h1>
</div>
<div class="contentdiv">
<div id="creditlinks">
<ul class="creditsmenu">
<li class="credits"><a class="active" href="?page=kopen&id=1"><i class="fa fa-cubes"></i> 15 credits - € 1,00</a></li>
<li class="credits"><a href><i class="fa fa-cubes"></i> 40 credits - € 2,00</a></li>
<li class="credits"><a href><i class="fa fa-cubes"></i> 100 credits - € 5,00</a></li>
<li class="credits"><a href><i class="fa fa-cubes"></i> 275 credits - € 10,00</a></li>
</ul>
</div>
<div id="creditrechts">
<?php
if($_GET['p'] == 'cancel' AND $_GET['id'] == ''){
echo'Mislukt / geannulleerd';
}
elseif($_GET['id'] == ''){
echo'Kies bla bla';
}
elseif($_GET['id'] == '1'){
?>
<form action="<?php echo $paypal_url; ?>" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="<?php echo $paypal_id; ?>">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="<?php echo $pp_naam; ?>">
<input type="hidden" name="item_number" value="<?php echo $pp_id; ?>">
<input type="hidden" name="amount" value="<?php echo $pp_prijs ?>">
<input type="hidden" name="currency_code" value="EUR">
<!-- Specify URLs -->
<input type='hidden' name='cancel_return' value='http://<?=$siteurl?>/?page=kopen&p=cancel'>
<input type='hidden' name='return' value='http://<?=$siteurl?>/?page=kopen&id=1&p=success'>
<!-- Display the payment button. -->
<input type="submit" name="submit" value="Koop via Paypal">
</form>
<?php
}
#Begin ID 1
elseif($_GET['p'] == 'success' && $_GET['id'] == '1'){
$item_number = $_GET['item_number'];
$txn_id = $_GET['tx'];
$payment_gross = $_GET['amt'];
$currency_code = $_GET['cc'];
$payment_status = $_GET['st'];
if(!empty($txn_id) && $payment_gross == '0.10'){
//Inser tansaction data into the database
mysqli_query($GLOBALS["___mysqli_ston"], "UPDATE `users` SET `belcredits`=`belcredits`+15,`kerengebeld`=`kerengebeld`+1 WHERE `login`='{$data->login}'")
or die("Er is een fout opgetreden. Je belcredits zijn NIET bijgeschreven!! Meld dit gelijk bij de webmaster.");
mysqli_query($GLOBALS["___mysqli_ston"], "INSERT INTO payments(item_number,txn_id,payment_gross,currency_code,payment_status) VALUES('".$item_number."','".$txn_id."','".$payment_gross."','".$currency_code."','".$payment_status."')");
$last_insert_id = $db->insert_id;
echo'Betaling gelukt. je betalings ID is '.$last_insert_id.'.';
}else{
echo'Betaling mislukt, gelieve dit te melden.';
}
}
#einde ID1
else{
echo'niets gevonden';
}
?>
</div>
</div>
Toon Meer
Alvast bedankt.
Tips en verbeteringen mogen zeker.