simplepay 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/History.txt +7 -0
- data/README.rdoc +37 -2
- data/lib/simplepay.rb +1 -1
- data/lib/simplepay/constants.rb +1 -0
- data/lib/simplepay/helpers/rails_helper.rb +3 -3
- data/lib/simplepay/service.rb +10 -0
- data/lib/simplepay/services/standard.rb +30 -0
- data/lib/simplepay/services/subscription.rb +36 -1
- data/simplepay.gemspec +1 -1
- data/test/simplepay/services/test_marketplace.rb +85 -0
- data/test/simplepay/services/test_marketplace_policy.rb +52 -0
- data/test/simplepay/services/test_standard.rb +3 -3
- data/test/simplepay/test_service.rb +4 -4
- metadata +4 -2
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.2.0 2009-01-03
|
2
|
+
|
3
|
+
* Added Marketplace Service support [Nick Plante (zapnap)]
|
4
|
+
* Added Standard and Subscription documentation.
|
5
|
+
* Added a submit tag override to simplepay_form_for helper.
|
6
|
+
* Added a Simplepay::ResponseStatusCode::All shortcut.
|
7
|
+
|
1
8
|
== 0.1.1 2008-12-11
|
2
9
|
|
3
10
|
* Added a NotificationHelper to aid with Amazon IPN validation.
|
data/README.rdoc
CHANGED
@@ -12,11 +12,11 @@ Supports the following Amazon Simple Pay services:
|
|
12
12
|
|
13
13
|
* Standard
|
14
14
|
* Subscription
|
15
|
+
* Marketplace
|
15
16
|
|
16
17
|
The following services are coming someday (hopefully soon):
|
17
18
|
|
18
19
|
* Donation
|
19
|
-
* Marketplace
|
20
20
|
|
21
21
|
== SYNOPSIS:
|
22
22
|
|
@@ -59,6 +59,41 @@ optional. This is done like so:
|
|
59
59
|
:recurring_frequency => "1 month"
|
60
60
|
}) %>
|
61
61
|
|
62
|
+
|
63
|
+
=== Marketplace forms
|
64
|
+
|
65
|
+
Amazon Simple Pay Marketplace makes it easy to facilitate payments between
|
66
|
+
buyers and sellers, and to charge a fee for the transaction. If you're building
|
67
|
+
a marketplace application, your sellers must first agree to the policy that you
|
68
|
+
set. You can do this by specifying the Simplepay::Services::MarketplacePolicy
|
69
|
+
service:
|
70
|
+
|
71
|
+
<%= simplepay_form_for(:marketplace_policy, {
|
72
|
+
:max_fixed_fee => 5.00,
|
73
|
+
:max_variable_fee => 5,
|
74
|
+
:return_url => 'http://yourservice.com',
|
75
|
+
:reference_id => '1234567890'
|
76
|
+
}) %>
|
77
|
+
|
78
|
+
The user will be prompted to login to their Amazon account and accept the policy
|
79
|
+
you propose. After they complete the process, they'll be returned to the return_url
|
80
|
+
specified. Amazon will also provide a recipientEmail parameter that will contain
|
81
|
+
the seller email here (you may want to craft your return url so that it contains the
|
82
|
+
reference_id value and use this to 'acknowledge' a sellers consent and record their
|
83
|
+
Amazon recipient email address).
|
84
|
+
|
85
|
+
Only once this is done will you be able to offer marketplace checkout options for
|
86
|
+
that sellers items:
|
87
|
+
|
88
|
+
<%= simplepay_form_for(:marketplace, {
|
89
|
+
:amount => 34.95,
|
90
|
+
:description => "Mutual profit!",
|
91
|
+
:recipient_email => 'seller@gmail.com',
|
92
|
+
:fixed_marketplace_fee => 10.00,
|
93
|
+
:variable_marketplace_fee => 5
|
94
|
+
}) %>
|
95
|
+
|
96
|
+
|
62
97
|
== REQUIREMENTS:
|
63
98
|
|
64
99
|
1. You must have an Amazon Payments <b>business account</b>.
|
@@ -92,4 +127,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
92
127
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
93
128
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
94
129
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
95
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
130
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/simplepay.rb
CHANGED
data/lib/simplepay/constants.rb
CHANGED
@@ -31,6 +31,7 @@ module Simplepay
|
|
31
31
|
Successful = [PaymentSuccessful, SubscriptionSuccessful]
|
32
32
|
Failure = [Abandoned, HtmlError, PaymentFailed, SystemError, SubscriptionFailed]
|
33
33
|
Pending = [PaymentInitiated, PaymentReserved]
|
34
|
+
All = [Successful, Failure, Pending].flatten
|
34
35
|
end
|
35
36
|
|
36
37
|
module Currency
|
@@ -4,7 +4,7 @@ module Simplepay
|
|
4
4
|
module Helpers
|
5
5
|
|
6
6
|
##
|
7
|
-
# Adds helpers to your views for generating the correct HTML
|
7
|
+
# Adds helpers to your views for generating the correct HTML forms and
|
8
8
|
# valid signatures.
|
9
9
|
#
|
10
10
|
module RailsHelper
|
@@ -20,9 +20,9 @@ module Simplepay
|
|
20
20
|
#
|
21
21
|
# <%= simplepay_form_for(:service_name, {:attr => 'foo'}) %>
|
22
22
|
#
|
23
|
-
def simplepay_form_for(service_name, attributes = {})
|
23
|
+
def simplepay_form_for(service_name, attributes = {}, submit_tag = nil)
|
24
24
|
service = get_simplepay_service(service_name)
|
25
|
-
service.form(attributes)
|
25
|
+
service.form(attributes, submit_tag)
|
26
26
|
end
|
27
27
|
|
28
28
|
|
data/lib/simplepay/service.rb
CHANGED
@@ -4,6 +4,14 @@ module Simplepay
|
|
4
4
|
# This is a base class from which to inherit functionality for all Amazon
|
5
5
|
# Simple Pay services (Subscriptions, Marketplace Buttons, etc.)
|
6
6
|
#
|
7
|
+
# === Required Fields
|
8
|
+
#
|
9
|
+
# The following fields are required for all Simple Pay services:
|
10
|
+
#
|
11
|
+
# access_key:: Your Amazon Web Service (AWS) access key (automatically filled from Simplepay.aws_access_key_id).
|
12
|
+
# account_id:: Your Amazon Payments account identifier (automatically filled from Simplepay.account_id)
|
13
|
+
# 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)
|
14
|
+
#
|
7
15
|
class Service
|
8
16
|
|
9
17
|
# Fully-qualified URL for the production endpoint for the service.
|
@@ -120,3 +128,5 @@ end
|
|
120
128
|
|
121
129
|
require 'simplepay/services/subscription'
|
122
130
|
require 'simplepay/services/standard'
|
131
|
+
require 'simplepay/services/marketplace'
|
132
|
+
require 'simplepay/services/marketplace_policy'
|
@@ -4,6 +4,36 @@ module Simplepay
|
|
4
4
|
##
|
5
5
|
# The Amazon Simple Pay Standard service is used for one-time payments.
|
6
6
|
#
|
7
|
+
# === Simple Pay Standard Fields
|
8
|
+
#
|
9
|
+
# ==== Required Fields
|
10
|
+
#
|
11
|
+
# The following attributes are required when creating a Simple Pay
|
12
|
+
# Standard form (in addition to those listed in +Simplepay::Service+):
|
13
|
+
#
|
14
|
+
# amount:: The dollar value you'd like to collect.
|
15
|
+
# description:: A summary of the reason for the payment, this is displayed to your customer during checkout.
|
16
|
+
#
|
17
|
+
# ==== Optional Fields
|
18
|
+
#
|
19
|
+
# abandon_url:: The fully-qualified URL to send your custom if they cancel during payment.
|
20
|
+
# cobranding_style:: Defines the type of cobranding to use during the checkout process.
|
21
|
+
# collect_shipping_address:: Tells Amazon whether or not to ask for shipping address and contact information.
|
22
|
+
# immediate_return:: Immediately returns the customer to your +return_url+ directly after payment.
|
23
|
+
# ipn_url:: Fully-qualified URL to which Amazon will POST instant payment notifications.
|
24
|
+
# process_immediately:: Instructs Amazon to immediately process the payment.
|
25
|
+
# reference_id:: A custom string your can set to identify this transaction, it will be returned with the IPNs and other returned data.
|
26
|
+
# return_url:: Fully-qualified URL for where to send your customer following payment.
|
27
|
+
#
|
28
|
+
# === Example
|
29
|
+
#
|
30
|
+
# (in your view, using the form helper)
|
31
|
+
#
|
32
|
+
# <%= simplepay_form_for(:standard, {
|
33
|
+
# :amount => 34.95,
|
34
|
+
# :description => "I want my money NOW!"
|
35
|
+
# }) %>
|
36
|
+
#
|
7
37
|
class Standard < Service
|
8
38
|
|
9
39
|
required_field :access_key
|
@@ -6,11 +6,46 @@ module Simplepay
|
|
6
6
|
# charged every interval (Simplepay::Support::BillingFrequency) until
|
7
7
|
# a limiting period (Simplepay::Support::SubscriptionPeriod) is met.
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# With this type of payment, for example, you may charge your customer:
|
10
10
|
#
|
11
11
|
# $10.00 every 3 days until 9 days.
|
12
12
|
# $9.95 every 1 month until forever.
|
13
13
|
#
|
14
|
+
# === Simple Pay Subscription Fields
|
15
|
+
#
|
16
|
+
# === Required Fields
|
17
|
+
#
|
18
|
+
# The following attributes are required when creating a Simple Pay
|
19
|
+
# Subscription form (in addition to those listed in +Simplepay::Service+):
|
20
|
+
#
|
21
|
+
# amount:: The dollar value you'd like to collect.
|
22
|
+
# description:: A summary of the reason for the payment, this is displayed to your customer during checkout.
|
23
|
+
# recurring_frequency:: Defines how often to charge your customer (ex. "1 month")
|
24
|
+
#
|
25
|
+
# ==== Optional Fields
|
26
|
+
#
|
27
|
+
# abandon_url:: The fully-qualified URL to send your custom if they cancel during payment.
|
28
|
+
# auto_renew:: Instructs Amazon to automatically renew the subscription after the +subscription_period+ ends.
|
29
|
+
# cobranding_style:: Defines the type of cobranding to use during the checkout process.
|
30
|
+
# collect_shipping_address:: Tells Amazon whether or not to ask for shipping address and contact information.
|
31
|
+
# immediate_return:: Immediately returns the customer to your +return_url+ directly after payment.
|
32
|
+
# ipn_url:: Fully-qualified URL to which Amazon will POST instant payment notifications.
|
33
|
+
# process_immediately:: Instructs Amazon to immediately process the payment.
|
34
|
+
# reference_id:: A custom string your can set to identify this transaction, it will be returned with the IPNs and other returned data.
|
35
|
+
# return_url:: Fully-qualified URL for where to send your customer following payment.
|
36
|
+
# start_date:: Instructs Amazon with the timestamp to start the recurring subscription charges.
|
37
|
+
# subscription_period:: Defines the expiration window of the subscription (i.e. charge +amount+ every +recurring_frequency+ for "36 months")
|
38
|
+
#
|
39
|
+
# === Example
|
40
|
+
#
|
41
|
+
# (in your view, using the form helper)
|
42
|
+
#
|
43
|
+
# <%= simplepay_form_for(:subscription, {
|
44
|
+
# :amount => 12.95,
|
45
|
+
# :recurring_frequency => "1 year",
|
46
|
+
# :description => "My.Url Yearly Dues"
|
47
|
+
# }) %>
|
48
|
+
#
|
14
49
|
class Subscription < Service
|
15
50
|
|
16
51
|
required_field :access_key
|
data/simplepay.gemspec
CHANGED
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
+
require 'simplepay/services/marketplace'
|
3
|
+
|
4
|
+
class Simplepay::Services::TestMarketplace < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def self.model_class; Simplepay::Services::Marketplace; end
|
7
|
+
|
8
|
+
context 'Simplepay::Services::Marketplace' do
|
9
|
+
|
10
|
+
should_have_service_field :access_key,
|
11
|
+
:as => 'accessKey',
|
12
|
+
:required => true
|
13
|
+
|
14
|
+
should_have_service_field :signature,
|
15
|
+
:as => 'signature',
|
16
|
+
:required => true
|
17
|
+
|
18
|
+
should_have_service_field :account_id,
|
19
|
+
:as => 'amazonPaymentsAccountId',
|
20
|
+
:required => true
|
21
|
+
|
22
|
+
should_have_service_field :description,
|
23
|
+
:as => 'description',
|
24
|
+
:required => true
|
25
|
+
|
26
|
+
should_have_service_field :amount,
|
27
|
+
:as => 'amount',
|
28
|
+
:required => true,
|
29
|
+
:class => Simplepay::Support::Amount
|
30
|
+
|
31
|
+
should_have_service_field :recipient_email,
|
32
|
+
:as => 'recipientEmail',
|
33
|
+
:required => true
|
34
|
+
|
35
|
+
should_have_service_field :fixed_marketplace_fee,
|
36
|
+
:as => 'fixedMarketplaceFee',
|
37
|
+
:required => true,
|
38
|
+
:class => Simplepay::Support::Amount
|
39
|
+
|
40
|
+
should_have_service_field :variable_marketplace_fee,
|
41
|
+
:as => 'variableMarketplaceFee',
|
42
|
+
:required => true
|
43
|
+
|
44
|
+
should_have_service_field :cobranding_style,
|
45
|
+
:as => 'cobrandingStyle',
|
46
|
+
:required => true
|
47
|
+
|
48
|
+
should_have_service_field :reference_id,
|
49
|
+
:as => 'referenceId',
|
50
|
+
:required => false
|
51
|
+
|
52
|
+
should_have_service_field :immediate_return,
|
53
|
+
:as => 'immediateReturn',
|
54
|
+
:required => false,
|
55
|
+
:class => Simplepay::Support::Boolean
|
56
|
+
|
57
|
+
should_have_service_field :collect_shipping_address,
|
58
|
+
:as => 'collectShippingAddress',
|
59
|
+
:required => false,
|
60
|
+
:class => Simplepay::Support::Boolean
|
61
|
+
|
62
|
+
should_have_service_field :process_immediately,
|
63
|
+
:as => 'processImmediate',
|
64
|
+
:required => false,
|
65
|
+
:class => Simplepay::Support::Boolean
|
66
|
+
|
67
|
+
should_have_service_field :return_url,
|
68
|
+
:as => 'returnUrl',
|
69
|
+
:required => false
|
70
|
+
|
71
|
+
should_have_service_field :abandon_url,
|
72
|
+
:as => 'abandonUrl',
|
73
|
+
:required => false
|
74
|
+
|
75
|
+
should_have_service_field :ipn_url,
|
76
|
+
:as => 'ipnUrl',
|
77
|
+
:required => false
|
78
|
+
|
79
|
+
should_have_service_field :donation_widget,
|
80
|
+
:as => 'isDonationWidget',
|
81
|
+
:required => false
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
+
require 'simplepay/services/marketplace_policy'
|
3
|
+
|
4
|
+
class Simplepay::Services::TestMarketplacePolicy < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def self.model_class; Simplepay::Services::MarketplacePolicy; end
|
7
|
+
|
8
|
+
context 'Simplepay::Services::MarketplacePolicy' do
|
9
|
+
|
10
|
+
should_have_service_field :access_key,
|
11
|
+
:as => 'callerKey',
|
12
|
+
:required => true
|
13
|
+
|
14
|
+
should_have_service_field :signature,
|
15
|
+
:as => 'awsSignature',
|
16
|
+
:required => true
|
17
|
+
|
18
|
+
should_have_service_field :account_id,
|
19
|
+
:as => 'callerAccountId',
|
20
|
+
:required => true
|
21
|
+
|
22
|
+
should_have_service_field :max_fixed_fee,
|
23
|
+
:as => 'maxFixedFee',
|
24
|
+
:required => true
|
25
|
+
|
26
|
+
should_have_service_field :max_variable_fee,
|
27
|
+
:as => 'maxVariableFee',
|
28
|
+
:required => true
|
29
|
+
|
30
|
+
should_have_service_field :return_url,
|
31
|
+
:as => 'returnUrl',
|
32
|
+
:required => true
|
33
|
+
|
34
|
+
should_have_service_field :recipient_pays_fee,
|
35
|
+
:as => 'recipientPaysFee',
|
36
|
+
:required => true
|
37
|
+
|
38
|
+
should_have_service_field :reference_id,
|
39
|
+
:as => 'callerReference',
|
40
|
+
:required => true
|
41
|
+
|
42
|
+
should_have_service_field :collect_email_address,
|
43
|
+
:as => 'collectEmailAddress',
|
44
|
+
:required => true
|
45
|
+
|
46
|
+
should_have_service_field :pipeline_name,
|
47
|
+
:as => 'pipelineName',
|
48
|
+
:required => true
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../test_helper'
|
2
2
|
require 'simplepay/services/subscription'
|
3
3
|
|
4
|
-
class Simplepay::Services::
|
4
|
+
class Simplepay::Services::TestStandard < Test::Unit::TestCase
|
5
5
|
|
6
6
|
def self.model_class; Simplepay::Services::Standard; end
|
7
7
|
|
8
|
-
context 'Simplepay::Services::
|
8
|
+
context 'Simplepay::Services::Standard' do
|
9
9
|
|
10
10
|
should_have_service_field :access_key,
|
11
11
|
:as => 'accessKey',
|
@@ -77,4 +77,4 @@ class Simplepay::Services::TestSubscription < Test::Unit::TestCase
|
|
77
77
|
|
78
78
|
end
|
79
79
|
|
80
|
-
end
|
80
|
+
end
|
@@ -64,12 +64,12 @@ class Simplepay::TestService < Test::Unit::TestCase
|
|
64
64
|
|
65
65
|
should 'generate an HTML FORM' do
|
66
66
|
@service.required = 'set'
|
67
|
-
assert_match
|
68
|
-
assert_match
|
67
|
+
assert_match(/\A<form/i, @service.form)
|
68
|
+
assert_match(/<\/form>\Z/i, @service.form)
|
69
69
|
end
|
70
70
|
|
71
71
|
should 'post the form to the endpoint' do
|
72
|
-
assert_match
|
72
|
+
assert_match(/<form action="#{Regexp.escape('http://test.host.url/sandbox')}" method="post"/, @service.form({:required => 'set'}))
|
73
73
|
end
|
74
74
|
|
75
75
|
should 'generate HIDDEN HTML INPUTs for each non-empty field' do
|
@@ -115,4 +115,4 @@ class Simplepay::TestService < Test::Unit::TestCase
|
|
115
115
|
|
116
116
|
end
|
117
117
|
|
118
|
-
end
|
118
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplepay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathaniel E. Bibler
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
DXxToz6dXyCgpN1XYMMB+A==
|
31
31
|
-----END CERTIFICATE-----
|
32
32
|
|
33
|
-
date:
|
33
|
+
date: 2009-01-03 00:00:00 -05:00
|
34
34
|
default_executable:
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
@@ -146,6 +146,8 @@ specification_version: 2
|
|
146
146
|
summary: This gem provides a Rails interface to the Amazon Simple Pay payment service.
|
147
147
|
test_files:
|
148
148
|
- test/simplepay/helpers/test_notifier.rb
|
149
|
+
- test/simplepay/services/test_marketplace.rb
|
150
|
+
- test/simplepay/services/test_marketplace_policy.rb
|
149
151
|
- test/simplepay/services/test_standard.rb
|
150
152
|
- test/simplepay/services/test_subscription.rb
|
151
153
|
- test/simplepay/support/test_amount.rb
|
metadata.gz.sig
CHANGED
Binary file
|