אשכול: שאלה | PAYPAL
View Single Post
ישן 14-07-09, 14:39   # 1
Hezi & BomBas
חבר בקהילה
 
מיני פרופיל
תאריך הצטרפות: May 2008
הודעות: 325
שלח הודעה באמצעות ICO אל Hezi & BomBas שלח הודעה באמצעות MSN אל Hezi & BomBas

Hezi & BomBas לא מחובר  

שאלה | PAYPAL

היי, אני כרגע בונה מערכת קטנה המשלבת תשלום ישיר באמצעות PAYPAL.
את התשלום כבר בניתי והכל בסדר, הגדרתי גם כתובת חזרה לאחר התשלום. השאלה שלי - איך אני מוודא שהמשתמש אכן שילם ולא סתם נכנס לכתובת המתבקשת? תודה.

זה הקוד שלי:
PHP קוד:
    require "config.php";

    
    
$req = 'cmd=_notify-synch';
    
    
$tx_token = $_GET['tx'];
    
$req .= "&tx=$tx_token";
    
    
// post back to PayPal system to validate the payment.
    
    
$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";
    
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
    
    if ( ! 
$fp )
    {
        
$output = 'Error opening PayPal';
    }
    else
    {
        
fputs ($fp, $header . $req);
        
// Read the body data .
        
$res = '';
        
$headerdone = false;
        while ( ! 
feof($fp) )
        {
            
$line = fgets ($fp, 1024);
            if (
strcmp($line, "\r\n") == 0) {
            
// Read the header.
            
$headerdone = true;
            }
            else if (
$headerdone)
            {
                
$res .= $line;
            }
        }
        
        
// 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 if the payment_status has been Completed.
            // check that the receiver_email is your Primary PayPal email.
            // check that payment_amount/payment_currency are correct.
            // Process payment.
            
            
$output = $_GET['item_name'];
        
        }
        else
        {
            
$output = 'error';
        }
    }
    
    print 
$output; 
אחרי הקנייה הוא מדפיס "error".
  Reply With Quote