paypal-express 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
@@ -8,6 +8,10 @@ module Paypal
|
|
8
8
|
:RETURNURL => self.return_url,
|
9
9
|
:CANCELURL => self.cancel_url
|
10
10
|
}
|
11
|
+
if options[:no_shipping]
|
12
|
+
params[:REQCONFIRMSHIPPING] = 0
|
13
|
+
params[:NOSHIPPING] = 1
|
14
|
+
end
|
11
15
|
Array(payment_requests).each_with_index do |payment_request, index|
|
12
16
|
params.merge! payment_request.to_params(index)
|
13
17
|
end
|
@@ -11,24 +11,29 @@ module Paypal
|
|
11
11
|
|
12
12
|
def redirect_uri
|
13
13
|
endpoint = URI.parse Paypal.endpoint
|
14
|
-
endpoint.query = query.to_query
|
14
|
+
endpoint.query = query(:redirect).to_query
|
15
15
|
endpoint.to_s
|
16
16
|
end
|
17
17
|
|
18
18
|
def popup_uri
|
19
19
|
endpoint = URI.parse Paypal.popup_endpoint
|
20
|
-
endpoint.query =
|
20
|
+
endpoint.query = query(:popup).to_query
|
21
21
|
endpoint.to_s
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
-
def query
|
26
|
+
def query(mode)
|
27
27
|
_query_ = {:token => self.token}
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
case mode
|
29
|
+
when :redirect
|
30
|
+
if self.on_mobile
|
31
|
+
_query_.merge!(:cmd => '_express-checkout-mobile')
|
32
|
+
else
|
33
|
+
_query_.merge!(:cmd => '_express-checkout')
|
34
|
+
end
|
35
|
+
when :popup
|
36
|
+
# No popup specific params for now
|
32
37
|
end
|
33
38
|
if self.pay_on_paypal
|
34
39
|
_query_.merge!(:useraction => 'commit')
|
@@ -27,8 +27,11 @@ module Paypal
|
|
27
27
|
}.delete_if do |k, v|
|
28
28
|
v.blank?
|
29
29
|
end
|
30
|
-
self.items.
|
31
|
-
params
|
30
|
+
if self.items.present?
|
31
|
+
params[:"PAYMENTREQUEST_#{index}_ITEMAMT"] = items.sum(&:amount)
|
32
|
+
self.items.each_with_index do |item, item_index|
|
33
|
+
params.merge! item.to_params(index, item_index)
|
34
|
+
end
|
32
35
|
end
|
33
36
|
params
|
34
37
|
end
|
@@ -3,6 +3,10 @@ module Paypal
|
|
3
3
|
class Request::Item < Base
|
4
4
|
attr_optional :name, :description, :amount, :quantity, :category
|
5
5
|
|
6
|
+
def initialize(attributes = {})
|
7
|
+
@quantity ||= 1
|
8
|
+
end
|
9
|
+
|
6
10
|
def to_params(parent_index, index = 0)
|
7
11
|
{
|
8
12
|
:"L_PAYMENTREQUEST_#{parent_index}_NAME#{index}" => self.name,
|
@@ -30,13 +30,14 @@ describe Paypal::Express::Response do
|
|
30
30
|
it 'should support on_mobile option' do
|
31
31
|
response = request.setup payment_request, :on_mobile => true
|
32
32
|
response.on_mobile.should be_true
|
33
|
-
response.send(:query)[:cmd].should == '_express-checkout-mobile'
|
33
|
+
response.send(:query, :redirect)[:cmd].should == '_express-checkout-mobile'
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should support pay_on_paypal option' do
|
37
37
|
response = request.setup payment_request, :pay_on_paypal => true
|
38
38
|
response.pay_on_paypal.should be_true
|
39
|
-
response.send(:query)[:useraction].should == 'commit'
|
39
|
+
response.send(:query, :popup)[:useraction].should == 'commit'
|
40
|
+
response.send(:query, :redirect)[:useraction].should == 'commit'
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
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:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 8
|
10
|
+
version: 0.0.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- nov matake
|