paypal-express 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.6
1
+ 0.2.7
@@ -1,10 +1,19 @@
1
1
  module Paypal
2
2
  module Payment
3
3
  class Request < Base
4
- attr_optional :amount, :action, :currency_code, :description, :notify_url, :billing_type, :billing_agreement_description
5
- attr_accessor :items
4
+ attr_optional :action, :currency_code, :description, :notify_url, :billing_type, :billing_agreement_description
5
+ attr_accessor :amount, :items
6
6
 
7
7
  def initialize(attributes = {})
8
+ @amount = if attributes[:amount].is_a?(Common::Amount)
9
+ attributes[:amount]
10
+ else
11
+ Common::Amount.new(
12
+ :total => attributes[:amount],
13
+ :tax => attributes[:tax_amount],
14
+ :shipping => attributes[:shipping_amount]
15
+ )
16
+ end
8
17
  @items = []
9
18
  Array(attributes[:items]).each do |item_attrs|
10
19
  @items << Item.new(item_attrs)
@@ -15,7 +24,9 @@ module Paypal
15
24
  def to_params(index = 0)
16
25
  params = {
17
26
  :"PAYMENTREQUEST_#{index}_PAYMENTACTION" => self.action,
18
- :"PAYMENTREQUEST_#{index}_AMT" => Util.formatted_amount(self.amount),
27
+ :"PAYMENTREQUEST_#{index}_AMT" => Util.formatted_amount(self.amount.total),
28
+ :"PAYMENTREQUEST_#{index}_TAXAMT" => Util.formatted_amount(self.amount.tax),
29
+ :"PAYMENTREQUEST_#{index}_SHIPPINGAMT" => Util.formatted_amount(self.amount.shipping),
19
30
  :"PAYMENTREQUEST_#{index}_CURRENCYCODE" => self.currency_code,
20
31
  :"PAYMENTREQUEST_#{index}_DESC" => self.description,
21
32
  # NOTE:
@@ -91,6 +91,8 @@ describe Paypal::Express::Request do
91
91
  :RETURNURL => 'http://example.com/success',
92
92
  :CANCELURL => 'http://example.com/cancel',
93
93
  :PAYMENTREQUEST_0_AMT => '1000.00',
94
+ :PAYMENTREQUEST_0_TAXAMT => "0.00",
95
+ :PAYMENTREQUEST_0_SHIPPINGAMT => "0.00",
94
96
  :REQCONFIRMSHIPPING => 0,
95
97
  :NOSHIPPING => 1
96
98
  }
@@ -106,7 +108,9 @@ describe Paypal::Express::Request do
106
108
  :PAYMENTREQUEST_0_DESC => 'Instant Payment Request',
107
109
  :RETURNURL => 'http://example.com/success',
108
110
  :CANCELURL => 'http://example.com/cancel',
109
- :PAYMENTREQUEST_0_AMT => '1000.00'
111
+ :PAYMENTREQUEST_0_AMT => '1000.00',
112
+ :PAYMENTREQUEST_0_TAXAMT => "0.00",
113
+ :PAYMENTREQUEST_0_SHIPPINGAMT => "0.00"
110
114
  }
111
115
  end
112
116
  end
@@ -122,7 +126,9 @@ describe Paypal::Express::Request do
122
126
  :L_BILLINGAGREEMENTDESCRIPTION0 => 'Recurring Payment Request',
123
127
  :RETURNURL => 'http://example.com/success',
124
128
  :CANCELURL => 'http://example.com/cancel',
125
- :PAYMENTREQUEST_0_AMT => '0.00'
129
+ :PAYMENTREQUEST_0_AMT => '0.00',
130
+ :PAYMENTREQUEST_0_TAXAMT => "0.00",
131
+ :PAYMENTREQUEST_0_SHIPPINGAMT => "0.00"
126
132
  }
127
133
  end
128
134
  end
@@ -162,7 +168,9 @@ describe Paypal::Express::Request do
162
168
  :PAYERID => 'payer_id',
163
169
  :TOKEN => 'token',
164
170
  :PAYMENTREQUEST_0_DESC => 'Instant Payment Request',
165
- :PAYMENTREQUEST_0_AMT => '1000.00'
171
+ :PAYMENTREQUEST_0_AMT => '1000.00',
172
+ :PAYMENTREQUEST_0_TAXAMT => "0.00",
173
+ :PAYMENTREQUEST_0_SHIPPINGAMT => "0.00"
166
174
  }
167
175
  end
168
176
  end
@@ -3,7 +3,9 @@ require 'spec_helper.rb'
3
3
  describe Paypal::Payment::Request do
4
4
  let :instant_request do
5
5
  Paypal::Payment::Request.new(
6
- :amount => 23.8,
6
+ :amount => 25.7,
7
+ :tax_amount => 0.4,
8
+ :shipping_amount => 1.5,
7
9
  :currency_code => :JPY,
8
10
  :description => 'Instant Payment Request',
9
11
  :notify_url => 'http://merchant.example.com/notify',
@@ -16,7 +18,7 @@ describe Paypal::Payment::Request do
16
18
  :quantity => 3,
17
19
  :name => 'Item2',
18
20
  :description => 'Awesome Item 2!',
19
- :amount => 1.1
21
+ :amount => 1.1
20
22
  }]
21
23
  )
22
24
  end
@@ -31,7 +33,9 @@ describe Paypal::Payment::Request do
31
33
 
32
34
  describe '.new' do
33
35
  it 'should handle Instant Payment parameters' do
34
- instant_request.amount.should == 23.8
36
+ instant_request.amount.total.should == 25.7
37
+ instant_request.amount.tax.should == 0.4
38
+ instant_request.amount.shipping.should == 1.5
35
39
  instant_request.currency_code.should == :JPY
36
40
  instant_request.description.should == 'Instant Payment Request'
37
41
  instant_request.notify_url.should == 'http://merchant.example.com/notify'
@@ -47,7 +51,9 @@ describe Paypal::Payment::Request do
47
51
  describe '#to_params' do
48
52
  it 'should handle Instant Payment parameters' do
49
53
  instant_request.to_params.should == {
50
- :PAYMENTREQUEST_0_AMT => "23.80",
54
+ :PAYMENTREQUEST_0_AMT => "25.70",
55
+ :PAYMENTREQUEST_0_TAXAMT => "0.40",
56
+ :PAYMENTREQUEST_0_SHIPPINGAMT => "1.50",
51
57
  :PAYMENTREQUEST_0_CURRENCYCODE => :JPY,
52
58
  :PAYMENTREQUEST_0_DESC => "Instant Payment Request",
53
59
  :PAYMENTREQUEST_0_NOTIFYURL => "http://merchant.example.com/notify",
@@ -66,6 +72,8 @@ describe Paypal::Payment::Request do
66
72
  it 'should handle Recurring Payment parameters' do
67
73
  recurring_request.to_params.should == {
68
74
  :PAYMENTREQUEST_0_AMT => "0.00",
75
+ :PAYMENTREQUEST_0_TAXAMT => "0.00",
76
+ :PAYMENTREQUEST_0_SHIPPINGAMT => "0.00",
69
77
  :PAYMENTREQUEST_0_CURRENCYCODE => :JPY,
70
78
  :L_BILLINGTYPE0 => :RecurringPayments,
71
79
  :L_BILLINGAGREEMENTDESCRIPTION0 => "Recurring Payment Request"
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paypal-express
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 6
10
- version: 0.2.6
5
+ version: 0.2.7
11
6
  platform: ruby
12
7
  authors:
13
8
  - nov matake
@@ -15,8 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-04-21 00:00:00 +09:00
19
- default_executable:
13
+ date: 2011-04-25 00:00:00 Z
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
22
16
  name: activesupport
@@ -26,10 +20,6 @@ dependencies:
26
20
  requirements:
27
21
  - - ">="
28
22
  - !ruby/object:Gem::Version
29
- hash: 5
30
- segments:
31
- - 2
32
- - 3
33
23
  version: "2.3"
34
24
  type: :runtime
35
25
  version_requirements: *id001
@@ -41,9 +31,6 @@ dependencies:
41
31
  requirements:
42
32
  - - ">="
43
33
  - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
34
  version: "0"
48
35
  type: :runtime
49
36
  version_requirements: *id002
@@ -55,9 +42,6 @@ dependencies:
55
42
  requirements:
56
43
  - - ">="
57
44
  - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
45
  version: "0"
62
46
  type: :runtime
63
47
  version_requirements: *id003
@@ -69,11 +53,6 @@ dependencies:
69
53
  requirements:
70
54
  - - ">="
71
55
  - !ruby/object:Gem::Version
72
- hash: 25
73
- segments:
74
- - 0
75
- - 0
76
- - 3
77
56
  version: 0.0.3
78
57
  type: :runtime
79
58
  version_requirements: *id004
@@ -85,10 +64,6 @@ dependencies:
85
64
  requirements:
86
65
  - - ">="
87
66
  - !ruby/object:Gem::Version
88
- hash: 27
89
- segments:
90
- - 0
91
- - 8
92
67
  version: "0.8"
93
68
  type: :development
94
69
  version_requirements: *id005
@@ -100,10 +75,6 @@ dependencies:
100
75
  requirements:
101
76
  - - ">="
102
77
  - !ruby/object:Gem::Version
103
- hash: 25
104
- segments:
105
- - 0
106
- - 9
107
78
  version: "0.9"
108
79
  type: :development
109
80
  version_requirements: *id006
@@ -115,9 +86,6 @@ dependencies:
115
86
  requirements:
116
87
  - - ">="
117
88
  - !ruby/object:Gem::Version
118
- hash: 7
119
- segments:
120
- - 2
121
89
  version: "2"
122
90
  type: :development
123
91
  version_requirements: *id007
@@ -129,11 +97,6 @@ dependencies:
129
97
  requirements:
130
98
  - - ">="
131
99
  - !ruby/object:Gem::Version
132
- hash: 27
133
- segments:
134
- - 1
135
- - 3
136
- - 0
137
100
  version: 1.3.0
138
101
  type: :development
139
102
  version_requirements: *id008
@@ -214,7 +177,6 @@ files:
214
177
  - spec/paypal/payment/response_spec.rb
215
178
  - spec/paypal/util_spec.rb
216
179
  - spec/spec_helper.rb
217
- has_rdoc: true
218
180
  homepage: http://github.com/nov/paypal-express
219
181
  licenses: []
220
182
 
@@ -228,25 +190,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
228
190
  requirements:
229
191
  - - ">="
230
192
  - !ruby/object:Gem::Version
231
- hash: 3
232
- segments:
233
- - 0
234
193
  version: "0"
235
194
  required_rubygems_version: !ruby/object:Gem::Requirement
236
195
  none: false
237
196
  requirements:
238
197
  - - ">="
239
198
  - !ruby/object:Gem::Version
240
- hash: 23
241
- segments:
242
- - 1
243
- - 3
244
- - 6
245
199
  version: 1.3.6
246
200
  requirements: []
247
201
 
248
202
  rubyforge_project:
249
- rubygems_version: 1.5.3
203
+ rubygems_version: 1.7.2
250
204
  signing_key:
251
205
  specification_version: 3
252
206
  summary: PayPal Express Checkout API Client for Instance, Recurring and Digital Goods Payment.