Skip to content

Commit

Permalink
Added method documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
nbibler committed Dec 12, 2008
1 parent ba34f42 commit a46c97d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
29 changes: 29 additions & 0 deletions lib/simplepay/helpers/notification_helper.rb
Expand Up @@ -3,11 +3,40 @@
module Simplepay
module Helpers

##
# Adds a +valid_simplepay_request?+ method to your ActionControllers.
#
# In order to use this, you should just directly hand your +params+ into
# the method:
#
# class FooController < ApplicationController
#
# def receive_ipn
# if valid_simplepay_request?(params)
# ... record something useful ...
# else
# ... maybe log a bad request? ...
# end
# end
#
# end
#
module NotificationHelper

protected


##
# Authenticates the incoming request by validating the +signature+
# provided.
#
# (from within your controller)
# def receive_ipn
# if valid_simplepay_request?(params)
# ...
# end
# end
#
def valid_simplepay_request?(request_hash)
hash = request_hash.symbolize_keys
signature = hash.delete(:signature) || ''
Expand Down
17 changes: 16 additions & 1 deletion lib/simplepay/helpers/rails_helper.rb
Expand Up @@ -3,8 +3,23 @@
module Simplepay
module Helpers

##
# Adds helpers to your views for generating the correct HTML FORMs and
# valid signatures.
#
module RailsHelper

##
# This is the general interface for generating your Simple Pay service
# forms. See Simplepay::Services for available services and information
# specific to each.
#
# === Example
#
# (in your view)
#
# <%= simplepay_form_for(:service_name, {:attr => 'foo'}) %>
#
def simplepay_form_for(service_name, attributes = {})
service = get_simplepay_service(service_name)
service.form(attributes)
Expand All @@ -14,7 +29,7 @@ def simplepay_form_for(service_name, attributes = {})
private


def get_simplepay_service(name)
def get_simplepay_service(name) #:nodoc:
service = "Simplepay::Services::#{name.to_s.camelize}".constantize
service.new
end
Expand Down

0 comments on commit a46c97d

Please sign in to comment.