pag_seguro 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -1
- data/lib/pag_seguro/transaction.rb +15 -3
- data/lib/pag_seguro/version.rb +1 -1
- data/spec/pag_seguro/notification_spec.rb +1 -0
- data/spec/pag_seguro/query_spec.rb +1 -0
- data/spec/pag_seguro/transaction_spec.rb +1 -0
- data/spec/support/transaction_shared_examples.rb +30 -0
- metadata +2 -2
data/README.md
CHANGED
@@ -143,4 +143,6 @@ Desenvolvida por [Stefano Diem Benatti](mailto:stefano@heavenstudio.com.br)
|
|
143
143
|
|
144
144
|
## Colaboradores
|
145
145
|
|
146
|
-
Rafael Castilho (<http://github.com/castilhor>)
|
146
|
+
Rafael Castilho (<http://github.com/castilhor>)
|
147
|
+
|
148
|
+
Rafael Ivan Garcia (https://github.com/rafaelivan)
|
@@ -23,6 +23,18 @@ module PagSeguro
|
|
23
23
|
PAGSEGURO_CHARGE = 4
|
24
24
|
PAGSEGURO_BONUS = 5
|
25
25
|
|
26
|
+
def self.status_for(status_code)
|
27
|
+
case status_code
|
28
|
+
when PAGSEGURO_PROCESSING then :processing
|
29
|
+
when PAGSEGURO_IN_ANALYSIS then :in_analysis
|
30
|
+
when PAGSEGURO_APPROVED then :approved
|
31
|
+
when PAGSEGURO_AVAILABLE then :available
|
32
|
+
when PAGSEGURO_DISPUTED then :disputed
|
33
|
+
when PAGSEGURO_RETURNED then :returned
|
34
|
+
when PAGSEGURO_CANCELLED then :cancelled
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
26
38
|
def initialize(transaction_xml)
|
27
39
|
@data = transaction_data(transaction_xml)
|
28
40
|
end
|
@@ -44,15 +56,15 @@ module PagSeguro
|
|
44
56
|
end
|
45
57
|
|
46
58
|
def net_amount
|
47
|
-
@data.css("
|
59
|
+
@data.css("netAmount").first.content
|
48
60
|
end
|
49
61
|
|
50
62
|
def extra_amount
|
51
|
-
@data.css("
|
63
|
+
@data.css("extraAmount").first.content
|
52
64
|
end
|
53
65
|
|
54
66
|
def installment_count
|
55
|
-
@data.css("
|
67
|
+
@data.css("installmentCount").first.content.to_i
|
56
68
|
end
|
57
69
|
|
58
70
|
def item_count
|
data/lib/pag_seguro/version.rb
CHANGED
@@ -5,6 +5,7 @@ require 'spec_helper'
|
|
5
5
|
describe PagSeguro::Notification do
|
6
6
|
before { PagSeguro::Notification.any_instance.stub(transaction_data: transaction_data) }
|
7
7
|
let(:transaction){ PagSeguro::Notification.new("mail", "token", "not_code") }
|
8
|
+
subject{ PagSeguro::Notification }
|
8
9
|
|
9
10
|
it_behaves_like "a transaction"
|
10
11
|
end
|
@@ -5,6 +5,7 @@ require 'spec_helper'
|
|
5
5
|
describe PagSeguro::Query do
|
6
6
|
before { PagSeguro::Query.any_instance.stub(transaction_data: transaction_data) }
|
7
7
|
let(:transaction){ PagSeguro::Query.new("mail", "token", "trans_code") }
|
8
|
+
subject{ PagSeguro::Query }
|
8
9
|
|
9
10
|
it_behaves_like "a transaction"
|
10
11
|
end
|
@@ -177,4 +177,34 @@ shared_examples_for "a transaction" do
|
|
177
177
|
transaction.should be_bonus
|
178
178
|
end
|
179
179
|
end
|
180
|
+
|
181
|
+
describe "::status_for" do
|
182
|
+
it "should return :processing when 1" do
|
183
|
+
subject.status_for(1).should == :processing
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should return :in_analysis when 2" do
|
187
|
+
subject.status_for(2).should == :in_analysis
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should return :approved when 3" do
|
191
|
+
subject.status_for(3).should == :approved
|
192
|
+
end
|
193
|
+
|
194
|
+
it "should return :available when 4" do
|
195
|
+
subject.status_for(4).should == :available
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should return :disputed when 5" do
|
199
|
+
subject.status_for(5).should == :disputed
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should return :returned when 6" do
|
203
|
+
subject.status_for(6).should == :returned
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should return :cancelled when 7" do
|
207
|
+
subject.status_for(7).should == :cancelled
|
208
|
+
end
|
209
|
+
end
|
180
210
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|