From 96547a9769915667216ebc64f92688d6f98c7838 Mon Sep 17 00:00:00 2001 From: Nathaniel Bibler Date: Fri, 12 Dec 2008 23:33:25 -0500 Subject: [PATCH] Updated documentation for Standard and Subscription services. Added submit tag override to simplepay_form_for helper. Added Simplepay::ResponseStatusCode:All shortcut. --- History.txt | 6 ++++++ lib/simplepay/constants.rb | 1 + lib/simplepay/helpers/rails_helper.rb | 4 ++-- lib/simplepay/service.rb | 8 +++++++ lib/simplepay/services/standard.rb | 30 ++++++++++++++++++++++++++ lib/simplepay/services/subscription.rb | 27 ++++++++++++++++++++++- 6 files changed, 73 insertions(+), 3 deletions(-) diff --git a/History.txt b/History.txt index 4025038..d23808a 100644 --- a/History.txt +++ b/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. diff --git a/lib/simplepay/constants.rb b/lib/simplepay/constants.rb index c51a826..daa57ef 100644 --- a/lib/simplepay/constants.rb +++ b/lib/simplepay/constants.rb @@ -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 diff --git a/lib/simplepay/helpers/rails_helper.rb b/lib/simplepay/helpers/rails_helper.rb index bf2f529..9c4e402 100644 --- a/lib/simplepay/helpers/rails_helper.rb +++ b/lib/simplepay/helpers/rails_helper.rb @@ -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 diff --git a/lib/simplepay/service.rb b/lib/simplepay/service.rb index f67ed75..b91253b 100644 --- a/lib/simplepay/service.rb +++ b/lib/simplepay/service.rb @@ -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. diff --git a/lib/simplepay/services/standard.rb b/lib/simplepay/services/standard.rb index c980997..fc0f68e 100644 --- a/lib/simplepay/services/standard.rb +++ b/lib/simplepay/services/standard.rb @@ -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 diff --git a/lib/simplepay/services/subscription.rb b/lib/simplepay/services/subscription.rb index 4afc041..db0fe49 100644 --- a/lib/simplepay/services/subscription.rb +++ b/lib/simplepay/services/subscription.rb @@ -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