【问题标题】:My IPN Returing all time INVAID我的 IP 一直返回 INVALID
【发布时间】:2017-03-19 01:03:57
【问题描述】:

我需要验证我的 IPN 消息,但它总是返回 INVALID

我的 IPN

cmd=_notify-validate&mc_gross=76.00&protection_eligibility=Ineligible&payer_id=5F68MJE8GYSFL&tax=0.00&payment_date=23%3A01%3A49%2BNov%2B04%2C%2B2016%2BPDT&payment_status=Completed&charset=UTF-8&first_name=Buyer%2BBrij&mc_fee=2.78¬ify_version=3.8&custom=&payer_status=verified&business=brij.mohan-softo-facilitator%40softobiz.com&quantity=1&payer_email=brij.mohan-softo-buyer%40softobiz.com&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31A2CY4u8sMD28t8rYIS1l.8kZv8Om&txn_id=2M448997GH018883K&payment_type=instant&last_name=Softobiz&receiver_email=brij.mohan-softo-facilitator%40softobiz.com&payment_fee=&receiver_id=UUEGZHZ6WXVCG&txn_type=web_accept&item_name=Hire%2BGuard&mc_currency=GBP&item_number=&residence_country=GB&test_ipn=1&handling_amount=0.00&transaction_subject=&payment_gross=&shipping=0.00&merchant_return_link=click%2Bhere&auth=AtmNfVa7oX-lTpjA7qqntT12AX085EG9DbyOgtWjgrr1Qm7nc3hfy442zorp44VGQ59KWCXZbifuNdzDp.A3n.w&form_charset=UTF-8

然后我在这里查看了 IPN

1.) https://www.sandbox.paypal.com/webscr

2.) 我的帐户-> 历史记录-> IPN 历史记录-> 即时付款通知 (IPN) 详细信息

下面是IPN消息

 mc_gross=76.00&protection_eligibility=Ineligible&payer_id=5F68MJE8GYSFL&tax=0.00&payment_date=23:01:49 Nov 04, 2016 PDT&payment_status=Completed&charset=UTF-8&first_name=Buyer Brij&mc_fee=2.78&notify_version=3.8&custom=&payer_status=verified&business=brij.mohan-softo-facilitator@softobiz.com&quantity=1&verify_sign=A--8MSCLabuvN8L.-MHjxC9uypBtA5uyYRfhtvRLzxfTdTg29AzcboEl&payer_email=brij.mohan-softo-buyer@softobiz.com&txn_id=2M448997GH018883K&payment_type=instant&last_name=Softobiz&receiver_email=brij.mohan-softo-facilitator@softobiz.com&payment_fee=&receiver_id=UUEGZHZ6WXVCG&txn_type=web_accept&item_name=Hire Guard&mc_currency=GBP&item_number=&residence_country=GB&test_ipn=1&handling_amount=0.00&transaction_subject=&payment_gross=&shipping=0.00&ipn_track_id=3ab983572cde

我在谷歌上进行了研究,据我所知,除了这一点,一切似乎都很好

验证您对测试 IPN 消息的响应是否包含与测试消息完全相同的变量和值,并且它们与测试消息中的顺序相同。最后,验证原始变量前面是否有 cmd=_notify-validate 变量。

可能我无法理解我如何以相同的顺序和相同的值发送 ipn,因此教皇可以验证我的 IPN。当我将我的 ipn 与原始 ipn 进行比较时,您会注意到 ¬ify_version=3.8 和原始 ipn 消息 notify_version=3.8

我正在使用这个 paypal IPN 验证类

https://github.com/paypal/ipn-code-samples/tree/master/php

这是我的贝宝表格

<form name="myform" action="<?php echo $paypal_url;?>" method="post">
<input type="hidden" name="business" value="<?php echo $merchant_email;?>" />
<input type="hidden" name="notify_url" value="<?php echo $notify_url;?>" />
<input type="hidden" name="cancel_return" value="<?php echo $cancel_return;?>" />
<input type="hidden" name="return" value="<?php echo $success_return;?>" />
 <input type="hidden" name="user_id" value="<?php echo get_current_user_id(); ?>">
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="lc" value="" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="page_style" value="paypal" />
<input type="hidden" name="charset" value="UTF-8" />
<input type="hidden" name="item_name" value="Hire Guard" />
<input type="hidden" name="cbt" value="Back to FormGet" />
<input type="hidden" value="_xclick" name="cmd"/>
<input type="text" name="amount" value="<?php echo esc_attr($_POST['amount']); ?>" />
<input type="submit" class="button button-primary button-border-white submit-btn " value="Pay now" />

【问题讨论】:

    标签: wordpress paypal paypal-ipn


    【解决方案1】:

    此代码片段已被验证可以正常工作。准备好后确保将其切换到实时模式。这直接来自 PayPal 的 IPN 文档。

    <?php
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);
    
    
    // Send an empty HTTP 200 OK response to acknowledge receipt of the notification
    header('HTTP/1.1 200 OK');
    
    // read the IPN notification from PayPal and add the 'cmd' parameter to the beginning of the acknowledgement you will send back
    $req = 'cmd=_notify-validate';
    
    // Loop through the notification name-value pairs
    foreach ($_POST as $key => $value) {
        // Encode the values
        $value = urlencode(stripslashes($value));
        // Add the name-value pairs to the acknowledgement
        $req .= "&$key=$value";
    }
    
    // post back to PayPal system to validate
    $header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
    
    // Set up other acknowledgement request headers
    $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
    
    // If testing on Sandbox use:
    $header .= "Host: www.sandbox.paypal.com:443\r\n";
    // For live servers use $header .= "Host: www.paypal.com:443\r\n";
    
    // Open a socket for the acknowledgement request
    // If testing on Sandbox use:
    $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
    // For live servers use $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
    
    // Send the HTTP POST request back to PayPal for validation
    fputs($fp, $header . $req);
    
    
    //Do any commands with POST variables here, for ex:
    echo $_POST['payment_status'];
    
    ?>

    【讨论】:

      猜你喜欢
      • 2012-05-11
      • 2022-07-27
      • 2014-10-01
      • 2018-09-27
      • 2018-02-11
      • 2016-03-12
      • 2016-10-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多