Skip to content

Commit

Permalink
Updated documentation for Standard and Subscription services.
Browse files Browse the repository at this point in the history
Added submit tag override to simplepay_form_for helper.
Added Simplepay::ResponseStatusCode:All shortcut.
  • Loading branch information
nbibler committed Dec 13, 2008
1 parent a3f704b commit 96547a9
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 3 deletions.
6 changes: 6 additions & 0 deletions History.txt
@@ -1,3 +1,9 @@
== 0.1.2 UNRELEASED

* Added Standard and Subscription documentation.
* Added a submit tag override to simplepay_form_for helper.
* Added a Simplepay::ResponseStatusCode::All shortcut.

== 0.1.1 2008-12-11

* Added a NotificationHelper to aid with Amazon IPN validation.
Expand Down
1 change: 1 addition & 0 deletions lib/simplepay/constants.rb
Expand Up @@ -31,6 +31,7 @@ module ResponseStatusCode
Successful = [PaymentSuccessful, SubscriptionSuccessful]
Failure = [Abandoned, HtmlError, PaymentFailed, SystemError, SubscriptionFailed]
Pending = [PaymentInitiated, PaymentReserved]
All = [Successful, Failure, Pending].flatten
end

module Currency
Expand Down
4 changes: 2 additions & 2 deletions lib/simplepay/helpers/rails_helper.rb
Expand Up @@ -20,9 +20,9 @@ module RailsHelper
#
# <%= simplepay_form_for(:service_name, {:attr => 'foo'}) %>
#
def simplepay_form_for(service_name, attributes = {})
def simplepay_form_for(service_name, attributes = {}, submit_tag = nil)
service = get_simplepay_service(service_name)
service.form(attributes)
service.form(attributes, submit_tag)
end


Expand Down
8 changes: 8 additions & 0 deletions lib/simplepay/service.rb
Expand Up @@ -4,6 +4,14 @@ module Simplepay
# This is a base class from which to inherit functionality for all Amazon
# Simple Pay services (Subscriptions, Marketplace Buttons, etc.)
#
# === Required Fields
#
# The following fields are required for all Simple Pay services:
#
# access_key:: Your Amazon Web Service (AWS) access key (automatically filled from Simplepay.aws_access_key_id).
# account_id:: Your Amazon Payments account identifier (automatically filled from Simplepay.account_id)
# signature:: The validation string, guaranteeing that you are the one generating the request and that the values were not tampered with enroute (automatically generated by the form generators)
#
class Service

# Fully-qualified URL for the production endpoint for the service.
Expand Down
30 changes: 30 additions & 0 deletions lib/simplepay/services/standard.rb
Expand Up @@ -4,6 +4,36 @@ module Services
##
# The Amazon Simple Pay Standard service is used for one-time payments.
#
# === Simple Pay Standard Fields
#
# ==== Required Fields
#
# The following attributes are required when creating a Simple Pay
# Standard form (in addition to those listed in +Simplepay::Service+):
#
# amount:: The dollar value you'd like to collect.
# description:: A summary of the reason for the payment, this is displayed to your customer during checkout.
#
# ==== Optional Fields
#
# abandon_url:: The fully-qualified URL to send your custom if they cancel during payment.
# cobranding_style:: Defines the type of cobranding to use during the checkout process.
# collect_shipping_address:: Tells Amazon whether or not to ask for shipping address and contact information.
# immediate_return:: Immediately returns the customer to your +return_url+ directly after payment.
# ipn_url:: Fully-qualified URL to which Amazon will POST instant payment notifications.
# process_immediately:: Instructs Amazon to immediately process the payment.
# reference_id:: A custom string your can set to identify this transaction, it will be returned with the IPNs and other returned data.
# return_url:: Fully-qualified URL for where to send your customer following payment.
#
# === Example
#
# (in your view, using the form helper)
#
# <%= simplepay_form_for(:standard, {
# :amount => 34.95,
# :description => "I want my money NOW!"
# }) %>
#
class Standard < Service

required_field :access_key
Expand Down
27 changes: 26 additions & 1 deletion lib/simplepay/services/subscription.rb
Expand Up @@ -6,11 +6,36 @@ module Services
# charged every interval (Simplepay::Support::BillingFrequency) until
# a limiting period (Simplepay::Support::SubscriptionPeriod) is met.
#
# For example, you may charge your customer:
# With this type of payment, for example, you may charge your customer:
#
# $10.00 every 3 days until 9 days.
# $9.95 every 1 month until forever.
#
# === Simple Pay Subscription Fields
#
# === Required Fields
#
# The following attributes are required when creating a Simple Pay
# Subscription form (in addition to those listed in +Simplepay::Service+):
#
# amount:: The dollar value you'd like to collect.
# description:: A summary of the reason for the payment, this is displayed to your customer during checkout.
# recurring_frequency:: Defines how often to charge your customer (ex. "1 month")
#
# ==== Optional Fields
#
# abandon_url:: The fully-qualified URL to send your custom if they cancel during payment.
# auto_renew:: Instructs Amazon to automatically renew the subscription after the +subscription_period+ ends.
# cobranding_style:: Defines the type of cobranding to use during the checkout process.
# collect_shipping_address:: Tells Amazon whether or not to ask for shipping address and contact information.
# immediate_return:: Immediately returns the customer to your +return_url+ directly after payment.
# ipn_url:: Fully-qualified URL to which Amazon will POST instant payment notifications.
# process_immediately:: Instructs Amazon to immediately process the payment.
# reference_id:: A custom string your can set to identify this transaction, it will be returned with the IPNs and other returned data.
# return_url:: Fully-qualified URL for where to send your customer following payment.
# start_date:: Instructs Amazon with the timestamp to start the recurring subscription charges.
# subscription_period:: Defines the expiration window of the subscription (i.e. charge +amount+ every +recurring_frequency+ for "36 months")
#
class Subscription < Service

required_field :access_key
Expand Down

0 comments on commit 96547a9

Please sign in to comment.