pag_seguro 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/pag_seguro/payment.rb +5 -1
- data/lib/pag_seguro/version.rb +1 -1
- data/spec/pag_seguro/payment_spec.rb +33 -0
- metadata +9 -9
data/lib/pag_seguro/payment.rb
CHANGED
@@ -22,6 +22,10 @@ module PagSeguro
|
|
22
22
|
@max_age = options[:max_age]
|
23
23
|
end
|
24
24
|
|
25
|
+
def self.checkout_payment_url(code)
|
26
|
+
"https://pagseguro.uol.com.br/v2/checkout/payment.html?code=#{code}"
|
27
|
+
end
|
28
|
+
|
25
29
|
def checkout_xml
|
26
30
|
xml_content = File.open( File.dirname(__FILE__) + "/checkout.xml.haml" ).read
|
27
31
|
Haml::Engine.new(xml_content).render(nil, items: @items, payment: self, sender: @sender, shipping: @shipping)
|
@@ -32,7 +36,7 @@ module PagSeguro
|
|
32
36
|
end
|
33
37
|
|
34
38
|
def checkout_payment_url
|
35
|
-
|
39
|
+
self.class.checkout_payment_url(code)
|
36
40
|
end
|
37
41
|
|
38
42
|
def code
|
data/lib/pag_seguro/version.rb
CHANGED
@@ -90,6 +90,10 @@ describe PagSeguro::Payment do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
context "checking out" do
|
93
|
+
it "should generate a checkout url with an external code" do
|
94
|
+
PagSeguro::Payment.checkout_payment_url("aabbcc").should == "https://pagseguro.uol.com.br/v2/checkout/payment.html?code=aabbcc"
|
95
|
+
end
|
96
|
+
|
93
97
|
it "should have a checkout_url_with_params" do
|
94
98
|
PagSeguro::Payment.new("mymail", "mytoken").checkout_url_with_params.should == 'https://ws.pagseguro.uol.com.br/v2/checkout?email=mymail&token=mytoken'
|
95
99
|
end
|
@@ -99,5 +103,34 @@ describe PagSeguro::Payment do
|
|
99
103
|
payment.stub(:code).and_return("aabbcc")
|
100
104
|
payment.checkout_payment_url.should == "https://pagseguro.uol.com.br/v2/checkout/payment.html?code=aabbcc"
|
101
105
|
end
|
106
|
+
|
107
|
+
describe "parse_checkout_response" do
|
108
|
+
before do
|
109
|
+
@payment = PagSeguro::Payment.new("mymail", "mytoken")
|
110
|
+
@response = double("response")
|
111
|
+
@payment.stub(:send_checkout){ @response }
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should raise PagSeguro::Errors::InvalidData if response code is 400" do
|
115
|
+
@response.stub(code: 400, body: "some error description")
|
116
|
+
lambda { @payment.send(:parse_checkout_response) }.should raise_error(PagSeguro::Errors::InvalidData)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should raise PagSeguro::Errors::Unauthorized if response code is 400" do
|
120
|
+
@response.stub(code: 401)
|
121
|
+
lambda { @payment.send(:parse_checkout_response) }.should raise_error(PagSeguro::Errors::Unauthorized)
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should not raise errors if response code is 200" do
|
125
|
+
@response.stub(code: 200, body: "some response body")
|
126
|
+
lambda { @payment.send(:parse_checkout_response) }.should_not raise_error
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should raise PagSeguro::Errors::UnknownError if response code is not 200, 400 or 401" do
|
130
|
+
@response.stub(code: 300, body: "some response body")
|
131
|
+
lambda { @payment.send(:parse_checkout_response) }.should raise_error(PagSeguro::Errors::UnknownError)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
102
135
|
end
|
103
136
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pag_seguro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-17 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152459520 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152459520
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: haml
|
27
|
-
requirement: &
|
27
|
+
requirement: &2152458800 !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: *2152458800
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: nokogiri
|
38
|
-
requirement: &
|
38
|
+
requirement: &2152458100 !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: *2152458100
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rest-client
|
49
|
-
requirement: &
|
49
|
+
requirement: &2152457160 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 1.6.7
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2152457160
|
58
58
|
description:
|
59
59
|
email:
|
60
60
|
- stefano.diem@gmail.com
|