PayPal IPN and SSL

I have a PayPal IPN working. Well it did work. Now it doesn't and I believe it has to do that they now want it to be posted via 443. Can I just change 80 to 443 and be ok?

@query = 'cmd=_notify-validate' request.params.each_pair {|key, value| @query = @query + '&' + key + '=' + value.first if key != 'register/pay_pal_ipn.html/pay_pal_ipn' } http = Net::HTTP.new('www.paypal.com', 80) response = http.post('/cgi-bin/webscr', @query)

I have a PayPal IPN working. Well it did work. Now it doesn't and I believe it has to do that they now want it to be posted via 443. Can I just change 80 to 443 and be ok?

you also need to set it to use ssl (just set http.use_ssl to true)

Fred

Frederick Cheung wrote:

Frederick Cheung wrote:

Pål Bergström wrote:

Frederick Cheung wrote:

I have a PayPal IPN working. Well it did work. Now it doesn't and I believe it has to do that they now want it to be posted via 443. Can I just change 80 to 443 and be ok?

you also need to set it to use ssl (just set http.use_ssl to true)

Fred

Is this correct?

http = Net::HTTP.new('www.paypal.com', 80) http.use_ssl response = http.post('/cgi-bin/webscr', @query)

Another thing related to this. In the paypalipn respons I first check request.post? Is that ok?

Jason wrote:

Hi, Did you every get your PayPal IPN script working. If so, did you use a plugin or custom code? Would you be willing to share this code for reference? I am looking to accomplish the same task as you.

Thanks, Jason

On Aug 20 2008, 10:26�am, P�l Bergstr�m <rails-mailing-l...@andreas-

This is what I have as a IPN script.

[code]

if request.post?

  #new   @params = params   @params[:cmd] = "_notify-validate"   @params.delete(:action)   @params.delete(:controller)

  url = URI.parse("https://www.paypal.com/cgi-bin/webscr&quot;\)   req = Net::HTTP::Post.new(url.path)   req.set_form_data(@params)   sock = Net::HTTP.new(url.host, url.port)   sock.use_ssl = true   response = sock.start {|http| http.request(req)}

  item_name = params[:item_name]   payment_status = params[:payment_status]   payment_amount = params[:mc_gross]   payment_currency = params[:mc_currency]   payer_email = params[:payer_email]   receiver_email = params[:receiver_email]   txn_id = params[:txn_id]

  if response

    @user = User.find_by_email(payer_email)

    if @user       #find account and update       @account = Account.find_by_user_id(@user.id)       unless @account         @account = Account.new()       end       @account.status = 'Init'     end

    if response.body == 'VERIFIED'         if payment_status == 'Completed'           @date = Date.today() + 365           @account.ipn = 'Completed'           @account.status = 'Completed'           @account.amount = payment_amount           @account.paypal_id = txn_id           @account.expires = @date           @account.save           @user.status = "Open"           @user.expires = @date           @user.save(false)         else           @account.status = 'Not Verified'           @account.save           @account.update_attribute(:ipn,'Pending')         end     else         @account.status = 'Not-Passed'         @account.save     end

  end end

render :nothing => true

[/code]

Hi Pål Bergström,

I suggest you use paypal plugin which is available here… in the sanbox we can generate virtual ipn… but most of people gave negavtive feedback about ipn…

let me know anything else…

Thanks

Arun

Thanks Pål, I really appreciate your sample code.