IPN listener didn't provide 'verified' status for successful recurring payment

JayaRathan
Contributor
Contributor

We are using IPN for receiving customer details for recurring payments. In testing, using sandbox account for recurring payment is working well and its IPN listener provides 'verified' status. so my requirement is fulfill in that case, But in live site, my IPN listener didn't provide 'verified' status for successful recurring payment. I attached part of my code(implementing IPN) for references

  def ipn_paypal
    response = validate_IPN_notification(request.raw_post)
    case response
    when "VERIFIED"
      if params[:payment_status] == "Completed" && params[:receiver_email] == "#{ENV['PAYPAL_MERCHANT_EMAIL']}"
        contributor = build_contributor(params)
        #trigger mail for successful payment
      end
    when "INVALID"
        #need require actions
    else
    end
    head :ok
  end

 def validate_IPN_notification(raw)
    uri = URI.parse("#{ENV['PAYPAL_IPN_URL']}")
    http = Net::HTTP.new(uri.host, uri.port)
    http.open_timeout = 60
    http.read_timeout = 60
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER
    http.use_ssl = true
    response = http.post(uri.request_uri, raw,
                         'Content-Length' => "#{raw.size}",
                         'User-Agent' => "My custom user agent"
                       ).body
  end

. I don't know why? I followed https://github.com/paypal/ipn-code-samples/blob/master/ruby/paypal_ipn_rails.rb these documentation to implement IPN my site

Login to Me Too
1 REPLY 1

JayaRathan
Contributor
Contributor

I found the solution. I missed to attach the variable `cmd=_notify-validate`to Verify that response to an IPN in live site. The correct IPN URL is https://ipnpb.paypal.com/cgi-bin/webscr?cmd=_notify-validate 

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.