Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Removed unused controller file.

  • Loading branch information...
commit cc1853ef87358601e699de7cebf31a7c8b8bedcf 1 parent 40be354
Sean Schofield schof authored

Showing 1 changed file with 0 additions and 142 deletions. Show diff stats Hide diff stats

  1. +0 142 lib/paypal/orders_controller.rb
142 lib/paypal/orders_controller.rb
... ... @@ -1,142 +0,0 @@
1   -module Paypal
2   - module OrdersController
3   -
4   - include ActiveMerchant::Billing::Integrations
5   -
6   - # You can send in test notifications on the developer page here:
7   - # https://developer.paypal.com/us/cgi-bin/devscr?cmd=_ipn-link-session
8   - def notify
9   - ipn = Paypal::Notification.new(request.raw_post)
10   - # the IPN invoice is equivalent to the order number
11   - @order = Order.find_by_number(ipn.invoice)
12   -
13   - # create a payment for the order
14   -
15   - # create a transaction which records the details of the notification
16   - @payment.txns.build :transaction_id => ipn.transaction_id, :amount => ipn.gross, :fee => ipn.fee,
17   - :currency_type => ipn.currency, :status => ipn.status, :received_at => ipn.received_at
18   - @payment.save
19   -
20   - if ipn.acknowledge
21   - case ipn.status
22   - when "Completed"
23   - if ipn.gross.to_d == @order.total
24   - @order.status = Order::Status::PAID
25   - else
26   - @order.status = Order::Status::INCOMPLETE
27   - logger.error("Incorrect order total during Paypal's notification, please investigate (Paypal processed #{ipn.gross}, and order total is #{@order.total})")
28   - end
29   - when "Pending"
30   - @order.status = Order::Status::PENDING_PAYMENT
31   - else
32   - @order.status = Order::Status::INCOMPLETE
33   - logger.error("Failed to verify Paypal's notification, please investigate")
34   - end
35   - else
36   - logger.error("Failed to acknowledge Paypal's notification, please investigate.")
37   - @order.status = Order::Status::INCOMPLETE
38   - end
39   -
40   - @order.save
41   -
42   - # call notify hook (which will email users, etc.)
43   - after_notify(@payment) if @order.status == Order::Status::PAID
44   -
45   - render :nothing => true
46   - end
47   -
48   - # When they've returned from paypal
49   - # Not really "success" as in they've paid. "Success" as in the transaction is in progress
50   - # Notify is called when the transaction is successfull
51   - def successful
52   -
53   - puts ">>>>>>>>>>>>>>>>> order: #{@order}"
54   -=begin
55   - ref_hash = params[:invoice]
56   - @order = find_order(ref_hash)
57   -
58   - store_user_in_order(@order)
59   -
60   - # create a transaction for the order (record what little information we have from paypal)
61   - @payment.txns.build :amount => params[:mc_gross], :status => "order-processed"
62   - @payment.save
63   -=end
64   -
65   -
66   - # call success hook (which will email users, etc.)
67   - after_success(@payment)
68   -
69   - # Render thank you (unless redirected by hook of course)
70   -=begin
71   - if logged_in?
72   - store_user_in_order(@order)
73   - render :action => 'thank_you'
74   - else
75   - flash[:notice] = "Please create an account or login so we can associate this order with an account"
76   - session[:return_to] = url_for(:action => :thank_you, :id => @order.number)
77   - redirect_to signup_path
78   - end
79   -=end
80   - end
81   -
82   - def after_notify(payment)
83   - # override this method in your own custom extension if you wish (see README for details)
84   - end
85   -
86   - def after_success(payment)
87   - # override this method in your own custom extension if you wish (see README for details)
88   - end
89   -
90   - def thank_you
91   - if logged_in? # If the user is logged in then show the thank you
92   - @order = Order.find_by_number(params[:id])
93   - store_user_in_order(@order)
94   - else # redirect them to make an account. For some reason they may have not hit the success action,
95   - # in which case, they still need to create an account
96   - flash[:notice] = "Please create an account or login so you can view this invoice"
97   - session[:return_to] = url_for(:action => :thank_you, :id => @order.number)
98   - redirect_to signup_path
99   - end
100   - end
101   -=begin
102   - private
103   -
104   - def find_order(ref_hash)
105   - # Check to see if there is a cart record matching the invoice hash
106   - if cart = Cart.find_by_reference_hash(ref_hash)
107   - Order.transaction do
108   - # Create an order from the cart (include the user if cart has one)
109   - @order = Order.new_from_cart(cart)
110   - @order.status = Order::Status::PENDING_PAYMENT
111   - @order.number = Order.generate_order_number
112   - @order.ip_address = request.env['REMOTE_ADDR']
113   - # Create a payment for the order
114   - @payment = PaypalPayment.create(:reference_hash => ref_hash)
115   - @order.paypal_payment = @payment
116   - # Get the tax & shipping
117   - @order.tax_amount = params[:tax].to_f if params[:tax]
118   - @order.ship_amount = params[:mc_shipping].to_f if params[:mc_shipping]
119   - @order.total = @order.total
120   - @order.save
121   - # Destroy the cart (optimistic locking for the cart in case notify is racing us)
122   - cart.destroy
123   - end
124   - else
125   - # we must have already heard from paypal re: this order
126   - @payment = PaypalPayment.find_by_reference_hash ref_hash
127   - @order = @payment.order
128   - end
129   -
130   - @order
131   - end
132   -
133   - def store_user_in_order(order)
134   - # if this user is logged in, but order doesn't have a user yet, associate it
135   - if !order.user_id && logged_in?
136   - order.user = current_user
137   - order.save
138   - end
139   - end
140   -=end
141   - end
142   -end

0 comments on commit cc1853e

Please sign in to comment.
Something went wrong with that request. Please try again.