paypal-express 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/paypal/express/request.rb +2 -2
- data/lib/paypal/express/response.rb +24 -4
- data/spec/paypal/express/response_spec.rb +28 -3
- metadata +6 -6
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
@@ -3,7 +3,7 @@ module Paypal
|
|
3
3
|
class Request < NVP::Request
|
4
4
|
attr_required :return_url, :cancel_url
|
5
5
|
|
6
|
-
def setup(payment_requests)
|
6
|
+
def setup(payment_requests, options = {})
|
7
7
|
params = {
|
8
8
|
:RETURNURL => self.return_url,
|
9
9
|
:CANCELURL => self.cancel_url
|
@@ -12,7 +12,7 @@ module Paypal
|
|
12
12
|
params.merge! payment_request.to_params(index)
|
13
13
|
end
|
14
14
|
response = self.request :SetExpressCheckout, params
|
15
|
-
Response.new response
|
15
|
+
Response.new response, options
|
16
16
|
end
|
17
17
|
|
18
18
|
def details(token)
|
@@ -1,14 +1,34 @@
|
|
1
1
|
module Paypal
|
2
2
|
module Express
|
3
3
|
class Response < NVP::Response
|
4
|
+
attr_accessor :on_mobile, :pay_on_paypal
|
5
|
+
|
6
|
+
def initialize(response, options = {})
|
7
|
+
super response
|
8
|
+
@on_mobile = options[:on_mobile]
|
9
|
+
@pay_on_paypal = options[:pay_on_paypal]
|
10
|
+
end
|
11
|
+
|
4
12
|
def redirect_uri
|
5
13
|
endpoint = URI.parse Paypal.endpoint
|
6
|
-
endpoint.query =
|
7
|
-
:cmd => '_express-checkout',
|
8
|
-
:token => self.token
|
9
|
-
}.to_query
|
14
|
+
endpoint.query = query.to_query
|
10
15
|
endpoint.to_s
|
11
16
|
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def query
|
21
|
+
_query_ = {:token => self.token}
|
22
|
+
if self.on_mobile
|
23
|
+
_query_.merge!(:cmd => '_express-checkout-mobile')
|
24
|
+
else
|
25
|
+
_query_.merge!(:cmd => '_express-checkout')
|
26
|
+
end
|
27
|
+
if self.pay_on_paypal
|
28
|
+
_query_.merge!(:useraction => 'commit')
|
29
|
+
end
|
30
|
+
_query_
|
31
|
+
end
|
12
32
|
end
|
13
33
|
end
|
14
34
|
end
|
@@ -1,20 +1,45 @@
|
|
1
1
|
require 'spec_helper.rb'
|
2
2
|
|
3
3
|
describe Paypal::Express::Response do
|
4
|
-
let :
|
5
|
-
|
4
|
+
let :request do
|
5
|
+
Paypal::Express::Request.new(
|
6
6
|
:username => 'nov',
|
7
7
|
:password => 'password',
|
8
8
|
:signature => 'sig',
|
9
9
|
:return_url => 'http://example.com/success',
|
10
10
|
:cancel_url => 'http://example.com/cancel'
|
11
11
|
)
|
12
|
-
|
12
|
+
end
|
13
|
+
|
14
|
+
let :payment_request do
|
15
|
+
Paypal::Payment::Request.new(
|
13
16
|
:billing_type => :RecurringPayments,
|
14
17
|
:billing_agreement_description => 'Recurring Payment Request'
|
15
18
|
)
|
16
19
|
end
|
17
20
|
|
21
|
+
let :instance do
|
22
|
+
request.setup payment_request
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#initialize' do
|
26
|
+
before do
|
27
|
+
fake_response 'SetExpressCheckout/success'
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should support on_mobile option' do
|
31
|
+
response = request.setup payment_request, :on_mobile => true
|
32
|
+
response.on_mobile.should be_true
|
33
|
+
response.send(:query)[:cmd].should == '_express-checkout-mobile'
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should support pay_on_paypal option' do
|
37
|
+
response = request.setup payment_request, :pay_on_paypal => true
|
38
|
+
response.pay_on_paypal.should be_true
|
39
|
+
response.send(:query)[:useraction].should == 'commit'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
18
43
|
describe '#redirect_uri' do
|
19
44
|
it 'should return express-checkout redirect endpoint with token' do
|
20
45
|
fake_response 'SetExpressCheckout/success'
|
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:
|
5
|
-
prerelease:
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
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-02-
|
18
|
+
date: 2011-02-14 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -242,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
242
242
|
requirements: []
|
243
243
|
|
244
244
|
rubyforge_project:
|
245
|
-
rubygems_version: 1.
|
245
|
+
rubygems_version: 1.5.2
|
246
246
|
signing_key:
|
247
247
|
specification_version: 3
|
248
248
|
summary: PayPal Express Checkout API Client Supporting Both Instant and Recurring Payment
|