Ruby on Rails Friday, August 31, 2012

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
### 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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
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.
 
 

No comments:

Post a Comment