1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Moip\Tests\Resource; |
4
|
|
|
|
5
|
|
|
use Moip\Tests\TestCase; |
6
|
|
|
|
7
|
|
|
class RefundTest extends TestCase |
8
|
|
|
{ |
9
|
|
|
public function testRefundOrderCreditCardFull() |
10
|
|
|
{ |
11
|
|
|
$order = $this->paymentCreditCard(false); |
12
|
|
|
|
13
|
|
|
$this->mockHttpSession($this->body_order_refund_full_cc); |
|
|
|
|
14
|
|
|
$refund = $order->refunds()->creditCardFull(); |
15
|
|
|
|
16
|
|
|
$this->assertNotEmpty($refund->getId()); |
17
|
|
|
$this->assertEquals('FULL', $refund->getType()); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function testRefundOrderCreditCardPartial() |
21
|
|
|
{ |
22
|
|
|
$order = $this->paymentCreditCard(false); |
23
|
|
|
|
24
|
|
|
$this->mockHttpSession($this->body_order_refund_partial_cc); |
|
|
|
|
25
|
|
|
$refund = $order->refunds()->creditCardPartial(5000); |
26
|
|
|
|
27
|
|
|
$this->assertNotEmpty($refund->getId()); |
28
|
|
|
$this->assertEquals('PARTIAL', $refund->getType()); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
View Code Duplication |
public function testRefundOrderBankAccountFull() |
|
|
|
|
32
|
|
|
{ |
33
|
|
|
$order = $this->paymentBoleto(false); |
34
|
|
|
|
35
|
|
|
$this->mockHttpSession($this->body_order_refund_full_bankaccount); |
|
|
|
|
36
|
|
|
$refund = $order->refunds() |
37
|
|
|
->bankAccountFull('CHECKING', '001', '1584', '9', '00210169', '6', $order->getCustomer()); |
38
|
|
|
|
39
|
|
|
$this->assertNotEmpty($refund->getId()); |
40
|
|
|
$this->assertEquals('FULL', $refund->getType()); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
View Code Duplication |
public function testRefundOrderBankAccountPartial() |
|
|
|
|
44
|
|
|
{ |
45
|
|
|
$order = $this->paymentBoleto(false); |
46
|
|
|
|
47
|
|
|
$this->mockHttpSession($this->body_payment_refund_partial_bankaccount); |
|
|
|
|
48
|
|
|
$refund = $order->refunds() |
49
|
|
|
->bankAccountPartial(20000, 'SAVING', '001', '1584', '9', '00210169', '6', $order->getCustomer()); |
50
|
|
|
|
51
|
|
|
$this->assertNotEmpty($refund->getId()); |
52
|
|
|
$this->assertEquals('PARTIAL', $refund->getType()); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testRefundPaymentCreditCardFull() |
56
|
|
|
{ |
57
|
|
|
$payment = $this->paymentCreditCard(); |
58
|
|
|
|
59
|
|
|
$this->mockHttpSession($this->body_payment_refund_full_cc); |
|
|
|
|
60
|
|
|
$refund = $payment->refunds()->creditCardFull(); |
61
|
|
|
|
62
|
|
|
$this->assertNotEmpty($refund->getId()); |
63
|
|
|
$this->assertEquals('FULL', $refund->getType()); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
View Code Duplication |
public function testRefundPaymentCreditCardPartial() |
|
|
|
|
67
|
|
|
{ |
68
|
|
|
$payment = $this->paymentCreditCard(); |
69
|
|
|
|
70
|
|
|
$this->mockHttpSession($this->body_payment_refund_partial_cc); |
|
|
|
|
71
|
|
|
$refund = $payment->refunds()->creditCardPartial(5000); |
72
|
|
|
|
73
|
|
|
$this->assertNotEmpty($refund->getId()); |
74
|
|
|
$this->assertEquals('PARTIAL', $refund->getType()); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
View Code Duplication |
public function testRefundPaymentBankAccountFull() |
|
|
|
|
78
|
|
|
{ |
79
|
|
|
$payment = $this->paymentBoleto(); |
80
|
|
|
|
81
|
|
|
$this->mockHttpSession($this->body_payment_refund_full_bankaccount); |
|
|
|
|
82
|
|
|
$refund = $payment->refunds() |
83
|
|
|
->bankAccountFull('CHECKING', '001', '1584', '9', '00210169', '6', $payment->getOrder()->getCustomer()); |
84
|
|
|
|
85
|
|
|
$this->assertNotEmpty($refund->getId()); |
86
|
|
|
$this->assertEquals('FULL', $refund->getType()); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
View Code Duplication |
public function testRefundPaymentBankAccountPartial() |
|
|
|
|
90
|
|
|
{ |
91
|
|
|
$payment = $this->paymentBoleto(); |
92
|
|
|
|
93
|
|
|
$this->mockHttpSession($this->body_payment_refund_partial_bankaccount); |
94
|
|
|
$refund = $payment->refunds() |
95
|
|
|
->bankAccountPartial(20000, 'SAVING', '001', '1584', '9', '00210169', '6', $payment->getOrder()->getCustomer()); |
96
|
|
|
|
97
|
|
|
$this->assertNotEmpty($refund->getId()); |
98
|
|
|
$this->assertEquals('PARTIAL', $refund->getType()); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
View Code Duplication |
public function testRefundCCFullWithResourceId() |
|
|
|
|
102
|
|
|
{ |
103
|
|
|
$payment = $this->paymentCreditCard(); |
104
|
|
|
|
105
|
|
|
$this->mockHttpSession($this->body_payment_refund_full_cc); |
106
|
|
|
$refund = $this->moip->refunds()->creditCard($payment->getId()); |
107
|
|
|
|
108
|
|
|
$this->assertNotEmpty($refund->getId()); |
109
|
|
|
$this->assertEquals('FULL', $refund->getType()); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
View Code Duplication |
public function testRefundCCPartialWithResourceId() |
|
|
|
|
113
|
|
|
{ |
114
|
|
|
$payment = $this->paymentCreditCard(); |
115
|
|
|
|
116
|
|
|
$this->mockHttpSession($this->body_payment_refund_partial_cc); |
117
|
|
|
$refund = $this->moip->refunds()->creditCard($payment->getId(), 5000); |
118
|
|
|
|
119
|
|
|
$this->assertNotEmpty($refund->getId()); |
120
|
|
|
$this->assertEquals('PARTIAL', $refund->getType()); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
View Code Duplication |
public function testRefundBankAccountFullWithResourceId() |
|
|
|
|
124
|
|
|
{ |
125
|
|
|
$payment = $this->paymentBoleto(); |
126
|
|
|
|
127
|
|
|
$this->mockHttpSession($this->body_payment_refund_full_bankaccount); |
128
|
|
|
$refund = $this->moip->refunds()->bankAccount($payment->getId(), $this->bankAccount()); |
129
|
|
|
|
130
|
|
|
$this->assertNotEmpty($refund->getId()); |
131
|
|
|
$this->assertEquals('FULL', $refund->getType()); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
View Code Duplication |
public function testRefundBankAccountPartialWithResourceId() |
|
|
|
|
135
|
|
|
{ |
136
|
|
|
$payment = $this->paymentBoleto(); |
137
|
|
|
|
138
|
|
|
$this->mockHttpSession($this->body_payment_refund_partial_bankaccount); |
139
|
|
|
$refund = $this->moip->refunds()->bankAccount($payment->getId(), $this->bankAccount(), 5000); |
140
|
|
|
|
141
|
|
|
$this->assertNotEmpty($refund->getId()); |
142
|
|
|
$this->assertEquals('PARTIAL', $refund->getType()); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
View Code Duplication |
public function testRefundOrderCCFullWithResourceId() |
|
|
|
|
146
|
|
|
{ |
147
|
|
|
$order = $this->paymentCreditCard(false); |
148
|
|
|
|
149
|
|
|
$this->mockHttpSession($this->body_order_refund_full_cc); |
|
|
|
|
150
|
|
|
$refund = $this->moip->refunds()->creditCard($order->getId()); |
151
|
|
|
|
152
|
|
|
$this->assertNotEmpty($refund->getId()); |
153
|
|
|
$this->assertEquals('FULL', $refund->getType()); |
154
|
|
|
} |
155
|
|
|
|
156
|
|
View Code Duplication |
public function testRefundOrderCCPartialWithResourceId() |
|
|
|
|
157
|
|
|
{ |
158
|
|
|
$order = $this->paymentCreditCard(false); |
159
|
|
|
|
160
|
|
|
$this->mockHttpSession($this->body_order_refund_partial_cc); |
|
|
|
|
161
|
|
|
$refund = $this->moip->refunds()->creditCard($order->getId(), 5000); |
162
|
|
|
|
163
|
|
|
$this->assertNotEmpty($refund->getId()); |
164
|
|
|
$this->assertEquals('PARTIAL', $refund->getType()); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
View Code Duplication |
public function testRefundOrderBankAccountFullWithResourceId() |
|
|
|
|
168
|
|
|
{ |
169
|
|
|
$order = $this->paymentBoleto(false); |
170
|
|
|
|
171
|
|
|
$this->mockHttpSession($this->body_order_refund_full_bankaccount); |
|
|
|
|
172
|
|
|
$refund = $this->moip->refunds()->bankAccount($order->getId(), $this->bankAccount()); |
173
|
|
|
|
174
|
|
|
$this->assertNotEmpty($refund->getId()); |
175
|
|
|
$this->assertEquals('FULL', $refund->getType()); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
View Code Duplication |
public function testRefundOrderBankAccountPartialWithResourceId() |
|
|
|
|
179
|
|
|
{ |
180
|
|
|
$order = $this->paymentBoleto(false); |
181
|
|
|
|
182
|
|
|
$this->mockHttpSession($this->body_order_refund_partial_bankaccount); |
|
|
|
|
183
|
|
|
$refund = $this->moip->refunds()->bankAccount($order->getId(), $this->bankAccount(), 5000); |
184
|
|
|
|
185
|
|
|
$this->assertNotEmpty($refund->getId()); |
186
|
|
|
$this->assertEquals('PARTIAL', $refund->getType()); |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
private function bankAccount() |
190
|
|
|
{ |
191
|
|
|
return $this->moip->bankaccount() |
192
|
|
|
->setType('CHECKING') |
193
|
|
|
->setBankNumber('237') |
194
|
|
|
->setAgencyNumber('12346') |
195
|
|
|
->setAgencyCheckNumber('0') |
196
|
|
|
->setAccountNumber('12345679') |
197
|
|
|
->setAccountCheckNumber('7') |
198
|
|
|
->setHolder('Jose Silva', '22222222222', 'CPF'); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
View Code Duplication |
private function paymentBoleto($returnPayment = true) |
|
|
|
|
202
|
|
|
{ |
203
|
|
|
$this->mockHttpSession($this->body_order); |
204
|
|
|
$order = $this->createOrder()->create(); |
205
|
|
|
$this->mockHttpSession($this->body_billet_pay); |
206
|
|
|
$payment = $order->payments() |
|
|
|
|
207
|
|
|
->setBoleto(new \DateTime('today +1day'),'http://dev.moip.com.br/images/logo-header-moip.png') |
208
|
|
|
->execute(); |
209
|
|
|
$this->mockHttpSession(''); |
210
|
|
|
$payment->authorize(); |
211
|
|
|
|
212
|
|
|
return $returnPayment ? $payment : $order; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
View Code Duplication |
private function paymentCreditCard($returnPayment = true) |
|
|
|
|
216
|
|
|
{ |
217
|
|
|
$this->mockHttpSession($this->body_order); |
218
|
|
|
$order = $this->createOrder()->create(); |
219
|
|
|
$this->mockHttpSession($this->body_cc_pay_pci); |
220
|
|
|
$payment = ($order->payments()->setCreditCard(5, 2018, '5555666677778884', 123, $this->createCustomer())->execute()); |
|
|
|
|
221
|
|
|
|
222
|
|
|
return $returnPayment ? $payment : $order; |
223
|
|
|
} |
224
|
|
|
} |
225
|
|
|
|
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.