Insert cod in baza de date dupa plata PayPal
Discutii despre script-uri si coduri PHP-MySQL, precum si lucru cu XML in PHP.
-
k0rupe
- Mesaje:20
Insert cod in baza de date dupa plata PayPal
Salut marplo
Cum asi putea imediat dupa ce fac o plata prin paypal sa imi insereze un cod in baza de date.
Cu generarea codului am rezolvat as:
Cod: Selectaţi tot
<?php
function generateRandomString($length) {
$characters = '0123456789';
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
return $randomString;
}
$string = generateRandomString(20);
echo substr(chunk_split($string, 5, '-'), 0, -1);
?>
Dar nu ma pricep deloc la paypal.
Edit:
- Cred ca am rezolvat, o sa revin.
k0rupe
Mesaje:20
Dupa ce fac plata prin paypal ma redirectioneaza catre:
Dar in loc de:
Cod: Selectaţi tot
<div id='form-content'><div class='success'>Thank you for your payment, we will contact you shortly!</div></div>
Sa imi arate un cod + inserarea lui in baza de date. (ASTA O REZOLV EU!!)
Problema ar fi ca oricine poate accesa:
fara sa plateasca.
Cum sa procedez ?
Exclus trimiterea codului prin email.
Cod: Selectaţi tot
<?php
switch ($_GET['action']) {
case 'success': // Order was successful...
echo "<div id='form-content'><div class='success'>Thank you for your payment, we will contact you shortly!</div></div>";
break;
case 'cancel': // Order was canceled...
echo "<div id='form-content'><div class='cancelled'>The payment was canceled!</div><a href='".$script_base."'>Click here</a> to return to terminal</div>";
break;
case 'ipn': // Paypal is calling page for IPN validation...
if ($paypal->validate_ipn()) {
//-----> send notification
//creating message for sending
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
$headers .= "From: '".$title."' <".$store_email."> \n";
$subject = "New Payment Received";
$message = "New payment was successfully recieved through paypal payment terminal \n";
$message .= "from ".$paypal->pp_data['payer_email']." on ".date('m/d/Y');
$message .= " at ".date('g:i A');
mail($admin_email,$subject,$message,$headers);
//-----> send notification end
}
break;
}
?>
Subiecte similare
- Adaugare orar zilele saptamanii in baza de date
PHP - MySQL - XML
Primul mesaj
Salut
Am o baza de date cu toate locatiile
location_id | name |address |telephone | open
Si un formular prin care incarc datele in bd....
Ultimul mesaj
Treaba cu adaugare json in mysql e simpla, se rezuma la adaugarea unui sir care contine ghilimele duble.
Problema la tine e ca acele ghilimele sunt...