【问题标题】:retrieve value of paypal custom var检索贝宝自定义变量的值
【发布时间】:2011-09-15 01:08:23
【问题描述】:

有谁知道一旦付款将用户重定向回感谢页面后如何检索贝宝快速结帐的隐藏输入自定义变量?,这是我的代码

<form action="https://sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="test@gmail.com">
<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>   

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

【问题讨论】:

  • 在使用 Paypal 自定义变量时要小心,尤其是对于包含 amersands 的值。它们间歇性地失败,因为我们已经能够在我们的生产系统上多次复制。

标签: php codeigniter paypal


【解决方案1】:

根据我的经验,您执行 PayPal 的一个 API 调用,以根据您的 PayPal 凭据和 PayPal 因成功购买而生成的令牌接收交易详细信息。查看Step 2C

【解决方案2】:

在您自己的 PayPal 帐户中,您应该指定一个脚本 PayPal 将在确认交易时联系。同一页面应再次打开与 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
    $fp=@fsockopen($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[]=@fgets($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) 的示例转储(细节已被更改...duh):

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

如果有帮助,请告诉我。

【讨论】:

    【解决方案3】:

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

    【讨论】:

      猜你喜欢
      • 2012-06-29
      • 2019-06-08
      • 2013-05-07
      • 2010-12-22
      • 2018-01-03
      • 1970-01-01
      • 1970-01-01
      • 2011-11-23
      • 1970-01-01
      相关资源
      最近更新 更多