【问题标题】:PayPal IPN listener script never stops executingPayPal IPN 侦听器脚本永远不会停止执行
【发布时间】:2018-08-22 13:53:59
【问题描述】:

我有一个 PHP 网页,它使用创建发票并允许用户通过 PayPal 付款。该脚本通过 https 识别 IPN 监听页面,并在用户完成交易后调用该页面。在调用的 IPN 脚本中,我将发票状态更新为“已付款”以及成功付款后的其他相关信息。好消息是所有功能都完美无缺。但是,当我在例程中向获得销售额百分比的供应商添加单笔付款时,脚本会一遍又一遍地执行并且永不停止。似乎造成问题的脚本部分是

        case "Completed":
        $vBody = "PayPal has identifed this transaction as Completed.  Your account will be credited.";
        // BEGIN MassPay API Call
        // Create PayPal object.
        $PayPalConfig = array(
            'Sandbox' => $sandbox,
            'APIUsername' => $api_username,
            'APIPassword' => $api_password,
            'APISignature' => $api_signature,
            'PrintHeaders' => $print_headers,
            'LogResults' => $log_results,
            'LogPath' => $log_path,
            );
        $PayPal = new angelleye\PayPal\PayPal($PayPalConfig);
        // Prepare request arrays
        $MPFields = array(
                'emailsubject' => 'Notification of Payment',    // The subject line of the email that PayPal sends when the transaction is completed.  Same for all recipients.  255 char max.
                'currencycode' => 'USD',                                // Three-letter currency code.
                'receivertype' => 'EmailAddress'                        // Indicates how you identify the recipients of payments in this call to MassPay.  Must be EmailAddress or UserID
            );
        // Build MPItems array. 
        $Item1 = array(
                'l_email' => 'recipient@gmail.com',                 // Required.  Email address of recipient.  You must specify either L_EMAIL or L_RECEIVERID but you must not mix the two.
                'l_receiverid' => '',                                   // Required.  ReceiverID of recipient.  Must specify this or email address, but not both.
                'l_amt' => '3.00',                                      // Required.  Payment amount.
                'l_uniqueid' => $Post["invoice"],                       // Transaction-specific ID number for tracking in an accounting system.
                'l_note' => 'Payment per PayPal transaction processing fee.'                                // Custom note for each recipient.
        );
        $MPItems = array($Item1);
        //$MPItems = $Item1;  // ($Item1, $Item2, etc
        $PayPalRequestData = array('MPFields'=>$MPFields, 'MPItems' => $MPItems);
        // Pass data into class for processing with PayPal and load the response array into $PayPalResult
        $PayPalResult = $PayPal->MassPay($PayPalRequestData);
        // END MassPay API Call
        //Update database on succcessful payment

脚本执行良好,沙盒中向供应商的大规模付款有效,但它从未停止。如果我使用它完成交易,发件人的 PayPal 帐户将耗尽所有资金。我已经读到沙盒可能存在问题,但不确定这是否准确,我无法将其投入生产。谁能告诉我如何解决或识别问题?

【问题讨论】:

标签: php paypal


【解决方案1】:

尝试使用:

 break;

或者:

exit();

这会导致脚本在第一次执行后停止执行

【讨论】:

  • 我会试试的。但是,该页面似乎被 PayPal 多次调用,因为我有代码来添加记录以跟踪每分钟执行一次。
  • 然后简单地对事务进行检查,第一次将数据发送到数据库,然后每次检查记录是否存在,如果存在则不执行任何操作,否则执行脚本你想要并在数据库上标记它。这只是您可以做的简单预防。
  • 使用唯一的 id 对数据库中的每个变量进行身份验证
  • 问题是如果 PayPal 不断调用脚本,它将永远不会停止。我可以检查是否已经付款,然后什么都不做,但是贝宝不会继续尝试执行吗?因此,如果 10 个人一天进行 10 笔交易,PayPal 将每分钟点击这些付款的链接进行 10 笔交易,并且永不停止,在某些时候,要查找的点击次数和记录以检查交易不是新的会变得很累。
  • 我真正需要弄清楚的是 PayPal 如何知道 IPN 链接已成功执行,然后停止为特定交易发送它。
猜你喜欢
  • 2012-10-09
  • 2012-05-20
  • 2013-08-07
  • 2019-06-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-22
  • 2023-03-20
相关资源
最近更新 更多