2

I am implementing a payment gateway in my app. Its like this: The user fills the form with necessary details, along with a field containing return_url(say http://myapp.com/ebs_payment/ebs_response?dr={somedata}) and submit the form to a secure payment site. After the transaction is complete, the secure site puts some encrypted data into my param {dr} and the user is redirected back to the return url. The problem here is, when the user returns to the app with the return_url, the application fails to pick up the session data and returns a nil value.

Before submitting the form, I put the object @fdPaymentDets in to session.

Here is my controller:

class EbsPaymentController < ApplicationController
  #before_filter :login_required,:check_user_authenticate  
  #access_control [:ebs_response] => ('user')

  def ebs_response
    @fdPaymentDets = session["fd_payment_details"]

    @deal = Deal.find(@fdPaymentDets.deal_id)

    @categories = find_all_categories    
  end

  private
  def find_all_categories
     @sp = SitePreference.find(:first)
     Category.find(:all,:limit => @sp.categories_display_limit,:order => 'position')
  end

end

When the user is redirected to the return url (http://myapp.com/ebs_payment/ebs_response?dr={encrypted_data}) from the secure site, rails is not picking the @fdPaymentDets object from session and making it nil thus resulting in an error when accessing data from the nil object.

The surprising thing is that, when I put the same return_url in my browser by hand, the session data is neatly picked and everything goes well.

Am missing any thing here? What could be the obvious reason? Any help appreciated.

Vasiliy Ermolovich
  • 24,459
  • 5
  • 79
  • 77
Venkat
  • 21
  • 3
  • I have observed the same problem, I wish my question or your gets an answer, this is pretty serious stuff. – Victor S Jun 12 '12 at 20:43

1 Answers1

0

Cookies and redirects are messy and bug prone (from a browser's implementation perspective). Take a look at

Safari doesn't set Cookie but IE / FF does

Suggestion would be to change the implementation to set the session first in the show action, and then update the value before the redirect

Community
  • 1
  • 1
Syed Ali
  • 662
  • 1
  • 4
  • 15