0
votes

I have a server-route set up that accepts POST requests from an external service (PayPal). I used to be able to get all the details by accessing this.request.body inside the action function of route, but after doing a meteor update recently, the request body is no longer being parsed correctly, and figuring out why is apparently way beyond my skill level.

I suppose I could roll back the updates to get everything to work again, but I'm trying to figure out what is going on.

So my question is: Why is the request body not being parsed correctly? Even just a nod in a general direction would be much appreciated, as I am clueless here.

My route looks like this:

  this.route('ipnPay', {
    path: '/ipn/pay',
    where: 'server',
    action: function() {
        var request = this.request;

        console.log(request.body);
        //do other stuff
     }
   });

Which used to print out a response that looked like this:

I20150727-18:09:46.656(-4)? { payment_request_date: 'Mon Jul 27 15:09:12 PDT 2015',
I20150727-18:09:46.657(-4)?   'transaction[0].id_for_sender_txn': '9PB44643108585943',
I20150727-18:09:46.657(-4)?   'transaction[0].receiver': '[email protected]',
I20150727-18:09:46.657(-4)?   'transaction[0].is_primary_receiver': 'false',
I20150727-18:09:46.657(-4)?   'transaction[0].id': '2HH18284E5553225C',
I20150727-18:09:46.657(-4)?   'transaction[0].status': 'Completed',
I20150727-18:09:46.658(-4)?   'transaction[0].paymentType': 'PERSONAL',
I20150727-18:09:46.658(-4)?   'transaction[0].status_for_sender_txn': 'Completed',
I20150727-18:09:46.658(-4)?   'transaction[0].pending_reason': 'NONE',
I20150727-18:09:46.658(-4)?   'transaction[0].amount': 'USD 266.67' }

But after doing update, the request body is being parsed like this:

I20150727-18:32:35.812(-4)?    { payment_request_date: 'Mon Jul 27 15:32:22 PDT 2015',
I20150727-18:32:35.813(-4)?      transaction: 
I20150727-18:32:35.813(-4)?       { '0].id_for_sender_tx': '7WE57612VB713004Y',
I20150727-18:32:35.813(-4)?         '0].receive': '[email protected]',
I20150727-18:32:35.813(-4)?         '0].is_primary_receive': 'false',
I20150727-18:32:35.814(-4)?         '0].i': '8B180259507549243',
I20150727-18:32:35.814(-4)?         '0].statu': 'Completed',
I20150727-18:32:35.814(-4)?         '0].paymentTyp': 'PERSONAL',
I20150727-18:32:35.814(-4)?         '0].status_for_sender_tx': 'Completed',
I20150727-18:32:35.814(-4)?         '0].pending_reaso': 'NONE',
I20150727-18:32:35.814(-4)?         '0].amoun': 'USD 10.00' } }

So instead of the flat data structure in the first example, the parser is now trying create a nested transaction object. But key values are getting messed up..eg the first [ is being discarded as is the final character ( statu instead of status, typ instead of type, etc. )

Any ideas here??

The body of the actual actual request, that I obtained through ngrok is :

payment_request_date=Mon+Jul+27+15%3A09%3A12+PDT+2015&return_url=http%3A//localhost%3A3000/events/mHsWRFFnQSiX7zyem&fees_payer=SENDER&ipn_notification_url=http%3A//fnfndr.ngrok.io/ipn/pay&sender_email=xyz%40example.com&verify_sign=AqIeeetyNLVMnJSHSYCajOvN1y05Ai91xec8RhhiuUk10kK0d-xTI6gp&test_ipn=1&transaction%5B0%5D.id_for_sender_txn=9PB44643108585943&transaction%5B0%5D.receiver=tom%40example.com&cancel_url=http%3A//localhost%3A3000/events/mHsWRFFnQSiX7zyem&transaction%5B0%5D.is_primary_receiver=false&pay_key=AP-12T24911F3500884N&action_type=PAY&transaction%5B0%5D.id=2HH18284E5553225C&transaction%5B0%5D.status=Completed&transaction%5B0%5D.paymentType=PERSONAL&preapproval_key=PA-33150539CY900002V&transaction%5B0%5D.status_for_sender_txn=Completed&transaction%5B0%5D.pending_reason=NONE&transaction_type=Adaptive+Payment+PAY&transaction%5B0%5D.amount=USD+266.67&status=COMPLETED&log_default_shipping_address_in_transaction=false&charset=windows-1252&notify_version=UNVERSIONED&reverse_all_parallel_payments_on_error=false

And these were the packages that got updated when i ran meteor update:

bigdsk:inputmask             upgraded from 3.1.42 to 3.1.63
gadicohen:sitemaps           upgraded from 0.0.21 to 0.0.22
meteorhacks:kadira           upgraded from 2.21.0 to 2.22.1
meteorhacks:kadira-profiler  upgraded from 1.1.0 to 1.2.0
meteorhacks:npm              upgraded from 1.3.0 to 1.4.0
meteorhacks:subs-manager     upgraded from 1.4.0 to 1.5.2
momentjs:moment              upgraded from 2.9.0 to 2.10.5
nemo64:bootstrap             upgraded from 3.3.4_2 to 3.3.5_2
nemo64:bootstrap-data        upgraded from 3.3.4_1 to 3.3.5
nimble:restivus              upgraded from 0.6.6 to 0.8.1
simple:json-routes           added, version 1.0.3
summernote:standalone        upgraded from 0.6.7 to 0.6.13
1

1 Answers

0
votes

This behavior has something to do with these two packages:

nimble:restivus              upgraded from 0.6.6 to 0.8.1
simple:json-routes           added, version 1.0.3

I don't fully understand how or why, but it is somehow interfering with the way iron:router normally parses HTTP requests.

So if you run into the same error, you can either downgrade or remove the packages above.