1

有人會告訴我這是否是IPN正確答案?我沒有發現任何文件顯示缺少字母的索引交易。有沒有人遇到過這個問題?paypal ipn在交易數組上丟失字母

{ 
    "payment_request_date": "Wed Nov 20 18:27:12 PST 2013", 
    "return_url": "https://www.xxxx.com/payment/confirmation?tid=6cabb650-5254-11e3-b556-417057e4769f", 
    "fees_payer": "EACHRECEIVER", 
    "ipn_notification_url": "https://www.xxxx.com/payment/paypal/ipn?tid=6cabb650-5254-11e3-b556-417057e4769f", 
    "sender_email": "[email protected]", 
    "verify_sign": "Axib8Qr9snmjWbcBJ4CIf7btl81aAI8SG1XiXJt3ayuBCZlhX9OfmLc6", 
    "test_ipn": "1", 
    "transaction": { 
     "0].id_for_sender_tx": "730140804D999991E", 
     "0].receive": "[email protected]", 
     "0].is_primary_receive": "false", 
     "0].i": "2YM92644S8890074S", 
     "0].statu": "Completed", 
     "0].paymentTyp": "SERVICE", 
     "0].status_for_sender_tx": "Completed", 
     "0].pending_reaso": "NONE", 
     "0].amoun": "USD 15.00", 
     "__proto__": {} 
    }, 
    "cancel_url": "https://www.xxxx.com/payment/canceled?tid=6cabb650-5254-11e3-b556-417057e4769f", 
    "pay_key": "AP-2KN00752WL371LLSA", 
    "action_type": "PAY", 
    "transaction_type": "Adaptive Payment PAY", 
    "status": "COMPLETED", 
    "log_default_shipping_address_in_transaction": "false", 
    "charset": "windows-1252", 
    "notify_version": "UNVERSIONED", 
    "reverse_all_parallel_payments_on_error": "false", 
    "__proto__": {} 
} 

Trasaction畸形:

"transaction": { 
    "0].id_for_sender_tx": "730140804D999991E", 
    "0].receive": "[email protected]", 
    "0].is_primary_receive": "false", 
    "0].i": "2YM92644S8890074S", 
    "0].statu": "Completed", 
    "0].paymentTyp": "SERVICE", 
    "0].status_for_sender_tx": "Completed", 
    "0].pending_reaso": "NONE", 
    "0].amoun": "USD 15.00", 
    "__proto__": {} 
}, 

感謝,

回答

0

我檢查的原始數據,這是對的。問題在於sails-express bodyParser是以錯誤的方式解析的。我已將bodyParser更改爲:

module.exports = { 
    express: { 
     'bodyParser' : function(options){ 
      var _urlencoded = urlencoded(options) 
      , _multipart = multipart(options) 
      , _json = json(options); 

      return function bodyParser(req, res, next) { 

       var buf = ''; 
       req.setEncoding('utf8'); 
       req.on('data', function(chunk){ buf += chunk }); 
       req.on('end', function(){ 
        req.rawBody = buf; 
       });    

       _json(req, res, function(err){ 
        if (err) return next(err); 
         _urlencoded(req, res, function(err){ 
          if (err) return next(err); 
           _multipart(req, res, next); 
         }); 
       }); 
      } 
     } 
    } 

和使用新的req.rawBody屬性的ipn驗證函數。

謝謝大家,