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