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

Ignore foreign ipn #16

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

hoverlover
Copy link

This PR includes code that will ignore an IPN message if the invoice doesn't correspond with a Spree order. Sometimes, PayPal users will receive funds outside of Spree. With the current codebase, this will cause a 500 error because the order can't be found. The code I've included will simply return a 200 response for the IPN request if the invoice param doesn't match the format of the Spree order number.

@tomash
Copy link
Owner

tomash commented Mar 18, 2012

i don't like the params[:invoice].index condition

i don't like it because it's tied to default spree order numbering system, and doesn't guarantee that it's an actual order in the db.

what i did in my own store (haven't expected it to be useful to other people) :


private
  def return_for_inexisting_orders
    @order = Order.find_by_number(params[:invoice])
    if(@order.nil? || params[:invoice].nil?)
      render :text => 'not found', :status => 200, :layout => false
    end
  end

other than that, good job! i'd prefer feature-related commits and testing-environment-related ones to be in separate pull requests, though.

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

Successfully merging this pull request may close these issues.

2 participants