Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing the response variables #5

Open
tomblomfield-zz opened this issue Mar 4, 2011 · 7 comments
Open

Accessing the response variables #5

tomblomfield-zz opened this issue Mar 4, 2011 · 7 comments

Comments

@tomblomfield-zz
Copy link

I'm not sure if I'm getting confused, but I'm struggling to access attributes of Paypal response in a clean way

Eg
ipn = PaypalAdaptive::IpnNotification.new
ipn.send_back(env['rack.request.form_vars'])
if ipn.verified? #do some stuff.

But then if I want to know about the "status" attribute, I have to call
params["status"].

This seems wrong? Shouldn't I be able to access the attributes through the ipn object?

@tzoro
Copy link

tzoro commented Dec 10, 2011

Me to, and i still did not find any solution, Ipn notification is returned as object and i don't know objects attributes... :(

@tzoro
Copy link

tzoro commented Dec 13, 2011

Check this: #35

@rromanchuk
Copy link
Contributor

If you're using RoR the response of of the IPN will be in params. paypal_adaptive doesn't 'wrap' this for you, all the hard work is already done!

def my_callback
logger.error params.inspect
logger.error "sweet it worked!" if params["status"] == "COMPLETED" 
end

here is an example params hash if you are interested

{"transaction"=>
      {"0"=>
        {".is_primary_receiver"=>"true", 
          ".id_for_sender_txn"=>"0D1051131N314315E", 
          ".receiver"=>"[email protected]", 
          ".amount"=>"USD 50.00", ".status"=>"Completed", 
          ".id"=>"4WF324015C547172T", 
          ".status_for_sender_txn"=>"Completed", 
          ".paymentType"=>"SERVICE", 
          ".pending_reason"=>"NONE"}, 
      "1"=>
        {".paymentType"=>"SERVICE", 
          ".id_for_sender_txn"=>"8RN84136258572825", 
          ".is_primary_receiver"=>"false", 
          ".status_for_sender_txn"=>"Completed", 
          ".receiver"=>"[email protected]", 
          ".amount"=>"USD 5.00", 
          ".pending_reason"=>"NONE", 
          ".id"=>"50546824JL989701Y", 
          ".status"=>"Completed"}}, 
    "log_default_shipping_address_in_transaction"=>"false", 
    "action_type"=>"PAY", 
    "ipn_notification_url"=>"http://blah.com/mycallback", 
    "charset"=>"windows-1252", 
    "transaction_type"=>"Adaptive Payment PAY", 
    "notify_version"=>"UNVERSIONED", 
    "cancel_url"=>"blahblahs", 
    "verify_sign"=>"blahblah", 
    "sender_email"=>"[email protected]", "fees_payer"=>"EACHRECEIVER", 
    "return_url"=>"blahblah", 
    "reverse_all_parallel_payments_on_error"=>"false", 
    "pay_key"=>"487234987234", 
    "status"=>"COMPLETED", 
    "test_ipn"=>"1", 
    "payment_request_date"=>"Mon Dec 12 12:25:56 PST 2011", 
    "id"=>"1"} 

@tzoro
Copy link

tzoro commented Dec 16, 2011

ipn = PaypalAdaptive::IpnNotification.new
ipn.send_back(request.raw_post)
#_________________________________-Data
ipn.txn_id = params['pay_key']
ipn.save
...
still blank, only timestamps

@tc
Copy link
Owner

tc commented Dec 17, 2012

tzoro, are you running your code inside a rails action?

@mihirjb
Copy link

mihirjb commented Dec 12, 2014

@rromanchuk But how does one access params["transaction"]["0"][".id_for_sender_txn"] ???
params['transaction[0].id'] doesn't work
params[:transaction[0].id] doesn't work
Please help.

@rchekaluk
Copy link
Contributor

@mihirjb Use:

params['transaction']['0']['.id_for_sender_txn']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants