Skip to content

Query String with Array of Objects doesn't seem to work correctly #30

Open

Description

@jthereliable

I'm working with PayPal IPN notifications right now and I'm getting an issue with express.bodyParser

transaction%5B1%5D.status_for_sender_txn=Completed&transaction%5B1%5D.receiver=...

What I'm getting back is:

{
        'transaction': {
                '0].id_for_sender_tx': '5WF402232G129313C',
                '0].receive': '......'
        }
}

I'm not sure if what PayPal is sending back to me is correct protocol but how the data is being parsed really messes up what I have to send back to them.

Activity

  1. tj commented on Jan 6, 2012

    @tj
    Owner

    there isn't really anything "correct" but typically "transaction[1].foo=" is just transaction[1][foo]=", im sure we can fit in support for that though. do you mind posting the whole thing? or most of it for a test case

  2. jthereliable commented on Jan 6, 2012

    @jthereliable
    Author

    I had to strip the values out of some things, but here's what I got back:

    transaction%5B0%5D.is_primary_receiver=true&transaction%5B0%5D.id_for_sender_txn=transaction_info&log_default_shipping_address_in_transaction=false&transaction%5B0%5D.receiver=receiver_email&action_type=PAY&ipn_notification_url=ipn_url&transaction%5B1%5D.paymentType=SERVICE&transaction%5B0%5D.amount=cost&charset=windows-1252&transaction_type=Adaptive+Payment+PAY&transaction%5B1%5D.id_for_sender_txn=transaction_detail&transaction%5B1%5D.is_primary_receiver=false&transaction%5B0%5D.status=Completed&notify_version=UNVERSIONED&transaction%5B0%5D.id=transaction_id&cancel_url=cancel_url&transaction%5B1%5D.status_for_sender_txn=Completed&transaction%5B1%5D.receiver=receiver_email&verify_sign=verify_sign&sender_email=buyer_email&fees_payer=PRIMARYRECEIVER&transaction%5B0%5D.status_for_sender_txn=Completed&return_url=return_url&transaction%5B0%5D.paymentType=SERVICE&memo=memo&transaction%5B1%5D.amount=cost&reverse_all_parallel_payments_on_error=false&tracking_id=tracking_id&transaction%5B1%5D.pending_reason=NONE&pay_key=pay_key&transaction%5B1%5D.id=transaction_id&transaction%5B0%5D.pending_reason=NONE&status=COMPLETED&transaction%5B1%5D.status=Completed&test_ipn=1&payment_request_date=Fri+Jan+06+10%3A02%3A31+PST+2012
    

    With the query parser, I get:

    { transaction:
       { '0].is_primary_receive': 'true',
         '0].id_for_sender_tx': 'transaction_info',
         '0].receive': 'receiver_email',
         '1].paymentTyp': 'SERVICE',
         '0].amoun': 'cost',
         '1].id_for_sender_tx': 'transaction_detail',
         '1].is_primary_receive': 'false',
         '0].statu': 'Completed',
         '0].i': 'transaction_id',
         '1].status_for_sender_tx': 'Completed',
         '1].receive': 'receiver_email',
         '0].status_for_sender_tx': 'Completed',
         '0].paymentTyp': 'SERVICE',
         '1].amoun': 'cost',
         '1].pending_reaso': 'NONE',
         '1].i': 'transaction_id',
         '0].pending_reaso': 'NONE',
         '1].statu': 'Completed' },
      log_default_shipping_address_in_transaction: 'false',
      action_type: 'PAY',
      ipn_notification_url: 'ipn_url',
      charset: 'windows-1252',
      transaction_type: 'Adaptive Payment PAY',
      notify_version: 'UNVERSIONED',
      cancel_url: 'cancel_url',
      verify_sign: 'verify_sign',
      sender_email: 'buyer_email',
      fees_payer: 'PRIMARYRECEIVER',
      return_url: 'return_url',
      memo: 'memo',
      reverse_all_parallel_payments_on_error: 'false',
      tracking_id: 'tracking_id',
      pay_key: 'pay_key',
      status: 'COMPLETED',
      test_ipn: '1',
      payment_request_date: 'Fri Jan 06 10:02:31 PST 2012' }
    
  3. tj commented on Jan 6, 2012

    @tj
    Owner

    thanks that will do

  4. atheken commented on Aug 11, 2013

    @atheken

    @visionmedia It looks like the issue is that the [] balancing is off. I was able to get things parsed correctly by leaving off one of the closing brackets ( ']' ) on my fields, is this being worked on? or is this something that would be good for a fork/fix?

  5. sunknudsen commented on Apr 15, 2014

    @sunknudsen

    @visionmedia I am running into the same issue. Did someone find a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions