pagseguro-oficial 2.0.8 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -4
- data/README.md +15 -16
- data/examples/abandoned_transactions.rb +1 -1
- data/examples/transaction_by_notification_code.rb +55 -1
- data/examples/transaction_by_reference.rb +24 -0
- data/examples/transactions_by_date.rb +7 -1
- data/lib/pagseguro/creditor_fee.rb +23 -0
- data/lib/pagseguro/document.rb +11 -0
- data/lib/pagseguro/installment.rb +1 -1
- data/lib/pagseguro/payment_release.rb +21 -0
- data/lib/pagseguro/payment_releases.rb +25 -0
- data/lib/pagseguro/payment_request/response.rb +6 -1
- data/lib/pagseguro/payment_request.rb +4 -3
- data/lib/pagseguro/payment_status.rb +2 -0
- data/lib/pagseguro/request.rb +9 -7
- data/lib/pagseguro/sender.rb +8 -0
- data/lib/pagseguro/transaction/search/search_abandoned.rb +19 -0
- data/lib/pagseguro/transaction/search/search_by_date.rb +15 -0
- data/lib/pagseguro/transaction/search/search_by_reference.rb +12 -0
- data/lib/pagseguro/{report.rb → transaction/search.rb} +8 -11
- data/lib/pagseguro/transaction/serializer.rb +39 -4
- data/lib/pagseguro/transaction.rb +40 -9
- data/lib/pagseguro/version.rb +1 -1
- data/lib/pagseguro.rb +16 -7
- data/spec/fixtures/transactions/success.xml +24 -2
- data/spec/pagseguro/creditor_fee_spec.rb +10 -0
- data/spec/pagseguro/document_spec.rb +6 -0
- data/spec/pagseguro/installment_spec.rb +3 -2
- data/spec/pagseguro/pagseguro_spec.rb +4 -4
- data/spec/pagseguro/payment_release_spec.rb +9 -0
- data/spec/pagseguro/payment_releases_spec.rb +34 -0
- data/spec/pagseguro/payment_request_spec.rb +1 -1
- data/spec/pagseguro/payment_status_spec.rb +2 -0
- data/spec/pagseguro/request_spec.rb +7 -7
- data/spec/pagseguro/sender_spec.rb +1 -0
- data/spec/pagseguro/transaction/serializer_spec.rb +16 -1
- data/spec/pagseguro/transaction_spec.rb +29 -20
- metadata +20 -4
@@ -34,8 +34,8 @@ module PagSeguro
|
|
34
34
|
# The discount amount.
|
35
35
|
attr_accessor :discount_amount
|
36
36
|
|
37
|
-
# The
|
38
|
-
|
37
|
+
# The charged fees.
|
38
|
+
attr_reader :creditor_fees
|
39
39
|
|
40
40
|
# The net amount.
|
41
41
|
attr_accessor :net_amount
|
@@ -62,21 +62,21 @@ module PagSeguro
|
|
62
62
|
|
63
63
|
# Set the transaction errors.
|
64
64
|
attr_reader :errors
|
65
|
-
|
65
|
+
|
66
66
|
# Find a transaction by its transactionCode
|
67
67
|
# Return a PagSeguro::Transaction instance
|
68
68
|
def self.find_by_code(code)
|
69
|
-
load_from_response
|
69
|
+
load_from_response send_request("transactions/#{code}")
|
70
70
|
end
|
71
71
|
|
72
72
|
# Find a transaction by its notificationCode.
|
73
73
|
# Return a PagSeguro::Transaction instance.
|
74
74
|
def self.find_by_notification_code(code)
|
75
|
-
load_from_response
|
75
|
+
load_from_response send_request("transactions/notifications/#{code}")
|
76
76
|
end
|
77
77
|
|
78
78
|
# Search transactions within a date range.
|
79
|
-
# Return a PagSeguro::
|
79
|
+
# Return a PagSeguro::SearchByDate instance
|
80
80
|
#
|
81
81
|
# Options:
|
82
82
|
#
|
@@ -91,12 +91,23 @@ module PagSeguro
|
|
91
91
|
ends_at: Time.now,
|
92
92
|
per_page: 50
|
93
93
|
}.merge(options)
|
94
|
+
SearchByDate.new("transactions", options, page)
|
95
|
+
end
|
94
96
|
|
95
|
-
|
97
|
+
# Search a transaction by its reference code
|
98
|
+
# Return a PagSeguro::SearchByReference instance
|
99
|
+
#
|
100
|
+
# Options:
|
101
|
+
#
|
102
|
+
# # +reference+: the transaction reference code
|
103
|
+
#
|
104
|
+
def self.find_by_reference(reference)
|
105
|
+
options = { reference: reference }
|
106
|
+
SearchByReference.new("transactions", options)
|
96
107
|
end
|
97
108
|
|
98
109
|
# Get abandoned transactions.
|
99
|
-
# Return a PagSeguro::
|
110
|
+
# Return a PagSeguro::SearchByDate instance
|
100
111
|
#
|
101
112
|
# Options:
|
102
113
|
#
|
@@ -112,7 +123,7 @@ module PagSeguro
|
|
112
123
|
per_page: 50
|
113
124
|
}.merge(options)
|
114
125
|
|
115
|
-
|
126
|
+
SearchAbandoned.new("transactions/abandoned", options, page)
|
116
127
|
end
|
117
128
|
|
118
129
|
# Serialize the HTTP response into data.
|
@@ -124,11 +135,21 @@ module PagSeguro
|
|
124
135
|
end
|
125
136
|
end
|
126
137
|
|
138
|
+
# Send a get request to v3 API version, with the path given
|
139
|
+
def self.send_request(path)
|
140
|
+
Request.get(path, 'v3')
|
141
|
+
end
|
142
|
+
|
127
143
|
# Serialize the XML object.
|
128
144
|
def self.load_from_xml(xml) # :nodoc:
|
129
145
|
new Serializer.new(xml).serialize
|
130
146
|
end
|
131
147
|
|
148
|
+
# Normalize creditor fees object
|
149
|
+
def creditor_fees=(creditor_fees)
|
150
|
+
@creditor_fees = ensure_type(CreditorFee, creditor_fees)
|
151
|
+
end
|
152
|
+
|
132
153
|
# Normalize the sender object.
|
133
154
|
def sender=(sender)
|
134
155
|
@sender = ensure_type(Sender, sender)
|
@@ -139,6 +160,16 @@ module PagSeguro
|
|
139
160
|
@shipping = ensure_type(Shipping, shipping)
|
140
161
|
end
|
141
162
|
|
163
|
+
# Hold the transaction's payments
|
164
|
+
def payment_releases
|
165
|
+
@payment_releases ||= PaymentReleases.new
|
166
|
+
end
|
167
|
+
|
168
|
+
# Normalize the transaction's payments list
|
169
|
+
def payment_releases=(_payments)
|
170
|
+
_payments.each { |payment| payment_releases << payment }
|
171
|
+
end
|
172
|
+
|
142
173
|
# Hold the transaction's items.
|
143
174
|
def items
|
144
175
|
@items ||= Items.new
|
data/lib/pagseguro/version.rb
CHANGED
data/lib/pagseguro.rb
CHANGED
@@ -8,11 +8,15 @@ require "i18n"
|
|
8
8
|
|
9
9
|
require "pagseguro/version"
|
10
10
|
require "pagseguro/config"
|
11
|
-
|
12
|
-
require "pagseguro/exceptions"
|
11
|
+
|
13
12
|
require "pagseguro/extensions/mass_assignment"
|
14
13
|
require "pagseguro/extensions/ensure_type"
|
14
|
+
|
15
|
+
require "pagseguro/creditor_fee"
|
16
|
+
require "pagseguro/errors"
|
17
|
+
require "pagseguro/exceptions"
|
15
18
|
require "pagseguro/address"
|
19
|
+
require "pagseguro/document"
|
16
20
|
require "pagseguro/shipping"
|
17
21
|
require "pagseguro/phone"
|
18
22
|
require "pagseguro/installment"
|
@@ -21,17 +25,22 @@ require "pagseguro/installment/serializer"
|
|
21
25
|
require "pagseguro/item"
|
22
26
|
require "pagseguro/items"
|
23
27
|
require "pagseguro/payment_method"
|
28
|
+
require "pagseguro/payment_release"
|
29
|
+
require "pagseguro/payment_releases"
|
24
30
|
require "pagseguro/payment_request"
|
25
31
|
require "pagseguro/payment_request/serializer"
|
26
32
|
require "pagseguro/payment_request/response"
|
27
33
|
require "pagseguro/payment_status"
|
28
34
|
require "pagseguro/request"
|
29
|
-
require "pagseguro/report"
|
30
35
|
require "pagseguro/sender"
|
31
36
|
require "pagseguro/notification"
|
32
37
|
require "pagseguro/transaction"
|
33
38
|
require "pagseguro/transaction/response"
|
34
39
|
require "pagseguro/transaction/serializer"
|
40
|
+
require "pagseguro/transaction/search"
|
41
|
+
require "pagseguro/transaction/search/search_by_date"
|
42
|
+
require "pagseguro/transaction/search/search_by_reference"
|
43
|
+
require "pagseguro/transaction/search/search_abandoned"
|
35
44
|
|
36
45
|
I18n.load_path += Dir[File.expand_path("../../locales/*.yml", __FILE__)]
|
37
46
|
|
@@ -57,12 +66,12 @@ module PagSeguro
|
|
57
66
|
def self.uris
|
58
67
|
@uris ||= {
|
59
68
|
production: {
|
60
|
-
api: "https://ws.pagseguro.uol.com.br/
|
61
|
-
site: "https://pagseguro.uol.com.br/
|
69
|
+
api: "https://ws.pagseguro.uol.com.br/",
|
70
|
+
site: "https://pagseguro.uol.com.br/"
|
62
71
|
},
|
63
72
|
sandbox: {
|
64
|
-
site: 'https://sandbox.pagseguro.uol.com.br/
|
65
|
-
api: 'https://ws.sandbox.pagseguro.uol.com.br/
|
73
|
+
site: 'https://sandbox.pagseguro.uol.com.br/',
|
74
|
+
api: 'https://ws.sandbox.pagseguro.uol.com.br/'
|
66
75
|
}
|
67
76
|
}
|
68
77
|
end
|
@@ -15,10 +15,26 @@
|
|
15
15
|
<paymentLink>https://pagseguro.uol.com.br/checkout/imprimeBoleto.jhtml?code=667D39144F9F47059FB6CA6FA0DF8A20</paymentLink>
|
16
16
|
<grossAmount>459.50</grossAmount>
|
17
17
|
<discountAmount>0.00</discountAmount>
|
18
|
-
|
18
|
+
<creditorFees>
|
19
|
+
<operationalFeeAmount>0.00</operationalFeeAmount>
|
20
|
+
<installmentFeeAmount>0.00</installmentFeeAmount>
|
21
|
+
<intermediationRateAmount>0.40</intermediationRateAmount>
|
22
|
+
<intermediationFeeAmount>1644.80</intermediationFeeAmount>
|
23
|
+
<commissionFeeAmount>1.98</commissionFeeAmount>
|
24
|
+
<efrete>1.98</efrete>
|
25
|
+
</creditorFees>
|
19
26
|
<netAmount>445.77</netAmount>
|
20
27
|
<extraAmount>0.00</extraAmount>
|
21
28
|
<installmentCount>1</installmentCount>
|
29
|
+
<paymentReleases>
|
30
|
+
<paymentRelease>
|
31
|
+
<installment>1</installment>
|
32
|
+
<totalAmount>202.92</totalAmount>
|
33
|
+
<releaseAmount>202.92</releaseAmount>
|
34
|
+
<status>OPENED</status>
|
35
|
+
<releaseDate>2015-03-25T16:14:23-03:00</releaseDate>
|
36
|
+
</paymentRelease>
|
37
|
+
</paymentReleases>
|
22
38
|
<itemCount>1</itemCount>
|
23
39
|
<items>
|
24
40
|
<item>
|
@@ -35,6 +51,12 @@
|
|
35
51
|
<areaCode>11</areaCode>
|
36
52
|
<number>12345678</number>
|
37
53
|
</phone>
|
54
|
+
<documents>
|
55
|
+
<document>
|
56
|
+
<type>CPF</type>
|
57
|
+
<value>65647162142</value>
|
58
|
+
</document>
|
59
|
+
</documents>
|
38
60
|
</sender>
|
39
61
|
<shipping>
|
40
62
|
<address>
|
@@ -42,10 +64,10 @@
|
|
42
64
|
<number>1384</number>
|
43
65
|
<complement>5 ANDAR</complement>
|
44
66
|
<district>JARDIM PAULISTANO</district>
|
67
|
+
<postalCode>01452002</postalCode>
|
45
68
|
<city>SAO PAULO</city>
|
46
69
|
<state>SP</state>
|
47
70
|
<country>BRA</country>
|
48
|
-
<postalCode>01452002</postalCode>
|
49
71
|
</address>
|
50
72
|
<type>2</type>
|
51
73
|
<cost>0.00</cost>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PagSeguro::CreditorFee do
|
4
|
+
it_assigns_attribute :intermediation_rate_amount
|
5
|
+
it_assigns_attribute :intermediation_fee_amount
|
6
|
+
it_assigns_attribute :installment_fee_amount
|
7
|
+
it_assigns_attribute :operational_fee_amount
|
8
|
+
it_assigns_attribute :commission_fee_amount
|
9
|
+
it_assigns_attribute :efrete
|
10
|
+
end
|
@@ -10,10 +10,11 @@ describe PagSeguro::Installment do
|
|
10
10
|
describe ".find" do
|
11
11
|
context "when request succeeds" do
|
12
12
|
let(:request) { double("request") }
|
13
|
+
let(:version) { 'v2' }
|
13
14
|
|
14
15
|
it "finds installments by the given amount" do
|
15
16
|
expect(PagSeguro::Request).to receive(:get)
|
16
|
-
.with("installments?amount=100.00")
|
17
|
+
.with("installments?amount=100.00", version)
|
17
18
|
.and_return(request)
|
18
19
|
expect(PagSeguro::Installment).to receive(:load_from_response)
|
19
20
|
.with(request)
|
@@ -23,7 +24,7 @@ describe PagSeguro::Installment do
|
|
23
24
|
|
24
25
|
it "find installments by amount and credit card brand" do
|
25
26
|
expect(PagSeguro::Request).to receive(:get)
|
26
|
-
.with("installments?amount=100.00&cardBrand=visa")
|
27
|
+
.with("installments?amount=100.00&cardBrand=visa", version)
|
27
28
|
.and_return(request)
|
28
29
|
expect(PagSeguro::Installment).to receive(:load_from_response)
|
29
30
|
.with(request)
|
@@ -50,13 +50,13 @@ describe PagSeguro do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it "returns production api url when the environment is :production" do
|
53
|
-
expect(PagSeguro.api_url("/some/path")).to eql("https://ws.pagseguro.uol.com.br/v2/some/path")
|
53
|
+
expect(PagSeguro.api_url("v2/some/path")).to eql("https://ws.pagseguro.uol.com.br/v2/some/path")
|
54
54
|
end
|
55
55
|
|
56
56
|
it "returns sandbox api url when the environment is :sandbox" do
|
57
57
|
PagSeguro.environment = :sandbox
|
58
58
|
|
59
|
-
expect(PagSeguro.api_url("/some/path")).to eql("https://ws.sandbox.pagseguro.uol.com.br/v2/some/path")
|
59
|
+
expect(PagSeguro.api_url("v2/some/path")).to eql("https://ws.sandbox.pagseguro.uol.com.br/v2/some/path")
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
@@ -71,12 +71,12 @@ describe PagSeguro do
|
|
71
71
|
end
|
72
72
|
|
73
73
|
it "returns production site url when the environment is production" do
|
74
|
-
expect(PagSeguro.site_url("/some/path")).to eql("https://pagseguro.uol.com.br/v2/some/path")
|
74
|
+
expect(PagSeguro.site_url("v2/some/path")).to eql("https://pagseguro.uol.com.br/v2/some/path")
|
75
75
|
end
|
76
76
|
|
77
77
|
it "returns sandbox site url when the environment is :sandbox" do
|
78
78
|
PagSeguro.environment = :sandbox
|
79
|
-
expect(PagSeguro.site_url("/some/path")).to eql("https://sandbox.pagseguro.uol.com.br/v2/some/path")
|
79
|
+
expect(PagSeguro.site_url("v2/some/path")).to eql("https://sandbox.pagseguro.uol.com.br/v2/some/path")
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PagSeguro::PaymentReleases do
|
4
|
+
it "implements #each" do
|
5
|
+
expect(PagSeguro::PaymentReleases.new).to respond_to(:each)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "includes Enumerable" do
|
9
|
+
expect(PagSeguro::PaymentReleases.included_modules).to include(Enumerable)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "sets payment" do
|
13
|
+
payment = PagSeguro::PaymentRelease.new
|
14
|
+
payments = PagSeguro::PaymentReleases.new
|
15
|
+
payments << payment
|
16
|
+
|
17
|
+
expect(payments.size).to eql(1)
|
18
|
+
expect(payments).to include(payment)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "sets payment releases from Hash" do
|
22
|
+
payment = PagSeguro::PaymentRelease.new(installment: 1)
|
23
|
+
|
24
|
+
expect(PagSeguro::PaymentRelease).to(
|
25
|
+
receive(:new)
|
26
|
+
.with({installment: 1})
|
27
|
+
.and_return(payment))
|
28
|
+
|
29
|
+
payments = PagSeguro::PaymentReleases.new
|
30
|
+
payments << {installment: 1}
|
31
|
+
|
32
|
+
expect(payments).to include(payment)
|
33
|
+
end
|
34
|
+
end
|
@@ -20,5 +20,7 @@ describe PagSeguro::PaymentStatus do
|
|
20
20
|
it_behaves_like "payment status mapping", 5, :in_dispute
|
21
21
|
it_behaves_like "payment status mapping", 6, :refunded
|
22
22
|
it_behaves_like "payment status mapping", 7, :cancelled
|
23
|
+
it_behaves_like "payment status mapping", 8, :chargeback_charged
|
24
|
+
it_behaves_like "payment status mapping", 9, :contested
|
23
25
|
end
|
24
26
|
end
|
@@ -16,7 +16,7 @@ describe PagSeguro::Request do
|
|
16
16
|
it "includes credentials" do
|
17
17
|
PagSeguro.email = "EMAIL"
|
18
18
|
PagSeguro.token = "TOKEN"
|
19
|
-
PagSeguro::Request.post("checkout")
|
19
|
+
PagSeguro::Request.post("checkout", "v3")
|
20
20
|
|
21
21
|
expect(FakeWeb.last_request.body).to include("email=EMAIL&token=TOKEN")
|
22
22
|
end
|
@@ -24,18 +24,18 @@ describe PagSeguro::Request do
|
|
24
24
|
it "includes custom credentials" do
|
25
25
|
PagSeguro.email = "EMAIL"
|
26
26
|
PagSeguro.token = "TOKEN"
|
27
|
-
PagSeguro::Request.post("checkout", email: 'foo', token: 'bar')
|
27
|
+
PagSeguro::Request.post("checkout", "v3", email: 'foo', token: 'bar')
|
28
28
|
|
29
29
|
expect(FakeWeb.last_request.body).to include("email=foo&token=bar")
|
30
30
|
end
|
31
31
|
|
32
32
|
it "includes encoding" do
|
33
|
-
PagSeguro::Request.post("checkout")
|
33
|
+
PagSeguro::Request.post("checkout", "v3")
|
34
34
|
expect(FakeWeb.last_request.body).to include("charset=UTF-8")
|
35
35
|
end
|
36
36
|
|
37
37
|
it "include request headers" do
|
38
|
-
PagSeguro::Request.post("checkout")
|
38
|
+
PagSeguro::Request.post("checkout", "v3")
|
39
39
|
request = FakeWeb.last_request
|
40
40
|
|
41
41
|
expect(request["Accept-Charset"]).to eql("UTF-8")
|
@@ -53,18 +53,18 @@ describe PagSeguro::Request do
|
|
53
53
|
it "includes credentials" do
|
54
54
|
PagSeguro.email = "EMAIL"
|
55
55
|
PagSeguro.token = "TOKEN"
|
56
|
-
PagSeguro::Request.get("checkout")
|
56
|
+
PagSeguro::Request.get("checkout", "v3")
|
57
57
|
|
58
58
|
expect(FakeWeb.last_request.path).to include("email=EMAIL&token=TOKEN")
|
59
59
|
end
|
60
60
|
|
61
61
|
it "includes encoding" do
|
62
|
-
PagSeguro::Request.get("checkout")
|
62
|
+
PagSeguro::Request.get("checkout", "v3")
|
63
63
|
expect(FakeWeb.last_request.path).to include("charset=UTF-8")
|
64
64
|
end
|
65
65
|
|
66
66
|
it "include request headers" do
|
67
|
-
PagSeguro::Request.get("checkout")
|
67
|
+
PagSeguro::Request.get("checkout", "v3")
|
68
68
|
request = FakeWeb.last_request
|
69
69
|
|
70
70
|
expect(request["Accept-Charset"]).to eql("UTF-8")
|
@@ -18,7 +18,6 @@ describe PagSeguro::Transaction::Serializer do
|
|
18
18
|
it { expect(data).to include(payment_link: "https://pagseguro.uol.com.br/checkout/imprimeBoleto.jhtml?code=667D39144F9F47059FB6CA6FA0DF8A20") }
|
19
19
|
it { expect(data).to include(gross_amount: BigDecimal("459.50")) }
|
20
20
|
it { expect(data).to include(discount_amount: BigDecimal("0.00")) }
|
21
|
-
it { expect(data).to include(fee_amount: BigDecimal("13.73")) }
|
22
21
|
it { expect(data).to include(net_amount: BigDecimal("445.77")) }
|
23
22
|
it { expect(data).to include(extra_amount: BigDecimal("0.00")) }
|
24
23
|
it { expect(data).to include(installments: 1) }
|
@@ -26,6 +25,20 @@ describe PagSeguro::Transaction::Serializer do
|
|
26
25
|
it { expect(data.keys).not_to include(:cancellation_source) }
|
27
26
|
it { expect(data.keys).not_to include(:escrow_end_date) }
|
28
27
|
|
28
|
+
it { expect(data[:creditor_fees]).to include(intermediation_rate_amount: BigDecimal("0.40")) }
|
29
|
+
it { expect(data[:creditor_fees]).to include(intermediation_fee_amount: BigDecimal("1644.80")) }
|
30
|
+
it { expect(data[:creditor_fees]).to include(installment_fee_amount: BigDecimal("0.00")) }
|
31
|
+
it { expect(data[:creditor_fees]).to include(operational_fee_amount: BigDecimal("0.00")) }
|
32
|
+
it { expect(data[:creditor_fees]).to include(commission_fee_amount: BigDecimal("1.98")) }
|
33
|
+
it { expect(data[:creditor_fees]).to include(efrete: BigDecimal("1.98")) }
|
34
|
+
|
35
|
+
it { expect(data[:payment_releases].size).to eq(1) }
|
36
|
+
it { expect(data[:payment_releases].first).to include(installment: "1") }
|
37
|
+
it { expect(data[:payment_releases].first).to include(total_amount: BigDecimal("202.92")) }
|
38
|
+
it { expect(data[:payment_releases].first).to include(release_amount: BigDecimal("202.92")) }
|
39
|
+
it { expect(data[:payment_releases].first).to include(status: "OPENED") }
|
40
|
+
it { expect(data[:payment_releases].first).to include(release_date: Time.parse("2015-03-25T16:14:23-03:00")) }
|
41
|
+
|
29
42
|
it { expect(data[:items].size).to eq(1) }
|
30
43
|
it { expect(data[:items].first).to include(id: "1234") }
|
31
44
|
it { expect(data[:items].first).to include(description: "Some product") }
|
@@ -36,6 +49,8 @@ describe PagSeguro::Transaction::Serializer do
|
|
36
49
|
it { expect(data[:sender]).to include(email: "john@example.com") }
|
37
50
|
it { expect(data[:sender][:phone]).to include(area_code: "11") }
|
38
51
|
it { expect(data[:sender][:phone]).to include(number: "12345678") }
|
52
|
+
it { expect(data[:sender][:document]).to include(type: "CPF") }
|
53
|
+
it { expect(data[:sender][:document]).to include(value: "65647162142") }
|
39
54
|
|
40
55
|
it { expect(data[:shipping]).to include(type_id: "2") }
|
41
56
|
|
@@ -7,7 +7,7 @@ describe PagSeguro::Transaction do
|
|
7
7
|
|
8
8
|
PagSeguro::Request
|
9
9
|
.should_receive(:get)
|
10
|
-
.with("transactions/notifications/CODE")
|
10
|
+
.with("transactions/notifications/CODE", "v3")
|
11
11
|
.and_return(double.as_null_object)
|
12
12
|
|
13
13
|
PagSeguro::Transaction.find_by_notification_code("CODE")
|
@@ -24,31 +24,26 @@ describe PagSeguro::Transaction do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
describe ".find_by_date" do
|
27
|
-
it "initializes
|
27
|
+
it "initializes search with default options" do
|
28
28
|
now = Time.now
|
29
29
|
Time.stub now: now
|
30
30
|
|
31
|
-
PagSeguro::
|
31
|
+
PagSeguro::SearchByDate
|
32
32
|
.should_receive(:new)
|
33
|
-
.with(
|
34
|
-
|
35
|
-
"transactions",
|
36
|
-
hash_including(per_page: 50, starts_at: now - 86400, ends_at: now),
|
37
|
-
0
|
38
|
-
)
|
33
|
+
.with("transactions",
|
34
|
+
hash_including(starts_at: now - 86400, ends_at: now, per_page: 50), 0)
|
39
35
|
|
40
36
|
PagSeguro::Transaction.find_by_date
|
41
37
|
end
|
42
38
|
|
43
|
-
it "initializes
|
39
|
+
it "initializes search with given options" do
|
44
40
|
starts_at = Time.now - 3600
|
45
41
|
ends_at = starts_at + 180
|
46
|
-
page =
|
42
|
+
page = 0
|
47
43
|
|
48
|
-
PagSeguro::
|
44
|
+
PagSeguro::SearchByDate
|
49
45
|
.should_receive(:new)
|
50
46
|
.with(
|
51
|
-
PagSeguro::Transaction,
|
52
47
|
"transactions",
|
53
48
|
hash_including(per_page: 10, starts_at: starts_at, ends_at: ends_at),
|
54
49
|
page
|
@@ -61,15 +56,30 @@ describe PagSeguro::Transaction do
|
|
61
56
|
end
|
62
57
|
end
|
63
58
|
|
59
|
+
describe ".find_by_reference" do
|
60
|
+
it 'initializes search with given reference code' do
|
61
|
+
now = Time.now
|
62
|
+
Time.stub now: now
|
63
|
+
|
64
|
+
PagSeguro::SearchByReference
|
65
|
+
.should_receive(:new)
|
66
|
+
.with(
|
67
|
+
"transactions",
|
68
|
+
hash_including(reference: 'ref1234'),
|
69
|
+
)
|
70
|
+
|
71
|
+
PagSeguro::Transaction.find_by_reference('ref1234')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
64
75
|
describe ".find_abandoned" do
|
65
|
-
it "initializes
|
76
|
+
it "initializes search with default options" do
|
66
77
|
now = Time.now
|
67
78
|
Time.stub now: now
|
68
79
|
|
69
|
-
PagSeguro::
|
80
|
+
PagSeguro::SearchAbandoned
|
70
81
|
.should_receive(:new)
|
71
82
|
.with(
|
72
|
-
PagSeguro::Transaction,
|
73
83
|
"transactions/abandoned",
|
74
84
|
hash_including(per_page: 50, starts_at: now - 86400, ends_at: now - 900),
|
75
85
|
0
|
@@ -78,22 +88,21 @@ describe PagSeguro::Transaction do
|
|
78
88
|
PagSeguro::Transaction.find_abandoned
|
79
89
|
end
|
80
90
|
|
81
|
-
it "initializes
|
91
|
+
it "initializes search with given options" do
|
82
92
|
starts_at = Time.now - 3600
|
83
93
|
ends_at = starts_at + 180
|
84
94
|
page = 1
|
85
95
|
|
86
|
-
PagSeguro::
|
96
|
+
PagSeguro::SearchAbandoned
|
87
97
|
.should_receive(:new)
|
88
98
|
.with(
|
89
|
-
PagSeguro::Transaction,
|
90
99
|
"transactions/abandoned",
|
91
100
|
hash_including(per_page: 10, starts_at: starts_at, ends_at: ends_at),
|
92
101
|
page
|
93
102
|
)
|
94
103
|
|
95
104
|
PagSeguro::Transaction.find_abandoned(
|
96
|
-
{per_page: 10, starts_at: starts_at, ends_at: ends_at},
|
105
|
+
{ per_page: 10, starts_at: starts_at, ends_at: ends_at },
|
97
106
|
page
|
98
107
|
)
|
99
108
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagseguro-oficial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aitch
|
@@ -185,11 +185,14 @@ files:
|
|
185
185
|
- examples/invalid_transaction_by_notification_code.rb
|
186
186
|
- examples/payment_request.rb
|
187
187
|
- examples/transaction_by_notification_code.rb
|
188
|
+
- examples/transaction_by_reference.rb
|
188
189
|
- examples/transactions_by_date.rb
|
189
190
|
- lib/pagseguro-oficial.rb
|
190
191
|
- lib/pagseguro.rb
|
191
192
|
- lib/pagseguro/address.rb
|
192
193
|
- lib/pagseguro/config.rb
|
194
|
+
- lib/pagseguro/creditor_fee.rb
|
195
|
+
- lib/pagseguro/document.rb
|
193
196
|
- lib/pagseguro/errors.rb
|
194
197
|
- lib/pagseguro/exceptions.rb
|
195
198
|
- lib/pagseguro/extensions/ensure_type.rb
|
@@ -201,17 +204,22 @@ files:
|
|
201
204
|
- lib/pagseguro/items.rb
|
202
205
|
- lib/pagseguro/notification.rb
|
203
206
|
- lib/pagseguro/payment_method.rb
|
207
|
+
- lib/pagseguro/payment_release.rb
|
208
|
+
- lib/pagseguro/payment_releases.rb
|
204
209
|
- lib/pagseguro/payment_request.rb
|
205
210
|
- lib/pagseguro/payment_request/response.rb
|
206
211
|
- lib/pagseguro/payment_request/serializer.rb
|
207
212
|
- lib/pagseguro/payment_status.rb
|
208
213
|
- lib/pagseguro/phone.rb
|
209
|
-
- lib/pagseguro/report.rb
|
210
214
|
- lib/pagseguro/request.rb
|
211
215
|
- lib/pagseguro/sender.rb
|
212
216
|
- lib/pagseguro/shipping.rb
|
213
217
|
- lib/pagseguro/transaction.rb
|
214
218
|
- lib/pagseguro/transaction/response.rb
|
219
|
+
- lib/pagseguro/transaction/search.rb
|
220
|
+
- lib/pagseguro/transaction/search/search_abandoned.rb
|
221
|
+
- lib/pagseguro/transaction/search/search_by_date.rb
|
222
|
+
- lib/pagseguro/transaction/search/search_by_reference.rb
|
215
223
|
- lib/pagseguro/transaction/serializer.rb
|
216
224
|
- lib/pagseguro/version.rb
|
217
225
|
- locales/pt-BR.yml
|
@@ -225,6 +233,8 @@ files:
|
|
225
233
|
- spec/fixtures/transactions/success.xml
|
226
234
|
- spec/pagseguro/address_spec.rb
|
227
235
|
- spec/pagseguro/config_spec.rb
|
236
|
+
- spec/pagseguro/creditor_fee_spec.rb
|
237
|
+
- spec/pagseguro/document_spec.rb
|
228
238
|
- spec/pagseguro/errors_spec.rb
|
229
239
|
- spec/pagseguro/installment/serializer_spec.rb
|
230
240
|
- spec/pagseguro/installment_spec.rb
|
@@ -233,6 +243,8 @@ files:
|
|
233
243
|
- spec/pagseguro/notification_spec.rb
|
234
244
|
- spec/pagseguro/pagseguro_spec.rb
|
235
245
|
- spec/pagseguro/payment_method_spec.rb
|
246
|
+
- spec/pagseguro/payment_release_spec.rb
|
247
|
+
- spec/pagseguro/payment_releases_spec.rb
|
236
248
|
- spec/pagseguro/payment_request/response_spec.rb
|
237
249
|
- spec/pagseguro/payment_request/serializer_spec.rb
|
238
250
|
- spec/pagseguro/payment_request_spec.rb
|
@@ -267,7 +279,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
267
279
|
version: '0'
|
268
280
|
requirements: []
|
269
281
|
rubyforge_project:
|
270
|
-
rubygems_version: 2.
|
282
|
+
rubygems_version: 2.2.2
|
271
283
|
signing_key:
|
272
284
|
specification_version: 4
|
273
285
|
summary: Biblioteca oficial de integração PagSeguro em Ruby
|
@@ -281,6 +293,8 @@ test_files:
|
|
281
293
|
- spec/fixtures/transactions/success.xml
|
282
294
|
- spec/pagseguro/address_spec.rb
|
283
295
|
- spec/pagseguro/config_spec.rb
|
296
|
+
- spec/pagseguro/creditor_fee_spec.rb
|
297
|
+
- spec/pagseguro/document_spec.rb
|
284
298
|
- spec/pagseguro/errors_spec.rb
|
285
299
|
- spec/pagseguro/installment/serializer_spec.rb
|
286
300
|
- spec/pagseguro/installment_spec.rb
|
@@ -289,6 +303,8 @@ test_files:
|
|
289
303
|
- spec/pagseguro/notification_spec.rb
|
290
304
|
- spec/pagseguro/pagseguro_spec.rb
|
291
305
|
- spec/pagseguro/payment_method_spec.rb
|
306
|
+
- spec/pagseguro/payment_release_spec.rb
|
307
|
+
- spec/pagseguro/payment_releases_spec.rb
|
292
308
|
- spec/pagseguro/payment_request/response_spec.rb
|
293
309
|
- spec/pagseguro/payment_request/serializer_spec.rb
|
294
310
|
- spec/pagseguro/payment_request_spec.rb
|