2011-06-14 148 views
0

的价值没有人知道如何检索PayPal快速结账的隐藏输入自定义变量一旦付款重定向到感谢页面?用户,这里是我的代码检索贝宝自定义变量

<form action="https://sandbox.paypal.com/cgi-bin/webscr" method="post"> 
<input type="hidden" name="cmd" value="_cart"> 
<input type="hidden" name="business" value="[email protected]"> 
<input type="hidden" name="item_name" value="<?php echo $this->input->get('GeneralHealth').'test'; ?>"> 
<input type="hidden" name="item_number" value="<?php echo $this->input->get('GeneralHealth'); ?>"> 
<input type="hidden" name="amount" value="<?php foreach($query3->result() as $row){echo $row->price; } ?>"> 
<input type="hidden" name="quantity" value="1" disabled="disabled"> 
<input type="hidden" name="currency_code" value="USD"> 
<input type="hidden" name="custom" value="<?php $id = $this->ion_auth->get_user(); echo $id->id; ?>" /> 
<input type=hidden name=notify_url value="http://ci/paragon/site/thankyou" /> 
<input type="hidden" name="return" value="http://ci/paragon/index.php/site/thankyou"/> 
<input type="image" id="checkout" src="https://www.paypal.com/images/x-click-but6.gif" Border="0" name=submit><br> 
<input type="hidden" name="add" value="1"></form> 

那里,基于上面的代码,我将如何获得自定义隐藏字段的值?

+0

请注意使用Paypal自定义变量,特别是使用包含amersands的值。由于我们能够在我们的生产系统上多次复制,所以它们间歇性地失败。 – 2017-03-21 03:35:04

回答

0

根据我的经验,您可以执行PayPal的API调用之一,以根据您的PayPal凭证和由于成功购买而由PayPal生成的令牌来接收交易详情。退房Step 2C

+0

先生,我可以问一个示例代码吗? – sasori 2011-06-14 21:00:16

+0

[大多数PayPal API的示例代码](https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/library_code) – Josh 2011-06-15 19:45:13

0

在您自己的贝宝账户中,您应该指定一个贝宝将在确认交易时联系的脚本。同一页面应该再次打开与PayPal的另一个连接,以确认该源是有效的。从第一个请求开始,您应该会收到您需要的所有信息。

这里是我使用的代码:

//posts transaction data using fsockopen. 
function fsockPost($url,$data) { 

    //Parse url 
    $web=parse_url($url); 

    //build post string 
    foreach($data as $i=>$v) { 

     $postdata.= $i . "=" . urlencode($v) . "&"; 

    } 
    $postdata.="cmd=_notify-validate"; 

    //Set the port number 
    if($web[scheme] == "https") { 

     $web[port]="443"; 
     $ssl="ssl://"; 

    } else { 

     $web[port]="80"; 

    } 

    //Create paypal connection 
    [email protected]($ssl . $web[host],$web[port],$errnum,$errstr,30); 

//Error checking 
    if(!$fp) { 

     echo "$errnum: $errstr"; 

    } else { //Post Data 

     fputs($fp, "POST $web[path] HTTP/1.1\r\n"); 
     fputs($fp, "Host: $web[host]\r\n"); 
     fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); 
     fputs($fp, "Content-length: ".strlen($postdata)."\r\n"); 
     fputs($fp, "Connection: close\r\n\r\n"); 
     fputs($fp, $postdata . "\r\n\r\n"); 

     //loop through the response from the server 
     while(!feof($fp)) { 

      $info[][email protected]($fp, 1024); 

     } 

     //close fp - we are done with it 
     fclose($fp); 

     //break up results into a string 
     $info=implode(",",$info); 

    } 

    return $info; 

} 

$result=fsockPost("http://www.paypal.com/cgi-bin/webscr", $_POST); 

$ result变量(底部)中填充有响应文本(其用作验证,这是来自PayPal)。来自该脚本的第一次调用(应该来自PayPal)的POST值应该包含您需要的所有信息。这里是($ POSTDATA)的样本转储(细节已经改变...杜):

mc_gross=15.00&protection_eligibility=Ineligible&address_status=confirmed&payer_id=123456789T4JL&tax=0.00&address_street=23+23rd+Ave&payment_date=39%3A42%3A34+Feb+23%2C+2011+PST&payment_status=Completed&charset=windows-1252&address_zip=12345&first_name=John&mc_fee=0.81&address_country_code=US&address_name=John+Doe&notify_version=3.0&custom=&payer_status=verified&business=yourbusiness.com&address_country=United+States&address_city=NYC&quantity=1&verify_sign=AShYUCI1AJfCySIHj5coaxvlUU.RAHLmp.bWuPpa4vyNvWgV9qowpF3f&payer_email=payer_mail%40gmail.com&txn_id=48661819D0514811P&payment_type=instant&last_name=Doe&address_state=NY&receiver_email=your%40mail.com&payment_fee=0.81&receiver_id=RVBKNFXM3HCQL&txn_type=web_accept&item_name=Donation+-+23j&mc_currency=USD&item_number=d565ef66e70&residence_country=US&handling_amount=0.00&transaction_subject=Donation+-+23j&payment_gross=15.00&shipping=0.00&cmd=_notify-validate 

让我知道这是否有帮助。

+0

我可以要求示例代码先生吗? – sasori 2011-06-14 21:18:50

0

cm GET var保存自定义隐藏字段的值,当PayPal重定向回您的网站时。