Skip to content

Commit

Permalink
version 0.2.3
Browse files Browse the repository at this point in the history
fixed ITEMAMT calculation
  • Loading branch information
nov committed Mar 29, 2011
1 parent 99b1ad5 commit 75511d2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.2.2
0.2.3
2 changes: 1 addition & 1 deletion lib/paypal/payment/request.rb
Expand Up @@ -28,7 +28,7 @@ def to_params(index = 0)
v.blank?
end
if self.items.present?
params[:"PAYMENTREQUEST_#{index}_ITEMAMT"] = Util.formatted_amount(items.sum(&:amount).to_i)
params[:"PAYMENTREQUEST_#{index}_ITEMAMT"] = Util.formatted_amount(items.sum(&:amount))
self.items.each_with_index do |item, item_index|
params.merge! item.to_params(index, item_index)
end
Expand Down
24 changes: 16 additions & 8 deletions spec/paypal/payment/request_spec.rb
Expand Up @@ -3,14 +3,18 @@
describe Paypal::Payment::Request do
let :instant_request do
Paypal::Payment::Request.new(
:amount => 10,
:amount => 20.3,
:currency_code => :JPY,
:description => 'Instant Payment Request',
:notify_url => 'http://merchant.example.com/notify',
:items => [{
:name => 'Item0',
:description => 'Awesome Item!',
:amount => 10.25
}, {
:name => 'Item1',
:description => 'Awesome Item!',
:amount => 10
:amount => 10.05
}]
)
end
Expand All @@ -25,7 +29,7 @@

describe '.new' do
it 'should handle Instant Payment parameters' do
instant_request.amount.should == 10
instant_request.amount.should == 20.3
instant_request.currency_code.should == :JPY
instant_request.description.should == 'Instant Payment Request'
instant_request.notify_url.should == 'http://merchant.example.com/notify'
Expand All @@ -41,15 +45,19 @@
describe '#to_params' do
it 'should handle Instant Payment parameters' do
instant_request.to_params.should == {
:PAYMENTREQUEST_0_AMT => "10.00",
:PAYMENTREQUEST_0_AMT => "20.30",
:PAYMENTREQUEST_0_CURRENCYCODE => :JPY,
:PAYMENTREQUEST_0_DESC => "Instant Payment Request",
:PAYMENTREQUEST_0_NOTIFYURL => "http://merchant.example.com/notify",
:PAYMENTREQUEST_0_ITEMAMT => "10.00",
:L_PAYMENTREQUEST_0_NAME0 => "Item1",
:PAYMENTREQUEST_0_ITEMAMT => "20.30",
:L_PAYMENTREQUEST_0_NAME0 => "Item0",
:L_PAYMENTREQUEST_0_DESC0 => "Awesome Item!",
:L_PAYMENTREQUEST_0_AMT0 => "10.00",
:L_PAYMENTREQUEST_0_QTY0 => 1
:L_PAYMENTREQUEST_0_AMT0 => "10.25",
:L_PAYMENTREQUEST_0_QTY0 => 1,
:L_PAYMENTREQUEST_0_NAME1 => "Item1",
:L_PAYMENTREQUEST_0_DESC1 => "Awesome Item!",
:L_PAYMENTREQUEST_0_AMT1 => "10.05",
:L_PAYMENTREQUEST_0_QTY1 => 1
}
end

Expand Down

0 comments on commit 75511d2

Please sign in to comment.