paypal-recurring 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paypal-recurring (0.1.1)
4
+ paypal-recurring (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -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 => "9.00",
108
- # :currency => "USD",
109
- # :description => "Awesome - Monthly Subscription",
110
- # :ipn_url => "http://example.com/paypal/ipn",
111
- # :frequency => 1,
112
- # :token => "EC-05C46042TU8306821",
113
- # :period => :monthly,
114
- # :reference => "1234",
115
- # :payer_id => "WTTS5KC2T46YU",
116
- # :start_at => Time.now,
117
- # :failed => 1,
118
- # :outstanding => :next_billing
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 => "ACTION",
32
- :amount => ["PAYMENTREQUEST_0_AMT", "AMT"],
33
- :billing_type => "L_BILLINGTYPE0",
34
- :cancel_url => "CANCELURL",
35
- :currency => ["PAYMENTREQUEST_0_CURRENCYCODE", "CURRENCYCODE"],
36
- :description => ["DESC", "PAYMENTREQUEST_0_DESC", "L_BILLINGAGREEMENTDESCRIPTION0"],
37
- :email => "EMAIL",
38
- :failed => "MAXFAILEDPAYMENTS",
39
- :frequency => "BILLINGFREQUENCY",
40
- :ipn_url => ["PAYMENTREQUEST_0_NOTIFYURL", "NOTIFYURL"],
41
- :method => "METHOD",
42
- :no_shipping => "NOSHIPPING",
43
- :outstanding => "AUTOBILLOUTAMT",
44
- :password => "PWD",
45
- :payer_id => "PAYERID",
46
- :payment_action => "PAYMENTREQUEST_0_PAYMENTACTION",
47
- :period => "BILLINGPERIOD",
48
- :profile_id => "PROFILEID",
49
- :reference => "PROFILEREFERENCE",
50
- :return_url => "RETURNURL",
51
- :signature => "SIGNATURE",
52
- :start_at => "PROFILESTARTDATE",
53
- :token => "TOKEN",
54
- :username => "USER",
55
- :version => "VERSION",
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
@@ -20,7 +20,8 @@ module PayPal
20
20
  :period => :BILLINGPERIOD,
21
21
  :frequency => :BILLINGFREQUENCY,
22
22
  :currency => :CURRENCYCODE,
23
- :amount => :AMT
23
+ :amount => :AMT,
24
+ :initial_amount => :AGGREGATEOPTIONALAMT
24
25
  )
25
26
 
26
27
  OUTSTANDING = {
@@ -3,7 +3,7 @@ module PayPal
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- PATCH = 1
6
+ PATCH = 2
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
8
  end
9
9
  end
@@ -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 => "9.00",
10
- :currency => "USD",
11
- :description => "Awesome - Monthly Subscription",
12
- :ipn_url => "http://example.com/paypal/ipn",
13
- :frequency => 1,
14
- :token => "EC-2UK36172XH723314S",
15
- :period => :monthly,
16
- :reference => "1234",
17
- :payer_id => "WTTS5KC2T46YU",
18
- :start_at => Time.now,
19
- :failed => 1,
20
- :outstanding => :next_billing
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
  }
@@ -27,6 +27,7 @@ describe PayPal::Recurring::Response::Profile do
27
27
  its(:frequency) { should == "1" }
28
28
  its(:currency) { should == "USD" }
29
29
  its(:amount) { should == "9.00" }
30
+ its(:initial_amount) { should == "0.00" }
30
31
  end
31
32
 
32
33
  context "when failure" do
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.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-06-28 00:00:00 Z
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: -1456604981268972750
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: -1456604981268972750
154
+ hash: 2223999469554791748
155
155
  segments:
156
156
  - 0
157
157
  version: "0"