Class: Spree::PaypalStandardCallbacksController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Spree::PaypalStandardCallbacksController
- Defined in:
- app/controllers/spree/paypal_standard_callbacks_controller.rb
Instance Method Summary (collapse)
-
- (Object) notify
Called by paypoint when the payment is paid, but all security measures must be taken as this could easily be spoofed.
-
- (Object) return
Paypal sends us a post with lots of useful information in it, however at this point we ignore it and just wait for the IPN.
Instance Method Details
- (Object) notify
Called by paypoint when the payment is paid, but all security measures must be taken as this could easily be spoofed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/spree/paypal_standard_callbacks_controller.rb', line 5 def notify payment_method=PaymentMethod.find_by_id(params[:payment_method_id]) notify = ActiveMerchant::Billing::Integrations::Paypal::Notification.new(request.raw_post) @order = ::Order.find_by_number(notify.item_id) if notify.acknowledge begin if notify.complete? and @order.total.to_f == notify.amount.to_f p=@order.payment p.complete @order.state='complete' @order.finalize! else Rails.logger.warn "Warning:: Order #{notify.item_id} was not authorised - reason #{notify. rescue ''}" p=@order.payment p.fail p.save end rescue => e p=@order.payment p.fail p.save raise end end render :text=>'', :status=>200 end |
- (Object) return
Paypal sends us a post with lots of useful information in it, however at this point we ignore it and just wait for the IPN
37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/spree/paypal_standard_callbacks_controller.rb', line 37 def return notify = ActiveMerchant::Billing::Integrations::Paypal::Notification.new(request.raw_post) @order = ::Order.find_by_number(notify.item_id) if notify.acknowledge begin redirect_to thank_you_order_url(@order) rescue => e redirect_to '/' end end end |