Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8958787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:17:43+00:00 2026-06-15T15:17:43+00:00

I’ve a simple Rails app that makes a request to an external website and

  • 0

I’ve a simple Rails app that makes a request to an external website and returns a json url response with a callback to my site to notify my Rails app about the response. The json url sample is https://voguepay.com/?v_transaction_id=demo-1345109950&type=json and the response body is below:

{"merchant_id":"demo","transaction_id":"demo-1345109950","email":"testuser@buyerdomain.com","total":"10","total_paid_by_buyer":"10.00","total_credited_to_merchant":"9.90","extra_charges_by_merchant":"0.00","merchant_ref":"","memo":"Donation of N10 to Test User","status":"Approved","date":"2012-01-01 11:39:11","referrer":"http:\/\/sellerdomain.com\/buy_now.html","method":"VoguePay","fund_maturity":"2012-01-03"}

I’d like to convert this response into a Rails method than can simply give me the attribute I need to make my query. For example, from the response body I need to make an action like:

def notify
  response = Json.parse('https://voguepay.com/?v_transaction_id=demo-1345109950&type=json').body
  response.status
  response.date
  response.merchant_id
  response.total
end

The code above is just a sample to explain what I want to achieve. Any help will be great.

I’ve tried both typhoeus and yajl-ruby gems but when the request comes in, all my authentication methods are removed and I keep getting the error message cannot authenticate csrf meta token. Even if I skip it the current user will be signed out automatically ( with devise authentication). The code sample used is below:

class NotificationsController < ApplicationController
  skip_before_filter :verify_authenticity_token

  def notify
      @transaction_id = params[:transaction_id]
      do_notify
  end

  private
  def do_notify
    hydra = Typhoeus::Hydra.new
    request = Typhoeus::Request.new("https://voguepay.com/?v_transaction_id=#{@transaction_id}&type=json")
    request.on_complete do |response|
        logger.info("#{response.request.url} in #{response.time} seconds")  #remove in production to avoid huge logs
              transaction = Yajl::Parser.parse(response.body)  #or Yajl::Parser.parse(response.body)

              #Now we have the following keys in our transaction hash  you can do whatever
              transaction[:merchant_id]
              transaction[:transaction_id]
              transaction[:email]
              transaction[:total]
              transaction[:merchant_ref]
              transaction[:memo]
              transaction[:status]
              transaction[:date]
              transaction[:referrer]
              transaction[:method]
              @plan = Plan.find_by_id(transaction[:merchant_ref])
              if(transaction[:total] == 0)
                logger.error "Invalid total for transaction:#{@transaction_id}"
                 #do not subscribe the user or generate invoice, notify user of error n cancel order
              elsif(transaction[:status] != 'Approved')
                logger.error "Failed transaction for transaction:#{@transaction_id}"
                 #do not subscribe the user or generate invoice, notify user of error n cancel order
              elsif(transaction[:total] >= @plan.naira_price.to_s)
                current_user.award_user_credits(@plan.hjc.to_i)
              end            
    end
    hydra.queue(request)
    hydra.run
  end
end

Anymore, I don’t want to use a gem I want to do it manually to see if the csrf meta token will not be affected. So any idea on how I can achieve this will be great. I am using rails 3.2.9.

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:17:44+00:00Added an answer on June 15, 2026 at 3:17 pm

    You can do:

    def notify
      response = JSON('https://voguepay.com/?v_transaction_id=demo-1345109950&type=json').body
     response["status"]
     response["date"]
     response["merchant_id"]
     response["total"]
    end    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.