1 | <?php |
||
6 | class PagseguroController extends AppController implements GatewayInterface |
||
7 | { |
||
8 | |||
9 | private $paymentRequest; |
||
10 | private $email; |
||
11 | private $token; |
||
12 | private $produtos = array(); |
||
13 | private $client = array(); |
||
|
|||
14 | private $reference; |
||
15 | private $valor_frete; |
||
16 | |||
17 | public function __construct() |
||
18 | { |
||
19 | $this->paymentRequest = new PagSeguroPaymentRequest(); |
||
20 | // Set the currency |
||
21 | $this->paymentRequest->setCurrency("BRL"); |
||
22 | } |
||
23 | |||
24 | // $products, $andress, $client, $total, $valor_frete, $id_venda |
||
25 | public function finalizarPedido() |
||
26 | { |
||
27 | $this->paymentRequest->setReference($this->reference); |
||
28 | $this->paymentRequest->setShippingCost($this->valor_frete); |
||
29 | |||
30 | |||
31 | // Set the url used by PagSeguro to redirect user after checkout process ends |
||
32 | $this->paymentRequest->setRedirectUrl("http://www.lojamodelo.com.br"); |
||
33 | |||
34 | try { |
||
35 | |||
36 | /* |
||
37 | * #### Credentials ##### |
||
38 | * Replace the parameters below with your credentials |
||
39 | * You can also get your credentials from a config file. See an example: |
||
40 | * $credentials = PagSeguroConfig::getAccountCredentials(); |
||
41 | // */ |
||
42 | |||
43 | // seller authentication |
||
44 | $credentials = new PagSeguroAccountCredentials($this->email, $this->token); |
||
45 | |||
46 | // application authentication |
||
47 | //$credentials = PagSeguroConfig::getApplicationCredentials(); |
||
48 | |||
49 | //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
||
50 | |||
51 | // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer. |
||
52 | $url = $this->paymentRequest->register($credentials); |
||
53 | |||
54 | return $url; |
||
55 | |||
56 | } catch (PagSeguroServiceException $e) { |
||
57 | |||
58 | die($e->getMessage()); |
||
59 | |||
60 | } |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @return void |
||
65 | * @param String $token |
||
66 | **/ |
||
67 | public function setToken($token) |
||
68 | { |
||
69 | $this->token = $token; |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @return String $token |
||
74 | **/ |
||
75 | public function getToken() |
||
76 | { |
||
77 | return $this->token; |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * @return void |
||
82 | * @param String $email |
||
83 | **/ |
||
84 | public function setEmail($email) |
||
85 | { |
||
86 | $this->email = $email; |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * @return String $email |
||
91 | **/ |
||
92 | public function getEmail() |
||
93 | { |
||
94 | return $this->email; |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * @return void |
||
99 | * @param Array $produtos |
||
100 | **/ |
||
101 | public function setProdutos($produtos) |
||
105 | |||
106 | /** |
||
107 | * @return Array $produtos |
||
108 | **/ |
||
109 | public function getProdutos() |
||
110 | { |
||
111 | return $this->produtos; |
||
113 | |||
114 | /** |
||
115 | * @param Array Produtos |
||
116 | * @return Array Produtos |
||
117 | **/ |
||
118 | public function adicionarProdutosGateway() |
||
136 | |||
137 | public function setEndereco($endereco) |
||
141 | |||
142 | public function getEndereco() |
||
146 | |||
147 | public function setEnderecoClienteGateway() |
||
170 | |||
171 | public function setReference($reference) |
||
175 | |||
176 | public function getReference() |
||
180 | |||
181 | public function setValorFrete($valor_frete) |
||
185 | |||
186 | public function getValorFrete() |
||
190 | |||
191 | public function setClienteGateway() |
||
210 | |||
211 | public function setCliente($cliente) |
||
215 | |||
216 | public function getCliente() |
||
220 | |||
221 | } |
This check marks private properties in classes that are never used. Those properties can be removed.