paypal-express 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +9 -3
- data/VERSION +1 -1
- data/lib/paypal/express/request.rb +5 -0
- data/lib/paypal/nvp/response.rb +21 -1
- data/lib/paypal/payment/request/item.rb +4 -2
- data/lib/paypal/payment/response.rb +5 -1
- data/lib/paypal/payment/response/item.rb +6 -1
- data/spec/fake_response/GetTransactionDetails/failure.txt +1 -0
- data/spec/fake_response/GetTransactionDetails/success.txt +1 -0
- data/spec/paypal/express/request_spec.rb +39 -8
- data/spec/paypal/payment/request/item_spec.rb +4 -2
- data/spec/paypal/payment/response/item_spec.rb +2 -0
- data/spec/spec_helper.rb +0 -3
- metadata +22 -18
data/Rakefile
CHANGED
@@ -5,9 +5,15 @@ require 'rspec/core/rake_task'
|
|
5
5
|
RSpec::Core::RakeTask.new(:spec)
|
6
6
|
|
7
7
|
if RUBY_VERSION >= '1.9'
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
namespace :cover_me do
|
9
|
+
desc "Generates and opens code coverage report."
|
10
|
+
task :report do
|
11
|
+
require 'cover_me'
|
12
|
+
CoverMe.complete!
|
13
|
+
end
|
14
|
+
end
|
15
|
+
task :spec do
|
16
|
+
Rake::Task['cover_me:report'].invoke
|
11
17
|
end
|
12
18
|
else
|
13
19
|
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.5
|
@@ -25,6 +25,11 @@ module Paypal
|
|
25
25
|
Response.new response
|
26
26
|
end
|
27
27
|
|
28
|
+
def transaction_details( transaction_id )
|
29
|
+
response = self.request :GetTransactionDetails, {:TRANSACTIONID=> transaction_id}
|
30
|
+
Response.new response
|
31
|
+
end
|
32
|
+
|
28
33
|
def checkout!(token, payer_id, payment_requests)
|
29
34
|
params = {
|
30
35
|
:TOKEN => token,
|
data/lib/paypal/nvp/response.rb
CHANGED
@@ -15,7 +15,26 @@ module Paypal
|
|
15
15
|
:NOTIFYURL => :notify_url,
|
16
16
|
:TIMESTAMP => :timestamp,
|
17
17
|
:TOKEN => :token,
|
18
|
-
:VERSION => :version
|
18
|
+
:VERSION => :version,
|
19
|
+
# Some of the attributes below are duplicates of what
|
20
|
+
# exists in the payment response, but paypal doesn't
|
21
|
+
# prefix these with PAYMENTREQUEST when issuing a
|
22
|
+
# GetTransactionDetails response.
|
23
|
+
:RECEIVEREMAIL => :receiver_email,
|
24
|
+
:RECEIVERID => :receiver_id,
|
25
|
+
:ADDRESSOWNER => :address_owner,
|
26
|
+
:SUBJECT => :subject,
|
27
|
+
:TRANSACTIONID => :transaction_id,
|
28
|
+
:TRANSACTIONTYPE => :transaction_type,
|
29
|
+
:PAYMENTTYPE => :payment_type,
|
30
|
+
:ORDERTIME => :order_time,
|
31
|
+
:PAYMENTSTATUS => :payment_status,
|
32
|
+
:PENDINGREASON => :pending_reason,
|
33
|
+
:REASONCODE => :reason_code,
|
34
|
+
:PROTECTIONELIGIBILITY => :protection_eligibility,
|
35
|
+
:PROTECTIONELIGIBILITYTYPE => :protection_eligibility_type,
|
36
|
+
:ADDRESSOWNER => :address_owner,
|
37
|
+
:ADDRESSSTATUS => :address_status
|
19
38
|
}
|
20
39
|
attr_accessor *@@attribute_mapping.values
|
21
40
|
attr_accessor :shipping_options_is_default, :success_page_redirect_requested, :insurance_option_selected
|
@@ -189,6 +208,7 @@ module Paypal
|
|
189
208
|
|
190
209
|
# remove duplicated parameters
|
191
210
|
attrs.delete(:SHIPTOCOUNTRY) # NOTE: Same with SHIPTOCOUNTRYCODE
|
211
|
+
attrs.delete(:SALESTAX) # Same as TAXAMT
|
192
212
|
|
193
213
|
# warn ignored attrs
|
194
214
|
attrs.each do |key, value|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Paypal
|
2
2
|
module Payment
|
3
3
|
class Request::Item < Base
|
4
|
-
attr_optional :name, :description, :amount, :quantity, :category
|
4
|
+
attr_optional :name, :description, :amount, :number, :quantity, :category, :url
|
5
5
|
|
6
6
|
def initialize(attributes = {})
|
7
7
|
super
|
@@ -13,8 +13,10 @@ module Paypal
|
|
13
13
|
:"L_PAYMENTREQUEST_#{parent_index}_NAME#{index}" => self.name,
|
14
14
|
:"L_PAYMENTREQUEST_#{parent_index}_DESC#{index}" => self.description,
|
15
15
|
:"L_PAYMENTREQUEST_#{parent_index}_AMT#{index}" => Util.formatted_amount(self.amount),
|
16
|
+
:"L_PAYMENTREQUEST_#{parent_index}_NUMBER#{index}" => self.number,
|
16
17
|
:"L_PAYMENTREQUEST_#{parent_index}_QTY#{index}" => self.quantity,
|
17
|
-
:"L_PAYMENTREQUEST_#{parent_index}_ITEMCATEGORY#{index}" => self.category
|
18
|
+
:"L_PAYMENTREQUEST_#{parent_index}_ITEMCATEGORY#{index}" => self.category,
|
19
|
+
:"L_PAYMENTREQUEST_#{parent_index}_ITEMURL#{index}" => self.url
|
18
20
|
}.delete_if do |k, v|
|
19
21
|
v.blank?
|
20
22
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Paypal
|
2
2
|
module Payment
|
3
3
|
class Response < Base
|
4
|
-
attr_accessor :amount, :ship_to, :description, :note, :items, :notify_url, :insurance_option_offered, :currency_code, :error_code, :transaction_id, :billing_agreement_id
|
4
|
+
attr_accessor :amount, :ship_to, :description, :note, :items, :notify_url, :insurance_option_offered, :currency_code, :short_message, :long_message, :error_code, :severity_code, :ack, :transaction_id, :billing_agreement_id
|
5
5
|
|
6
6
|
def initialize(attributes = {})
|
7
7
|
attrs = attributes.dup
|
@@ -29,7 +29,11 @@ module Paypal
|
|
29
29
|
@notify_url = attrs.delete(:NOTIFYURL)
|
30
30
|
@insurance_option_offered = attrs.delete(:INSURANCEOPTIONOFFERED) == 'true'
|
31
31
|
@currency_code = attrs.delete(:CURRENCYCODE)
|
32
|
+
@short_message = attrs.delete(:SHORTMESSAGE)
|
33
|
+
@long_message = attrs.delete(:LONGMESSAGE)
|
32
34
|
@error_code = attrs.delete(:ERRORCODE)
|
35
|
+
@severity_code = attrs.delete(:SEVERITYCODE)
|
36
|
+
@ack = attrs.delete(:ACK)
|
33
37
|
@transaction_id = attrs.delete(:TRANSACTIONID)
|
34
38
|
@billing_agreement_id = attrs.delete(:BILLINGAGREEMENTID)
|
35
39
|
|
@@ -6,11 +6,16 @@ module Paypal
|
|
6
6
|
:NAME => :name,
|
7
7
|
:DESC => :description,
|
8
8
|
:QTY => :quantity,
|
9
|
+
:NUMBER => :number,
|
9
10
|
:ITEMCATEGORY => :category,
|
10
11
|
:ITEMWIDTHVALUE => :width,
|
11
12
|
:ITEMHEIGHTVALUE => :height,
|
12
13
|
:ITEMLENGTHVALUE => :length,
|
13
|
-
:ITEMWEIGHTVALUE => :weight
|
14
|
+
:ITEMWEIGHTVALUE => :weight,
|
15
|
+
:SHIPPINGAMT => :shipping,
|
16
|
+
:HANDLINGAMT => :handling,
|
17
|
+
:CURRENCYCODE => :currency
|
18
|
+
|
14
19
|
}
|
15
20
|
attr_accessor *@@attribute_mapping.values
|
16
21
|
attr_accessor :amount
|
@@ -0,0 +1 @@
|
|
1
|
+
ADDRESSOWNER=PayPal&ADDRESSSTATUS=None&TIMESTAMP=2012%2d02%2d23T21%3a07%3a22Z&CORRELATIONID=4e18d75a23953&ACK=Failure&VERSION=78%2e0&BUILD=2571254&L_ERRORCODE0=10004&L_SHORTMESSAGE0=Transaction%20refused%20because%20of%20an%20invalid%20argument%2e%20See%20additional%20error%20messages%20for%20details%2e&L_LONGMESSAGE0=The%20transaction%20id%20is%20not%20valid&L_SEVERITYCODE0=Error&PENDINGREASON=None&REASONCODE=None
|
@@ -0,0 +1 @@
|
|
1
|
+
RECEIVEREMAIL=test%40email%2ecom&RECEIVERID=ABCDEFG12345&EMAIL=test%40email%2ecom&PAYERID=12345ABCDEFG&PAYERSTATUS=verified&COUNTRYCODE=US&SHIPTONAME=Billy%20Bob&SHIPTOSTREET=1%20Main%20St&SHIPTOCITY=San%20Jose&SHIPTOSTATE=CA&SHIPTOCOUNTRYCODE=US&SHIPTOCOUNTRYNAME=United%20States&SHIPTOZIP=95131&ADDRESSOWNER=PayPal&ADDRESSSTATUS=Confirmed&SALESTAX=0%2e00&SUBJECT=Test%20Subject&TIMESTAMP=2012%2d02%2d23T20%3a51%3a29Z&CORRELATIONID=4fc0a06cbaec7&ACK=Success&VERSION=78%2e0&BUILD=2571254&FIRSTNAME=Billy&LASTNAME=Bob&TRANSACTIONID=123456789ABCD&TRANSACTIONTYPE=cart&PAYMENTTYPE=instant&ORDERTIME=2012%2d02%2d13T23%3a09%3a46Z&AMT=740%2e43&FEEAMT=21%2e77&TAXAMT=0%2e00&SHIPPINGAMT=0%2e00&HANDLINGAMT=0%2e00&CURRENCYCODE=USD&PAYMENTSTATUS=Completed&PENDINGREASON=None&REASONCODE=None&PROTECTIONELIGIBILITY=Eligible&PROTECTIONELIGIBILITYTYPE=ItemNotReceivedEligible%2cUnauthorizedPaymentEligible&L_NAME0=Item%201&L_NAME1=Item%202&L_QTY0=1&L_QTY1=1&L_SHIPPINGAMT0=0%2e00&L_SHIPPINGAMT1=0%2e00&L_HANDLINGAMT0=0%2e00&L_HANDLINGAMT1=0%2e00&L_CURRENCYCODE0=USD&L_CURRENCYCODE1=USD&L_AMT0=687%2e93&L_AMT1=52%2e50
|
@@ -198,6 +198,37 @@ describe Paypal::Express::Request do
|
|
198
198
|
end
|
199
199
|
end
|
200
200
|
|
201
|
+
describe '#transaction_details' do
|
202
|
+
it 'should return Paypal::Express::Response' do
|
203
|
+
fake_response 'GetTransactionDetails/success'
|
204
|
+
response = instance.transaction_details 'transaction_id'
|
205
|
+
response.should be_instance_of Paypal::Express::Response
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'should call GetTransactionDetails' do
|
209
|
+
expect do
|
210
|
+
instance.transaction_details 'transaction_id'
|
211
|
+
end.should request_to nvp_endpoint, :post
|
212
|
+
instance._method_.should == :GetTransactionDetails
|
213
|
+
instance._sent_params_.should == {
|
214
|
+
:TRANSACTIONID=> 'transaction_id'
|
215
|
+
}
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'should fail with bad transaction id' do
|
219
|
+
expect do
|
220
|
+
fake_response 'GetTransactionDetails/failure'
|
221
|
+
response = instance.transaction_details 'bad_transaction_id'
|
222
|
+
end.should raise_error(Paypal::Exception::APIError)
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'should handle all attributes' do
|
226
|
+
Paypal.logger.should_not_receive(:warn)
|
227
|
+
fake_response 'GetTransactionDetails/success'
|
228
|
+
response = instance.transaction_details 'transaction_id'
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
201
232
|
describe '#checkout!' do
|
202
233
|
it 'should return Paypal::Express::Response' do
|
203
234
|
fake_response 'DoExpressCheckoutPayment/success'
|
@@ -222,23 +253,23 @@ describe Paypal::Express::Request do
|
|
222
253
|
|
223
254
|
context "with many items" do
|
224
255
|
before do
|
225
|
-
|
256
|
+
fake_response 'DoExpressCheckoutPayment/success_with_many_items'
|
226
257
|
end
|
227
258
|
|
228
259
|
it 'should handle all attributes' do
|
229
|
-
|
230
|
-
|
260
|
+
Paypal.logger.should_not_receive(:warn)
|
261
|
+
response = instance.checkout! 'token', 'payer_id', instant_payment_request_with_many_items
|
231
262
|
end
|
232
263
|
|
233
264
|
it 'should return Paypal::Express::Response' do
|
234
|
-
|
235
|
-
|
265
|
+
response = instance.checkout! 'token', 'payer_id', instant_payment_request_with_many_items
|
266
|
+
response.should be_instance_of Paypal::Express::Response
|
236
267
|
end
|
237
268
|
|
238
269
|
it 'should return twenty items' do
|
239
|
-
|
240
|
-
|
241
|
-
|
270
|
+
response = instance.checkout! 'token', 'payer_id', instant_payment_request_with_many_items
|
271
|
+
instance._method_.should == :DoExpressCheckoutPayment
|
272
|
+
response.items.count.should == 20
|
242
273
|
end
|
243
274
|
end
|
244
275
|
end
|
@@ -7,7 +7,8 @@ describe Paypal::Payment::Request::Item do
|
|
7
7
|
:description => 'Description',
|
8
8
|
:amount => 10,
|
9
9
|
:quantity => 5,
|
10
|
-
:category => :Digital
|
10
|
+
:category => :Digital,
|
11
|
+
:number => '1'
|
11
12
|
)
|
12
13
|
end
|
13
14
|
|
@@ -18,7 +19,8 @@ describe Paypal::Payment::Request::Item do
|
|
18
19
|
:L_PAYMENTREQUEST_1_DESC0 => 'Description',
|
19
20
|
:L_PAYMENTREQUEST_1_AMT0 => '10.00',
|
20
21
|
:L_PAYMENTREQUEST_1_QTY0 => 5,
|
21
|
-
:L_PAYMENTREQUEST_1_ITEMCATEGORY0 => :Digital
|
22
|
+
:L_PAYMENTREQUEST_1_ITEMCATEGORY0 => :Digital,
|
23
|
+
:L_PAYMENTREQUEST_1_NUMBER0 => '1'
|
22
24
|
}
|
23
25
|
end
|
24
26
|
end
|
@@ -6,6 +6,7 @@ describe Paypal::Payment::Response::Info do
|
|
6
6
|
:NAME => 'Item Name',
|
7
7
|
:DESC => 'Item Description',
|
8
8
|
:QTY => '1',
|
9
|
+
:NUMBER => '1',
|
9
10
|
:ITEMCATEGORY => 'Digital',
|
10
11
|
:ITEMWIDTHVALUE => '1.0',
|
11
12
|
:ITEMHEIGHTVALUE => '2.0',
|
@@ -24,6 +25,7 @@ describe Paypal::Payment::Response::Info do
|
|
24
25
|
its(:height) { should == '2.0' }
|
25
26
|
its(:length) { should == '3.0' }
|
26
27
|
its(:weight) { should == '4.0' }
|
28
|
+
its(:number) { should == '1' }
|
27
29
|
|
28
30
|
context 'when non-supported attributes are given' do
|
29
31
|
it 'should ignore them and warn' do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paypal-express
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-24 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70190063841760 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.3'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70190063841760
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: i18n
|
27
|
-
requirement: &
|
27
|
+
requirement: &70190063841120 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70190063841120
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: restclient_with_cert
|
38
|
-
requirement: &
|
38
|
+
requirement: &70190063840100 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70190063840100
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: attr_required
|
49
|
-
requirement: &
|
49
|
+
requirement: &70190063829120 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.0.5
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70190063829120
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &70190063827760 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0.8'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70190063827760
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: cover_me
|
71
|
-
requirement: &
|
71
|
+
requirement: &70190063826720 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 1.2.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70190063826720
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &70190063826000 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '2'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70190063826000
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: fakeweb
|
93
|
-
requirement: &
|
93
|
+
requirement: &70190063823880 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: 1.3.0
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70190063823880
|
102
102
|
description: PayPal Express Checkout API Client for Instance, Recurring and Digital
|
103
103
|
Goods Payment.
|
104
104
|
email: nov@matake.jp
|
@@ -161,6 +161,8 @@ files:
|
|
161
161
|
- spec/fake_response/GetExpressCheckoutDetails/with_billing_accepted_status.txt
|
162
162
|
- spec/fake_response/GetRecurringPaymentsProfileDetails/failure.txt
|
163
163
|
- spec/fake_response/GetRecurringPaymentsProfileDetails/success.txt
|
164
|
+
- spec/fake_response/GetTransactionDetails/failure.txt
|
165
|
+
- spec/fake_response/GetTransactionDetails/success.txt
|
164
166
|
- spec/fake_response/IPN/invalid.txt
|
165
167
|
- spec/fake_response/IPN/valid.txt
|
166
168
|
- spec/fake_response/ManageRecurringPaymentsProfileStatus/failure.txt
|
@@ -231,6 +233,8 @@ test_files:
|
|
231
233
|
- spec/fake_response/GetExpressCheckoutDetails/with_billing_accepted_status.txt
|
232
234
|
- spec/fake_response/GetRecurringPaymentsProfileDetails/failure.txt
|
233
235
|
- spec/fake_response/GetRecurringPaymentsProfileDetails/success.txt
|
236
|
+
- spec/fake_response/GetTransactionDetails/failure.txt
|
237
|
+
- spec/fake_response/GetTransactionDetails/success.txt
|
234
238
|
- spec/fake_response/IPN/invalid.txt
|
235
239
|
- spec/fake_response/IPN/valid.txt
|
236
240
|
- spec/fake_response/ManageRecurringPaymentsProfileStatus/failure.txt
|