Forum: Ruby on Rails Paypal and Rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
98f7f49eca94a17d8ac4c61ee5700249?d=identicon&s=25 Bryan Corey (mrpunkin)
on 2006-02-07 17:53
Hello everyone,

I am looking for a way to pass off a simple payment to paypal using our
own interface. I understand that this requires making full use of
Paypal's API since we won't be using their shopping cart or anything. I
found the article by Pranav Bihari on his site and in the Wiki on using
SOAP4R and the paypal WSDL file to interface with paypal web services,
but I guess maybe I'm too new to ruby to understand his "simple" script.
I figured what we are doing is very simple and I just can't figure out
how to do it though simply.

What we have is a user logged into our system. We will provide them a
secure page to enter billing info for an order whose total is already
calculated and ready to send to paypal. Basically all we need is to post
the users info that paypal requires for credit card payments and no
account, and our total, to paypal and have it bill them for that.

Can anyone point me in the right direction on this? Thanks ahead of
time.
8c49880a7f274947b01d576c5828a5f6?d=identicon&s=25 Lon Baker (spdemac)
on 2006-02-07 18:18
Bryan Corey wrote:
> Hello everyone,
>
> I am looking for a way to pass off a simple payment to paypal using our
> own interface. I understand that this requires making full use of
> Paypal's API since we won't be using their shopping cart or anything. I
> found the article by Pranav Bihari on his site and in the Wiki on using
> SOAP4R and the paypal WSDL file to interface with paypal web services,
> but I guess maybe I'm too new to ruby to understand his "simple" script.
> I figured what we are doing is very simple and I just can't figure out
> how to do it though simply.
>
> What we have is a user logged into our system. We will provide them a
> secure page to enter billing info for an order whose total is already
> calculated and ready to send to paypal. Basically all we need is to post
> the users info that paypal requires for credit card payments and no
> account, and our total, to paypal and have it bill them for that.
>
> Can anyone point me in the right direction on this? Thanks ahead of
> time.

You might look into Paypal Website Pro. This is a relatively new
offering from Paypal, which I think allows the functionality you are
looking for.
98f7f49eca94a17d8ac4c61ee5700249?d=identicon&s=25 Bryan Corey (mrpunkin)
on 2006-02-07 18:33
Lon Baker wrote:
> Bryan Corey wrote:
>> Hello everyone,
>>
>> I am looking for a way to pass off a simple payment to paypal using our
>> own interface. I understand that this requires making full use of
>> Paypal's API since we won't be using their shopping cart or anything. I
>> found the article by Pranav Bihari on his site and in the Wiki on using
>> SOAP4R and the paypal WSDL file to interface with paypal web services,
>> but I guess maybe I'm too new to ruby to understand his "simple" script.
>> I figured what we are doing is very simple and I just can't figure out
>> how to do it though simply.
>>
>> What we have is a user logged into our system. We will provide them a
>> secure page to enter billing info for an order whose total is already
>> calculated and ready to send to paypal. Basically all we need is to post
>> the users info that paypal requires for credit card payments and no
>> account, and our total, to paypal and have it bill them for that.
>>
>> Can anyone point me in the right direction on this? Thanks ahead of
>> time.
>
> You might look into Paypal Website Pro. This is a relatively new
> offering from Paypal, which I think allows the functionality you are
> looking for.

Thanks for the heads up. The Direct Paypment system of Website Payment
Pro seems great, but unfortunately still requires full branding with
paypal as an option for our users. We want to avoid an external shopping
cart at all costs and just use paypal for CC processing as we can't do
that in house. We looked into other places that do CC authorization and
processing but paypal still seems cheaper and more friendly in the long
run.
3320715fa6264e6309503d5bd089fad2?d=identicon&s=25 Mufaddal Khumri (mkhumri)
on 2006-02-07 18:38
(Received via mailing list)
Hi,

This is just a hunch. Does Paypal provide a jar that has all the API
that you need to use? If yes, could you use that jar via jruby?

-Mufaddal.
98f7f49eca94a17d8ac4c61ee5700249?d=identicon&s=25 Bryan Corey (mrpunkin)
on 2006-02-07 18:45
Mufaddal Khumri wrote:
> Hi,
>
> This is just a hunch. Does Paypal provide a jar that has all the API
> that you need to use? If yes, could you use that jar via jruby?
>
> -Mufaddal.

Mufaddal - they offer full SDK kits for Java, PHP, or ASP as well as
WSDL files for use with SOAP. I was curious if anyone could point me to
an easy-walkthrough of using maybe SOAP4R with WSDL files to get some
actual ruby methods setup to use within our app.
2a3be1d8227283eb4e1613ef631d78b8?d=identicon&s=25 Rob Kaufman (Guest)
on 2006-02-08 02:08
(Received via mailing list)
I'm not super familiar with Paypal (yet ;-) does Paypal for Ruby
(http://dist.leetsoft.com/api/paypal/) accomplish what you need?

Rob Kaufman
A7db9ec803b5895ae5f916a74e2db329?d=identicon&s=25 HH (Guest)
on 2006-02-08 06:29
(Received via mailing list)
The PayPal gem is built around PayPal's IPN, or Instant Payment
Notification
system.

Basically you send the user to PayPal by pre-filling a form directed at
their server. The user pays and when they do PayPal sends an HTTP GET to
a
URL you define in the PayPal setup.

You confirm that the details are legit and if so, you've got a payment
made...

It's PayPal's old school setup, predating the soap-y crap they're
pushing
these days.
143d37bc67b04ad4fdc69beddda48651?d=identicon&s=25 Tom Taylor (Guest)
on 2006-02-08 19:05
(Received via mailing list)
HH wrote:
> The PayPal gem is built around PayPal's IPN, or Instant Payment Notification
> system.
>
> Basically you send the user to PayPal by pre-filling a form directed at
> their server. The user pays and when they do PayPal sends an HTTP GET to a
> URL you define in the PayPal setup.

I'm using this in production at the moment, and it works fine. Obviously
you have to put users through a Paypal branded checkout, but aside from
that it's all good.

Cheers,

Tom
Cf17040cecb2618506f5ca4c14957957?d=identicon&s=25 Robert Dempsey (flatekmonkey)
on 2006-04-04 01:34
Tom Taylor wrote:
> HH wrote:
>> The PayPal gem is built around PayPal's IPN, or Instant Payment Notification
>> system.
>>
>> Basically you send the user to PayPal by pre-filling a form directed at
>> their server. The user pays and when they do PayPal sends an HTTP GET to a
>> URL you define in the PayPal setup.
>
> I'm using this in production at the moment, and it works fine. Obviously
> you have to put users through a Paypal branded checkout, but aside from
> that it's all good.
>
> Cheers,
>
> Tom

Tom,

Could you point me to the example or directions you used to set this up?
I currently have a paypal account and just need to be able to verify
that a customer has put through a payment in order for them to access
certain content on my site. Any and all help (and step by steps for this
newbie) are greatly appreciated. Thanks in advance.

Sincerely,

Robert Dempsey
28668141f2faf4eb9f90fbaab79d220c?d=identicon&s=25 Dave (Guest)
on 2006-04-04 01:46
>
> Could you point me to the example or directions you used to set this up?
> I currently have a paypal account and just need to be able to verify
> that a customer has put through a payment in order for them to access
> certain content on my site. Any and all help (and step by steps for this
> newbie) are greatly appreciated. Thanks in advance.
>
> Sincerely,
>
> Robert Dempsey

Hi Robert - I basically use the example from the leetsoft paypal
library.  Here's some of my controller that processes the paypal ipn
response.  It certainly doesn't handle all cases, but does seem to get
the job done.  I look up user records via their sha1 user id that is set
on the paypal submission form I've setup.  This allows someone to make a
payment from paypal that doesn't match the email address I have on file
for them.

Heres some of the controller:

  def paypal_ipn

   notify = Paypal::Notification.new(request.raw_post)

  acknowleged = false
  if notify.acknowledge
    acknowledged = true
  end

  if acknowledged

    logger.info "item_id: #{notify.item_id}" #1000
    logger.info "complete?: #{notify.complete?}" #true
    logger.info "status: #{notify.status}" #Completed
    logger.info "transaction_id: #{notify.transaction_id}" #8fx...
    logger.info "type: #{notify.type}" #subscr_signup, subscr_payment,
subscr_cancel
    logger.info "invoice: #{notify.invoice}" #9348...
    logger.info "notice amt: #{notify.amount}"

    logger.info "subscr_id: #{@params[:subscr_id]}" #
S-5C507750HS1209630
    paid_user = User.find(:first, :conditions => ["sha1('somesalt' + id)
= ?", notify.invoice.split("_")[0] ])


    if !paid_user.nil?
      case notify.type
        when "subscr_payment"
          if notify.complete?
            logger.info "got a signup for #{paid_user.id}"
            logger.info "amount: #{notify.amount}"
            logger.info "gross: #{notify.gross}"
            logger.info "fee: #{notify.fee}"

            case notify.item_id
              when "basic_monthly"
                if notify.amount == Money.us_dollar(200)
                  logger.info "updating member to 1 and subscr_id to
#{@params[:subscr_id]}"
                  paid_user.update_attributes("member" => 1, "subscr_id"
=> @params[:subscr_id], "subscription_type" => "basic_monthly",
"subscribed_on" => Time.now)
                end
              else
                # we have an error - don't do anything...
                logger.error "unknown item id '#{notify.item_id}'"
            end
          end # end case notify.item_id
        when "subscr_cancel"
          logger.info "processing a cancellation..."
          begin
            user = User.find_by_subscr_id(@params[:subscr_id])
            user.update_attributes("member" => 0, "subscr_id" => nil,
"cancelled_on" => Time.now)
          rescue
            logger.error $!
          end
        when "web_accept"
          logger.info "got web_accept"
          if notify.complete?
            case notify.item_id
              when "basic_yearly"
                if notify.amount == Money.us_dollar(1200)
                  logger.info "processing a yearl subscription for
#{paid_user.id}"
                  paid_user.update_attributes("member" => 1,
"subscription_type" => "basic_yearly", "subscribed_on" => Time.now)
                end
              else
                logger.info "unknown item id '#{notify.item_id}'"
            end
          end
        else
          logger.info "unknown type '#{notify.type}'"
      end # end case notify.type
    else
      logger.info "unable to find user #{notify.invoice.split('_')[0]}"
    end
  end

   render :nothing => true
  end


And here's some of the form that makes a post to paypal:

<form action="<%= Paypal::Notification.ipn_url %>" method="post">
<input name="cmd" type="hidden" value="_xclick" />
<input name="quantity" type="hidden" value="1" />
<input name="business" type="hidden" value="<%= paypal_payto %>" />
<input name="amount" type="hidden" value="12.95" />
<input name="item_number" type="hidden" value="basic_yearly" />
<input name="item_name" type="hidden" value="Yearly" />
<input name="no_shipping" type="hidden" value="1" />
<input name="no_note" type="hidden" value="1" />
<input type="hidden" name="return"
value="http://www.yourwebsite.com/payment/thankyou" />
<input type="hidden" name="cancel_return"
value="http://www.yourwebsite.com/payment/cancel" />
<input type="hidden" name="notify_url"
value="http://www.yourwebsite.com/payment/paypal_ipn" />
<input type="hidden" name="invoice" value="<%= encode_userid %>" />

<input name="currency_code" type="hidden" value="USD" />
<input name="charset" type="hidden" value="utf-8" />
<input type="image"
src="https://www.paypal.com/en_US/i/btn/x-click-but01.gif" border="0"
name="submit" alt="Make payments with PayPal - it's fast, free and
secure!">
</form>


Good luck -

Dave
http://www.favoriterun.com
54a6fc785e9fcf73ead8e387432b32f5?d=identicon&s=25 Dan Harper (Guest)
on 2006-04-04 01:48
(Received via mailing list)
What you're looking for is this:
http://www.elctech.com/products_ruby_paypal.shtml

It does the full API connection to PayPal from Ruby on Rails.

A couple of issues that I found:
 - I couldn't get the initial step to work where you download the new
API stuff from PayPal.  Thankfully, the package already has the files
included.  I used these and was able to make transactions with no
problem.
 - I believe you'll need to update the SOAP stuff in Ruby, I'm not sure
if the update is needed when running in production as I didn't get that
far (I wanted to process AUD currency - see below)
 - The login and password temporary names in the README are actually
called something else.
 - The API only processes payments in USD, so if you're wanting to use
any other currency your out of luck.
 - The "docs" and other info around the place suck, so this adds to the
difficulty level.
 - This whole thing is far from "simple", but is a nice solution if you
can get it working.
 - Use "ruby -d script/server" when running the connection to PayPal and
you'll see the SOAP response from PayPal.  It includes the error
messages in the XML string, handy for debugging.
 - I didn't get as far as parsing the response for error strings, but I
don't think it would be that difficult.

Yes it works, and yes I've got it working previously.  If you need help
let me know, but this should be enough to get you started.

Cheers,
Dan
http://www.gogogadget.com.au
Cf17040cecb2618506f5ca4c14957957?d=identicon&s=25 Robert Dempsey (flatekmonkey)
on 2006-04-04 01:51
Dave and Dan,

Thank you both. I am sure that with your input I will get things up and
going asap! I will let you know how it goes.

- Rob
83b5c9943dd360dc52ea71a593f9b584?d=identicon&s=25 donut donut (donut)
on 2006-11-23 05:24
Dave wrote:
>
> Hi Robert - I basically use the example from the leetsoft paypal
> library.  Here's some of my controller that processes the paypal ipn
> response.  It certainly doesn't handle all cases, but does seem to get
> the job done.  I look up user records via their sha1 user id that is set
> on the paypal submission form I've setup.  This allows someone to make a
> payment from paypal that doesn't match the email address I have on file
> for them.
>
> Heres some of the controller:
>
>   def paypal_ipn
>
>    notify = Paypal::Notification.new(request.raw_post)
>
>   acknowleged = false
>   if notify.acknowledge
>     acknowledged = true
>   end
>
>   if acknowledged
>
>     logger.info "item_id: #{notify.item_id}" #1000
>     logger.info "complete?: #{notify.complete?}" #true
>     logger.info "status: #{notify.status}" #Completed
>     logger.info "transaction_id: #{notify.transaction_id}" #8fx...
>     logger.info "type: #{notify.type}" #subscr_signup, subscr_payment,
> subscr_cancel
>     logger.info "invoice: #{notify.invoice}" #9348...
>     logger.info "notice amt: #{notify.amount}"
>
>     logger.info "subscr_id: #{@params[:subscr_id]}" #
> S-5C507750HS1209630
>     paid_user = User.find(:first, :conditions => ["sha1('somesalt' + id)
> = ?", notify.invoice.split("_")[0] ])
>
>
>     if !paid_user.nil?
>       case notify.type
>         when "web_accept"
>           logger.info "got web_accept"
>           if notify.complete?
>             case notify.item_id
>               when "basic_yearly"
>                 if notify.amount == Money.us_dollar(1200)
>                   logger.info "processing a yearl subscription for
> #{paid_user.id}"
>                   paid_user.update_attributes("member" => 1,
> "subscription_type" => "basic_yearly", "subscribed_on" => Time.now)
>                 end
>               else
>                 logger.info "unknown item id '#{notify.item_id}'"
>             end
>           end
>         else
>           logger.info "unknown type '#{notify.type}'"
>       end # end case notify.type
>     else
>       logger.info "unable to find user #{notify.invoice.split('_')[0]}"
>     end
>   end
>
>    render :nothing => true
>   end
>

I want to run this by you guys who have implemented PayPal payment.

One of the issues I'm facing in using PayPal with Rails is that my
website does not know if the user has pressed the PayPal button(in this
case a Buy-Now button) to make a purchase because the user gets
redirected to paypal once the button is clicked.  I can't pre-generate
an invoice number to stick in the button because the user may decide not
to make a purchase.  So when the IPN comes in, I don't really have an
invoice number to verify with.  I do the normal verification such as
checking notify.acknowledge and payment_status, etc, and then just
record the purchase in the database.  Is there anything wrong with this?

Also, if the user checks the order status before the IPN comes in(if IPN
takes a  few minutes for some reason), I can't even tell the user that
the order is pending.  This is pretty bad.  How do you guys get around
this?
Db303dc84d03a992b33cd3ac978f89ae?d=identicon&s=25 Benjamin Curtis (Guest)
on 2006-11-23 07:30
(Received via mailing list)
On Nov 22, 2006, at 8:24 PM, donut donut wrote:

>> make a
>>   acknowleged = false
>>     logger.info "type: #{notify.type}" #subscr_signup,
>>
>> #{paid_user.id}"
>>     else
>
> record the purchase in the database.  Is there anything wrong with
> this?
>
> Also, if the user checks the order status before the IPN comes in
> (if IPN
> takes a  few minutes for some reason), I can't even tell the user that
> the order is pending.  This is pretty bad.  How do you guys get around
> this?
>

I describe how to do exactly this in my Rails e-commerce book:
http://www.agilewebdevelopment.com/rails-ecommerce

The short version is that you have your order form submit to an
action in your app that creates the transaction and renders a view
with the paypal form filled out and submitted automatically via
javascript.  This form can then be populated with an invoice number
that you can verify at IPN time.  You would also have a transaction
in pending state for a customer to be able to see immediately.
Ce01db9bec66e5796cad9fe202acf8e1?d=identicon&s=25 Chris Martin (Guest)
on 2006-11-23 08:03
(Received via mailing list)
On 11/22/06, Benjamin Curtis <rails@bencurtis.com> wrote:
>
hate to counter plug, but there's also the small pdf only title
'Payment Processing with Paypal and Ruby ' from Joe Fair.
http://pragmaticprogrammer.com/titles/jfpaypal/index.html

I haven't read either yet, so can't really advise, only state the
obvious :)

--
Chris Martin
Web Developer
Open Source & Web Standards Advocate
http://www.chriscodes.com/
6d993d4e32992c2992d0e85e8dde8a90?d=identicon&s=25 John Ward (johnward)
on 2006-11-23 08:27
(Received via mailing list)
Hi,
I create an order record with a status of in progress, if the IPN comes
back
I update the status to paid. If it doesn't I now have a record of orders
that were abandoned.

Your invoice numbers don't have to be in sequence for paypal to work.

Regards,
John
Db303dc84d03a992b33cd3ac978f89ae?d=identicon&s=25 Benjamin Curtis (Guest)
on 2006-11-23 17:35
(Received via mailing list)
On Nov 22, 2006, at 10:59 PM, Chris Martin wrote:

>> that you can verify at IPN time.  You would also have a transaction
>> in pending state for a customer to be able to see immediately.
>>
>
> hate to counter plug, but there's also the small pdf only title
> 'Payment Processing with Paypal and Ruby ' from Joe Fair.
> http://pragmaticprogrammer.com/titles/jfpaypal/index.html
>
> I haven't read either yet, so can't really advise, only state the
> obvious :)
>

Heh, good point. :)
4f0c9dc6cf209d996ab24502ee5c7f2f?d=identicon&s=25 Bothari (Guest)
on 2006-11-29 05:01
(Received via mailing list)
Sorry for the late reply.

Another option is to use something similar to IPN called PDT.  When
the user gets done and PayPal redirects them to your web site PayPal
puts a hidden field in the redirect.  This field has a token that you
can use to directly query PayPal before you build the response page.
You can save the results of the query, too.

> > hate to counter plug, but there's also the small pdf only title
> > 'Payment Processing with Paypal and Ruby ' from Joe Fair.
> > http://pragmaticprogrammer.com/titles/jfpaypal/index.html

Yes, but he's not as responsive in monitoring the mailing lists. ;-)

Joe


--
"For a new software system, the requirements will not be completely
known until after the users have used it."  Humphrey's Requirements
Uncertainty Principle.
83b5c9943dd360dc52ea71a593f9b584?d=identicon&s=25 donut donut (donut)
on 2006-11-29 05:18
Bothari wrote:
> Sorry for the late reply.
>
> Another option is to use something similar to IPN called PDT.  When
> the user gets done and PayPal redirects them to your web site PayPal
> puts a hidden field in the redirect.  This field has a token that you
> can use to directly query PayPal before you build the response page.
> You can save the results of the query, too.
>

According to the PayPal documentation, you are not guaranteed to
received a PDT due to various reasons.  Actually, I'm not sure why PDT
exists..
4f0c9dc6cf209d996ab24502ee5c7f2f?d=identicon&s=25 Bothari (Guest)
on 2006-11-29 06:18
(Received via mailing list)
> According to the PayPal documentation, you are not guaranteed to
> received a PDT due to various reasons.
That's true.  The way I understand it, the reason you *wouldn't* get a
PDT message is if the redirect to your site too "too long" and the
user closed the browser.  I could see that happening somewhat
frequently, esp. if you have to receive the token, go get the data,
parse it, save it to the database, and build the page before the user
gets a response.

To combat this, the PayPal page that the user sees before the redirect
says something to the effect of "Don't Close This Window Until It Says
Order Complete" and in the PDT docs it talks about the things you
should display, including "Order Complete".

> Actually, I'm not sure why PDT
> exists..
At first I couldn't figure it out either.  It's not guaranteed, it
depends on the user's patience, it's slower, and it's a pain to code
up this AND IPN.

However, the problem it solves is exactly the original question:  How
do I show the user what they ordered on the web page they return to.

If that's what you need, that's what it gives you.  The problem is
that it kind of appears to be an alternative to IPN, but really it's
not.  You can use either, both, or neither.  If I used PDT I'd also
enable IPN.

In my last post I left out what I intended to be the how-to part.
- Read up on PDT on PayPal's web site.  There is no fee.
http://www.paypal.com/cgi-bin/webscr?cmd=p/xcl/rec...

- For api-level detail of IPN and PDT, see the Order Management
Integration Guide at
https://www.paypal.com/en_US/pdf/PP_OrderManagemen...

- Enable it for your account on the PayPal web site.  That's where you
set the landing page.

- Build a landing page controller that takes the token, pulls the data
down, and saves it.

- Build the display.

These steps are from memory, so check the facts with the PayPal doc.

One last caveat:  PDT requires PayPal to use "AutoReturn" to return
the user to your site.  If you are selling a subscription and want
PayPal to create the username and password, you can't use
"AutoReturn", so those two scenarios are mutually exclusive.

Thanks,
Joe

--
"For a new software system, the requirements will not be completely
known until after the users have used it."  Humphrey's Requirements
Uncertainty Principle.
D5df9fcd7ef4c3c937435d7d6adeab2a?d=identicon&s=25 Greg Hauptmann (Guest)
on 2007-01-19 16:31
(Received via mailing list)
Is there a reason for not opting for the "Website Payments
Standard<https://www.paypal.com/cgi-bin/webscr?cmd=_wp-stan...
option rather than "Website Payments
Pro<https://www.paypal.com/cgi-bin/webscr?cmd=_wp-pro-....
The transaction fees don't seem to be any higher plus you wouldn't have
to
go through an API based integration?
375d7ac426d619ce9c2add272a51d5bf?d=identicon&s=25 Arun Kumar (jakthegr8)
on 2009-03-19 13:37
Dave wrote:
>
>>
>> Could you point me to the example or directions you used to set this up?
>> I currently have a paypal account and just need to be able to verify
>> that a customer has put through a payment in order for them to access
>> certain content on my site. Any and all help (and step by steps for this
>> newbie) are greatly appreciated. Thanks in advance.
>>
>> Sincerely,
>>
>> Robert Dempsey
>
> Hi Robert - I basically use the example from the leetsoft paypal
> library.  Here's some of my controller that processes the paypal ipn
> response.  It certainly doesn't handle all cases, but does seem to get
> the job done.  I look up user records via their sha1 user id that is set
> on the paypal submission form I've setup.  This allows someone to make a
> payment from paypal that doesn't match the email address I have on file
> for them.
>
> Heres some of the controller:
>
>   def paypal_ipn
>
>    notify = Paypal::Notification.new(request.raw_post)
>
>   acknowleged = false
>   if notify.acknowledge
>     acknowledged = true
>   end
>
>   if acknowledged
>
>     logger.info "item_id: #{notify.item_id}" #1000
>     logger.info "complete?: #{notify.complete?}" #true
>     logger.info "status: #{notify.status}" #Completed
>     logger.info "transaction_id: #{notify.transaction_id}" #8fx...
>     logger.info "type: #{notify.type}" #subscr_signup, subscr_payment,
> subscr_cancel
>     logger.info "invoice: #{notify.invoice}" #9348...
>     logger.info "notice amt: #{notify.amount}"
>
>     logger.info "subscr_id: #{@params[:subscr_id]}" #
> S-5C507750HS1209630
>     paid_user = User.find(:first, :conditions => ["sha1('somesalt' + id)
> = ?", notify.invoice.split("_")[0] ])
>
>
>     if !paid_user.nil?
>       case notify.type
>         when "subscr_payment"
>           if notify.complete?
>             logger.info "got a signup for #{paid_user.id}"
>             logger.info "amount: #{notify.amount}"
>             logger.info "gross: #{notify.gross}"
>             logger.info "fee: #{notify.fee}"
>
>             case notify.item_id
>               when "basic_monthly"
>                 if notify.amount == Money.us_dollar(200)
>                   logger.info "updating member to 1 and subscr_id to
> #{@params[:subscr_id]}"
>                   paid_user.update_attributes("member" => 1, "subscr_id"
> => @params[:subscr_id], "subscription_type" => "basic_monthly",
> "subscribed_on" => Time.now)
>                 end
>               else
>                 # we have an error - don't do anything...
>                 logger.error "unknown item id '#{notify.item_id}'"
>             end
>           end # end case notify.item_id
>         when "subscr_cancel"
>           logger.info "processing a cancellation..."
>           begin
>             user = User.find_by_subscr_id(@params[:subscr_id])
>             user.update_attributes("member" => 0, "subscr_id" => nil,
> "cancelled_on" => Time.now)
>           rescue
>             logger.error $!
>           end
>         when "web_accept"
>           logger.info "got web_accept"
>           if notify.complete?
>             case notify.item_id
>               when "basic_yearly"
>                 if notify.amount == Money.us_dollar(1200)
>                   logger.info "processing a yearl subscription for
> #{paid_user.id}"
>                   paid_user.update_attributes("member" => 1,
> "subscription_type" => "basic_yearly", "subscribed_on" => Time.now)
>                 end
>               else
>                 logger.info "unknown item id '#{notify.item_id}'"
>             end
>           end
>         else
>           logger.info "unknown type '#{notify.type}'"
>       end # end case notify.type
>     else
>       logger.info "unable to find user #{notify.invoice.split('_')[0]}"
>     end
>   end
>
>    render :nothing => true
>   end
>
>
> And here's some of the form that makes a post to paypal:
>
> <form action="<%= Paypal::Notification.ipn_url %>" method="post">
> <input name="cmd" type="hidden" value="_xclick" />
> <input name="quantity" type="hidden" value="1" />
> <input name="business" type="hidden" value="<%= paypal_payto %>" />
> <input name="amount" type="hidden" value="12.95" />
> <input name="item_number" type="hidden" value="basic_yearly" />
> <input name="item_name" type="hidden" value="Yearly" />
> <input name="no_shipping" type="hidden" value="1" />
> <input name="no_note" type="hidden" value="1" />
> <input type="hidden" name="return"
> value="http://www.yourwebsite.com/payment/thankyou" />
> <input type="hidden" name="cancel_return"
> value="http://www.yourwebsite.com/payment/cancel" />
> <input type="hidden" name="notify_url"
> value="http://www.yourwebsite.com/payment/paypal_ipn" />
> <input type="hidden" name="invoice" value="<%= encode_userid %>" />
>
> <input name="currency_code" type="hidden" value="USD" />
> <input name="charset" type="hidden" value="utf-8" />
> <input type="image"
> src="https://www.paypal.com/en_US/i/btn/x-click-but01.gif" border="0"
> name="submit" alt="Make payments with PayPal - it's fast, free and
> secure!">
> </form>
>
>
> Good luck -
>
> Dave
> http://www.favoriterun.com




Hi Dave, i used paypal helper for form tag.. it default form target to
sanbox address how to change the default address(sandbox address) to
orginal address sub :How to change paypal url from sandbox to papal
original url.

i am using paypal lib -- paypal (2.0.0)

i paste my code below.. plz check it.

    <% form_tag Paypal::Notification.ipn_url do %>
          <%= paypal_setup "Credit purchase", (amounts.collect {|a|
a.amount}.join(".") unless amounts.empty?), "bussiness@xxx.com",
:notify_url =>url_for(:only_path => false, :action => 'paypal_ipn'
),:return =>url_for(:only_path => false, :action =>
'paypal_success'),:cancel_return => url_for(:only_path => false, :action
=> 'paypal_failure'),:currency_code => 'JPY',:custom =>
request.remote_ip, :on0 => user.id.to_s, :on1 => "xxx"%>
   <%= image_submit_tag("/images/btn_submit1.gif") %>
   <%end%>

Default the submit tag went to sandbox site
(https://www.sandbox.paypal.com/cgi-bin/webscr) , how to change the form
tag to pay (https://www.paypal.com/cgi-bin/webscr)
This topic is locked and can not be replied to.