问下做过paypal接口的朋友,使用paypal付款成功,然后接收paypal返回的值更改本网站订单状态,要怎样实现的! <input type="hidden" name="return" value="http://www.xxxx.com/dingdanreturn.php">
<!--交易完后自动返回的位置-->dingdanreturn.php页面怎样接收paypal返回的交易信息,网上查了多是不全面,请直接给代码,Thankyou!

解决方案 »

  1.   

    流程好像是先下单  然后去paypal付费查看付费后  后台更新订单状态!
      

  2.   

    用户用paypal支付完成后会跳转购物网站的接收页面dingdanreturn.php,把一些本次交易信息传递过去,比如交易成功或失败的状态、网站订单、商品价格、商品币种,现在的问题是dingdanreturn.php页面如何接收这些交易信息,得到交易成功的状态后更改本网站的订单状态,然后用户在本网站可以看到本次的交易成功信息!
      

  3.   


    paypal 有提供交易后返回值的接口么?  交易是跳转到 paypal上处理的
      

  4.   

    // read the post from PayPal system and add 'cmd'
    $req = 'cmd=_notify-validate';foreach ($_POST as $key => $value) {
      $value = urlencode(stripslashes($value));
      $req .= "&$key=$value";
    }// post back to PayPal system to validate
    $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) {
       // ERROR
       echo "$errstr ($errno)";
    } else {
       fputs ($fp, $header . $req);
       while (!feof($fp)) {
          $res = fgets ($fp, 1024);
         if (strcmp ($res, "VERIFIED") == 0) {
    // echo "WE ARE IN THE VERIFIED CYCLE<br>";
       if ($payment_status == "Completed"){}
           } else if (strcmp ($res, "INVALID") == 0) {
    if ($_REQUEST['table'] != 100) {
           }
       }
       fclose ($fp);
    }
      

  5.   

    出于项目安全问题,只能提供以上信息给你,可以借助这个并在paypal的官网上搜索资料。
      

  6.   

    本网站向paypal提交此次交易页面表单
    <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_blank"><input type="hidden" name="cmd" value="_xclick">  
    <!--// "_xclick" 立即购买--><input type="hidden" name="business" value="[email protected]"> 
     <!--//PayPal测试账户上的电子邮件地址--><input type="hidden" name="item_name" value="<? echo 'svnshops'.$dingdanhao; ?>">
    <!-- //物品名称--><input type="hidden" name="item_number" value="<? echo $dingdanhao; ?>">
    <!-- //购物单号--><input type="hidden" name="currency_code" value="GBP"> 
    <!--//定义币种以标示货币变量 值可以为 "USD"、"EUR"、"GBP"、"CAD"、"JPY"。 --><input type="hidden" name="amount" value="<? echo  $yinfu; ?>">
    <!-- //物品的价格--><input type="hidden" name="return" value="http://www.xxxx.com/dingdanreturn.php">
    <!--交易完后自动返回的位置--> <input type="image" src="http://www.paypal.com/zh_XC/i/btn/x-click-but01.gif" name="submit" alt="PayPal"></form>
    支付完成后从paypal跳转本网站的页面地址为:
    http://www.xxx.com/dingdanreturn.php?merchant_return_link=Return+to+fan+guanghong%27s+Test+Store为了弄清从paypal回传回来的信息用下面方法显示:
    foreach($_GET as $key => $value)
    {
      echo " Data: ".$key."  Values: ".$value." ----<br>";
     }显示的结果为:
    Data: merchant_return_link Values: Return to fan guanghong\'s Test Store ----
    请问dingdanreturn.php怎样才可以正确接收此次的交易信息,要代码,谢谢!
      

  7.   

    个人认为提交购买表单的值可能不全,我在paypal网站上费了九牛二虎之力终于找到了支付完成后回传值的示例代码,并修改dingdanreturn页面内容如下,
    <?php
    // read the post from PayPal system and add 'cmd'
    $req = 'cmd=_notify-synch';$tx_token = $_GET['tx'];
    $auth_token = "GX_sTf5bW3wxRfFEbgofs88nQxvMQ7nsI8m21rzNESnl_79ccFTWj2aPgQ0";
    $req .= "&tx=$tx_token&at=$auth_token";// post back to PayPal system to validate
    $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 possible, securely post back to paypal using HTTPS
    // Your PHP server will need to be SSL enabled
    // $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);if (!$fp) {
    // HTTP ERROR
    } 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)
    {
    // header has been read. now read the contents
    $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 the payment_status is Completed
    // check that txn_id has not been previously processed
    // check that receiver_email is your Primary PayPal email
    // check that payment_amount/payment_currency are correct
    // process payment
    $firstname = $keyarray['first_name'];
    $lastname = $keyarray['last_name'];
    $itemname = $keyarray['item_name'];
    $amount = $keyarray['payment_gross'];echo ("<p><h3>Thank you for your purchase!</h3></p>");echo ("<b>Payment Details</b><br>\n");
    echo ("<li>Name: $firstname $lastname</li>\n");
    echo ("<li>Item: $itemname</li>\n");
    echo ("<li>Amount: $amount</li>\n");
    echo ("");
    }
    else if (strcmp ($lines[0], "FAIL") == 0) {
    // log for manual investigation
    }}fclose ($fp);?>现在支付完后跳转的地址为:http://www.xxx.com/dingdanreturn.php?merchant_return_link=Return+to+fan+guanghong%27s+Test+Store
    ,明显地址里的参数并没有dingdanreturn所需要的参数,从这个地址再往前一步,估计就是购买提交表单页面的问题,可能少了某些要提交的参数,还在分析解决中,望大家指教!
      

  8.   

    paypal官方的文档,你采用paypal的哪种付费api呢?
      

  9.   

    要放在notfiy_url的页面里处理,
    return_url只是给用户支付完毕后返回的页面,一般只显示"谢谢"等信息
    notify_url是用来给paypal在处理该交易过程中通知你网站的(不一定是支付成功),从该页面就可以读到完整的信息代码,在paypal上有demo code,基本照着改就行
      

  10.   

    己找到新的php paypal支付方法,支付完成后跳转回购物网站更新订单支付状态,有点复杂!
    结贴给大家散分了!
      

  11.   

    楼主能分享找到的新php paypal支付方法吗?谢谢~~