class PaypalTransactionsController < ApplicationController
  before_filter :authenticate_user!

  def preapproval
    @club = Club.find params[:club_id]

    # attempt to get the subscription of the user (handle bogus requests)
    begin
      subscription = current_user.subscriptions.select{ |subscription| subscription.club_id == @club.id }.first
    rescue
    end

    # check that the user has a subscription, a xuuid is passed and
    # the xuuid matches the preapproval_uuid in the subscription
    if subscription.blank? or params[:xuuid].blank? or params[:xuuid].to_s != subscription.preapproval_uuid
      @sales_page = @club.sales_page

      redirect_to club_sales_page_path(@club)
    else
      subscription.pro_active = true
      subscription.save

      redirect_to @club
    end
  end
end

Add PayPal Transactions Controller for Preapproval
Add PayPal Transactions Controller for Preapproval

Add a controller to handle the response from PayPal for when a
Preapproval request is granted via the PayPal request forms.
