Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit ed99701

Browse files
committed
Set escrow in order
1 parent 1b54106 commit ed99701

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

src/Resource/Escrow.php

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
/*
4+
* To change this license header, choose License Headers in Project Properties.
5+
* To change this template file, choose Tools | Templates
6+
* and open the template in the editor.
7+
*/
8+
9+
namespace Moip\Resource;
10+
11+
/**
12+
* Description of Escrow
13+
*
14+
* @author caiogaspar
15+
*/
16+
class Escrow extends MoipResource {
17+
18+
/**
19+
* @const string
20+
*/
21+
const PATH = 'escrows';
22+
23+
/**
24+
* Initializes new instances.
25+
*/
26+
protected function initialize()
27+
{
28+
$this->data = new stdClass();
29+
$this->data->installmentCount = 1;
30+
$this->data->fundingInstrument = new stdClass();
31+
}
32+
33+
/**
34+
* Mount payment structure.
35+
*
36+
* @param \stdClass $response
37+
*
38+
* @return Escrow
39+
*/
40+
protected function populate(stdClass $response)
41+
{
42+
$escrow = clone $this;
43+
44+
$escrow->data->id = $this->getIfSet('id', $response);
45+
$escrow->data->status = $this->getIfSet('status', $response);
46+
$escrow->data->delayCapture = $this->getIfSet('delayCapture', $response);
47+
$escrow->data->amount = new stdClass();
48+
$escrow->data->amount->total = $this->getIfSet('total', $response->amount);
49+
$escrow->data->amount->currency = $this->getIfSet('currency', $response->amount);
50+
$escrow->data->installmentCount = $this->getIfSet('installmentCount', $response);
51+
$escrow->data->fundingInstrument = $this->getIfSet('fundingInstrument', $response);
52+
$escrow->data->fees = $this->getIfSet('fees', $response);
53+
$escrow->data->refunds = $this->getIfSet('refunds', $response);
54+
$escrow->data->_links = $this->getIfSet('_links', $response);
55+
$escrow->data->createdAt = $this->getIfSetDateTime('createdAt', $response);
56+
$escrow->data->updatedAt = $this->getIfSetDateTime('updatedAt', $response);
57+
58+
return $escrow;
59+
}
60+
}

src/Resource/Payment.php

+12
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,18 @@ public function setDelayCapture()
502502

503503
return $this;
504504
}
505+
506+
/**
507+
* Set escrow to a payment
508+
*
509+
* @return $this
510+
*/
511+
public function setEscrow($description = '') {
512+
$this->data->escrow = new stdClass();
513+
$this->data->escrow->description = $description;
514+
515+
return $this;
516+
}
505517

506518
/**
507519
* Capture a pre-authorized amount on a credit card payment.

tests/Resource/PaymentTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,9 @@ public function testCreditCardPCIStore()
4747
$this->assertFalse($payment->getFundingInstrument()->creditCard->store);
4848
$this->assertNotEmpty($payment->getId());
4949
}
50+
51+
public function shouldCreateEscrowPayment()
52+
{
53+
54+
}
5055
}

0 commit comments

Comments
 (0)