On 31 August 2012 12:14, keerthi priya
<emailtokeerthipriya-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi i was following this link
>
http://www.funonrails.com/search?q=paypal&imageField.x=0&imageField.y=0&max-results=10
> for PayPal integration in the process i got this error
>
> undefined local variable or method `pay_bill_url'' for
> #<#<Class:0x927b3f8>:0x92794b8>
>
>
> View Name:create
> <%= form_for @payment ||= Payment.new, :url => pay_bill_url, :html
=> {:id
> => :payForm} do |p| %>
> <%=p.text_field :amount%>
> <%=p.submit ''Pay''%>
> <% end %>
>
> Controller Name: billing
>
>
> class BillingController < ApplicationController
> before_filter :get_order, :only => [:checkout, :paypal, :thank_you]
>
>
> def new
> @payment = Payment.new params[:payment]
> if @payment.save
> ## Paypal Checkout page
> redirect_to billing_url
> else
> render :action => :new
> end
> end
>
>
> def create
>
> end
>
> # ASSUMPTION
> # order is valid i.e. amount is entered
>
> def checkout
> response = @order.setup_purchase(:return_url =>
> confirm_paypal_url(@order), :cancel_return_url => root_url)
> redirect_to @order.redirect_url_for(response.token)
> end
>
> ## CALL BACK
> def paypal
> @order = @order.purchase(:token => params[:token], :payer_id =>
> params[:PayerID], :ip => request.remote_ip)
> @order.save redirect_to thank_you_billing_url(@order)
> end
>
> private
> def get_order
> @order = Payment.find_by_id(params[:id])
> @order && @order.valid? || invalid_url
> end
>
>
>
>
> end
>
> Routes:
> match ''billing/create'' =>
''billing#create''
> ## Callback URL
> match ''/billing/paypal/:id/confirm'', :to =>
''billing#paypal'', :as =>
> :confirm_paypal
> ## Create payment
> #match ''/billing'', :to =>
''billing#create'', :as => :pay_bill
Is this the line that should give you pay_bill_url? If you look
closely you will see it is not quite correct. If you cannot see it
examine every character on the line and work out what that character
does.
Colin
> ### Request URL
> match ''/billing/paypal/:id'', :to =>
''billing#checkout'', :as => :billing
> match ''/billing/thank_you/:id'', :to =>
''billing#checkout'', :as =>
> :billing_thank_you
>
>
> Cheers
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/coAAsT9DYEcJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.