|
1
|
|
|
<?php |
|
2
|
|
|
namespace PHPSC\PagSeguro\Requests\Checkout; |
|
3
|
|
|
|
|
4
|
|
|
use PHPSC\PagSeguro\Customer\Customer; |
|
5
|
|
|
use PHPSC\PagSeguro\Items\Item; |
|
6
|
|
|
use PHPSC\PagSeguro\Requests\CheckoutBuilder as CheckoutBuilderInterface; |
|
7
|
|
|
use PHPSC\PagSeguro\Shipping\Shipping; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @author Luís Otávio Cobucci Oblonczyk <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
class CheckoutBuilder implements CheckoutBuilderInterface |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @var Checkout |
|
16
|
|
|
*/ |
|
17
|
|
|
private $checkout; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @param Checkout $checkout |
|
21
|
|
|
*/ |
|
22
|
11 |
|
public function __construct(Checkout $checkout = null) |
|
23
|
|
|
{ |
|
24
|
11 |
|
$this->checkout = $checkout ?: new Checkout(); |
|
25
|
11 |
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* {@inheritdoc} |
|
29
|
|
|
*/ |
|
30
|
1 |
|
public function addItem(Item $item) |
|
31
|
|
|
{ |
|
32
|
1 |
|
$this->checkout->getOrder()->getItems()->add($item); |
|
33
|
|
|
|
|
34
|
1 |
|
return $this; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* {@inheritdoc} |
|
39
|
|
|
*/ |
|
40
|
1 |
|
public function setShipping(Shipping $shipping) |
|
41
|
|
|
{ |
|
42
|
1 |
|
$this->checkout->getOrder()->setShipping($shipping); |
|
43
|
|
|
|
|
44
|
1 |
|
return $this; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* {@inheritdoc} |
|
49
|
|
|
*/ |
|
50
|
1 |
|
public function setReference($reference) |
|
51
|
|
|
{ |
|
52
|
1 |
|
$this->checkout->getOrder()->setReference($reference); |
|
53
|
|
|
|
|
54
|
1 |
|
return $this; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* {@inheritdoc} |
|
59
|
|
|
*/ |
|
60
|
1 |
|
public function setCustomer(Customer $customer) |
|
61
|
|
|
{ |
|
62
|
1 |
|
$this->checkout->setCustomer($customer); |
|
63
|
|
|
|
|
64
|
1 |
|
return $this; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* {@inheritdoc} |
|
69
|
|
|
*/ |
|
70
|
1 |
|
public function setRedirectTo($redirectTo) |
|
71
|
|
|
{ |
|
72
|
1 |
|
$this->checkout->setRedirectTo($redirectTo); |
|
73
|
|
|
|
|
74
|
1 |
|
return $this; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* {@inheritdoc} |
|
79
|
|
|
*/ |
|
80
|
1 |
|
public function setMaxAge($maxAge) |
|
81
|
|
|
{ |
|
82
|
1 |
|
$this->checkout->setMaxAge($maxAge); |
|
83
|
|
|
|
|
84
|
1 |
|
return $this; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* {@inheritdoc} |
|
89
|
|
|
*/ |
|
90
|
1 |
|
public function setMaxUses($maxUses) |
|
91
|
|
|
{ |
|
92
|
1 |
|
$this->checkout->setMaxUses($maxUses); |
|
93
|
|
|
|
|
94
|
1 |
|
return $this; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* {@inheritdoc} |
|
99
|
|
|
*/ |
|
100
|
|
|
public function setExtraAmount($extraAmount) |
|
101
|
|
|
{ |
|
102
|
|
|
$this->checkout->getOrder()->setExtraAmount($extraAmount); |
|
103
|
|
|
|
|
104
|
|
|
return $this; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* {@inheritdoc} |
|
109
|
|
|
*/ |
|
110
|
1 |
|
public function getCheckout() |
|
111
|
|
|
{ |
|
112
|
1 |
|
return $this->checkout; |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|