paypal-express 0.4.1 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paypal-express (0.4.0)
4
+ paypal-express (0.4.1)
5
5
  activesupport (>= 2.3)
6
6
  attr_required (>= 0.0.3)
7
7
  i18n
@@ -10,7 +10,7 @@ PATH
10
10
  GEM
11
11
  remote: http://rubygems.org/
12
12
  specs:
13
- activesupport (3.1.0)
13
+ activesupport (3.1.3)
14
14
  multi_json (~> 1.0)
15
15
  attr_required (0.0.3)
16
16
  bouncy-castle-java (1.5.0146.1)
@@ -19,7 +19,7 @@ GEM
19
19
  i18n (0.6.0)
20
20
  jruby-openssl (0.7.4)
21
21
  bouncy-castle-java
22
- mime-types (1.16)
22
+ mime-types (1.17.2)
23
23
  multi_json (1.0.3)
24
24
  rake (0.9.2)
25
25
  rcov (0.9.10)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
@@ -85,7 +85,16 @@ module Paypal
85
85
  :period => attrs.delete(:BILLINGPERIOD),
86
86
  :frequency => attrs.delete(:BILLINGFREQUENCY),
87
87
  :total_cycles => attrs.delete(:TOTALBILLINGCYCLES),
88
- :trial_amount_paid => attrs.delete(:TRIALAMTPAID)
88
+ :trial => {
89
+ :period => attrs.delete(:TRIALBILLINGPERIOD),
90
+ :frequency => attrs.delete(:TRIALBILLINGFREQUENCY),
91
+ :total_cycles => attrs.delete(:TRIALTOTALBILLINGCYCLES),
92
+ :currency_code => attrs.delete(:TRIALCURRENCYCODE),
93
+ :amount => attrs.delete(:TRIALAMT),
94
+ :tax_amount => attrs.delete(:TRIALTAXAMT),
95
+ :shipping_amount => attrs.delete(:TRIALSHIPPINGAMT),
96
+ :paid => attrs.delete(:TRIALAMTPAID)
97
+ }
89
98
  )
90
99
  end
91
100
  if attrs[:REGULARAMT]
@@ -1,8 +1,8 @@
1
1
  module Paypal
2
2
  module Payment
3
3
  class Recurring::Billing < Base
4
- attr_optional :period, :frequency, :paid, :currency_code, :total_cycles, :trial_period, :trial_frequency, :trial_total_cycles, :trial_amount, :trial_amount_paid
5
- attr_accessor :amount
4
+ attr_optional :period, :frequency, :paid, :currency_code, :total_cycles
5
+ attr_accessor :amount, :trial
6
6
 
7
7
  def initialize(attributes = {})
8
8
  @amount = if attributes[:amount].is_a?(Common::Amount)
@@ -14,23 +14,25 @@ module Paypal
14
14
  :shipping => attributes[:shipping_amount]
15
15
  )
16
16
  end
17
+ @trial = Recurring::Billing.new(attributes[:trial]) if attributes[:trial].present?
17
18
  super
18
19
  end
19
20
 
20
21
  def to_params
21
- {
22
+ trial_params = (trial.try(:to_params) || {}).inject({}) do |trial_params, (key, value)|
23
+ trial_params.merge(
24
+ :"TRIAL#{key}" => value
25
+ )
26
+ end
27
+ trial_params.merge(
22
28
  :BILLINGPERIOD => self.period,
23
29
  :BILLINGFREQUENCY => self.frequency,
24
30
  :TOTALBILLINGCYCLES => self.total_cycles,
25
31
  :AMT => Util.formatted_amount(self.amount.total),
26
- :TRIALBILLINGPERIOD => self.trial_period,
27
- :TRIALBILLINGFREQUENCY => self.trial_frequency,
28
- :TRIALTOTALBILLINGCYCLES => self.trial_total_cycles,
29
- :TRIALAMT => Util.formatted_amount(self.trial_amount),
30
32
  :CURRENCYCODE => self.currency_code,
31
33
  :SHIPPINGAMT => Util.formatted_amount(self.amount.shipping),
32
34
  :TAXAMT => Util.formatted_amount(self.amount.tax)
33
- }
35
+ )
34
36
  end
35
37
  end
36
38
  end
@@ -215,14 +215,11 @@ describe Paypal::Express::Request do
215
215
  instance._method_.should == :CreateRecurringPaymentsProfile
216
216
  instance._sent_params_.should == {
217
217
  :DESC => 'Recurring Profile',
218
- :TRIALAMT => '0.00',
219
218
  :TOKEN => 'token',
220
219
  :SHIPPINGAMT => '0.00',
221
220
  :AMT => '1000.00',
222
- :TRIALTOTALBILLINGCYCLES => 0,
223
221
  :BILLINGFREQUENCY => 1,
224
222
  :MAXFAILEDPAYMENTS => 0,
225
- :TRIALBILLINGFREQUENCY => 0,
226
223
  :BILLINGPERIOD => :Month,
227
224
  :TAXAMT => '0.00',
228
225
  :PROFILESTARTDATE => '2011-02-08 09:00:00',
@@ -5,6 +5,10 @@ describe Paypal::Payment::Recurring do
5
5
  Paypal::Payment::Recurring.optional_attributes
6
6
  end
7
7
 
8
+ let :trial_attributes do
9
+ {}
10
+ end
11
+
8
12
  let :attributes do
9
13
  {
10
14
  :identifier => '12345',
@@ -27,7 +31,7 @@ describe Paypal::Payment::Recurring do
27
31
  :period => 'Month',
28
32
  :frequency => '1',
29
33
  :total_cycles => '0',
30
- :trial_amount_paid => '0'
34
+ :trial => trial_attributes
31
35
  },
32
36
  :regular_billing => {
33
37
  :amount => '1000',
@@ -61,6 +65,24 @@ describe Paypal::Payment::Recurring do
61
65
  instance.description.should == 'Subscription Payment Profile'
62
66
  instance.status.should == 'Active'
63
67
  instance.start_date.should == '2011-02-03T15:00:00Z'
68
+ instance.billing.trial.should be_nil
69
+ end
70
+
71
+ context 'when optional trial info given' do
72
+ let :trial_attributes do
73
+ {
74
+ :period => 'Month',
75
+ :frequency => '1',
76
+ :total_cycles => '0',
77
+ :currency_code => 'JPY',
78
+ :amount => '1000',
79
+ :shipping_amount => '0',
80
+ :tax_amount => '0'
81
+ }
82
+ end
83
+ it 'should setup trial billing info' do
84
+ instance.billing.trial.should == Paypal::Payment::Recurring::Billing.new(trial_attributes)
85
+ end
64
86
  end
65
87
  end
66
88
 
@@ -69,7 +91,6 @@ describe Paypal::Payment::Recurring do
69
91
  instance.to_params.should == {
70
92
  :AUTOBILLOUTAMT => 'NoAutoBill',
71
93
  :BILLINGFREQUENCY => 1,
72
- :TRIALTOTALBILLINGCYCLES => 0,
73
94
  :SHIPPINGAMT => '0.00',
74
95
  :DESC => 'Subscription Payment Profile',
75
96
  :SUBSCRIBERNAME => 'Nov Matake',
@@ -77,9 +98,7 @@ describe Paypal::Payment::Recurring do
77
98
  :AMT => '1000.00',
78
99
  :MAXFAILEDPAYMENTS => 0,
79
100
  :TOTALBILLINGCYCLES => 0,
80
- :TRIALBILLINGFREQUENCY => 0,
81
101
  :TAXAMT => '0.00',
82
- :TRIALAMT => '0.00',
83
102
  :PROFILESTARTDATE => '2011-02-03T15:00:00Z',
84
103
  :CURRENCYCODE => 'JPY'
85
104
  }
@@ -94,6 +113,43 @@ describe Paypal::Payment::Recurring do
94
113
  instance.to_params[:PROFILESTARTDATE].should == '2011-02-08 15:00:00'
95
114
  end
96
115
  end
116
+
117
+ context 'when optional trial setting given' do
118
+ let :trial_attributes do
119
+ {
120
+ :period => 'Month',
121
+ :frequency => '1',
122
+ :total_cycles => '0',
123
+ :currency_code => 'JPY',
124
+ :amount => '1000',
125
+ :shipping_amount => '0',
126
+ :tax_amount => '0'
127
+ }
128
+ end
129
+ it 'should setup trial billing info' do
130
+ instance.to_params.should == {
131
+ :TRIALBILLINGPERIOD => "Month",
132
+ :TRIALBILLINGFREQUENCY => 1,
133
+ :TRIALTOTALBILLINGCYCLES => 0,
134
+ :TRIALAMT => "1000.00",
135
+ :TRIALCURRENCYCODE => "JPY",
136
+ :TRIALSHIPPINGAMT => "0.00",
137
+ :TRIALTAXAMT => "0.00",
138
+ :BILLINGPERIOD => "Month",
139
+ :BILLINGFREQUENCY => 1,
140
+ :TOTALBILLINGCYCLES => 0,
141
+ :AMT => "1000.00",
142
+ :CURRENCYCODE => "JPY",
143
+ :SHIPPINGAMT => "0.00",
144
+ :TAXAMT => "0.00",
145
+ :DESC => "Subscription Payment Profile",
146
+ :MAXFAILEDPAYMENTS => 0,
147
+ :AUTOBILLOUTAMT => "NoAutoBill",
148
+ :PROFILESTARTDATE => "2011-02-03T15:00:00Z",
149
+ :SUBSCRIBERNAME => "Nov Matake"
150
+ }
151
+ end
152
+ end
97
153
  end
98
154
 
99
155
  describe '#numeric_attribute?' do
metadata CHANGED
@@ -1,115 +1,113 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: paypal-express
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.2
4
5
  prerelease:
5
- version: 0.4.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - nov matake
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-10-31 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2011-12-12 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: activesupport
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70322854319420 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "2.3"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '2.3'
24
22
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: i18n
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70322854319420
25
+ - !ruby/object:Gem::Dependency
26
+ name: i18n
27
+ requirement: &70322854315180 !ruby/object:Gem::Requirement
30
28
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
35
33
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: restclient_with_cert
39
34
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70322854315180
36
+ - !ruby/object:Gem::Dependency
37
+ name: restclient_with_cert
38
+ requirement: &70322854310980 !ruby/object:Gem::Requirement
41
39
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
46
44
  type: :runtime
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: attr_required
50
45
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *70322854310980
47
+ - !ruby/object:Gem::Dependency
48
+ name: attr_required
49
+ requirement: &70322854675020 !ruby/object:Gem::Requirement
52
50
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
56
54
  version: 0.0.3
57
55
  type: :runtime
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: rake
61
56
  prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *70322854675020
58
+ - !ruby/object:Gem::Dependency
59
+ name: rake
60
+ requirement: &70322854724440 !ruby/object:Gem::Requirement
63
61
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: "0.8"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0.8'
68
66
  type: :development
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
71
- name: rcov
72
67
  prerelease: false
73
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *70322854724440
69
+ - !ruby/object:Gem::Dependency
70
+ name: rcov
71
+ requirement: &70322854758020 !ruby/object:Gem::Requirement
74
72
  none: false
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- version: "0.9"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0.9'
79
77
  type: :development
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
82
- name: rspec
83
78
  prerelease: false
84
- requirement: &id007 !ruby/object:Gem::Requirement
79
+ version_requirements: *70322854758020
80
+ - !ruby/object:Gem::Dependency
81
+ name: rspec
82
+ requirement: &70322854774440 !ruby/object:Gem::Requirement
85
83
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: "2"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '2'
90
88
  type: :development
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
93
- name: fakeweb
94
89
  prerelease: false
95
- requirement: &id008 !ruby/object:Gem::Requirement
90
+ version_requirements: *70322854774440
91
+ - !ruby/object:Gem::Dependency
92
+ name: fakeweb
93
+ requirement: &70322854785300 !ruby/object:Gem::Requirement
96
94
  none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
100
98
  version: 1.3.0
101
99
  type: :development
102
- version_requirements: *id008
103
- description: PayPal Express Checkout API Client for Instance, Recurring and Digital Goods Payment.
100
+ prerelease: false
101
+ version_requirements: *70322854785300
102
+ description: PayPal Express Checkout API Client for Instance, Recurring and Digital
103
+ Goods Payment.
104
104
  email: nov@matake.jp
105
105
  executables: []
106
-
107
106
  extensions: []
108
-
109
- extra_rdoc_files:
107
+ extra_rdoc_files:
110
108
  - LICENSE
111
109
  - README.rdoc
112
- files:
110
+ files:
113
111
  - .document
114
112
  - .gitignore
115
113
  - .rspec
@@ -191,32 +189,31 @@ files:
191
189
  - spec/spec_helper.rb
192
190
  homepage: http://github.com/nov/paypal-express
193
191
  licenses: []
194
-
195
192
  post_install_message:
196
- rdoc_options:
193
+ rdoc_options:
197
194
  - --charset=UTF-8
198
- require_paths:
195
+ require_paths:
199
196
  - lib
200
- required_ruby_version: !ruby/object:Gem::Requirement
197
+ required_ruby_version: !ruby/object:Gem::Requirement
201
198
  none: false
202
- requirements:
203
- - - ">="
204
- - !ruby/object:Gem::Version
205
- version: "0"
206
- required_rubygems_version: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ! '>='
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ required_rubygems_version: !ruby/object:Gem::Requirement
207
204
  none: false
208
- requirements:
209
- - - ">="
210
- - !ruby/object:Gem::Version
205
+ requirements:
206
+ - - ! '>='
207
+ - !ruby/object:Gem::Version
211
208
  version: 1.3.6
212
209
  requirements: []
213
-
214
210
  rubyforge_project:
215
- rubygems_version: 1.8.10
211
+ rubygems_version: 1.8.12
216
212
  signing_key:
217
213
  specification_version: 3
218
- summary: PayPal Express Checkout API Client for Instance, Recurring and Digital Goods Payment.
219
- test_files:
214
+ summary: PayPal Express Checkout API Client for Instance, Recurring and Digital Goods
215
+ Payment.
216
+ test_files:
220
217
  - spec/fake_response/BillAgreementUpdate/fetch.txt
221
218
  - spec/fake_response/BillAgreementUpdate/revoke.txt
222
219
  - spec/fake_response/CreateBillingAgreement/success.txt