1
|
|
|
<?php |
2
|
|
|
namespace Moip\Tests\Resource; |
3
|
|
|
|
4
|
|
|
use Moip\Tests\TestCase; |
5
|
|
|
|
6
|
|
|
class PaymentTest extends TestCase |
7
|
|
|
{ |
8
|
|
|
//todo: credit card hash |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* MoipTest creating a credit card payment, passing all credit card data. |
12
|
|
|
*/ |
13
|
|
|
public function testCreditCardPCI() |
14
|
|
|
{ |
15
|
|
|
$this->mockHttpSession($this->body_order); |
16
|
|
|
$order = $this->createOrder()->create(); |
17
|
|
|
$this->mockHttpSession($this->body_cc_pay_pci); |
18
|
|
|
$cc = '5555666677778884'; |
19
|
|
|
$payment = $order->payments()->setCreditCard(5, 2018, $cc, 123, $this->createCustomer())->execute(); |
|
|
|
|
20
|
|
|
$this->assertNotEmpty($payment->getFundingInstrument()->creditCard); |
21
|
|
|
$first6 = $payment->getFundingInstrument()->creditCard->first6; |
22
|
|
|
$last4 = $payment->getFundingInstrument()->creditCard->last4; |
23
|
|
|
$this->assertEquals($first6, substr($cc, 0, 6)); |
24
|
|
|
$this->assertEquals($last4, substr($cc, -4)); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* MoipTest creating a billet payment. |
29
|
|
|
*/ |
30
|
|
|
public function testBillet() |
31
|
|
|
{ |
32
|
|
|
$this->mockHttpSession($this->body_order); |
33
|
|
|
$order = $this->createOrder()->create(); |
34
|
|
|
$this->mockHttpSession($this->body_billet_pay); |
35
|
|
|
$payment = $order->payments()->setBoleto(new \DateTime('today +1day'), 'http://dev.moip.com.br/images/logo-header-moip.png')->execute(); |
|
|
|
|
36
|
|
|
$this->assertNotEmpty($payment->getFundingInstrument()->boleto); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
View Code Duplication |
public function testCreditCardPCIStore() |
|
|
|
|
40
|
|
|
{ |
41
|
|
|
$this->mockHttpSession($this->body_order); |
42
|
|
|
$order = $this->createOrder()->create(); |
43
|
|
|
$cc = '5555666677778884'; |
44
|
|
|
$this->mockHttpSession($this->body_cc_pay_pci_store); |
45
|
|
|
$payment = $order->payments()->setCreditCard(5, 2018, $cc, 123, $this->createCustomer(), false)->execute(); |
|
|
|
|
46
|
|
|
$this->assertFalse($payment->getFundingInstrument()->creditCard->store); |
47
|
|
|
$this->assertNotEmpty($payment->getId()); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
View Code Duplication |
public function testShouldCreateEscrowPaymentWithCreditCard() |
|
|
|
|
51
|
|
|
{ |
52
|
|
|
$this->mockHttpSession($this->body_order); |
53
|
|
|
$order = $this->createOrder()->create(); |
54
|
|
|
$cc = '5555666677778884'; |
55
|
|
|
$this->mockHttpSession($this->body_cc_pay_pci_escrow); |
56
|
|
|
$payment = $order->payments() |
|
|
|
|
57
|
|
|
->setCreditCard(5, 2018, $cc, 123, $this->createCustomer(), false) |
58
|
|
|
->setEscrow('teste de descricao') |
59
|
|
|
->execute(); |
60
|
|
|
$this->assertEquals('teste de descricao', $payment->getEscrow()->description); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: