贝宝噩梦

发布于 2024-11-28 05:54:34 字数 4873 浏览 0 评论 0原文

我已经包含了一个我试图在这里测试的示例,但由于我是 PayPal 的新手,而且我不知道如何调试 PayPal,沙箱对我也没有多大帮助:(

看起来付款已被处理并接受,我现在要做的就是更新 mysql 表,在下面标记的行上,就在 "if($ payment_amount == 10.00&& $ payment_currency =='GBP'){" 下。测试了我的phpmyadmin 上的 mysql 工作起来就像一个魅力,只是这里可能有其他问题:(

Paypal 按钮

<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
    <input type="hidden" name="cmd" value="_xclick-subscriptions" />
    <input type="hidden" name="business"  value="[email]" />
    <input type="hidden" name="item_name"  value="New Subscription" />
    <input type="hidden" name="first_name"  value="<?php echo  $arr['user']['fname']; ?>" />
    <input type="hidden" name="last_name"  value="<?php echo  $arr['user']['lname']; ?>" />
    <input type="hidden" name="address1"  value="<?php echo  $arr['user']['add1']; ?>" />
    <input type="hidden" name="address2"  value="<?php echo  $arr['user']['add2']; ?>" />
    <input type="hidden" name="city"  value="<?php echo  $arr['user']['town']; ?>" />
    <input type="hidden" name="zip"  value="<?php echo  $arr['user']['postcode']; ?>" />
    <input type="hidden" name="email"  value="[client_email]" />
    <input type="hidden" name="currency_code"  value="GBP" />
    <input type="hidden" name="no_shipping" value="1" />
    <input type="image" src="http://www.paypal.com/en_US/i/btn/btn_subscribe_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" />
    <input type="hidden" name="recurring" value="1" />  
    <input type="hidden" name="a3" value="10.00" />  
    <input type="hidden" name="p3" value="1" />
    <input type="hidden" name="t3" value="Y" />
    <input type="hidden" name="src" value="1" />
    <input type="hidden" name="sra" value="1" />
    <input type="hidden" name="item_number" value="<?php echo $arr['user']['id'] ?>" />
    <input type="hidden" name="return"  value="<?php echo site_url.'account/' ?>" />
    <input type="hidden" name="cancel_return"  value="<?php echo site_url.'account/' ?>" />
    <input type="hidden" name="notify_url"  value="<?php echo site_url.'account/ipn.php' ?>" />
</form>

Paypal IPN 处理程序

<?php 
// UPDATED LINE BELOW
mail("[myemail]", "PP",'initiated', "From:[email protected]"); 
// 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 ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
// $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

$item_name              = $_POST['item_name'];
$item_number            = $_POST['item_number'];
$payment_status         = $_POST['payment_status'];
$payment_amount         = $_POST['mc_gross'];
$payment_currency       = $_POST['mc_currency'];
$txn_id                 = $_POST['txn_id'];
$receiver_email         = $_POST['receiver_email'];
$business               = $_POST['business'];
$payer_email            = $_POST['payer_email'];
// $payer_email             = $_POST['payer_email'];


if (!$fp) {
    // echo 'Error 101 23';
    // die();
} else {
    fputs ($fp, $header . $req);
    while (!feof($fp)) {
        $res = fgets ($fp, 1024);
        if (strcmp ($res, "VERIFIED") == 0) {
            $data['paypal_receivers_email']     = '[email]';
            if($payment_status=='Completed' && $receiver_email == $data['paypal_receivers_email'] &&$receiver_email){
                if($payment_amount==10.00&&$payment_currency=='GBP'){
                    //successfully// now update db :)// <== this is where im strugling it does not seem to come down here at all.
                }
            }
        // 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
        }
        else if (strcmp ($res, "INVALID") == 0) {
        // log for manual investigation

        }
    }
    fclose ($fp);
}

?>

I have included an example I am trying to test here but since I am new to paypal, and I have no idea how to debug the paypal, sandbox is not helping me much either :(

It looks like the payment has been processed and accepted, All I have to do now is update mysql table, on the line marked below just under "if($payment_amount==10.00&&$payment_currency=='GBP'){". I have tested my mysql on phpmyadmin and it works like a charm it's just something else may be wrong up here :(

Paypal Button

<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
    <input type="hidden" name="cmd" value="_xclick-subscriptions" />
    <input type="hidden" name="business"  value="[email]" />
    <input type="hidden" name="item_name"  value="New Subscription" />
    <input type="hidden" name="first_name"  value="<?php echo  $arr['user']['fname']; ?>" />
    <input type="hidden" name="last_name"  value="<?php echo  $arr['user']['lname']; ?>" />
    <input type="hidden" name="address1"  value="<?php echo  $arr['user']['add1']; ?>" />
    <input type="hidden" name="address2"  value="<?php echo  $arr['user']['add2']; ?>" />
    <input type="hidden" name="city"  value="<?php echo  $arr['user']['town']; ?>" />
    <input type="hidden" name="zip"  value="<?php echo  $arr['user']['postcode']; ?>" />
    <input type="hidden" name="email"  value="[client_email]" />
    <input type="hidden" name="currency_code"  value="GBP" />
    <input type="hidden" name="no_shipping" value="1" />
    <input type="image" src="http://www.paypal.com/en_US/i/btn/btn_subscribe_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" />
    <input type="hidden" name="recurring" value="1" />  
    <input type="hidden" name="a3" value="10.00" />  
    <input type="hidden" name="p3" value="1" />
    <input type="hidden" name="t3" value="Y" />
    <input type="hidden" name="src" value="1" />
    <input type="hidden" name="sra" value="1" />
    <input type="hidden" name="item_number" value="<?php echo $arr['user']['id'] ?>" />
    <input type="hidden" name="return"  value="<?php echo site_url.'account/' ?>" />
    <input type="hidden" name="cancel_return"  value="<?php echo site_url.'account/' ?>" />
    <input type="hidden" name="notify_url"  value="<?php echo site_url.'account/ipn.php' ?>" />
</form>

Paypal IPN handler

<?php 
// UPDATED LINE BELOW
mail("[myemail]", "PP",'initiated', "From:[email protected]"); 
// 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 ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
// $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

$item_name              = $_POST['item_name'];
$item_number            = $_POST['item_number'];
$payment_status         = $_POST['payment_status'];
$payment_amount         = $_POST['mc_gross'];
$payment_currency       = $_POST['mc_currency'];
$txn_id                 = $_POST['txn_id'];
$receiver_email         = $_POST['receiver_email'];
$business               = $_POST['business'];
$payer_email            = $_POST['payer_email'];
// $payer_email             = $_POST['payer_email'];


if (!$fp) {
    // echo 'Error 101 23';
    // die();
} else {
    fputs ($fp, $header . $req);
    while (!feof($fp)) {
        $res = fgets ($fp, 1024);
        if (strcmp ($res, "VERIFIED") == 0) {
            $data['paypal_receivers_email']     = '[email]';
            if($payment_status=='Completed' && $receiver_email == $data['paypal_receivers_email'] &&$receiver_email){
                if($payment_amount==10.00&&$payment_currency=='GBP'){
                    //successfully// now update db :)// <== this is where im strugling it does not seem to come down here at all.
                }
            }
        // 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
        }
        else if (strcmp ($res, "INVALID") == 0) {
        // log for manual investigation

        }
    }
    fclose ($fp);
}

?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼泪淡了忧伤 2024-12-05 05:54:34

尝试调试,就像我所做的那样:

在每个步骤中,将 email() 与来自 paypal(通过邮寄)和其他人的详细信息放在一起。记录(邮寄给自己)每个成功、错误,它会给您问题根源。例如,

 mail("[email protected]", "PP", $res, "From:[email protected]"); 

在声明变量之后放置

Try to debug, as I did:

In each step, put email() with details which came from paypal (by post) and others. Log (mail yourself) each success, error and it will give you your problem source. for example, put

 mail("[email protected]", "PP", $res, "From:[email protected]"); 

just after declaring your variable

挖个坑埋了你 2024-12-05 05:54:34

site_url 是常量吗?

<input type="hidden" name="return"  value="<?php echo site_url.'account/' ?>" />
<input type="hidden" name="cancel_return"  value="<?php echo site_url.'account/' ?>" />
<input type="hidden" name="notify_url"  value="<?php echo site_url.'account/ipn.php' ?>" />

如果不是,则缺少 $ 或 () (如果它是函数)。

您是否仔细检查过完整的 url 是否以 html 源形式返回?如果它在浏览器中工作,则 PayPal 似乎可能无法获取 IPN 的正确返回 URL。

Is site_url a constant?

<input type="hidden" name="return"  value="<?php echo site_url.'account/' ?>" />
<input type="hidden" name="cancel_return"  value="<?php echo site_url.'account/' ?>" />
<input type="hidden" name="notify_url"  value="<?php echo site_url.'account/ipn.php' ?>" />

If it is not you are missing a $ or a () if it's a function.

Have you double checked that the full url is being returned in the form html source? If it works in the browser it seems that paypal may not be getting the correct return url for IPN.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文