代码之家  ›  专栏  ›  技术社区  ›  weng tee

通过返回url获取买家名称和送货地址

  •  1
  • weng tee  · 技术社区  · 7 年前

    我正在试验 PayPal-sandbox 对于一个网上商店,我正在努力建立。由于它目前的立场,买家只需选择一个产品,点击一口价按钮,然后被发送到贝宝完成交易。

    enter image description here

    一切正常,但我想知道是否也有可能从贝宝表捕获买家的名称和使用返回网址送货地址。

    function process_transaction() {
    
    
    
    if(isset($_GET['tx'])) { // ie. if transaction sale has been completed....
    
    $amount = $_GET['amt']; // get amount details for our db
    $currency = $_GET['cc'];
    $transaction = $_GET['tx']; // get transaction details and we will bump into our db
    $status = $_GET['st']; // get status, ie completed
    $total = 0; // default product total variables set to zero in the first instance 
    $item_quantity = 0;   // default quantity variable set to zero 
    
    
    
    
    $send_order = query(" INSERT INTO orders (order_amount, order_transaction, order_status, order_currency) VALUES('{$amount}','{$transaction}','{$status}','{$currency}')");
    
    
    
    confirm($send_order); 
    
    
    $last_id = last_id(); 
    
    
    
    foreach ($_SESSION as $name => $value) { 
    
    
    if($value > 0 ) { 
    
    
    if(substr($name, 0, 8) == "product_") { 
    
    
    $length = strlen($name) - 8; 
    
    $id = substr($name, 8 , $length);
    
    
    
    
    $query = query(" SELECT * FROM products WHERE product_id = " . escape_string($id). " " );
    
    confirm($query);
    
    
    
    while ($row = fetch_array($query)) {
    
    $product_price = $row['product_price'];
    $sub = $row['product_price']*$value;
    $item_quantity +=$value;
    
    
    
    $insert_report = query(" INSERT INTO reports (product_id, order_id, product_price, product_quantity) VALUES('{$id}','{$last_id}','{$product_price}','{$value}')");
    confirm($insert_report); //runs the confirm helper method  
    
    
    
    
    } // end of while loop
    
    
    $total += $sub; 
    echo $item_quantity; 
    
    
    } // end of substring if statement
    
    
    
    
    }
    
    
    
    
    } 
    
    
    session_destroy();
    
    } else {
    
    
    redirect("index.php");
    
    
    } 
    
    
    
    
    } 
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   yinken    7 年前

    您添加到数据库中的信息来自URL字符串,如您所说,使用PHP $amount = $_GET['amt'] ,等等。如果买家的姓名和所有其他信息包含在该字符串中,则必须以相同的方式进行解析,例如以“&customer\u name=firstname\u lastname”的形式。

    不过,我猜不会。以这种方式传输任何敏感数据是完全不安全的。

    您必须从其他来源获取客户信息。你应该得到它无论如何,因为你将不得不收集它在您的网上商店在一个点。

    推荐文章