With this code:
result = JSON.parse(mp_data.to_json)
I got the follow JSON saved at result:
{"payment_methods"=>{}, "init_point"=>"https://www.mercadopago.com/mla/checkout/pay?pref_id=126967384-e4abf2e6-79c5-47c6-8c0d-fce045278336", "collector_id"=>126967384, "back_urls"=>{"failure"=>"http://www.site.com/failure", "pending"=>"https://www.site.com/pending", "success"=>"http://www.site.com/success"}, "sponsor_id"=>nil, "expiration_date_from"=>nil, "additional_info"=>"", "marketplace_fee"=>0, "date_created"=>"2012-10-18T19:46:13.791-04:00", "subscription_plan_id"=>nil, "id"=>"126967384-e4abf2e6-79c5-47c6-8c0d-fce045278336", "expiration_date_to"=>nil, "expires"=>false, "external_reference"=>"OPERATION-ID-14288", "payer"=>{"email"=>"buyer@email.com", "name"=>"John", "surname"=>"Mikel"}, "items"=>[{"id"=>"123", "currency_id"=>"ARS", "title"=>"Example T-Shirt", "picture_url"=>"http://www.site.com/image/123.png", "description"=>"Red XL T-Shirt", "quantity"=>1, "unit_price"=>10.5}], "client_id"=>"963", "marketplace"=>"NONE"}
How can I make a “redirect_to” call to the “init_point” url??
Thanks!
Very simple, just access that hash key:
JSON.parsereturns a regular hash. So technically speaking, it’s inaccurate to say you got that “JSON saved at result”. You parsed the JSON and got a hash returned at “result”.But I’m confused about this:
Why convert the data to json, then go right back to parsing it? Why not just use
mp_datadirectly, like this?