pagseguro-oficial 2.5.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -1
  3. data/CONTRIBUTING.md +39 -0
  4. data/Dockerfile +20 -0
  5. data/README.md +22 -0
  6. data/docker-compose.yml +5 -0
  7. data/examples/checkout/create_payment_request.rb +1 -1
  8. data/examples/direct/create_transaction_using_boleto.rb +1 -1
  9. data/examples/direct/create_transaction_using_credit_card.rb +1 -1
  10. data/examples/direct/create_transaction_using_online_debit.rb +1 -1
  11. data/examples/preapproval/cancel_preapproval.rb +26 -0
  12. data/examples/preapproval/change_preapproval_payment.rb +50 -0
  13. data/examples/preapproval/change_preapproval_status.rb +29 -0
  14. data/examples/preapproval/charge_preapproval.rb +36 -0
  15. data/examples/preapproval/create_preapproval.rb +68 -0
  16. data/examples/preapproval/create_preapproval_auto.rb +53 -0
  17. data/examples/preapproval/create_preapproval_discount.rb +30 -0
  18. data/examples/preapproval/create_preapproval_manual.rb +58 -0
  19. data/examples/preapproval/create_preapproval_transparent.rb +41 -0
  20. data/examples/preapproval/preapproval_retry.rb +29 -0
  21. data/examples/preapproval/search/search_by_date_interval.rb +45 -0
  22. data/examples/preapproval/search/search_by_days_interval.rb +46 -0
  23. data/examples/preapproval/search/search_by_notification_code.rb +50 -0
  24. data/examples/preapproval/search/search_by_subscription_code.rb +50 -0
  25. data/examples/preapproval/search/search_subscription_payment_orders.rb +53 -0
  26. data/examples/split_payment/create_payment_request.rb +1 -1
  27. data/examples/split_payment/create_transaction_using_boleto.rb +118 -0
  28. data/examples/split_payment/create_transaction_using_credit_card.rb +152 -0
  29. data/lib/pagseguro.rb +33 -1
  30. data/lib/pagseguro/credit_card_transaction_request.rb +1 -1
  31. data/lib/pagseguro/document.rb +8 -0
  32. data/lib/pagseguro/holder.rb +8 -0
  33. data/lib/pagseguro/manual_subscription_charger.rb +59 -0
  34. data/lib/pagseguro/manual_subscription_charger/request_serializer.rb +50 -0
  35. data/lib/pagseguro/manual_subscription_charger/response.rb +36 -0
  36. data/lib/pagseguro/manual_subscription_charger/response_serializer.rb +17 -0
  37. data/lib/pagseguro/payment_request/request_serializer.rb +25 -1
  38. data/lib/pagseguro/receiver.rb +3 -0
  39. data/lib/pagseguro/request.rb +32 -2
  40. data/lib/pagseguro/sender.rb +21 -3
  41. data/lib/pagseguro/subscription.rb +132 -0
  42. data/lib/pagseguro/subscription/request_serializer.rb +129 -0
  43. data/lib/pagseguro/subscription/response.rb +49 -0
  44. data/lib/pagseguro/subscription/response_serializer.rb +62 -0
  45. data/lib/pagseguro/subscription/subscription_search.rb +135 -0
  46. data/lib/pagseguro/subscription_canceller.rb +30 -0
  47. data/lib/pagseguro/subscription_canceller/response.rb +34 -0
  48. data/lib/pagseguro/subscription_change_payment.rb +46 -0
  49. data/lib/pagseguro/subscription_change_payment/request_serializer.rb +80 -0
  50. data/lib/pagseguro/subscription_change_payment/response.rb +26 -0
  51. data/lib/pagseguro/subscription_change_status.rb +50 -0
  52. data/lib/pagseguro/subscription_change_status/request_serializer.rb +28 -0
  53. data/lib/pagseguro/subscription_change_status/response.rb +26 -0
  54. data/lib/pagseguro/subscription_discount.rb +41 -0
  55. data/lib/pagseguro/subscription_discount/request_serializer.rb +34 -0
  56. data/lib/pagseguro/subscription_discount/response.rb +34 -0
  57. data/lib/pagseguro/subscription_payment_method.rb +21 -0
  58. data/lib/pagseguro/subscription_payment_order.rb +57 -0
  59. data/lib/pagseguro/subscription_payment_order/response.rb +37 -0
  60. data/lib/pagseguro/subscription_payment_order/response_serializer.rb +51 -0
  61. data/lib/pagseguro/subscription_plan.rb +69 -0
  62. data/lib/pagseguro/subscription_plan/request_serializer.rb +81 -0
  63. data/lib/pagseguro/subscription_plan/response.rb +36 -0
  64. data/lib/pagseguro/subscription_plan/response_serializer.rb +17 -0
  65. data/lib/pagseguro/subscription_retry.rb +35 -0
  66. data/lib/pagseguro/subscription_retry/response.rb +34 -0
  67. data/lib/pagseguro/subscription_search_payment_orders.rb +131 -0
  68. data/lib/pagseguro/subscription_transaction.rb +29 -0
  69. data/lib/pagseguro/subscription_transactions.rb +5 -0
  70. data/lib/pagseguro/transaction.rb +0 -10
  71. data/lib/pagseguro/transaction/serializer.rb +19 -2
  72. data/lib/pagseguro/transaction_request.rb +26 -1
  73. data/lib/pagseguro/transaction_request/request_serializer.rb +164 -1
  74. data/lib/pagseguro/version.rb +1 -1
  75. data/spec/fixtures/manual_subscription_charger/fail.xml +6 -0
  76. data/spec/fixtures/manual_subscription_charger/success.xml +4 -0
  77. data/spec/fixtures/subscription/fail.xml +6 -0
  78. data/spec/fixtures/subscription/find_success.xml +28 -0
  79. data/spec/fixtures/subscription/search_success.xml +18 -0
  80. data/spec/fixtures/subscription/success.xml +4 -0
  81. data/spec/fixtures/subscription_canceller/fail.xml +6 -0
  82. data/spec/fixtures/subscription_change_payment/fail.xml +7 -0
  83. data/spec/fixtures/subscription_change_status/fail.xml +7 -0
  84. data/spec/fixtures/subscription_discount/fail.xml +6 -0
  85. data/spec/fixtures/subscription_payment_order/success.xml +18 -0
  86. data/spec/fixtures/subscription_plan/fail.xml +6 -0
  87. data/spec/fixtures/subscription_plan/success.xml +4 -0
  88. data/spec/fixtures/subscription_retry/fail.xml +7 -0
  89. data/spec/fixtures/subscription_search_payment_orders/success.xml +43 -0
  90. data/spec/fixtures/transactions/without_status_and_type.xml +71 -0
  91. data/spec/pagseguro/credit_card_transaction_request_spec.rb +1 -1
  92. data/spec/pagseguro/document_spec.rb +15 -0
  93. data/spec/pagseguro/holder_spec.rb +1 -0
  94. data/spec/pagseguro/manual_subscription_charger/request_serializer_spec.rb +79 -0
  95. data/spec/pagseguro/manual_subscription_charger/response_serializer_spec.rb +10 -0
  96. data/spec/pagseguro/manual_subscription_charger/response_spec.rb +65 -0
  97. data/spec/pagseguro/manual_subscription_charger_spec.rb +68 -0
  98. data/spec/pagseguro/payment_request/request_serializer_spec.rb +54 -22
  99. data/spec/pagseguro/receiver_spec.rb +1 -0
  100. data/spec/pagseguro/sender_spec.rb +16 -2
  101. data/spec/pagseguro/subscription/request_serializer_spec.rb +233 -0
  102. data/spec/pagseguro/subscription/response_serializer_spec.rb +46 -0
  103. data/spec/pagseguro/subscription/response_spec.rb +79 -0
  104. data/spec/pagseguro/subscription/subscription_search_spec.rb +154 -0
  105. data/spec/pagseguro/subscription_canceller/response_spec.rb +58 -0
  106. data/spec/pagseguro/subscription_canceller_spec.rb +57 -0
  107. data/spec/pagseguro/subscription_change_payment/request_serializer_spec.rb +150 -0
  108. data/spec/pagseguro/subscription_change_payment/response_spec.rb +41 -0
  109. data/spec/pagseguro/subscription_change_payment_spec.rb +60 -0
  110. data/spec/pagseguro/subscription_change_status/request_serializer_spec.rb +19 -0
  111. data/spec/pagseguro/subscription_change_status/response_spec.rb +41 -0
  112. data/spec/pagseguro/subscription_change_status_spec.rb +53 -0
  113. data/spec/pagseguro/subscription_discount/request_serializer_spec.rb +27 -0
  114. data/spec/pagseguro/subscription_discount/response_spec.rb +58 -0
  115. data/spec/pagseguro/subscription_discount_spec.rb +60 -0
  116. data/spec/pagseguro/subscription_payment_method_spec.rb +10 -0
  117. data/spec/pagseguro/subscription_payment_order/response_serializer_spec.rb +24 -0
  118. data/spec/pagseguro/subscription_payment_order/response_spec.rb +55 -0
  119. data/spec/pagseguro/subscription_payment_order_spec.rb +27 -0
  120. data/spec/pagseguro/subscription_plan/request_serializer_spec.rb +253 -0
  121. data/spec/pagseguro/subscription_plan/response_serializer_spec.rb +10 -0
  122. data/spec/pagseguro/subscription_plan/response_spec.rb +65 -0
  123. data/spec/pagseguro/subscription_plan_spec.rb +118 -0
  124. data/spec/pagseguro/subscription_retry/response_spec.rb +58 -0
  125. data/spec/pagseguro/subscription_retry_spec.rb +62 -0
  126. data/spec/pagseguro/subscription_search_payment_order_spec.rb +129 -0
  127. data/spec/pagseguro/subscription_spec.rb +137 -0
  128. data/spec/pagseguro/subscription_transaction_spec.rb +24 -0
  129. data/spec/pagseguro/subscription_transactions_spec.rb +37 -0
  130. data/spec/pagseguro/transaction/response_spec.rb +0 -42
  131. data/spec/pagseguro/transaction/serializer_spec.rb +5 -6
  132. data/spec/pagseguro/transaction_request/request_serializer_spec.rb +623 -159
  133. data/spec/pagseguro/transaction_request_spec.rb +26 -0
  134. data/spec/pagseguro/transaction_spec.rb +0 -48
  135. data/spec/spec_helper.rb +1 -0
  136. metadata +154 -8
  137. data/examples/checkout/search/search_transaction_status_history.rb +0 -22
  138. data/lib/pagseguro/transaction/status_collection.rb +0 -20
  139. data/spec/fixtures/transactions/status_history.xml +0 -12
  140. data/spec/pagseguro/transaction/status_collection_spec.rb +0 -43
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+
3
+ describe PagSeguro::Subscription::Response do
4
+ subject { PagSeguro::Subscription::Response.new(http_response, subscription) }
5
+ let(:subscription) { PagSeguro::Subscription.new }
6
+
7
+ context '#success?' do
8
+ let(:http_response) { double(:HttpResponse, xml?: true) }
9
+
10
+ it 'delegate to response' do
11
+ allow(http_response).to receive(:success?).and_return(true)
12
+ expect(subject).to be_success
13
+
14
+ allow(http_response).to receive(:success?).and_return(false)
15
+ expect(subject).not_to be_success
16
+ end
17
+ end
18
+
19
+ context '#serialize' do
20
+ let(:http_response) do
21
+ double(
22
+ :Request,
23
+ success?: true,
24
+ xml?: true,
25
+ data: xml_parsed,
26
+ body: raw_xml,
27
+ unauthorized?: false,
28
+ bad_request?: false,
29
+ not_found?: false
30
+ )
31
+ end
32
+
33
+ let(:xml_parsed) { Nokogiri::XML(raw_xml) }
34
+
35
+ context 'when request succeeds' do
36
+
37
+
38
+ context 'and response is normal' do
39
+ let(:raw_xml) { File.read('./spec/fixtures/subscription/success.xml') }
40
+
41
+ it 'not change subscription errors' do
42
+ expect { subject.serialize }.not_to change { subscription.errors.empty? }
43
+ end
44
+
45
+ it 'returns a hash with serialized response data' do
46
+ expect{ subject.serialize }.to change { subscription.code }
47
+ end
48
+ end
49
+
50
+ context 'and response is a search' do
51
+ let(:raw_xml) { File.read('./spec/fixtures/subscription/search_success.xml') }
52
+
53
+ it 'not change subscription errors' do
54
+ expect { subject.serialize }.not_to change { subscription.errors.empty? }
55
+ end
56
+
57
+ it 'return a hash with serialized search response data' do
58
+ expect{ subject.serialize(:search) }.to change { subscription.name }
59
+ end
60
+ end
61
+ end
62
+
63
+ context 'when request fails' do
64
+ before do
65
+ allow(http_response).to receive_messages(
66
+ success?: false,
67
+ error?: true,
68
+ error: Aitch::BadRequestError
69
+ )
70
+ end
71
+
72
+ let(:raw_xml) { File.read('./spec/fixtures/subscription/fail.xml') }
73
+
74
+ it 'errors should be present' do
75
+ expect { subject.serialize }.to change { subscription.errors }
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,154 @@
1
+ require 'spec_helper'
2
+
3
+ describe PagSeguro::SubscriptionSearch do
4
+ let(:path) { 'path-to-search' }
5
+ let(:credentials) { PagSeguro::AccountCredentials.new('user@example.com', 'TOKEN') }
6
+ let(:options) do
7
+ {
8
+ credentials: credentials
9
+ }
10
+ end
11
+
12
+ subject { PagSeguro::SubscriptionSearch.new(path, options) }
13
+
14
+ context 'when search succeeds' do
15
+ before do
16
+ FakeWeb.register_uri(
17
+ :get,
18
+ "https://ws.pagseguro.uol.com.br/v2/path-to-search?page=1&email=user%40example.com&token=TOKEN&charset=UTF-8",
19
+ body: response_body,
20
+ content_type: "text/xml"
21
+ )
22
+
23
+ subject.next_page!
24
+ end
25
+
26
+ let(:response_body) { File.read('./spec/fixtures/subscription/search_success.xml') }
27
+
28
+ it 'must have results in page' do
29
+ expect(subject.results).to eq 1
30
+ end
31
+
32
+ it 'must have total pages' do
33
+ expect(subject.total_pages).to eq 1
34
+ end
35
+
36
+ it 'must have date of create' do
37
+ expect(subject.created_at).to eq Time.new(2011,8,8,16,16,23, '-03:00')
38
+ end
39
+
40
+ context 'subscriptions' do
41
+ it 'must return a subscription array' do
42
+ expect(subject.subscriptions).to be_an Array
43
+
44
+ subject.subscriptions.each do |subscription|
45
+ expect(subscription).to be_a PagSeguro::Subscription
46
+ end
47
+ end
48
+
49
+ context 'subscription' do
50
+ let(:subscription) { subject.subscriptions.first }
51
+
52
+ it 'must have name' do
53
+ expect(subscription.name).to eq 'PagSeguro Pre Approval'
54
+ end
55
+
56
+ it 'must have code' do
57
+ expect(subscription.code).to eq '12E10BEF5E5EF94004313FB891C8E4CF'
58
+ end
59
+
60
+ it 'must have date' do
61
+ expect(subscription.date).to eq "2011-08-15T11:06:44.000-03:00"
62
+ end
63
+
64
+ it 'must have tracker' do
65
+ expect(subscription.tracker).to eq '624C17'
66
+ end
67
+
68
+ it 'must have status' do
69
+ expect(subscription.status).to eq 'INITIATED'
70
+ end
71
+
72
+ it 'must have reference' do
73
+ expect(subscription.reference).to eq 'R123456'
74
+ end
75
+
76
+ it 'must have last event date' do
77
+ expect(subscription.last_event_date).to eq "2011-08-08T15:37:30.000-03:00"
78
+ end
79
+
80
+ it 'must have charge' do
81
+ expect(subscription.charge).to eq 'auto'
82
+ end
83
+ end
84
+ end
85
+ end
86
+
87
+ context 'when search fails' do
88
+ before do
89
+ FakeWeb.register_uri(
90
+ :get,
91
+ "https://ws.pagseguro.uol.com.br/v2/path-to-search?page=1&email=user%40example.com&token=TOKEN&charset=UTF-8",
92
+ body: response_body,
93
+ status: ['400', 'ERROR'],
94
+ content_type: "text/xml"
95
+ )
96
+
97
+ subject.next_page!
98
+ end
99
+
100
+ let(:response_body) { File.read('./spec/fixtures/subscription/fail.xml') }
101
+
102
+ it 'must do not be valid' do
103
+ expect(subject).to_not be_valid
104
+ end
105
+
106
+ it 'errors must not be empty' do
107
+ expect{ subject.valid? }.to change{ subject.errors.empty? }
108
+ end
109
+ end
110
+
111
+ context 'page control' do
112
+ it 'page default should be 1' do
113
+ expect(subject.page).to eq 0
114
+ end
115
+
116
+ it 'search can begin with other page' do
117
+ options[:page] = 2
118
+ expect(subject.page).to eq 2
119
+ end
120
+
121
+ context 'next page' do
122
+ it 'should increment the page by 1' do
123
+ allow(subject).to receive(:total_pages).and_return(10)
124
+ expect{ subject.next_page! }.to change{ subject.page }.from(0).to(1)
125
+ end
126
+
127
+ it 'not increment if no have more pages' do
128
+ subject.next_page!
129
+ allow(subject).to receive(:total_pages).and_return(1)
130
+ expect{ subject.next_page! }.to_not change{ subject.page }
131
+ end
132
+ end
133
+
134
+ context 'previous page' do
135
+ it 'should decrement the page by 1' do
136
+ options[:page] = 3
137
+ expect{ subject.previous_page! }.to change{ subject.page }.from(3).to(2)
138
+ end
139
+
140
+ it 'not decrement unless current page be more than 1' do
141
+ expect{ subject.previous_page! }.not_to change{ subject.page }
142
+ end
143
+ end
144
+
145
+ context 'when page changes' do
146
+ it 'fetched clear! should be called' do
147
+ allow(subject).to receive(:total_pages).and_return(10)
148
+ expect(subject).to receive(:clear!).with(no_args)
149
+ subject.next_page!
150
+ end
151
+ end
152
+ end
153
+ end
154
+
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe PagSeguro::SubscriptionCanceller::Response do
4
+ subject { described_class.new(response, cancel) }
5
+
6
+ let(:cancel) { PagSeguro::SubscriptionCanceller.new }
7
+
8
+ context '#success?' do
9
+ let(:response) do
10
+ double(:HttpResponse, xml?: true)
11
+ end
12
+
13
+ it 'delegate to response' do
14
+ allow(response).to receive(:success?).and_return(true)
15
+ expect(subject).to be_success
16
+
17
+ allow(response).to receive(:success?).and_return(false)
18
+ expect(subject).not_to be_success
19
+ end
20
+ end
21
+
22
+ describe '#serialize' do
23
+ let(:response) do
24
+ double(:HttpResponse, xml?: true, success?: true)
25
+ end
26
+
27
+ context 'when request succeeds' do
28
+ it 'not change object errors' do
29
+ expect { subject.serialize }.not_to change { cancel.errors.empty? }
30
+ end
31
+ end
32
+
33
+ context 'when request fails' do
34
+ let(:response) do
35
+ double(
36
+ :HttpResponse,
37
+ data: parsed_xml,
38
+ error: Aitch::BadRequestError,
39
+ error?: true,
40
+ success?: false,
41
+ xml?: true
42
+ )
43
+ end
44
+
45
+ let(:raw_xml) do
46
+ File.read('./spec/fixtures/subscription_canceller/fail.xml')
47
+ end
48
+
49
+ let(:parsed_xml) do
50
+ Nokogiri::XML(raw_xml)
51
+ end
52
+
53
+ it 'change errors' do
54
+ expect { subject.serialize }.to change { cancel.errors.empty? }
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe PagSeguro::SubscriptionCanceller do
4
+ it_assigns_attribute :subscription_code
5
+
6
+ context 'errors attribute' do
7
+ it 'should start with errors' do
8
+ expect(subject.errors).to be_a PagSeguro::Errors
9
+ end
10
+
11
+ it 'should start with empty errors' do
12
+ expect(subject.errors).to be_empty
13
+ end
14
+ end
15
+
16
+ describe '#save' do
17
+ before do
18
+ subject.subscription_code = 'ABC'
19
+ subject.credentials = credentials
20
+
21
+ FakeWeb.register_uri(
22
+ :get,
23
+ 'https://ws.pagseguro.uol.com.br/v2/pre-approvals/cancel/ABC?email=user@example.com&token=TOKEN',
24
+ body: ''
25
+ )
26
+ end
27
+
28
+ let(:credentials) do
29
+ PagSeguro::AccountCredentials.new('user@example.com', 'TOKEN')
30
+ end
31
+
32
+ let(:request) do
33
+ double(
34
+ :Request,
35
+ success?: true,
36
+ xml?: true,
37
+ body: '<preApprovalRequest><code>1234</code></preApprovalRequest>'
38
+ )
39
+ end
40
+
41
+ it 'sends it to correct url' do
42
+ expect(PagSeguro).to receive(:api_url).with(
43
+ 'v2/pre-approvals/cancel/ABC?email=user@example.com&token=TOKEN'
44
+ ).and_return('https://ws.pagseguro.uol.com.br/v2/pre-approvals/cancel/ABC?email=user@example.com&token=TOKEN')
45
+
46
+ subject.save
47
+ end
48
+
49
+ it 'cancel' do
50
+ expect(PagSeguro::Request).to receive(:get_with_auth_on_url).with(
51
+ 'pre-approvals/cancel/ABC', :v2, credentials
52
+ ).and_return(request)
53
+
54
+ subject.save
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,150 @@
1
+ require 'spec_helper'
2
+
3
+ describe PagSeguro::SubscriptionChangePayment::RequestSerializer do
4
+ let(:object) do
5
+ PagSeguro::SubscriptionChangePayment.new
6
+ end
7
+
8
+ subject { described_class.new(object) }
9
+
10
+ context '#serialize' do
11
+ it 'must serialize type' do
12
+ expect(subject.serialize).to match %r[
13
+ .*<paymentMethod>
14
+ .*<type>CREDITCARD
15
+ ]xm
16
+ end
17
+
18
+ context "sender's" do
19
+ let(:object) do
20
+ PagSeguro::SubscriptionChangePayment.new(sender: sender)
21
+ end
22
+
23
+ let(:sender) do
24
+ PagSeguro::Sender.new(hash: 12345, ip: '192.168.0.1')
25
+ end
26
+
27
+ it 'hash' do
28
+ expect(subject.serialize).to match %r[
29
+ .*<paymentMethod>
30
+ .*<sender>
31
+ .*<hash>12345
32
+ ]xm
33
+ end
34
+
35
+ it 'ip' do
36
+ expect(subject.serialize).to match %r[
37
+ .*<paymentMethod>
38
+ .*<sender>
39
+ .*<ip>192.168.0.1
40
+ ]xm
41
+ end
42
+ end
43
+
44
+ context "payment method's" do
45
+ let(:object) do
46
+ PagSeguro::SubscriptionChangePayment.new(subscription_payment_method: payment_method)
47
+ end
48
+
49
+ let(:payment_method) do
50
+ PagSeguro::SubscriptionPaymentMethod.new(token: 'abcd', holder: holder)
51
+ end
52
+
53
+ let(:holder) do
54
+ PagSeguro::Holder.new(
55
+ name: 'Holder Name',
56
+ birth_date: Date.new(1990, 12, 31),
57
+ document: {
58
+ type: 'CPF',
59
+ value: '00000000191'
60
+ },
61
+ phone: {
62
+ area_code: 11,
63
+ number: 988881234
64
+ },
65
+ billing_address: {
66
+ street: 'Av Brigadeiro',
67
+ number: '1384',
68
+ complement: '3 andar',
69
+ district: 'Paulistano',
70
+ city: 'Sao Paulo',
71
+ state: 'SP',
72
+ country: 'BRA',
73
+ postal_code: '01452002'
74
+ }
75
+ )
76
+ end
77
+
78
+ context "holder's" do
79
+ it "name" do
80
+ expect(subject.serialize).to match %r[
81
+ .*<paymentMethod>
82
+ .*<creditCard>
83
+ .*<holder>
84
+ .*<name>Holder.Name
85
+ ]xm
86
+ end
87
+
88
+ it 'birth_date' do
89
+ expect(subject.serialize).to match %r[
90
+ .*<paymentMethod>
91
+ .*<creditCard>
92
+ .*<holder>
93
+ .*<birthDate>31/12/1990
94
+ ]xm
95
+ end
96
+
97
+ it 'not include <documents>' do
98
+ expect(subject.serialize).not_to match %r[
99
+ .*<paymentMethod>
100
+ .*<creditCard>
101
+ .*<holder>
102
+ .*<documents>
103
+ .*<document>
104
+ .*<type>CPF</type>
105
+ .*<value>00000000191
106
+ ]xm
107
+ end
108
+
109
+ it 'document' do
110
+ expect(subject.serialize).to match %r[
111
+ .*<paymentMethod>
112
+ .*<creditCard>
113
+ .*<holder>
114
+ .*<document>
115
+ .*<type>CPF</type>
116
+ .*<value>00000000191
117
+ ]xm
118
+ end
119
+
120
+ it 'billing address' do
121
+ expect(subject.serialize).to match %r[
122
+ .*<paymentMethod>
123
+ .*<creditCard>
124
+ .*<holder>
125
+ .*<billingAddress>
126
+ .*<street>Av.Brigadeiro</street>
127
+ .*<number>1384</number>
128
+ .*<complement>3.andar</complement>
129
+ .*<district>Paulistano</district>
130
+ .*<city>Sao.Paulo</city>
131
+ .*<state>SP</state>
132
+ .*<country>BRA</country>
133
+ .*<postalCode>01452002
134
+ ]xm
135
+ end
136
+
137
+ it 'phone' do
138
+ expect(subject.serialize).to match %r[
139
+ .*<paymentMethod>
140
+ .*<creditCard>
141
+ .*<holder>
142
+ .*<phone>
143
+ .*<areaCode>11</areaCode>
144
+ .*<number>988881234
145
+ ]xm
146
+ end
147
+ end
148
+ end
149
+ end
150
+ end