paypal-express 0.2.5 → 0.2.6

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.5
1
+ 0.2.6
@@ -28,13 +28,19 @@ module Paypal
28
28
  v.blank?
29
29
  end
30
30
  if self.items.present?
31
- params[:"PAYMENTREQUEST_#{index}_ITEMAMT"] = Util.formatted_amount(items.sum(&:quantity) * items.sum(&:amount).to_f)
31
+ params[:"PAYMENTREQUEST_#{index}_ITEMAMT"] = Util.formatted_amount(self.items_amount)
32
32
  self.items.each_with_index do |item, item_index|
33
33
  params.merge! item.to_params(index, item_index)
34
34
  end
35
35
  end
36
36
  params
37
37
  end
38
+
39
+ def items_amount
40
+ self.items.inject(0.0) do |total, item|
41
+ total += item.quantity * item.amount.to_f
42
+ end
43
+ end
38
44
  end
39
45
  end
40
46
  end
@@ -3,15 +3,20 @@ 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 => 20.5,
6
+ :amount => 23.8,
7
7
  :currency_code => :JPY,
8
8
  :description => 'Instant Payment Request',
9
9
  :notify_url => 'http://merchant.example.com/notify',
10
10
  :items => [{
11
11
  :quantity => 2,
12
12
  :name => 'Item1',
13
- :description => 'Awesome Item!',
13
+ :description => 'Awesome Item 1!',
14
14
  :amount => 10.25
15
+ }, {
16
+ :quantity => 3,
17
+ :name => 'Item2',
18
+ :description => 'Awesome Item 2!',
19
+ :amount => 1.1
15
20
  }]
16
21
  )
17
22
  end
@@ -26,7 +31,7 @@ describe Paypal::Payment::Request do
26
31
 
27
32
  describe '.new' do
28
33
  it 'should handle Instant Payment parameters' do
29
- instant_request.amount.should == 20.5
34
+ instant_request.amount.should == 23.8
30
35
  instant_request.currency_code.should == :JPY
31
36
  instant_request.description.should == 'Instant Payment Request'
32
37
  instant_request.notify_url.should == 'http://merchant.example.com/notify'
@@ -42,15 +47,19 @@ describe Paypal::Payment::Request do
42
47
  describe '#to_params' do
43
48
  it 'should handle Instant Payment parameters' do
44
49
  instant_request.to_params.should == {
45
- :PAYMENTREQUEST_0_AMT => "20.50",
50
+ :PAYMENTREQUEST_0_AMT => "23.80",
46
51
  :PAYMENTREQUEST_0_CURRENCYCODE => :JPY,
47
52
  :PAYMENTREQUEST_0_DESC => "Instant Payment Request",
48
53
  :PAYMENTREQUEST_0_NOTIFYURL => "http://merchant.example.com/notify",
49
- :PAYMENTREQUEST_0_ITEMAMT => "20.50",
54
+ :PAYMENTREQUEST_0_ITEMAMT => "23.80",
50
55
  :L_PAYMENTREQUEST_0_NAME0 => "Item1",
51
- :L_PAYMENTREQUEST_0_DESC0 => "Awesome Item!",
56
+ :L_PAYMENTREQUEST_0_DESC0 => "Awesome Item 1!",
52
57
  :L_PAYMENTREQUEST_0_AMT0 => "10.25",
53
- :L_PAYMENTREQUEST_0_QTY0 => 2
58
+ :L_PAYMENTREQUEST_0_QTY0 => 2,
59
+ :L_PAYMENTREQUEST_0_NAME1 => "Item2",
60
+ :L_PAYMENTREQUEST_0_DESC1 => "Awesome Item 2!",
61
+ :L_PAYMENTREQUEST_0_AMT1 => "1.10",
62
+ :L_PAYMENTREQUEST_0_QTY1 => 3
54
63
  }
55
64
  end
56
65
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paypal-express
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 5
10
- version: 0.2.5
9
+ - 6
10
+ version: 0.2.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - nov matake
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-20 00:00:00 +09:00
18
+ date: 2011-04-21 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency