【问题标题】:PayPal - IPN page贝宝 - IPN 页面
【发布时间】:2016-11-06 12:11:30
【问题描述】:

我有这个关于通过 php 支付 IPN Paypal 的问题。

ipn.php

<?php

    // 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);


    if (!$fp) {
    // HTTP ERROR
    } else {
    fputs ($fp, $header . $req);
    while (!feof($fp)) {
    $res = fgets ($fp, 1024);
    if (strcmp ($res, "VERIFIED") == 0) {

    // PAYMENT VALIDATED & VERIFIED!
        $hour = date("g:ia");
        $fp = fopen("richieste_".date("d_m_Y").".txt", "a");
        fwrite($fp, "1,16,6.01,".$hour.";");
    }

    else if (strcmp ($res, "INVALID") == 0) {

    // PAYMENT INVALID & INVESTIGATE MANUALY!

    }
    }
    fclose ($fp);
    }
?>

txt 文件未保存,ipn 状态为 payment_status=Completed with HTTP request code 200。 我哪里错了?

【问题讨论】:

  • 验证文件夹/文件权限
  • 嗨,不是权限问题,因为它保存的文件超出了脚本。

标签: php paypal paypal-ipn


【解决方案1】:

我总是使用这种方法:

$filename = **FULL_PATH** . "/" . $filename . ".txt";
$handle   = fopen( $filename, "a+" );

If( $handle ) {
  fwrite( $handle, YOUR_CONTENTS_HERE );
}

我可以看到你没有提供文件的完整路径。

【讨论】:

    猜你喜欢
    • 2011-01-03
    • 1970-01-01
    • 2015-06-16
    • 2016-05-09
    • 2023-03-11
    • 2014-04-24
    • 2012-08-19
    • 2012-08-15
    • 2014-08-25
    相关资源
    最近更新 更多