Visualizzazione dei risultati da 1 a 8 su 8

Discussione: IPN paypal

  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2016
    Messaggi
    17

    IPN paypal

    salve a tutti, ho utilizzato l'ipn di paypal per il mio sito, avendo aggiornato il php da 5.3 a 5.5 non funziona più la funziona sqlsrv_query apposto di essa ho usato odbc_exec che dovrebbe funzionare, invece non aggiorna nulla al database, la connessione con odbc_connecct funziona tutto okay, ma il resto no potete aiutarmi perfavore?
    Codice PHP:
    <?php    error_reporting(E_ALL);        // Require the configuration file    require_once('../config.php');        // The current time    $time = date("F j, Y, g:i a"); 
        // The database connection info    //$connection_info = array("UID" => $DATABASE_USER, "PWD" => $DATABASE_PASS, "Database" => $USER_DATABASE);    $conn = odbc_connect("Driver={SQL Server};Server=$DATABASE_HOST;Database=$USER_DATABASE",$DATABASE_USER,$DATABASE_PASS) or die('Database Connection Error!');    if(!$conn){        exit("Connection failed:".odbc_errormsg());    }     // Connect to the server    //$con = sqlsrv_connect($DATABASE_HOST, $connection_info);
        
    if (!$conn) die ("failed");    // The e-mail of the user submitting the payment    $payer_email = isset($_REQUEST['payer_email']) ? $_REQUEST['payer_email'] : die("Payer email value not set!");        // The email of the user receiving the payment    $receiver_email = isset($_REQUEST['receiver_email']) ? $_REQUEST['receiver_email'] : die("Receiver email value not set!");        // The payment status    $payment_status = isset($_REQUEST['payment_status']) ? $_REQUEST['payment_status'] : die("Payment status value not set!");        // The amount paid    $amount_paid = isset($_REQUEST['mc_gross']) ? $_REQUEST['mc_gross'] : die("Amount paid value not set!");        // The tax paid    $tax_paid = isset($_REQUEST['tax']) ? $_REQUEST['tax'] : die("Tax value not set!");        // Check if the payment status is completed, and the receiver email matches that in the configuration    if ($payment_status == "Completed" && $receiver_email == $PAYMENT_EMAIL) {                // The custom field set, to verify the correct details        $custom_variable = isset($_REQUEST['custom']) ? $_REQUEST['custom'] : die("Custom value not set!");
            // Split the field to an array        $custom_array = explode(":", $custom_variable);                // The User ID        $user_id = $custom_array[0];                // The custom amount paid        $custom_paid = $custom_array[1];                $insert_amountpay=odbc_exec($conn, "INSERT INTO PS_UserData.dbo.DonationTest (message, UserId) VALUES ('Amount paid: '$amount_paid', Custom paid: '$custom_paid ', Tax: ' $tax_paid '!', ' $user_id ')");                // Check if the product id exists        if (isset($DONATION_VALUES[$custom_paid])) {                        // The entry            $entry = $DONATION_VALUES[$custom_paid];                            $insert_tax=odbc_exec($conn, "INSERT INTO PS_UserData.dbo.DonationTest (message) VALUES ('Tax paid: '$tax_paid'!')");                        // Calculate the expected amount            $expected_amount = ($tax_paid != 0 ? ($amount_paid + $tax_paid) : $amount_paid);                        // Check the price and amount paid match            if ($custom_paid == $expected_amount) {                                $pagamento = odbc_exec($conn,"INSERT INTO PS_UserData.dbo.DonationTest (message, UserId) VALUES ('Points added: '$entry ' ! to', '$user_id')");                                                // The amount of points to give                $points = $entry;                                    // Check if the connection failed                if (!$conn) die("Connection to the database failed!");                                    // The query                                $updatepoints = odbc_exec($conn, "UPDATE PS_UserData.dbo.Users_Master SET Point += '$points' WHERE UserId = '$user_id'");                                                    // End the script                die("Donation successful! '$points' has been added to: ' $user_id'");            } else {                die("Request tempered! Mismatching payment amount!");                }        } else {                die("Value not found!");            }    }    odbc_close($conn);
    ?>
    fino quando c'era la funziona sqlsrv_query funzionava, effettuando questa modifica in odbc_exec non funziona più, usando il sandbox comunica con ipn e manda tutto il necessario, però alla verifica delle query non funziona.

    Utilizzo php 5.5.36 ed sql server 2012

    Grazie ancora
    Ultima modifica di AxelHack; 27-02-2016 a 14:35

  2. #2
    Moderatore di PHP L'avatar di Alhazred
    Registrato dal
    Oct 2003
    Messaggi
    12,445
    Hai dato un'occhiata al codice che hai postato? Non si capisce niente.
    Prima di inviare una discussione, visualizza l'anteprima ed assicurati che il codice sia ben formattato, se necessario sistemalo.

  3. #3
    Utente di HTML.it
    Registrato dal
    Feb 2016
    Messaggi
    17
    il forum in se ha scritto così appena ho messo la tag PHP
    Codice PHP:
    <?php 
        error_reporting
    (E_ALL);
        
        
    // Require the configuration file \n
        
    require_once('../config.php');
        
        
    // The current time\n
        
    $time date("F j, Y, g:i a"); 


        
    // The database connection info\n
        
    $conn odbc_connect("Driver={SQL Server};Server=$DATABASE_HOST;Database=$USER_DATABASE",$DATABASE_USER,$DATABASE_PASS) or die('Database Connection Error!');
        if(!
    $conn){
            exit(
    "Connection failed:".odbc_errormsg());
        } 
        
    // Connect to the server

        
    if (!$conn) die ("failed");
        
    // The e-mail of the user submitting the payment
        
    $payer_email = isset($_REQUEST['payer_email']) ? $_REQUEST['payer_email'] : die("Payer email value not set!");
        
        
    // The email of the user receiving the payment
        
    $receiver_email = isset($_REQUEST['receiver_email']) ? $_REQUEST['receiver_email'] : die("Receiver email value not set!");
        
        
    // The payment status
        
    $payment_status = isset($_REQUEST['payment_status']) ? $_REQUEST['payment_status'] : die("Payment status value not set!");
        
        
    // The amount paid
        
    $amount_paid = isset($_REQUEST['mc_gross']) ? $_REQUEST['mc_gross'] : die("Amount paid value not set!");
        
        
    // The tax paid
        
    $tax_paid = isset($_REQUEST['tax']) ? $_REQUEST['tax'] : die("Tax value not set!");
        
        
    // Check if the payment status is completed, and the receiver email matches that in the configuration
        
    if ($payment_status == "Completed" && $receiver_email == $PAYMENT_EMAIL) {
            
            
    // The custom field set, to verify the correct details
            
    $custom_variable = isset($_REQUEST['custom']) ? $_REQUEST['custom'] : die("Custom value not set!");


            
    // Split the field to an array
            
    $custom_array explode(":"$custom_variable);
            
            
    // The User ID
            
    $user_id $custom_array[0];
            
            
    // The custom amount paid\n
            
    $custom_paid $custom_array[1];
            
            
    $insert_amountpay=odbc_exec($conn"INSERT INTO PS_UserData.dbo.DonationTest (message, UserId) VALUES ('Amount paid: '$amount_paid', Custom paid: '$custom_paid ', Tax: ' $tax_paid '!', ' $user_id ')");
            
            
    // Check if the product id exists
            
    if (isset($DONATION_VALUES[$custom_paid])) {
                
                
    // The entry
                
    $entry $DONATION_VALUES[$custom_paid];
                    
                
    $insert_tax=odbc_exec($conn"INSERT INTO PS_UserData.dbo.DonationTest (message) VALUES ('Tax paid: '$tax_paid'!')");
               
                
    // Calculate the expected amount
                
    $expected_amount = ($tax_paid != ? ($amount_paid $tax_paid) : $amount_paid);
                
                
    // Check the price and amount paid match
                
    if ($custom_paid == $expected_amount) {
                    
                    
    $pagamento odbc_exec($conn,"INSERT INTO PS_UserData.dbo.DonationTest (message, UserId) VALUES ('Points added: '$entry ' ! to', '$user_id')");
                    
                    
                    
    // The amount of points to give
                    
    $points $entry;
                        
                    
    // Check if the connection failed
                    
    if (!$conn) die("Connection to the database failed!");
                        
                    
    // The query
                    
                    
    $updatepoints odbc_exec($conn"UPDATE PS_UserData.dbo.Users_Master SET Point += '$points' WHERE UserId = '$user_id'");
                                        
                    
    // End the script
                    
    die("Donation successful! '$points' has been added to: ' $user_id'");
                } else {
                    die(
    "Request tempered! Mismatching payment amount!");
                    }
            } else {
                    die(
    "Value not found!");
                }
        }
        
    odbc_close($conn);
    ?>
    ora va bene
    Ultima modifica di AxelHack; 28-02-2016 a 12:52

  4. #4
    Moderatore di PHP L'avatar di Alhazred
    Registrato dal
    Oct 2003
    Messaggi
    12,445
    Il forum scrive in base a cosa usi come carattere di ritorno a capo nei tuoi file (\n \r oppure \n\r)

    Continua ad usare i tag [php], ma prima di inviare il messaggio visualizza l'anteprima e se serve sistema i ritorni a capo.

  5. #5
    Utente di HTML.it
    Registrato dal
    Feb 2016
    Messaggi
    17
    Codice PHP:
    <?php 
        error_reporting
    (E_ALL);
        
        
    // Require the configuration file \n
        
    require_once('../config.php');
        
        
    // The current time\n
        
    $time date("F j, Y, g:i a"); 


        
    // The database connection info\n
        
    $conn odbc_connect("Driver={SQL Server};Server=$DATABASE_HOST;Database=$USER_DATABASE",$DATABASE_USER,$DATABASE_PASS) or die('Database Connection Error!');
        if(!
    $conn){
            exit(
    "Connection failed:".odbc_errormsg());
        } 
        
    // Connect to the server

        
    if (!$conn) die ("failed");
        
    // The e-mail of the user submitting the payment
        
    $payer_email = isset($_REQUEST['payer_email']) ? $_REQUEST['payer_email'] : die("Payer email value not set!");
        
        
    // The email of the user receiving the payment
        
    $receiver_email = isset($_REQUEST['receiver_email']) ? $_REQUEST['receiver_email'] : die("Receiver email value not set!");
        
        
    // The payment status
        
    $payment_status = isset($_REQUEST['payment_status']) ? $_REQUEST['payment_status'] : die("Payment status value not set!");
        
        
    // The amount paid
        
    $amount_paid = isset($_REQUEST['mc_gross']) ? $_REQUEST['mc_gross'] : die("Amount paid value not set!");
        
        
    // The tax paid
        
    $tax_paid = isset($_REQUEST['tax']) ? $_REQUEST['tax'] : die("Tax value not set!");
        
        
    // Check if the payment status is completed, and the receiver email matches that in the configuration
        
    if ($payment_status == "Completed" && $receiver_email == $PAYMENT_EMAIL) {
            
            
    // The custom field set, to verify the correct details
            
    $custom_variable = isset($_REQUEST['custom']) ? $_REQUEST['custom'] : die("Custom value not set!");


            
    // Split the field to an array
            
    $custom_array explode(":"$custom_variable);
            
            
    // The User ID
            
    $user_id $custom_array[0];
            
            
    // The custom amount paid\n
            
    $custom_paid $custom_array[1];
            
            
    $insert_amountpay=odbc_exec($conn"INSERT INTO PS_UserData.dbo.DonationTest (message, UserId) VALUES ('Amount paid: '$amount_paid', Custom paid: '$custom_paid ', Tax: ' $tax_paid '!', ' $user_id ')");
            
            
    // Check if the product id exists
            
    if (isset($DONATION_VALUES[$custom_paid])) {
                
                
    // The entry
                
    $entry $DONATION_VALUES[$custom_paid];
                    
                
    $insert_tax=odbc_exec($conn"INSERT INTO PS_UserData.dbo.DonationTest (message) VALUES ('Tax paid: '$tax_paid'!')");
               
                
    // Calculate the expected amount
                
    $expected_amount = ($tax_paid != ? ($amount_paid $tax_paid) : $amount_paid);
                
                
    // Check the price and amount paid match
                
    if ($custom_paid == $expected_amount) {
                    
                    
    $pagamento odbc_exec($conn,"INSERT INTO PS_UserData.dbo.DonationTest (message, UserId) VALUES ('Points added: '$entry ' ! to', '$user_id')");
                    
                    
                    
    // The amount of points to give
                    
    $points $entry;
                        
                    
    // Check if the connection failed
                    
    if (!$conn) die("Connection to the database failed!");
                        
                    
    // The query
                    
                    
    $updatepoints odbc_exec($conn"UPDATE PS_UserData.dbo.Users_Master SET Point += '$points' WHERE UserId = '$user_id'");
                                        
                    
    // End the script
                    
    die("Donation successful! '$points' has been added to: ' $user_id'");
                } else {
                    die(
    "Request tempered! Mismatching payment amount!");
                    }
            } else {
                    die(
    "Value not found!");
                }
        }
        
    odbc_close($conn);
    ?>

    cosi va bene.

  6. #6
    Moderatore di PHP L'avatar di Alhazred
    Registrato dal
    Oct 2003
    Messaggi
    12,445
    Non ricevi alcun messaggio d'errore?
    Prova amettere degli if anche per verificare che le query vadano a buon fine, per ora l'hai messo solo dopo la connessione, ma le cose potrebbero andare male anche dopo.
    Per esempio dopo
    Codice PHP:
    $insert_amountpay=odbc_exec($conn, ...); 
    metti
    Codice PHP:
    if ( ! $insert_amountpay ) { echo odbc_errormsg($conn); exit; }; 
    ma fallo per tutte le insert, almeno per ora finché non capisci cosa non funzioni.

    Ad occhio potresti avere problemi con gli apici nelle query, io questo
    Codice PHP:
    "INSERT INTO PS_UserData.dbo.DonationTest (message, UserId) VALUES ('Amount paid: '$amount_paid', Custom paid: '$custom_paid ', Tax: ' $tax_paid '!', ' $user_id ')" 
    proverei a scriverlo così
    Codice PHP:
    "INSERT INTO PS_UserData.dbo.DonationTest (message, UserId) VALUES ('Amount paid: $amount_paid, Custom paid: $custom_paid , Tax:  $tax_paid !', '$user_id')" 
    Ultima modifica di Alhazred; 28-02-2016 a 14:36

  7. #7
    Utente di HTML.it
    Registrato dal
    Feb 2016
    Messaggi
    17
    l'unico messaggio di errore è Payer email value not set!
    perchè non c'è un email inserita, in quanto IPN funziona con la paypal, quindi all'atto del pagamento esso ha i campi sotto stati, provare a rimuovere i campi che richiedono email e altro mi esce errore 500 del server, quindi quelli sono richiesti per funzionare , provato a rimuovere i "die" per ogni richiesta esterna, è sempre errore 500 del server, quindi non so come testate se esso mi dia un problema o meno

  8. #8
    Utente di HTML.it
    Registrato dal
    Feb 2016
    Messaggi
    17
    sistemato già da solo, grazie dell'aiuto.
    #richiesta di chiusura
    non so come funzioni qui xD

Tag per questa discussione

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.