paypal ipn 交易数组中缺少字母

标签 paypal paypal-ipn paypal-sandbox paypal-adaptive-payments

谁能告诉我这是否是 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": "sender@xxxx.com",
    "verify_sign": "Axib8Qr9snmjWbcBJ4CIf7btl81aAI8SG1XiXJt3ayuBCZlhX9OfmLc6",
    "test_ipn": "1",
    "transaction": {
        "0].id_for_sender_tx": "730140804D999991E",
        "0].receive": "bob-facilitator@gmail.com",
        "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__": {}
}

交易格式错误:

"transaction": {
    "0].id_for_sender_tx": "730140804D999991E",
    "0].receive": "bob-facilitator@gmail.com",
    "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__": {}
},

谢谢,

最佳答案

我检查了原始数据,是正确的。问题是 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 验证函数。

谢谢大家

关于paypal ipn 交易数组中缺少字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20242394/

相关文章:

jquery - codeigniter 上的 PayPal 付款

php - paypal php sdk 在上线时出现 float 问题

php - NSS : client certificate not found (nickname not specified) with Paypal with CURL

java - paypal:如何在 soap java 中确认我对每个 paypal 定期付款期的申请

php - Paypal IPN 设置 : "ship to" ZIP code and auto calculation of shipping charges

paypal - 如何将多行paypal ipn变量插入mysql数据库

button - PayPal 按钮通过 IPN 发送自定义变量

android - PAYMENT_CREATION_ERROR_NEED_VALID_FUNDING_INSTRUMENT

卡余额有限的 PayPal 沙盒帐户

php - Paypal 'Buy Now' 按钮不允许我动态设置价格