1

私は電子商取引が初めてで、https://github.com/smhack/Ticketに基づいて PHP を使用して発券システムを開発しました。すべてが正常に機能し、支払いも機能します (PayPal ショッピング カート) など... (PayPalサンドボックスを使用しています)

IPN シミュレーターで IPN をテストしましたが、動作しますが、私のプロジェクトでは、IPN の PHP コードが考慮されていない理由がわかりません (データベースに挿入し、確認メールを送信します)。

HTML :

<form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="m.bendriss-facilitator@gpayme.com">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="item_name" value="<?php echo $classTitle;?>">
    <input type="hidden" name="item_number" value="Class">
    <input type="hidden" name="custom" value="<?php echo $id;?>">
    <input type="hidden" name="amount" value="<?php echo $price;?>">
    <input type="hidden" name="return" value="http://www.croisentoi.com/ticket/">
    <input type="hidden" name="notify_url" value="http://www.croisentoi.com/ticket/ipn.php">
    <input type="image" src="http://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>

ipn.php :

<?php

    include('ipnlistener.php');
    include("config.php"); 

    if($sqlTicketservertype = 'mysql'){
    $db = new PDO('mysql:host='.$sqlTicketserver.';dbname='.$sqlTicketdbname, $sqlTicketusername, $sqlTicketpassword);
    }
    // tell PHP to log errors to ipn_errors.log in this directory
    ini_set('log_errors', true);
    ini_set('error_log', dirname(__FILE__).'/ipn_errors.log');

    $listener = new IpnListener();
    $listener->use_sandbox = true;

    try {
        $verified = $listener->processIpn();
    } catch (Exception $e) {
        // fatal error trying to process IPN.
    error_log($e->getMessage());
        exit(0);
    }

    if ($verified) {
        // IPN response was "VERIFIED"
        $email = $_POST['payer_email'];
        $txn = $_POST['txn_id'];
        $firstName = $_POST['first_name']; 
        $lastName = $_POST['last_name'];
        $paymentDate = $_POST['payment_date'];

        $query = $db->PREPARE("INSERT INTO tickets ( email, txn, firstName, lastName, paymentDate  ) VALUES ( '$email', '$txn', '$firstName', '$lastName', '$paymentDate'  )");
        $query->execute();

        mail('bendrissmehdi@gmail.com', 'Valid IPN', $listener->getTextReport());
    } else {
        // IPN response was "INVALID"
        mail('bendrissmehdi@gmail.com', 'Invalid IPN', $listener->getTextReport());
    }

?>

IPN は支払いが OK のときに実行する必要があると思いました。では、なぜこのファイルが読み取られないのでしょうか。これについて何か考えはありますか?

編集 : プロジェクトは http://croisentoi.com/ticketでホストされています

ありがとうございました

4

1 に答える 1

0

PHP スクリプトから IPN 通知を機能させるには、Paypal サンドボックス サイトでも IPN 通知をオンにする必要があります。先に進み、ipn url で有効にします (後で、php スクリプトの "return" 属性を使用してこの url を上書きできます):

https://www.sandbox.paypal.com/cgi-bin/customerprofileweb?cmd=_profile-ipn-notify

于 2013-10-24T04:03:39.137 に答える