paypal-recurring 0.1.1 → 0.1.2
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/Gemfile.lock +1 -1
- data/lib/paypal/recurring/base.rb +18 -14
- data/lib/paypal/recurring/request.rb +36 -25
- data/lib/paypal/recurring/response/profile.rb +2 -1
- data/lib/paypal/recurring/version.rb +1 -1
- data/spec/paypal/request_spec.rb +9 -0
- data/spec/paypal/response/create_recurring_profile_spec.rb +14 -12
- data/spec/paypal/response/profile_spec.rb +1 -0
- metadata +4 -4
data/Gemfile.lock
CHANGED
|
@@ -5,8 +5,11 @@ module PayPal
|
|
|
5
5
|
attr_accessor :cancel_url
|
|
6
6
|
attr_accessor :currency
|
|
7
7
|
attr_accessor :description
|
|
8
|
+
attr_accessor :email
|
|
8
9
|
attr_accessor :failed
|
|
9
10
|
attr_accessor :frequency
|
|
11
|
+
attr_accessor :initial_amount
|
|
12
|
+
attr_accessor :initial_amount_action
|
|
10
13
|
attr_accessor :ipn_url
|
|
11
14
|
attr_accessor :outstanding
|
|
12
15
|
attr_accessor :payer_id
|
|
@@ -16,7 +19,6 @@ module PayPal
|
|
|
16
19
|
attr_accessor :return_url
|
|
17
20
|
attr_accessor :start_at
|
|
18
21
|
attr_accessor :token
|
|
19
|
-
attr_accessor :email
|
|
20
22
|
|
|
21
23
|
def initialize(options = {})
|
|
22
24
|
options.each {|name, value| send("#{name}=", value)}
|
|
@@ -104,24 +106,26 @@ module PayPal
|
|
|
104
106
|
# Create a recurring billing profile.
|
|
105
107
|
#
|
|
106
108
|
# ppr = PayPal::Recurring.new({
|
|
107
|
-
# :amount
|
|
108
|
-
# :
|
|
109
|
-
# :
|
|
110
|
-
# :
|
|
111
|
-
# :
|
|
112
|
-
# :
|
|
113
|
-
# :
|
|
114
|
-
# :
|
|
115
|
-
# :
|
|
116
|
-
# :
|
|
117
|
-
# :
|
|
118
|
-
# :
|
|
109
|
+
# :amount => "9.00",
|
|
110
|
+
# :initial_amount => "9.00",
|
|
111
|
+
# :initial_amount_action => :cancel,
|
|
112
|
+
# :currency => "USD",
|
|
113
|
+
# :description => "Awesome - Monthly Subscription",
|
|
114
|
+
# :ipn_url => "http://example.com/paypal/ipn",
|
|
115
|
+
# :frequency => 1,
|
|
116
|
+
# :token => "EC-05C46042TU8306821",
|
|
117
|
+
# :period => :monthly,
|
|
118
|
+
# :reference => "1234",
|
|
119
|
+
# :payer_id => "WTTS5KC2T46YU",
|
|
120
|
+
# :start_at => Time.now,
|
|
121
|
+
# :failed => 1,
|
|
122
|
+
# :outstanding => :next_billing
|
|
119
123
|
# })
|
|
120
124
|
#
|
|
121
125
|
# response = ppr.create_recurring_profile
|
|
122
126
|
#
|
|
123
127
|
def create_recurring_profile
|
|
124
|
-
params = collect(:amount, :currency, :description, :payer_id, :token, :reference, :start_at, :failed, :outstanding, :ipn_url, :frequency, :period, :email)
|
|
128
|
+
params = collect(:amount, :initial_amount, :initial_amount_action, :currency, :description, :payer_id, :token, :reference, :start_at, :failed, :outstanding, :ipn_url, :frequency, :period, :email)
|
|
125
129
|
request.run(:create_profile, params)
|
|
126
130
|
end
|
|
127
131
|
|
|
@@ -10,6 +10,11 @@ module PayPal
|
|
|
10
10
|
:manage_profile => "ManageRecurringPaymentsProfileStatus"
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
INITIAL_AMOUNT_ACTIONS = {
|
|
14
|
+
:cancel => "CancelOnFailure",
|
|
15
|
+
:continue => "ContinueOnFailure"
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
ACTIONS = {
|
|
14
19
|
:cancel => "Cancel",
|
|
15
20
|
:suspend => "Suspend",
|
|
@@ -28,31 +33,33 @@ module PayPal
|
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
ATTRIBUTES = {
|
|
31
|
-
:action
|
|
32
|
-
:amount
|
|
33
|
-
:billing_type
|
|
34
|
-
:cancel_url
|
|
35
|
-
:currency
|
|
36
|
-
:description
|
|
37
|
-
:email
|
|
38
|
-
:failed
|
|
39
|
-
:frequency
|
|
40
|
-
:
|
|
41
|
-
:
|
|
42
|
-
:
|
|
43
|
-
:
|
|
44
|
-
:
|
|
45
|
-
:
|
|
46
|
-
:
|
|
47
|
-
:
|
|
48
|
-
:
|
|
49
|
-
:
|
|
50
|
-
:
|
|
51
|
-
:
|
|
52
|
-
:
|
|
53
|
-
:
|
|
54
|
-
:
|
|
55
|
-
:
|
|
36
|
+
:action => "ACTION",
|
|
37
|
+
:amount => ["PAYMENTREQUEST_0_AMT", "AMT"],
|
|
38
|
+
:billing_type => "L_BILLINGTYPE0",
|
|
39
|
+
:cancel_url => "CANCELURL",
|
|
40
|
+
:currency => ["PAYMENTREQUEST_0_CURRENCYCODE", "CURRENCYCODE"],
|
|
41
|
+
:description => ["DESC", "PAYMENTREQUEST_0_DESC", "L_BILLINGAGREEMENTDESCRIPTION0"],
|
|
42
|
+
:email => "EMAIL",
|
|
43
|
+
:failed => "MAXFAILEDPAYMENTS",
|
|
44
|
+
:frequency => "BILLINGFREQUENCY",
|
|
45
|
+
:initial_amount => "INITAMT",
|
|
46
|
+
:initial_amount_action => "FAILEDINITAMTACTION",
|
|
47
|
+
:ipn_url => ["PAYMENTREQUEST_0_NOTIFYURL", "NOTIFYURL"],
|
|
48
|
+
:method => "METHOD",
|
|
49
|
+
:no_shipping => "NOSHIPPING",
|
|
50
|
+
:outstanding => "AUTOBILLOUTAMT",
|
|
51
|
+
:password => "PWD",
|
|
52
|
+
:payer_id => "PAYERID",
|
|
53
|
+
:payment_action => "PAYMENTREQUEST_0_PAYMENTACTION",
|
|
54
|
+
:period => "BILLINGPERIOD",
|
|
55
|
+
:profile_id => "PROFILEID",
|
|
56
|
+
:reference => "PROFILEREFERENCE",
|
|
57
|
+
:return_url => "RETURNURL",
|
|
58
|
+
:signature => "SIGNATURE",
|
|
59
|
+
:start_at => "PROFILESTARTDATE",
|
|
60
|
+
:token => "TOKEN",
|
|
61
|
+
:username => "USER",
|
|
62
|
+
:version => "VERSION",
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
CA_FILE = File.dirname(__FILE__) + "/cacert.pem"
|
|
@@ -152,6 +159,10 @@ module PayPal
|
|
|
152
159
|
def build_action(value) # :nodoc:
|
|
153
160
|
ACTIONS.fetch(value.to_sym, value) if value
|
|
154
161
|
end
|
|
162
|
+
|
|
163
|
+
def build_initial_amount_action(value) # :nodoc:
|
|
164
|
+
INITIAL_AMOUNT_ACTIONS.fetch(value.to_sym, value) if value
|
|
165
|
+
end
|
|
155
166
|
end
|
|
156
167
|
end
|
|
157
168
|
end
|
data/spec/paypal/request_spec.rb
CHANGED
|
@@ -98,5 +98,14 @@ describe PayPal::Recurring::Request do
|
|
|
98
98
|
subject.normalize_params(:action => :suspend).should == {:ACTION => "Suspend"}
|
|
99
99
|
subject.normalize_params(:action => :reactivate).should == {:ACTION => "Reactivate"}
|
|
100
100
|
end
|
|
101
|
+
|
|
102
|
+
it "normalizes initial amount" do
|
|
103
|
+
subject.normalize_params(:initial_amount => "9.00").should == {:INITAMT => "9.00"}
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "normalizes initial amount action" do
|
|
107
|
+
subject.normalize_params(:initial_amount_action => :cancel).should == {:FAILEDINITAMTACTION => "CancelOnFailure"}
|
|
108
|
+
subject.normalize_params(:initial_amount_action => :continue).should == {:FAILEDINITAMTACTION => "ContinueOnFailure"}
|
|
109
|
+
end
|
|
101
110
|
end
|
|
102
111
|
end
|
|
@@ -6,18 +6,20 @@ describe PayPal::Recurring::Response::Profile do
|
|
|
6
6
|
|
|
7
7
|
subject {
|
|
8
8
|
ppr = PayPal::Recurring.new({
|
|
9
|
-
:amount
|
|
10
|
-
:
|
|
11
|
-
:
|
|
12
|
-
:
|
|
13
|
-
:
|
|
14
|
-
:
|
|
15
|
-
:
|
|
16
|
-
:
|
|
17
|
-
:
|
|
18
|
-
:
|
|
19
|
-
:
|
|
20
|
-
:
|
|
9
|
+
:amount => "9.00",
|
|
10
|
+
:initial_amount => "9.00",
|
|
11
|
+
:initial_amount_action => :cancel,
|
|
12
|
+
:currency => "USD",
|
|
13
|
+
:description => "Awesome - Monthly Subscription",
|
|
14
|
+
:ipn_url => "http://example.com/paypal/ipn",
|
|
15
|
+
:frequency => 1,
|
|
16
|
+
:token => "EC-2UK36172XH723314S",
|
|
17
|
+
:period => :monthly,
|
|
18
|
+
:reference => "1234",
|
|
19
|
+
:payer_id => "WTTS5KC2T46YU",
|
|
20
|
+
:start_at => Time.now,
|
|
21
|
+
:failed => 1,
|
|
22
|
+
:outstanding => :next_billing
|
|
21
23
|
})
|
|
22
24
|
ppr.create_recurring_profile
|
|
23
25
|
}
|
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: paypal-recurring
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 0.1.
|
|
5
|
+
version: 0.1.2
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Nando Vieira
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2011-
|
|
13
|
+
date: 2011-07-01 00:00:00 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: rspec
|
|
@@ -142,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
142
142
|
requirements:
|
|
143
143
|
- - ">="
|
|
144
144
|
- !ruby/object:Gem::Version
|
|
145
|
-
hash:
|
|
145
|
+
hash: 2223999469554791748
|
|
146
146
|
segments:
|
|
147
147
|
- 0
|
|
148
148
|
version: "0"
|
|
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
151
151
|
requirements:
|
|
152
152
|
- - ">="
|
|
153
153
|
- !ruby/object:Gem::Version
|
|
154
|
-
hash:
|
|
154
|
+
hash: 2223999469554791748
|
|
155
155
|
segments:
|
|
156
156
|
- 0
|
|
157
157
|
version: "0"
|