pagseguro-oficial 2.1.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +7 -5
  3. data/CHANGELOG.md +0 -1
  4. data/README.md +6 -1
  5. data/docs/transparent_checkout.md +201 -0
  6. data/examples/boleto_transaction_request.rb +94 -0
  7. data/examples/create_session.rb +13 -0
  8. data/examples/credit_card_transaction_request.rb +122 -0
  9. data/examples/installment.rb +20 -9
  10. data/examples/online_debit_transaction.rb +98 -0
  11. data/examples/transaction_by_code.rb +62 -0
  12. data/examples/transaction_by_notification_code.rb +55 -51
  13. data/lib/pagseguro.rb +17 -1
  14. data/lib/pagseguro/bank.rb +8 -0
  15. data/lib/pagseguro/boleto_transaction_request.rb +8 -0
  16. data/lib/pagseguro/credit_card_transaction_request.rb +39 -0
  17. data/lib/pagseguro/document.rb +2 -2
  18. data/lib/pagseguro/errors.rb +11 -5
  19. data/lib/pagseguro/holder.rb +28 -0
  20. data/lib/pagseguro/installment.rb +11 -16
  21. data/lib/pagseguro/installment/collection.rb +25 -0
  22. data/lib/pagseguro/installment/request_serializer.rb +24 -0
  23. data/lib/pagseguro/installment/response.rb +29 -4
  24. data/lib/pagseguro/installment/{serializer.rb → response_serializer.rb} +1 -1
  25. data/lib/pagseguro/items.rb +3 -0
  26. data/lib/pagseguro/online_debit_transaction_request.rb +17 -0
  27. data/lib/pagseguro/payment_method.rb +1 -0
  28. data/lib/pagseguro/payment_releases.rb +3 -0
  29. data/lib/pagseguro/sender.rb +4 -0
  30. data/lib/pagseguro/session.rb +34 -0
  31. data/lib/pagseguro/session/response.rb +32 -0
  32. data/lib/pagseguro/session/response_serializer.rb +18 -0
  33. data/lib/pagseguro/transaction.rb +6 -3
  34. data/lib/pagseguro/transaction/response.rb +1 -1
  35. data/lib/pagseguro/transaction_installment.rb +11 -0
  36. data/lib/pagseguro/transaction_request.rb +143 -0
  37. data/lib/pagseguro/transaction_request/request_serializer.rb +148 -0
  38. data/lib/pagseguro/transaction_request/response.rb +32 -0
  39. data/lib/pagseguro/transaction_request/response_serializer.rb +117 -0
  40. data/lib/pagseguro/version.rb +1 -1
  41. data/spec/fixtures/session/success.xml +4 -0
  42. data/spec/fixtures/transaction_request/success.xml +58 -0
  43. data/spec/fixtures/transactions/search.xml +40 -0
  44. data/spec/pagseguro/bank_spec.rb +5 -0
  45. data/spec/pagseguro/boleto_transaction_request_spec.rb +9 -0
  46. data/spec/pagseguro/credit_card_transaction_request_spec.rb +36 -0
  47. data/spec/pagseguro/document_spec.rb +1 -1
  48. data/spec/pagseguro/errors_spec.rb +5 -2
  49. data/spec/pagseguro/features/create_session_spec.rb +52 -0
  50. data/spec/pagseguro/features/create_transaction_request_spec.rb +58 -0
  51. data/spec/pagseguro/holder_spec.rb +9 -0
  52. data/spec/pagseguro/installment/collection_spec.rb +43 -0
  53. data/spec/pagseguro/installment/request_serializer_spec.rb +16 -0
  54. data/spec/pagseguro/installment/{serializer_spec.rb → response_serializer_spec.rb} +1 -1
  55. data/spec/pagseguro/installment/response_spec.rb +52 -0
  56. data/spec/pagseguro/installment_spec.rb +22 -73
  57. data/spec/pagseguro/online_debit_transaction_request_spec.rb +18 -0
  58. data/spec/pagseguro/payment_method_spec.rb +1 -0
  59. data/spec/pagseguro/payment_request/response_spec.rb +0 -11
  60. data/spec/pagseguro/sender_spec.rb +1 -0
  61. data/spec/pagseguro/session/response_serializer_spec.rb +12 -0
  62. data/spec/pagseguro/session/response_spec.rb +52 -0
  63. data/spec/pagseguro/session_spec.rb +41 -0
  64. data/spec/pagseguro/transaction/search/search_abandoned_spec.rb +27 -0
  65. data/spec/pagseguro/transaction/search/search_by_date_spec.rb +26 -0
  66. data/spec/pagseguro/transaction/search/search_by_reference_spec.rb +26 -0
  67. data/spec/pagseguro/transaction/search_spec.rb +131 -0
  68. data/spec/pagseguro/transaction_installment_spec.rb +6 -0
  69. data/spec/pagseguro/transaction_request/request_serializer_spec.rb +213 -0
  70. data/spec/pagseguro/transaction_request/response_serializer_spec.rb +52 -0
  71. data/spec/pagseguro/transaction_request/response_spec.rb +60 -0
  72. data/spec/pagseguro/transaction_request_spec.rb +125 -0
  73. data/spec/support/helpers.rb +14 -0
  74. metadata +79 -6
@@ -4,6 +4,7 @@ describe PagSeguro::Sender do
4
4
  it_assigns_attribute :name
5
5
  it_assigns_attribute :email
6
6
  it_assigns_attribute :cpf
7
+ it_assigns_attribute :hash
7
8
  it_ensures_type PagSeguro::Phone, :phone
8
9
  it_ensures_type PagSeguro::Document, :document
9
10
  end
@@ -0,0 +1,12 @@
1
+ require "spec_helper"
2
+
3
+ describe PagSeguro::Session::ResponseSerializer do
4
+ context "when there are installments" do
5
+ let(:source) { File.read("./spec/fixtures/session/success.xml") }
6
+ let(:xml) { Nokogiri::XML(source) }
7
+ let(:serializer) { described_class.new(xml.css("session").first) }
8
+ subject(:data) { serializer.serialize }
9
+
10
+ it { expect(data).to include(id: "620f99e348c24f07877c927b353e49d3") }
11
+ end
12
+ end
@@ -0,0 +1,52 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe PagSeguro::Session::Response do
4
+ subject { PagSeguro::Session::Response.new(http_response, session) }
5
+ let(:session) { PagSeguro::Session.new }
6
+
7
+ context "#success?" do
8
+ let(:http_response) do
9
+ double(:HttpResponse, xml?: true)
10
+ end
11
+
12
+ it "delegate to response" do
13
+ allow(http_response).to receive(:success?).and_return(true)
14
+ expect(subject).to be_success
15
+
16
+ allow(http_response).to receive(:success?).and_return(false)
17
+ expect(subject).not_to be_success
18
+ end
19
+ end
20
+
21
+ describe "#serialize" do
22
+ let(:http_response) do
23
+ double(:request, success?: true, xml?: true, data: xml_parsed,
24
+ body: raw_xml, unauthorized?: false, bad_request?: false)
25
+ end
26
+ let(:xml_parsed) { Nokogiri::XML(raw_xml) }
27
+
28
+ context "when request succeeds" do
29
+ let(:raw_xml) { File.read("./spec/fixtures/session/success.xml") }
30
+
31
+ it "returns a hash with serialized response data" do
32
+ expect { subject.serialize }.to change { session.id }
33
+ end
34
+
35
+ it "not change session errors" do
36
+ expect { subject.serialize }.not_to change { session.errors.empty? }
37
+ end
38
+ end
39
+
40
+ context "when request fails" do
41
+ before do
42
+ allow(http_response).to receive(:success?).and_return(false)
43
+ allow(http_response).to receive(:bad_request?).and_return(true)
44
+ end
45
+ let(:raw_xml) { File.read("./spec/fixtures/invalid_code.xml") }
46
+
47
+ it "change session errors" do
48
+ expect { subject.serialize }.to change { session.errors.empty? }
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,41 @@
1
+ require "spec_helper"
2
+
3
+ describe PagSeguro::Session do |variable|
4
+ describe ".create" do
5
+ subject { PagSeguro::Session }
6
+ let(:request) do
7
+ double(:request, success?: true, xml?: true, data: xml_parsed,
8
+ body: raw_xml, unauthorized?: false, bad_request?: false)
9
+ end
10
+ let(:xml_parsed) { Nokogiri::XML(raw_xml) }
11
+ let(:raw_xml) { File.read("./spec/fixtures/session/success.xml") }
12
+
13
+ before do
14
+ allow(PagSeguro::Request).to receive(:post)
15
+ .with("sessions", "v2")
16
+ .and_return(request)
17
+ end
18
+
19
+ context "when request succeeds" do
20
+ it "creates a session" do
21
+ expect(subject.create).to be_a(PagSeguro::Session)
22
+ end
23
+ end
24
+
25
+ context "when request fails" do
26
+ before do
27
+ allow(request).to receive(:success?).and_return(false)
28
+ allow(request).to receive(:bad_request?).and_return(true)
29
+ end
30
+ let(:raw_xml) { File.read("./spec/fixtures/invalid_code.xml") }
31
+
32
+ it "create a session" do
33
+ expect(subject.create).to be_a(PagSeguro::Session)
34
+ end
35
+
36
+ it "create a session with errors" do
37
+ expect(subject.create.errors).not_to be_empty
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe PagSeguro::SearchAbandoned do
4
+ describe 'it searches abandoned transactions' do
5
+ let(:options) { { starts_at: Time.now, ends_at: Time.now, page: 1, per_page: 10 } }
6
+ let(:search) { PagSeguro::SearchAbandoned.new("transactions/abandoned", options, 1) }
7
+ let(:source) { File.read("./spec/fixtures/transactions/search.xml") }
8
+ let(:xml) { Nokogiri::XML(source) }
9
+ let(:response) { double(:response, data: xml, unauthorized?: false, bad_request?: false) }
10
+
11
+ describe 'the search abandoned' do
12
+ before do
13
+ FakeWeb.register_uri :get, %r[#{PagSeguro.api_url('v2/transactions/abandoned')}.*],
14
+ body: xml
15
+ end
16
+
17
+ let(:transaction) { double(:transaction) }
18
+
19
+ it 'returns an array of transactions' do
20
+ expect(PagSeguro::Transaction).to receive(:load_from_xml).exactly(2)
21
+ .times
22
+ .and_return(transaction)
23
+ expect(search.transactions).to eq([transaction, transaction])
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe PagSeguro::SearchByDate do
4
+ describe 'it searches transactions by date' do
5
+ let(:options) { { starts_at: Time.now, ends_at: Time.now, per_page: 1 } }
6
+ let(:search) { PagSeguro::SearchByDate.new("transactions", options, 1) }
7
+ let(:source) { File.read("./spec/fixtures/transactions/search.xml") }
8
+ let(:xml) { Nokogiri::XML(source) }
9
+ let(:response) { double(:response, data: xml, unauthorized?: false, bad_request?: false) }
10
+
11
+ describe 'the search by date' do
12
+ before do
13
+ FakeWeb.register_uri :get, %r[#{PagSeguro.api_url('v3/transactions')}.*], body: xml
14
+ end
15
+
16
+ let(:transaction) { double(:transaction) }
17
+
18
+ it 'returns an array of transactions' do
19
+ expect(PagSeguro::Transaction).to receive(:load_from_xml).exactly(2)
20
+ .times
21
+ .and_return(transaction)
22
+ expect(search.transactions).to eq([transaction, transaction])
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe PagSeguro::SearchByReference do
4
+ describe 'it searches transactions by reference' do
5
+ let(:options) { { reference: "ref1234" } }
6
+ let(:search) { PagSeguro::SearchByReference.new("transactions", options, 1) }
7
+ let(:source) { File.read("./spec/fixtures/transactions/search.xml") }
8
+ let(:xml) { Nokogiri::XML(source) }
9
+ let(:response) { double(:response, data: xml, unauthorized?: false, bad_request?: false) }
10
+
11
+ describe 'the search by reference' do
12
+ before do
13
+ FakeWeb.register_uri :get, %r[#{PagSeguro.api_url('v3/transactions')}.*], body: xml
14
+ end
15
+
16
+ let(:transaction) { double(:transaction) }
17
+
18
+ it 'returns an array of transactions' do
19
+ expect(PagSeguro::Transaction).to receive(:load_from_xml).exactly(2)
20
+ .times
21
+ .and_return(transaction)
22
+ expect(search.transactions).to eq([transaction, transaction])
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,131 @@
1
+ require 'spec_helper'
2
+
3
+ describe PagSeguro::Search do
4
+ let(:search) { PagSeguro::Search.new("foo", "bar", 1) }
5
+ let(:source) { File.read("./spec/fixtures/transactions/search.xml") }
6
+ let(:xml) { Nokogiri::XML(source) }
7
+ let(:response) { double(:response, data: xml, unauthorized?: false, bad_request?: false) }
8
+
9
+ context 'when being initialized' do
10
+ it 'initializes with passed page number' do
11
+ search = PagSeguro::Search.new('/foo/bar', 'options', 1)
12
+ expect(search.page).to eq(1)
13
+ end
14
+
15
+ it 'initializes with default page number' do
16
+ search = PagSeguro::Search.new('/foo/bar', 'options')
17
+ expect(search.page).to eq(0)
18
+ end
19
+ end
20
+
21
+ describe 'methods that parse xml' do
22
+ before do
23
+ search.instance_exec(response) do |response|
24
+ @response = response
25
+ @errors = PagSeguro::Errors.new(response)
26
+ end
27
+
28
+ allow(search).to receive(:perform_request_and_serialize)
29
+ end
30
+
31
+ describe '#transactions' do
32
+ let(:transaction) { double(:transaction) }
33
+
34
+ it 'returns an array of transactions' do
35
+ expect(PagSeguro::Transaction).to receive(:load_from_xml).exactly(2)
36
+ .times
37
+ .and_return(transaction)
38
+ expect(search.transactions).to eq([transaction, transaction])
39
+ end
40
+ end
41
+
42
+ describe '#created_at' do
43
+ it 'returns the created date' do
44
+ expect(search.created_at).to eq(Time.parse("2011-02-16T20:14:35.000-02:00"))
45
+ end
46
+ end
47
+
48
+ describe '#results' do
49
+ it 'returns the number of results' do
50
+ expect(search.results).to eq(10)
51
+ end
52
+ end
53
+
54
+ describe '#total_pages' do
55
+ it 'returns the number of pages' do
56
+ expect(search.total_pages).to eq(1)
57
+ end
58
+ end
59
+ end
60
+
61
+ describe '#next_page?' do
62
+ context 'when there is a next page' do
63
+ search = PagSeguro::Search.new('foo', 'bar', 0)
64
+ it 'is page 0' do
65
+ expect(search.next_page?).to be_truthy
66
+ end
67
+
68
+ it 'is not page 0, but page < total_pages' do
69
+ allow(search).to receive(:total_pages).and_return(3)
70
+ expect(search.next_page?).to be_truthy
71
+ end
72
+ end
73
+
74
+ context 'when there is no next page' do
75
+ it 'is not page 0, but page == total_pages' do
76
+ allow(search).to receive(:total_pages).and_return(1)
77
+ expect(search.next_page?).to be_falsy
78
+ end
79
+ end
80
+ end
81
+
82
+ describe '#previous_page?' do
83
+ context 'when there is a previous page' do
84
+ search = PagSeguro::Search.new('foo', 'bar', 2)
85
+ it { expect(search.previous_page?).to be_truthy }
86
+ end
87
+
88
+ context 'when there is no previous page' do
89
+ it { expect(search.previous_page?).to be_falsy }
90
+ end
91
+ end
92
+
93
+ describe '#next_page!' do
94
+ it 'has next page' do
95
+ allow(search).to receive(:next_page?).and_return(true)
96
+ search.next_page!
97
+ expect(search.page).to eq(2)
98
+ end
99
+
100
+ it "doesn't have next page" do
101
+ allow(search).to receive(:next_page?).and_return(false)
102
+ search.next_page!
103
+ expect(search.page).to eq(1)
104
+ end
105
+ end
106
+
107
+ describe '#previous_page!' do
108
+ it 'has previous page' do
109
+ search = PagSeguro::Search.new("foo", "bar", 2)
110
+ search.previous_page!
111
+ expect(search.page).to eq(1)
112
+ end
113
+
114
+ it "does't have previous page" do
115
+ search.previous_page!
116
+ expect(search.page).to eq(1)
117
+ end
118
+ end
119
+
120
+ describe '#valid?' do
121
+ it 'is valid' do
122
+ allow(search).to receive(:fetch).and_return(true)
123
+ expect(search.valid?).to be_truthy
124
+ end
125
+
126
+ it "isn't valid" do
127
+ allow(search).to receive(:fetch).and_return(false)
128
+ expect(search.valid?).to be_falsy
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,6 @@
1
+ require "spec_helper"
2
+
3
+ describe PagSeguro::TransactionInstallment do
4
+ it_assigns_attribute :value
5
+ it_assigns_attribute :quantity
6
+ end
@@ -0,0 +1,213 @@
1
+ require "spec_helper"
2
+
3
+ describe PagSeguro::TransactionRequest::RequestSerializer do
4
+ let(:transaction_request) { PagSeguro::TransactionRequest.new }
5
+ let(:params) { serializer.to_params }
6
+ subject(:serializer) { described_class.new(transaction_request) }
7
+
8
+ before do
9
+ transaction_request.stub({
10
+ payment_method: "creditCard",
11
+ credit_card_token: "4as56d4a56d456as456dsa"
12
+ })
13
+ end
14
+
15
+ context "global configuration serialization" do
16
+ before do
17
+ PagSeguro.receiver_email = "RECEIVER"
18
+ end
19
+
20
+ it { expect(params).to include(receiverEmail: PagSeguro.receiver_email) }
21
+ end
22
+
23
+ context "generic attributes serialization" do
24
+ before do
25
+ transaction_request.stub({
26
+ currency: "BRL",
27
+ reference: "REF123",
28
+ extra_amount: 1234.50,
29
+ notification_url: "NOTIFICATION_URL",
30
+ payment_mode: "default"
31
+ })
32
+ end
33
+
34
+ it { expect(params).to include(currency: "BRL") }
35
+ it { expect(params).to include(reference: "REF123") }
36
+ it { expect(params).to include(extraAmount: "1234.50") }
37
+ it { expect(params).to include(notificationURL: "NOTIFICATION_URL") }
38
+ it { expect(params).to include(paymentMethod: "creditCard") }
39
+ it { expect(params).to include(paymentMode: "default") }
40
+ it { expect(params).to include(creditCardToken: "4as56d4a56d456as456dsa") }
41
+ end
42
+
43
+ context "items serialization" do
44
+ def build_item(index)
45
+ PagSeguro::Item.new({
46
+ id: "ID#{index}",
47
+ description: "DESC#{index}",
48
+ quantity: "QTY#{index}",
49
+ amount: index * 100 + 0.12,
50
+ weight: "WEIGHT#{index}",
51
+ shipping_cost: index * 100 + 0.34
52
+ })
53
+ end
54
+
55
+ shared_examples_for "item serialization" do |index|
56
+ it { expect(params).to include("itemId#{index}" => "ID#{index}") }
57
+ it { expect(params).to include("itemDescription#{index}" => "DESC#{index}") }
58
+ it { expect(params).to include("itemAmount#{index}" => "#{index}00.12") }
59
+ it { expect(params).to include("itemShippingCost#{index}" => "#{index}00.34") }
60
+ it { expect(params).to include("itemQuantity#{index}" => "QTY#{index}") }
61
+ it { expect(params).to include("itemWeight#{index}" => "WEIGHT#{index}") }
62
+ end
63
+
64
+ before do
65
+ transaction_request.items << build_item(1)
66
+ transaction_request.items << build_item(2)
67
+ end
68
+
69
+ it_behaves_like "item serialization", 1
70
+ it_behaves_like "item serialization", 2
71
+ end
72
+
73
+ context "bank serialization" do
74
+ before do
75
+ allow(transaction_request).to receive(:bank) do
76
+ PagSeguro::Bank.new({name: "itau"})
77
+ end
78
+ end
79
+
80
+ it { expect(params).to include(bankName: "itau") }
81
+ end
82
+
83
+ context "holder serialization" do
84
+ before do
85
+ holder = PagSeguro::Holder.new({
86
+ name: "Jose Comprador",
87
+ birth_date: "27/10/1987",
88
+ document: {
89
+ type: "CPF",
90
+ value: "22111944785"
91
+ },
92
+ phone: {
93
+ area_code: "11",
94
+ number: "56273440"
95
+ }
96
+ })
97
+
98
+ transaction_request.stub({holder: holder})
99
+ end
100
+
101
+ it { expect(params).to include(creditCardHolderName: "Jose Comprador") }
102
+ it { expect(params).to include(creditCardHolderBirthDate: "27/10/1987") }
103
+ it { expect(params).to include(creditCardHolderCPF: "22111944785") }
104
+ it { expect(params).to include(creditCardHolderAreaCode: "11") }
105
+ it { expect(params).to include(creditCardHolderPhone: "56273440") }
106
+ end
107
+
108
+ context "billing address serialization" do
109
+ before do
110
+ address = PagSeguro::Address.new({
111
+ street: "STREET",
112
+ state: "STATE",
113
+ city: "CITY",
114
+ postal_code: "POSTAL_CODE",
115
+ district: "DISTRICT",
116
+ number: "NUMBER",
117
+ complement: "COMPLEMENT"
118
+ })
119
+
120
+ transaction_request.stub(billing_address: address)
121
+ end
122
+
123
+ it { expect(params).to include(billingAddressStreet: "STREET") }
124
+ it { expect(params).to include(billingAddressCountry: "BRA") }
125
+ it { expect(params).to include(billingAddressState: "STATE") }
126
+ it { expect(params).to include(billingAddressCity: "CITY") }
127
+ it { expect(params).to include(billingAddressPostalCode: "POSTAL_CODE") }
128
+ it { expect(params).to include(billingAddressDistrict: "DISTRICT") }
129
+ it { expect(params).to include(billingAddressNumber: "NUMBER") }
130
+ it { expect(params).to include(billingAddressComplement: "COMPLEMENT") }
131
+ end
132
+
133
+ context "sender serialization" do
134
+ before do
135
+ sender = PagSeguro::Sender.new({
136
+ hash: "HASH",
137
+ email: "EMAIL",
138
+ name: "NAME",
139
+ cpf: "CPF",
140
+ phone: {
141
+ area_code: "AREA_CODE",
142
+ number: "NUMBER"
143
+ }
144
+ })
145
+
146
+ transaction_request.stub(sender: sender)
147
+ end
148
+
149
+ it { expect(params).to include(senderHash: "HASH") }
150
+ it { expect(params).to include(senderEmail: "EMAIL") }
151
+ it { expect(params).to include(senderName: "NAME") }
152
+ it { expect(params).to include(senderCPF: "CPF") }
153
+ it { expect(params).to include(senderAreaCode: "AREA_CODE") }
154
+ it { expect(params).to include(senderPhone: "NUMBER") }
155
+ end
156
+
157
+ context "shipping serialization" do
158
+ before do
159
+ transaction_request.shipping = PagSeguro::Shipping.new({
160
+ type_id: 1,
161
+ cost: 1234.56,
162
+ address: {
163
+ street: "STREET",
164
+ state: "STATE",
165
+ city: "CITY",
166
+ postal_code: "POSTAL_CODE",
167
+ district: "DISTRICT",
168
+ number: "NUMBER",
169
+ complement: "COMPLEMENT"
170
+ }
171
+ })
172
+ end
173
+
174
+ it { expect(params).to include(shippingType: 1) }
175
+ it { expect(params).to include(shippingCost: "1234.56") }
176
+ it { expect(params).to include(shippingAddressStreet: "STREET") }
177
+ it { expect(params).to include(shippingAddressCountry: "BRA") }
178
+ it { expect(params).to include(shippingAddressState: "STATE") }
179
+ it { expect(params).to include(shippingAddressCity: "CITY") }
180
+ it { expect(params).to include(shippingAddressPostalCode: "POSTAL_CODE") }
181
+ it { expect(params).to include(shippingAddressDistrict: "DISTRICT") }
182
+ it { expect(params).to include(shippingAddressNumber: "NUMBER") }
183
+ it { expect(params).to include(shippingAddressComplement: "COMPLEMENT") }
184
+ end
185
+
186
+ context "installment serialization" do
187
+ before do
188
+ installment = PagSeguro::TransactionInstallment.new({
189
+ value: "459.50",
190
+ quantity: "1"
191
+ })
192
+
193
+ transaction_request.stub({installment: installment})
194
+ end
195
+
196
+ it { expect(params).to include(installmentValue: "459.50") }
197
+ it { expect(params).to include(installmentQuantity: "1") }
198
+ end
199
+
200
+ context "extra params serialization" do
201
+ before do
202
+ transaction_request.stub({
203
+ extra_params: [
204
+ { extraParam: 'param_value' },
205
+ { newExtraParam: 'extra_param_value' }
206
+ ]
207
+ })
208
+ end
209
+
210
+ it { expect(params).to include(extraParam: 'param_value') }
211
+ it { expect(params).to include(newExtraParam: 'extra_param_value') }
212
+ end
213
+ end