nov / paypal-express

Ruby Gem for PayPal Express Checkout API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to access to request.raw_post

zedtux opened this issue · comments

I'm writing a Rails(3.0.9) application that use paypal-express(0.3.1) and I want to use:

Paypal::IPN.verify!(request.raw_post)

from https://github.com/nov/paypal-express/wiki/Instant-Payment-Notification but I can't access to:

request.raw_post

I have completely implemented Instant Access but I never have access to this request.raw_post method.

What am I missing?

Can you access to request itself?
If so, is it ActionDispatch::Request?
raw_post should be defined there.

request object as far as I understand Instant Payment is a Paypal::Express::Request object.

Ah, you're misunderstanding what IPN is.
IPN is what you "receive" from PayPal, and the request is ActionDispatch::Request you can get in your rails controllers.
(Paypal::Express::Request is what you "send" to PayPal.)

ps.
IPN details here.
https://www.paypal.com/ipn

Okay. I now have an request object in my notify method from my controller, and its class is ActionDispatch::Request but request.raw_post is an empty string...

Is there something else that I'm misunderstanding ?

Does the request have any body?

nov

On Aug 9, 2011, at 2:59 AM, zedtuxreply@reply.github.com wrote:

Okay. I now have an request object in my notify method from my controller, and its class is ActionDispatch::Request but request.raw_post is an empty string...

Is there something else that I'm misunderstanding ?

Reply to this email directly or view it on GitHub:
#16 (comment)

Yes it have request.body: #<StringIO:0x007fe8eeaad640>

Is it non-blank? (request.body.read)

request.body.read: ""

What do you think about it ?

See apache/nginx log.
BTW, is it POST request?

Nope.

Maybe there a misunderstanding on my side of what you expect from me.
So let me resume the situation ;-)

Well, first when the use click on the Paypal button, my controller do this:

response = @@PAYPAL_EXPRESS_REQUEST.setup(
    make_payment_request(params[:reward][:amount]),
    notify_poster_rewards_url,
    cancel_poster_rewards_url
)

Where @@PAYPAL_EXPRESS_REQUEST is created by an initializer like this:

@@PAYPAL_EXPRESS_REQUEST = Paypal::Express::Request.new(
  :username  => Settings.paypal.username,
  :password  => Settings.paypal.password,
  :signature => Settings.paypal.signature
)

The make_payment_request method do this:

Paypal::Payment::Request.new(
  :currency_code => :EUR,
  :amount        => amount,
  :description   => "This is my description"
)

And finaly, urls:

notify_poster_rewards GET    /posters/:poster_id/rewards/notify(.:format)      {:action=>"notify", :controller=>"payments"}

When on the sandbox site I login with a test account and click continue, I receive this:

Started GET "/posters/4e50c6563ea9406f1a000033/payments/notify?token=EC-03A61594B5140525F&PayerID=67UBXHPLUE38S" for 127.0.0.1 at 2011-08-22 18:55:29 +0200
  Processing by PaymentsController#notify as HTML
  Parameters: {"token"=>"EC-03A61594B5140525F", "PayerID"=>"67UBXHPLUE38S", "poster_id"=>"4e50c6563ea9406f1a000033"}

I think you will for sure understand where I'm doing things wrong (Or I hope ;-))

notify_poster_rewards_url in your code is just a success callback url.
IPN is background ping from PayPal to your server directly. (not through browsers)

If you use recurring payment, PayPal send IPN message every time they charge or when they failed to charge.
For onetime payment, I'm not sure you need IPN handling.
https://cms.paypal.com/cms_content/US/en_US/files/developer/IPNGuide.pdf

Alright.

So what I want is recurring payment... I will update my project for that. Thank you !

no problem