我的IPN一直在撤消INVAID

时间:2016-11-05 06:36:56

标签: wordpress paypal paypal-ipn

我需要验证我的IPN消息,但它始终返回无效

我的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 VERIFY CLASS

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

这是我的paypal表格

<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" />

1 个答案:

答案 0 :(得分:0)

此代码片段已经过验证可以正常运行。准备好后,务必将其切换到实时模式。这直接来自PayPal的IPN文档。

&#13;
&#13;
<?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'];

?>
&#13;
&#13;
&#13;