@@ -376,6 +376,8 @@ |
||
| 376 | 376 | |
| 377 | 377 | /** |
| 378 | 378 | * Valida o usuario que está tentando usar a api |
| 379 | + * @param CakeRequest $req |
|
| 380 | + * @param string $api |
|
| 379 | 381 | */ |
| 380 | 382 | public function validate_use_api($req, $api) |
| 381 | 383 | { |
@@ -32,8 +32,9 @@ |
||
| 32 | 32 | 'id_usuario' => $this->getIdUser(), |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | - if (isset($id_cliente)) |
|
| 36 | - $conditions['id'] = $id_cliente; |
|
| 35 | + if (isset($id_cliente)) { |
|
| 36 | + $conditions['id'] = $id_cliente; |
|
| 37 | + } |
|
| 37 | 38 | |
| 38 | 39 | |
| 39 | 40 | $cliente = $this->Cliente->find('all', |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | $type = $this->request; |
| 24 | 24 | |
| 25 | - if (!$this->validate_use_api($type, $api)) { |
|
| 25 | + if ( ! $this->validate_use_api($type, $api)) { |
|
| 26 | 26 | echo '{message: Você não tem permissão para usar nosso modulo}'; |
| 27 | 27 | return; |
| 28 | 28 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | return; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if (!empty($dados['nome1']) && !empty($dados['nome2']) && !empty($dados['email']) && !empty($dados['senha'])) { |
|
| 55 | + if ( ! empty($dados['nome1']) && ! empty($dados['nome2']) && ! empty($dados['email']) && ! empty($dados['senha'])) { |
|
| 56 | 56 | $this->postClient($dados); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | $type = $this->request; |
| 96 | 96 | |
| 97 | - if (!$this->validate_use_api($type, $api)) { |
|
| 97 | + if ( ! $this->validate_use_api($type, $api)) { |
|
| 98 | 98 | echo '{message: Você não tem permissão para usar nosso modulo}'; |
| 99 | 99 | return; |
| 100 | 100 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | return; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - if (!empty($dados['cliente_id'])) { |
|
| 129 | + if ( ! empty($dados['cliente_id'])) { |
|
| 130 | 130 | $this->postParent($dados); |
| 131 | 131 | } |
| 132 | 132 | |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | $type = $this->request; |
| 199 | 199 | |
| 200 | - if (!$this->validate_use_api($type, $api)) { |
|
| 200 | + if ( ! $this->validate_use_api($type, $api)) { |
|
| 201 | 201 | echo '{message: Você não tem permissão para usar nosso modulo}'; |
| 202 | 202 | return; |
| 203 | 203 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | |
| 224 | 224 | $this->Newsletter->save($dados); |
| 225 | 225 | |
| 226 | - $this->response->body('{"message": "success", "result":' . json_encode($dados) . '}'); |
|
| 226 | + $this->response->body('{"message": "success", "result":'.json_encode($dados).'}'); |
|
| 227 | 227 | return; |
| 228 | 228 | } |
| 229 | 229 | |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | $type = $this->request; |
| 240 | 240 | |
| 241 | - if (!$this->validate_use_api($type, $api)) { |
|
| 241 | + if ( ! $this->validate_use_api($type, $api)) { |
|
| 242 | 242 | echo '{message: Você não tem permissão para usar nosso modulo}'; |
| 243 | 243 | return; |
| 244 | 244 | } |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | ) |
| 255 | 255 | ); |
| 256 | 256 | |
| 257 | - if (!empty($banner)) { |
|
| 257 | + if ( ! empty($banner)) { |
|
| 258 | 258 | $this->response->body('{"message": "success", "result":'.json_encode($banner).'}'); |
| 259 | 259 | return; |
| 260 | 260 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | $type = $this->request; |
| 276 | 276 | |
| 277 | - if (!$this->validate_use_api($type, $api)) { |
|
| 277 | + if ( ! $this->validate_use_api($type, $api)) { |
|
| 278 | 278 | echo '{message: Você não tem permissão para usar nosso modulo}'; |
| 279 | 279 | return; |
| 280 | 280 | } |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | ) |
| 293 | 293 | ); |
| 294 | 294 | |
| 295 | - if (!empty($consulta)) { |
|
| 295 | + if ( ! empty($consulta)) { |
|
| 296 | 296 | $this->response->body('{"message": "success", "result":'.json_encode($consulta).'}'); |
| 297 | 297 | return; |
| 298 | 298 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | ) |
| 331 | 331 | ); |
| 332 | 332 | |
| 333 | - if (!empty($cliente)) { |
|
| 333 | + if ( ! empty($cliente)) { |
|
| 334 | 334 | $this->response->body('{"message": "success", "result":'.json_encode($cliente).'}'); |
| 335 | 335 | return; |
| 336 | 336 | } |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | $this->Cliente->id_usuario = $this->getIdUser(); |
| 367 | 367 | |
| 368 | 368 | if ($this->Cliente->save($dados)) { |
| 369 | - $this->response->body('{"message": "success", "result": '. json_encode($dados) .'}'); |
|
| 369 | + $this->response->body('{"message": "success", "result": '.json_encode($dados).'}'); |
|
| 370 | 370 | return; |
| 371 | 371 | } |
| 372 | 372 | |
@@ -400,9 +400,9 @@ discard block |
||
| 400 | 400 | ->subject('Newsletter OdontoClinic Pimentas'); |
| 401 | 401 | |
| 402 | 402 | $mensagem = 'Obrigado pelo cadastro, em breve você vai receber novidades e promoções!'; |
| 403 | - if (file_exists(APP . 'webroot/odontoclinicpimentas/ebooks/' . $dados['origem'] . '.pdf')) |
|
| 403 | + if (file_exists(APP.'webroot/odontoclinicpimentas/ebooks/'.$dados['origem'].'.pdf')) |
|
| 404 | 404 | { |
| 405 | - $email->attachments(APP . '/webroot/odontoclinicpimentas/ebooks/' . $dados['origem'] . '.pdf') ; |
|
| 405 | + $email->attachments(APP.'/webroot/odontoclinicpimentas/ebooks/'.$dados['origem'].'.pdf'); |
|
| 406 | 406 | |
| 407 | 407 | $mensagem = ' |
| 408 | 408 | Obrigado pelo cadastro, para mais informações veja o arquivo em anexo! |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | |
| 417 | 417 | $email->send($mensagem); |
| 418 | 418 | |
| 419 | - return $this->response->body('{"message": "success", "result":' . json_encode($dados) . '}'); |
|
| 419 | + return $this->response->body('{"message": "success", "result":'.json_encode($dados).'}'); |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | public function postParent($dados) |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | ) |
| 454 | 454 | ); |
| 455 | 455 | |
| 456 | - if (!empty($parente)) { |
|
| 456 | + if ( ! empty($parente)) { |
|
| 457 | 457 | $this->response->body('{"message": "success", "result":'.json_encode($parente).'}'); |
| 458 | 458 | return; |
| 459 | 459 | } |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | $this->Parente->id_usuario = $this->getIdUser(); |
| 473 | 473 | |
| 474 | 474 | if ($this->Parente->save($dados)) { |
| 475 | - $this->response->body('{"message": "success", "result": '. json_encode($dados) .'}'); |
|
| 475 | + $this->response->body('{"message": "success", "result": '.json_encode($dados).'}'); |
|
| 476 | 476 | return; |
| 477 | 477 | } |
| 478 | 478 | |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | ); |
| 509 | 509 | |
| 510 | 510 | if ($this->Consulta->save($dados)) { |
| 511 | - $this->response->body('{"message": "success", "result":' . json_encode($dados) . '}'); |
|
| 511 | + $this->response->body('{"message": "success", "result":'.json_encode($dados).'}'); |
|
| 512 | 512 | return; |
| 513 | 513 | } |
| 514 | 514 | |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | ) |
| 532 | 532 | ); |
| 533 | 533 | |
| 534 | - if (isset($resposta[0]) && !empty($resposta[0])) |
|
| 534 | + if (isset($resposta[0]) && ! empty($resposta[0])) |
|
| 535 | 535 | { |
| 536 | 536 | $resposta = $resposta[0]; |
| 537 | 537 | } |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | |
| 544 | 544 | $this->setIdUser($resposta['Usuario']['id']); |
| 545 | 545 | |
| 546 | - if (!$this->verifyUseApi($api)) |
|
| 546 | + if ( ! $this->verifyUseApi($api)) |
|
| 547 | 547 | { |
| 548 | 548 | return false; |
| 549 | 549 | } |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | |
| 581 | 581 | public function getIdUser() |
| 582 | 582 | { |
| 583 | - if (!is_numeric($this->instancia)) |
|
| 583 | + if ( ! is_numeric($this->instancia)) |
|
| 584 | 584 | { |
| 585 | 585 | return false; |
| 586 | 586 | } |
@@ -16,19 +16,19 @@ discard block |
||
| 16 | 16 | { |
| 17 | 17 | $api = 'cliente'; |
| 18 | 18 | |
| 19 | - $this->loadModel('Cliente'); |
|
| 19 | + $this->loadModel('Cliente'); |
|
| 20 | 20 | $this->autoRender = false; |
| 21 | 21 | $this->response->type('json'); |
| 22 | 22 | |
| 23 | 23 | $type = $this->request; |
| 24 | 24 | |
| 25 | - if (!$this->validate_use_api($type, $api)) { |
|
| 26 | - echo '{message: Você não tem permissão para usar nosso modulo}'; |
|
| 27 | - return; |
|
| 28 | - } |
|
| 25 | + if (!$this->validate_use_api($type, $api)) { |
|
| 26 | + echo '{message: Você não tem permissão para usar nosso modulo}'; |
|
| 27 | + return; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - if ($type->is('get')) { |
|
| 31 | - $conditions = array( |
|
| 30 | + if ($type->is('get')) { |
|
| 31 | + $conditions = array( |
|
| 32 | 32 | 'ativo' => 1, |
| 33 | 33 | 'id_usuario' => $this->getIdUser(), |
| 34 | 34 | ); |
@@ -37,70 +37,70 @@ discard block |
||
| 37 | 37 | $conditions['id'] = $id_cliente; |
| 38 | 38 | |
| 39 | 39 | |
| 40 | - $cliente = $this->Cliente->find('all', |
|
| 40 | + $cliente = $this->Cliente->find('all', |
|
| 41 | 41 | array('conditions' => |
| 42 | 42 | $conditions |
| 43 | 43 | ) |
| 44 | 44 | ); |
| 45 | 45 | |
| 46 | 46 | $this->response->body(json_encode($cliente)); |
| 47 | - } else if ($type->is('post')) { |
|
| 48 | - $dados = $this->request->data; |
|
| 47 | + } else if ($type->is('post')) { |
|
| 48 | + $dados = $this->request->data; |
|
| 49 | 49 | |
| 50 | - if (empty($dados)) { |
|
| 50 | + if (empty($dados)) { |
|
| 51 | 51 | $this->response->body(json_encode(array('message' => 'Ocorreu algum erro com os parametros passados'))); |
| 52 | 52 | return; |
| 53 | - } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - if (!empty($dados['nome1']) && !empty($dados['nome2']) && !empty($dados['email']) && !empty($dados['senha'])) { |
|
| 56 | - $this->postClient($dados); |
|
| 57 | - } |
|
| 55 | + if (!empty($dados['nome1']) && !empty($dados['nome2']) && !empty($dados['email']) && !empty($dados['senha'])) { |
|
| 56 | + $this->postClient($dados); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - $this->loginClient($dados); |
|
| 60 | - } else if ($type->is('put')) { |
|
| 59 | + $this->loginClient($dados); |
|
| 60 | + } else if ($type->is('put')) { |
|
| 61 | 61 | |
| 62 | - $dados = $this->request->data; |
|
| 62 | + $dados = $this->request->data; |
|
| 63 | 63 | |
| 64 | 64 | if (empty($dados)) { |
| 65 | 65 | $this->response->body(json_encode(array('message' => 'Ocorreu algum erro com os parametros passados'))); |
| 66 | 66 | return; |
| 67 | - } |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - if ($id_cliente == null) { |
|
| 70 | - $this->response->body(json_encode(array('message' => 'Você não passou o id do usuario'))); |
|
| 71 | - return; |
|
| 72 | - } |
|
| 69 | + if ($id_cliente == null) { |
|
| 70 | + $this->response->body(json_encode(array('message' => 'Você não passou o id do usuario'))); |
|
| 71 | + return; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - $this->putClient($dados, $id_cliente); |
|
| 75 | - } else if ($type->is('delete')) { |
|
| 74 | + $this->putClient($dados, $id_cliente); |
|
| 75 | + } else if ($type->is('delete')) { |
|
| 76 | 76 | |
| 77 | - if ($id_cliente == null) { |
|
| 78 | - $this->response->body(json_encode(array('message' => 'Você não passou o id do usuario'))); |
|
| 79 | - return; |
|
| 80 | - } |
|
| 77 | + if ($id_cliente == null) { |
|
| 78 | + $this->response->body(json_encode(array('message' => 'Você não passou o id do usuario'))); |
|
| 79 | + return; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - $this->inactiveClient($id_cliente); |
|
| 83 | - } |
|
| 82 | + $this->inactiveClient($id_cliente); |
|
| 83 | + } |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | public function parent($id_cliente = null, $id_parente = null) |
| 87 | 87 | { |
| 88 | 88 | $api = 'parente'; |
| 89 | 89 | |
| 90 | - $this->loadModel('Parente'); |
|
| 90 | + $this->loadModel('Parente'); |
|
| 91 | 91 | |
| 92 | 92 | $this->autoRender = false; |
| 93 | 93 | $this->response->type('json'); |
| 94 | 94 | |
| 95 | 95 | $type = $this->request; |
| 96 | 96 | |
| 97 | - if (!$this->validate_use_api($type, $api)) { |
|
| 98 | - echo '{message: Você não tem permissão para usar nosso modulo}'; |
|
| 99 | - return; |
|
| 100 | - } |
|
| 97 | + if (!$this->validate_use_api($type, $api)) { |
|
| 98 | + echo '{message: Você não tem permissão para usar nosso modulo}'; |
|
| 99 | + return; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - if ($type->is('get')) { |
|
| 103 | - $conditions = array( |
|
| 102 | + if ($type->is('get')) { |
|
| 103 | + $conditions = array( |
|
| 104 | 104 | 'ativo' => 1, |
| 105 | 105 | 'usuario_id' => $this->getIdUser(), |
| 106 | 106 | ); |
@@ -111,50 +111,50 @@ discard block |
||
| 111 | 111 | $conditions['id'] = $id_parente; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - $parentes = $this->Parente->find('all', |
|
| 114 | + $parentes = $this->Parente->find('all', |
|
| 115 | 115 | array('conditions' => |
| 116 | 116 | $conditions |
| 117 | 117 | ) |
| 118 | 118 | ); |
| 119 | 119 | |
| 120 | 120 | $this->response->body(json_encode($parentes)); |
| 121 | - } else if ($type->is('post')) { |
|
| 122 | - $dados = $this->request->data; |
|
| 121 | + } else if ($type->is('post')) { |
|
| 122 | + $dados = $this->request->data; |
|
| 123 | 123 | |
| 124 | - if (empty($dados)) { |
|
| 124 | + if (empty($dados)) { |
|
| 125 | 125 | $this->response->body(json_encode(array('message' => 'Ocorreu algum erro com os parametros passados'))); |
| 126 | 126 | return; |
| 127 | - } |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - if (!empty($dados['cliente_id'])) { |
|
| 130 | - $this->postParent($dados); |
|
| 131 | - } |
|
| 129 | + if (!empty($dados['cliente_id'])) { |
|
| 130 | + $this->postParent($dados); |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - $this->loginParent($dados); |
|
| 134 | - } else if ($type->is('put')) { |
|
| 133 | + $this->loginParent($dados); |
|
| 134 | + } else if ($type->is('put')) { |
|
| 135 | 135 | |
| 136 | - $dados = $this->request->data; |
|
| 136 | + $dados = $this->request->data; |
|
| 137 | 137 | |
| 138 | 138 | if (empty($dados)) { |
| 139 | 139 | $this->response->body(json_encode(array('message' => 'Ocorreu algum erro com os parametros passados'))); |
| 140 | 140 | return; |
| 141 | - } |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - if ($id_parente == null) { |
|
| 144 | - $this->response->body(json_encode(array('message' => 'Você não passou o id do usuario'))); |
|
| 145 | - return; |
|
| 146 | - } |
|
| 143 | + if ($id_parente == null) { |
|
| 144 | + $this->response->body(json_encode(array('message' => 'Você não passou o id do usuario'))); |
|
| 145 | + return; |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - $this->putParent($dados, $id_parente); |
|
| 149 | - } else if ($type->is('delete')) { |
|
| 148 | + $this->putParent($dados, $id_parente); |
|
| 149 | + } else if ($type->is('delete')) { |
|
| 150 | 150 | |
| 151 | - if ($id_parente == null) { |
|
| 152 | - $this->response->body(json_encode(array('message' => 'Você não passou o id do usuario'))); |
|
| 153 | - return; |
|
| 154 | - } |
|
| 151 | + if ($id_parente == null) { |
|
| 152 | + $this->response->body(json_encode(array('message' => 'Você não passou o id do usuario'))); |
|
| 153 | + return; |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - $this->inactiveClient($id_parente); |
|
| 157 | - } |
|
| 156 | + $this->inactiveClient($id_parente); |
|
| 157 | + } |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | public function occurrences($id_cliente = null) |
@@ -167,23 +167,23 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | $type = $this->request; |
| 169 | 169 | |
| 170 | - if ($type->is('get')) |
|
| 171 | - { |
|
| 172 | - $conditions = array( |
|
| 170 | + if ($type->is('get')) |
|
| 171 | + { |
|
| 172 | + $conditions = array( |
|
| 173 | 173 | 'ativo' => 1, |
| 174 | 174 | 'cliente_id' => $id_cliente, |
| 175 | 175 | ); |
| 176 | 176 | |
| 177 | 177 | $conditions['cliente_id'] = $id_cliente; |
| 178 | 178 | |
| 179 | - $ocorrencias = $this->Ocorrencias->find('all', |
|
| 179 | + $ocorrencias = $this->Ocorrencias->find('all', |
|
| 180 | 180 | array('conditions' => |
| 181 | 181 | $conditions |
| 182 | 182 | ) |
| 183 | 183 | ); |
| 184 | 184 | |
| 185 | 185 | $this->response->body(json_encode($ocorrencias)); |
| 186 | - } |
|
| 186 | + } |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | public function newsletter($sendMail = null) |
@@ -197,17 +197,17 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | $type = $this->request; |
| 199 | 199 | |
| 200 | - if (!$this->validate_use_api($type, $api)) { |
|
| 201 | - echo '{message: Você não tem permissão para usar nosso modulo}'; |
|
| 202 | - return; |
|
| 203 | - } |
|
| 200 | + if (!$this->validate_use_api($type, $api)) { |
|
| 201 | + echo '{message: Você não tem permissão para usar nosso modulo}'; |
|
| 202 | + return; |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - $request = $this->request->data; |
|
| 205 | + $request = $this->request->data; |
|
| 206 | 206 | |
| 207 | - if (empty($request)) { |
|
| 207 | + if (empty($request)) { |
|
| 208 | 208 | $this->response->body(json_encode(array('message' => 'Ocorreu algum erro com os parametros passados'))); |
| 209 | 209 | return; |
| 210 | - } |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | 212 | $dados = array( |
| 213 | 213 | 'email' => $request['email'], |
@@ -239,25 +239,25 @@ discard block |
||
| 239 | 239 | $type = $this->request; |
| 240 | 240 | |
| 241 | 241 | if (!$this->validate_use_api($type, $api)) { |
| 242 | - echo '{message: Você não tem permissão para usar nosso modulo}'; |
|
| 243 | - return; |
|
| 244 | - } |
|
| 242 | + echo '{message: Você não tem permissão para usar nosso modulo}'; |
|
| 243 | + return; |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - $conditions = array( |
|
| 246 | + $conditions = array( |
|
| 247 | 247 | 'ativo' => 1, |
| 248 | 248 | 'usuario_id' => $this->getIdUser() |
| 249 | 249 | ); |
| 250 | 250 | |
| 251 | - $banner = $this->Banner->find('all', |
|
| 251 | + $banner = $this->Banner->find('all', |
|
| 252 | 252 | array('conditions' => |
| 253 | 253 | $conditions |
| 254 | 254 | ) |
| 255 | 255 | ); |
| 256 | 256 | |
| 257 | - if (!empty($banner)) { |
|
| 257 | + if (!empty($banner)) { |
|
| 258 | 258 | $this->response->body('{"message": "success", "result":'.json_encode($banner).'}'); |
| 259 | 259 | return; |
| 260 | - } |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | 262 | $this->response->body('{"message": "error"}'); |
| 263 | 263 | return; |
@@ -275,39 +275,39 @@ discard block |
||
| 275 | 275 | $type = $this->request; |
| 276 | 276 | |
| 277 | 277 | if (!$this->validate_use_api($type, $api)) { |
| 278 | - echo '{message: Você não tem permissão para usar nosso modulo}'; |
|
| 279 | - return; |
|
| 280 | - } |
|
| 278 | + echo '{message: Você não tem permissão para usar nosso modulo}'; |
|
| 279 | + return; |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | 282 | |
| 283 | - if ($type->is('get')) { |
|
| 284 | - $conditions = array( |
|
| 283 | + if ($type->is('get')) { |
|
| 284 | + $conditions = array( |
|
| 285 | 285 | 'ativo' => 1, |
| 286 | 286 | 'id_usuario' => $this->getIdUser() |
| 287 | 287 | ); |
| 288 | 288 | |
| 289 | - $consulta = $this->Consulta->find('all', |
|
| 289 | + $consulta = $this->Consulta->find('all', |
|
| 290 | 290 | array('conditions' => |
| 291 | 291 | $conditions |
| 292 | 292 | ) |
| 293 | 293 | ); |
| 294 | 294 | |
| 295 | - if (!empty($consulta)) { |
|
| 295 | + if (!empty($consulta)) { |
|
| 296 | 296 | $this->response->body('{"message": "success", "result":'.json_encode($consulta).'}'); |
| 297 | 297 | return; |
| 298 | - } |
|
| 298 | + } |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | if ($type->is('post')) |
| 302 | 302 | { |
| 303 | - $dados = $this->request->data; |
|
| 303 | + $dados = $this->request->data; |
|
| 304 | 304 | |
| 305 | - if (empty($dados)) { |
|
| 305 | + if (empty($dados)) { |
|
| 306 | 306 | $this->response->body(json_encode(array('message' => 'Ocorreu algum erro com os parametros passados'))); |
| 307 | 307 | return; |
| 308 | - } |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | - return $this->postConsulta($dados); |
|
| 310 | + return $this->postConsulta($dados); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | $this->response->body('{"message": "error"}'); |
@@ -317,23 +317,23 @@ discard block |
||
| 317 | 317 | public function loginClient($dados) |
| 318 | 318 | { |
| 319 | 319 | |
| 320 | - $conditions = array( |
|
| 320 | + $conditions = array( |
|
| 321 | 321 | 'ativo' => 1, |
| 322 | 322 | 'id_usuario' => $this->getIdUser(), |
| 323 | 323 | 'email' => $dados['email'], |
| 324 | 324 | 'senha' => sha1($dados['senha']) |
| 325 | 325 | ); |
| 326 | 326 | |
| 327 | - $cliente = $this->Cliente->find('all', |
|
| 327 | + $cliente = $this->Cliente->find('all', |
|
| 328 | 328 | array('conditions' => |
| 329 | 329 | $conditions |
| 330 | 330 | ) |
| 331 | 331 | ); |
| 332 | 332 | |
| 333 | - if (!empty($cliente)) { |
|
| 333 | + if (!empty($cliente)) { |
|
| 334 | 334 | $this->response->body('{"message": "success", "result":'.json_encode($cliente).'}'); |
| 335 | 335 | return; |
| 336 | - } |
|
| 336 | + } |
|
| 337 | 337 | |
| 338 | 338 | $this->response->body('{"message": "error"}'); |
| 339 | 339 | return; |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | { |
| 344 | 344 | $this->loadModel('Cliente'); |
| 345 | 345 | |
| 346 | - $dados['senha'] = sha1($dados['senha']); |
|
| 346 | + $dados['senha'] = sha1($dados['senha']); |
|
| 347 | 347 | $dados['ativo'] = 1; |
| 348 | 348 | $dados['id_usuario'] = $this->instancia; |
| 349 | 349 | |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | |
| 422 | 422 | public function postParent($dados) |
| 423 | 423 | { |
| 424 | - $dados = array( |
|
| 424 | + $dados = array( |
|
| 425 | 425 | 'senha' => sha1($dados['senha']), |
| 426 | 426 | 'usuario_id' => $this->getIdUser(), |
| 427 | 427 | 'cliente_id' => $dados['cliente_id'], |
@@ -440,23 +440,23 @@ discard block |
||
| 440 | 440 | |
| 441 | 441 | public function loginParent($dados) |
| 442 | 442 | { |
| 443 | - $conditions = array( |
|
| 443 | + $conditions = array( |
|
| 444 | 444 | 'ativo' => 1, |
| 445 | 445 | 'usuario_id' => $this->getIdUser(), |
| 446 | 446 | 'login' => $dados['login'], |
| 447 | 447 | 'senha' => sha1($dados['senha']) |
| 448 | 448 | ); |
| 449 | 449 | |
| 450 | - $parente = $this->Parente->find('all', |
|
| 450 | + $parente = $this->Parente->find('all', |
|
| 451 | 451 | array('conditions' => |
| 452 | 452 | $conditions |
| 453 | 453 | ) |
| 454 | 454 | ); |
| 455 | 455 | |
| 456 | - if (!empty($parente)) { |
|
| 456 | + if (!empty($parente)) { |
|
| 457 | 457 | $this->response->body('{"message": "success", "result":'.json_encode($parente).'}'); |
| 458 | 458 | return; |
| 459 | - } |
|
| 459 | + } |
|
| 460 | 460 | |
| 461 | 461 | $this->response->body('{"message": "error"}'); |
| 462 | 462 | return; |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | |
| 498 | 498 | public function postConsulta($dados) |
| 499 | 499 | { |
| 500 | - $dados = array( |
|
| 500 | + $dados = array( |
|
| 501 | 501 | 'nome' => $dados['nome'], |
| 502 | 502 | 'email' => $dados['email'], |
| 503 | 503 | 'data' => $dados['date'], |
@@ -517,8 +517,8 @@ discard block |
||
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
| 520 | - * Valida o usuario que está tentando usar a api |
|
| 521 | - */ |
|
| 520 | + * Valida o usuario que está tentando usar a api |
|
| 521 | + */ |
|
| 522 | 522 | public function validate_use_api($req, $api) |
| 523 | 523 | { |
| 524 | 524 | $this->loadModel('Usuario'); |
@@ -2,6 +2,9 @@ |
||
| 2 | 2 | |
| 3 | 3 | class VariacaoController extends AppController { |
| 4 | 4 | |
| 5 | + /** |
|
| 6 | + * @param string $usuario_id |
|
| 7 | + */ |
|
| 5 | 8 | public function s_adicionar_variacao($variacoes, $produto_id, $usuario_id) { |
| 6 | 9 | if (empty($variacoes) || empty($produto_id)) { |
| 7 | 10 | return false; |
@@ -13,8 +13,8 @@ discard block |
||
| 13 | 13 | $dados['produto_id'] = $produto_id; |
| 14 | 14 | $dados['usuario_id'] = $usuario_id; |
| 15 | 15 | $dados['nome_variacao'] = $variacao['variacao']; |
| 16 | - $dados['estoque'] = $variacao['estoque']; |
|
| 17 | - $dados['ativo'] = 1; |
|
| 16 | + $dados['estoque'] = $variacao['estoque']; |
|
| 17 | + $dados['ativo'] = 1; |
|
| 18 | 18 | |
| 19 | 19 | $this->Variacao->save($dados); |
| 20 | 20 | } |
@@ -27,10 +27,10 @@ discard block |
||
| 27 | 27 | return false; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - $dados = array ('ativo' => '0'); |
|
| 31 | - $parametros = array ('produto_id' => $id); |
|
| 30 | + $dados = array('ativo' => '0'); |
|
| 31 | + $parametros = array('produto_id' => $id); |
|
| 32 | 32 | |
| 33 | - if (!$this->Variacao->updateAll($dados, $parametros)) { |
|
| 33 | + if ( ! $this->Variacao->updateAll($dados, $parametros)) { |
|
| 34 | 34 | return false; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -119,6 +119,9 @@ |
||
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | + /** |
|
| 123 | + * @param boolean|string $url |
|
| 124 | + */ |
|
| 122 | 125 | public static function printPaymentUrl($url) |
| 123 | 126 | { |
| 124 | 127 | if ($url) { |
@@ -26,107 +26,107 @@ |
||
| 26 | 26 | class CreatePaymentRequest |
| 27 | 27 | { |
| 28 | 28 | |
| 29 | - public static function main() |
|
| 30 | - { |
|
| 31 | - // Instantiate a new payment request |
|
| 32 | - $paymentRequest = new PagSeguroPaymentRequest(); |
|
| 33 | - |
|
| 34 | - // Set the currency |
|
| 35 | - $paymentRequest->setCurrency("BRL"); |
|
| 36 | - |
|
| 37 | - // Add an item for this payment request |
|
| 38 | - $paymentRequest->addItem('0001', 'Notebook prata', 2, 430.00); |
|
| 39 | - |
|
| 40 | - // Add another item for this payment request |
|
| 41 | - $paymentRequest->addItem('0002', 'Notebook rosa', 2, 560.00); |
|
| 42 | - |
|
| 43 | - // Set a reference code for this payment request. It is useful to identify this payment |
|
| 44 | - // in future notifications. |
|
| 45 | - $paymentRequest->setReference("REF123"); |
|
| 46 | - |
|
| 47 | - // Set shipping information for this payment request |
|
| 48 | - $sedexCode = PagSeguroShippingType::getCodeByType('SEDEX'); |
|
| 49 | - $paymentRequest->setShippingType($sedexCode); |
|
| 50 | - $paymentRequest->setShippingAddress( |
|
| 51 | - '01452002', |
|
| 52 | - 'Av. Brig. Faria Lima', |
|
| 53 | - '1384', |
|
| 54 | - 'apto. 114', |
|
| 55 | - 'Jardim Paulistano', |
|
| 56 | - 'São Paulo', |
|
| 57 | - 'SP', |
|
| 58 | - 'BRA' |
|
| 59 | - ); |
|
| 60 | - |
|
| 61 | - // Set your customer information. |
|
| 62 | - $paymentRequest->setSender( |
|
| 63 | - 'João Comprador', |
|
| 64 | - '[email protected]', |
|
| 65 | - '11', |
|
| 66 | - '56273440', |
|
| 67 | - 'CPF', |
|
| 68 | - '156.009.442-76' |
|
| 69 | - ); |
|
| 70 | - |
|
| 71 | - // Set the url used by PagSeguro to redirect user after checkout process ends |
|
| 72 | - $paymentRequest->setRedirectUrl("http://www.lojamodelo.com.br"); |
|
| 73 | - |
|
| 74 | - // Add checkout metadata information |
|
| 75 | - $paymentRequest->addMetadata('PASSENGER_CPF', '15600944276', 1); |
|
| 76 | - $paymentRequest->addMetadata('GAME_NAME', 'DOTA'); |
|
| 77 | - $paymentRequest->addMetadata('PASSENGER_PASSPORT', '23456', 1); |
|
| 78 | - |
|
| 79 | - // Another way to set checkout parameters |
|
| 80 | - $paymentRequest->addParameter('notificationURL', 'http://www.lojamodelo.com.br/nas'); |
|
| 81 | - $paymentRequest->addParameter('senderBornDate', '07/05/1981'); |
|
| 82 | - $paymentRequest->addIndexedParameter('itemId', '0003', 3); |
|
| 83 | - $paymentRequest->addIndexedParameter('itemDescription', 'Notebook Preto', 3); |
|
| 84 | - $paymentRequest->addIndexedParameter('itemQuantity', '1', 3); |
|
| 85 | - $paymentRequest->addIndexedParameter('itemAmount', '200.00', 3); |
|
| 86 | - |
|
| 87 | - // Add discount per payment method |
|
| 88 | - $paymentRequest->addPaymentMethodConfig('CREDIT_CARD', 1.00, 'DISCOUNT_PERCENT'); |
|
| 89 | - $paymentRequest->addPaymentMethodConfig('EFT', 2.90, 'DISCOUNT_PERCENT'); |
|
| 90 | - $paymentRequest->addPaymentMethodConfig('BOLETO', 10.00, 'DISCOUNT_PERCENT'); |
|
| 91 | - $paymentRequest->addPaymentMethodConfig('DEPOSIT', 3.45, 'DISCOUNT_PERCENT'); |
|
| 92 | - $paymentRequest->addPaymentMethodConfig('BALANCE', 0.01, 'DISCOUNT_PERCENT'); |
|
| 93 | - |
|
| 94 | - try { |
|
| 95 | - |
|
| 96 | - /* |
|
| 29 | + public static function main() |
|
| 30 | + { |
|
| 31 | + // Instantiate a new payment request |
|
| 32 | + $paymentRequest = new PagSeguroPaymentRequest(); |
|
| 33 | + |
|
| 34 | + // Set the currency |
|
| 35 | + $paymentRequest->setCurrency("BRL"); |
|
| 36 | + |
|
| 37 | + // Add an item for this payment request |
|
| 38 | + $paymentRequest->addItem('0001', 'Notebook prata', 2, 430.00); |
|
| 39 | + |
|
| 40 | + // Add another item for this payment request |
|
| 41 | + $paymentRequest->addItem('0002', 'Notebook rosa', 2, 560.00); |
|
| 42 | + |
|
| 43 | + // Set a reference code for this payment request. It is useful to identify this payment |
|
| 44 | + // in future notifications. |
|
| 45 | + $paymentRequest->setReference("REF123"); |
|
| 46 | + |
|
| 47 | + // Set shipping information for this payment request |
|
| 48 | + $sedexCode = PagSeguroShippingType::getCodeByType('SEDEX'); |
|
| 49 | + $paymentRequest->setShippingType($sedexCode); |
|
| 50 | + $paymentRequest->setShippingAddress( |
|
| 51 | + '01452002', |
|
| 52 | + 'Av. Brig. Faria Lima', |
|
| 53 | + '1384', |
|
| 54 | + 'apto. 114', |
|
| 55 | + 'Jardim Paulistano', |
|
| 56 | + 'São Paulo', |
|
| 57 | + 'SP', |
|
| 58 | + 'BRA' |
|
| 59 | + ); |
|
| 60 | + |
|
| 61 | + // Set your customer information. |
|
| 62 | + $paymentRequest->setSender( |
|
| 63 | + 'João Comprador', |
|
| 64 | + '[email protected]', |
|
| 65 | + '11', |
|
| 66 | + '56273440', |
|
| 67 | + 'CPF', |
|
| 68 | + '156.009.442-76' |
|
| 69 | + ); |
|
| 70 | + |
|
| 71 | + // Set the url used by PagSeguro to redirect user after checkout process ends |
|
| 72 | + $paymentRequest->setRedirectUrl("http://www.lojamodelo.com.br"); |
|
| 73 | + |
|
| 74 | + // Add checkout metadata information |
|
| 75 | + $paymentRequest->addMetadata('PASSENGER_CPF', '15600944276', 1); |
|
| 76 | + $paymentRequest->addMetadata('GAME_NAME', 'DOTA'); |
|
| 77 | + $paymentRequest->addMetadata('PASSENGER_PASSPORT', '23456', 1); |
|
| 78 | + |
|
| 79 | + // Another way to set checkout parameters |
|
| 80 | + $paymentRequest->addParameter('notificationURL', 'http://www.lojamodelo.com.br/nas'); |
|
| 81 | + $paymentRequest->addParameter('senderBornDate', '07/05/1981'); |
|
| 82 | + $paymentRequest->addIndexedParameter('itemId', '0003', 3); |
|
| 83 | + $paymentRequest->addIndexedParameter('itemDescription', 'Notebook Preto', 3); |
|
| 84 | + $paymentRequest->addIndexedParameter('itemQuantity', '1', 3); |
|
| 85 | + $paymentRequest->addIndexedParameter('itemAmount', '200.00', 3); |
|
| 86 | + |
|
| 87 | + // Add discount per payment method |
|
| 88 | + $paymentRequest->addPaymentMethodConfig('CREDIT_CARD', 1.00, 'DISCOUNT_PERCENT'); |
|
| 89 | + $paymentRequest->addPaymentMethodConfig('EFT', 2.90, 'DISCOUNT_PERCENT'); |
|
| 90 | + $paymentRequest->addPaymentMethodConfig('BOLETO', 10.00, 'DISCOUNT_PERCENT'); |
|
| 91 | + $paymentRequest->addPaymentMethodConfig('DEPOSIT', 3.45, 'DISCOUNT_PERCENT'); |
|
| 92 | + $paymentRequest->addPaymentMethodConfig('BALANCE', 0.01, 'DISCOUNT_PERCENT'); |
|
| 93 | + |
|
| 94 | + try { |
|
| 95 | + |
|
| 96 | + /* |
|
| 97 | 97 | * #### Credentials ##### |
| 98 | 98 | * Replace the parameters below with your credentials |
| 99 | 99 | * You can also get your credentials from a config file. See an example: |
| 100 | 100 | * $credentials = PagSeguroConfig::getAccountCredentials(); |
| 101 | 101 | // */ |
| 102 | 102 | |
| 103 | - // seller authentication |
|
| 104 | - $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
| 105 | - "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
| 103 | + // seller authentication |
|
| 104 | + $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
| 105 | + "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
| 106 | 106 | |
| 107 | - // application authentication |
|
| 108 | - //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
| 107 | + // application authentication |
|
| 108 | + //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
| 109 | 109 | |
| 110 | - //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
| 110 | + //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
| 111 | 111 | |
| 112 | - // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer. |
|
| 113 | - $url = $paymentRequest->register($credentials); |
|
| 112 | + // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer. |
|
| 113 | + $url = $paymentRequest->register($credentials); |
|
| 114 | 114 | |
| 115 | - self::printPaymentUrl($url); |
|
| 115 | + self::printPaymentUrl($url); |
|
| 116 | 116 | |
| 117 | - } catch (PagSeguroServiceException $e) { |
|
| 118 | - die($e->getMessage()); |
|
| 119 | - } |
|
| 120 | - } |
|
| 117 | + } catch (PagSeguroServiceException $e) { |
|
| 118 | + die($e->getMessage()); |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - public static function printPaymentUrl($url) |
|
| 123 | - { |
|
| 124 | - if ($url) { |
|
| 125 | - echo "<h2>Criando requisição de pagamento</h2>"; |
|
| 126 | - echo "<p>URL do pagamento: <strong>$url</strong></p>"; |
|
| 127 | - echo "<p><a title=\"URL do pagamento\" href=\"$url\">Ir para URL do pagamento.</a></p>"; |
|
| 128 | - } |
|
| 129 | - } |
|
| 122 | + public static function printPaymentUrl($url) |
|
| 123 | + { |
|
| 124 | + if ($url) { |
|
| 125 | + echo "<h2>Criando requisição de pagamento</h2>"; |
|
| 126 | + echo "<p>URL do pagamento: <strong>$url</strong></p>"; |
|
| 127 | + echo "<p><a title=\"URL do pagamento\" href=\"$url\">Ir para URL do pagamento.</a></p>"; |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | CreatePaymentRequest::main(); |
@@ -121,6 +121,9 @@ |
||
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | + /** |
|
| 125 | + * @param boolean|string $code |
|
| 126 | + */ |
|
| 124 | 127 | public static function printPaymentUrl($code) |
| 125 | 128 | { |
| 126 | 129 | if ($code) { |
@@ -35,103 +35,103 @@ |
||
| 35 | 35 | class CreatePaymentRequestLightbox |
| 36 | 36 | { |
| 37 | 37 | |
| 38 | - public static function main() |
|
| 39 | - { |
|
| 40 | - // Instantiate a new payment request |
|
| 41 | - $paymentRequest = new PagSeguroPaymentRequest(); |
|
| 42 | - |
|
| 43 | - // Set the currency |
|
| 44 | - $paymentRequest->setCurrency("BRL"); |
|
| 45 | - |
|
| 46 | - // Add an item for this payment request |
|
| 47 | - $paymentRequest->addItem('0001', 'Notebook prata', 2, 430.00); |
|
| 48 | - |
|
| 49 | - // Add another item for this payment request |
|
| 50 | - $paymentRequest->addItem('0002', 'Notebook rosa', 2, 560.00); |
|
| 51 | - |
|
| 52 | - // Set a reference code for this payment request, it is useful to identify this payment |
|
| 53 | - // in future notifications. |
|
| 54 | - $paymentRequest->setReference("REF123"); |
|
| 55 | - |
|
| 56 | - // Set shipping information for this payment request |
|
| 57 | - $sedexCode = PagSeguroShippingType::getCodeByType('SEDEX'); |
|
| 58 | - $paymentRequest->setShippingType($sedexCode); |
|
| 59 | - $paymentRequest->setShippingAddress( |
|
| 60 | - '01452002', |
|
| 61 | - 'Av. Brig. Faria Lima', |
|
| 62 | - '1384', |
|
| 63 | - 'apto. 114', |
|
| 64 | - 'Jardim Paulistano', |
|
| 65 | - 'São Paulo', |
|
| 66 | - 'SP', |
|
| 67 | - 'BRA' |
|
| 68 | - ); |
|
| 69 | - |
|
| 70 | - // Set your customer information. |
|
| 71 | - $paymentRequest->setSender( |
|
| 72 | - 'João Comprador', |
|
| 73 | - '[email protected]', |
|
| 74 | - '11', |
|
| 75 | - '56273440', |
|
| 76 | - 'CPF', |
|
| 77 | - '156.009.442-76' |
|
| 78 | - ); |
|
| 79 | - |
|
| 80 | - // Set the url used by PagSeguro to redirect user after checkout process ends |
|
| 81 | - $paymentRequest->setRedirectUrl("http://www.lojamodelo.com.br"); |
|
| 82 | - |
|
| 83 | - // Add checkout metadata information |
|
| 84 | - $paymentRequest->addMetadata('PASSENGER_CPF', '15600944276', 1); |
|
| 85 | - $paymentRequest->addMetadata('GAME_NAME', 'DOTA'); |
|
| 86 | - $paymentRequest->addMetadata('PASSENGER_PASSPORT', '23456', 1); |
|
| 87 | - |
|
| 88 | - // Another way to set checkout parameters |
|
| 89 | - $paymentRequest->addParameter('notificationURL', 'http://www.lojamodelo.com.br/nas'); |
|
| 90 | - $paymentRequest->addParameter('senderBornDate', '07/05/1981'); |
|
| 91 | - $paymentRequest->addIndexedParameter('itemId', '0003', 3); |
|
| 92 | - $paymentRequest->addIndexedParameter('itemDescription', 'Notebook Preto', 3); |
|
| 93 | - $paymentRequest->addIndexedParameter('itemQuantity', '1', 3); |
|
| 94 | - $paymentRequest->addIndexedParameter('itemAmount', '200.00', 3); |
|
| 95 | - |
|
| 96 | - try { |
|
| 97 | - |
|
| 98 | - /* |
|
| 38 | + public static function main() |
|
| 39 | + { |
|
| 40 | + // Instantiate a new payment request |
|
| 41 | + $paymentRequest = new PagSeguroPaymentRequest(); |
|
| 42 | + |
|
| 43 | + // Set the currency |
|
| 44 | + $paymentRequest->setCurrency("BRL"); |
|
| 45 | + |
|
| 46 | + // Add an item for this payment request |
|
| 47 | + $paymentRequest->addItem('0001', 'Notebook prata', 2, 430.00); |
|
| 48 | + |
|
| 49 | + // Add another item for this payment request |
|
| 50 | + $paymentRequest->addItem('0002', 'Notebook rosa', 2, 560.00); |
|
| 51 | + |
|
| 52 | + // Set a reference code for this payment request, it is useful to identify this payment |
|
| 53 | + // in future notifications. |
|
| 54 | + $paymentRequest->setReference("REF123"); |
|
| 55 | + |
|
| 56 | + // Set shipping information for this payment request |
|
| 57 | + $sedexCode = PagSeguroShippingType::getCodeByType('SEDEX'); |
|
| 58 | + $paymentRequest->setShippingType($sedexCode); |
|
| 59 | + $paymentRequest->setShippingAddress( |
|
| 60 | + '01452002', |
|
| 61 | + 'Av. Brig. Faria Lima', |
|
| 62 | + '1384', |
|
| 63 | + 'apto. 114', |
|
| 64 | + 'Jardim Paulistano', |
|
| 65 | + 'São Paulo', |
|
| 66 | + 'SP', |
|
| 67 | + 'BRA' |
|
| 68 | + ); |
|
| 69 | + |
|
| 70 | + // Set your customer information. |
|
| 71 | + $paymentRequest->setSender( |
|
| 72 | + 'João Comprador', |
|
| 73 | + '[email protected]', |
|
| 74 | + '11', |
|
| 75 | + '56273440', |
|
| 76 | + 'CPF', |
|
| 77 | + '156.009.442-76' |
|
| 78 | + ); |
|
| 79 | + |
|
| 80 | + // Set the url used by PagSeguro to redirect user after checkout process ends |
|
| 81 | + $paymentRequest->setRedirectUrl("http://www.lojamodelo.com.br"); |
|
| 82 | + |
|
| 83 | + // Add checkout metadata information |
|
| 84 | + $paymentRequest->addMetadata('PASSENGER_CPF', '15600944276', 1); |
|
| 85 | + $paymentRequest->addMetadata('GAME_NAME', 'DOTA'); |
|
| 86 | + $paymentRequest->addMetadata('PASSENGER_PASSPORT', '23456', 1); |
|
| 87 | + |
|
| 88 | + // Another way to set checkout parameters |
|
| 89 | + $paymentRequest->addParameter('notificationURL', 'http://www.lojamodelo.com.br/nas'); |
|
| 90 | + $paymentRequest->addParameter('senderBornDate', '07/05/1981'); |
|
| 91 | + $paymentRequest->addIndexedParameter('itemId', '0003', 3); |
|
| 92 | + $paymentRequest->addIndexedParameter('itemDescription', 'Notebook Preto', 3); |
|
| 93 | + $paymentRequest->addIndexedParameter('itemQuantity', '1', 3); |
|
| 94 | + $paymentRequest->addIndexedParameter('itemAmount', '200.00', 3); |
|
| 95 | + |
|
| 96 | + try { |
|
| 97 | + |
|
| 98 | + /* |
|
| 99 | 99 | * #### Credentials ##### |
| 100 | 100 | * Replace the parameters below with your credentials |
| 101 | 101 | * You can also get your credentials from a config file. See an example: |
| 102 | 102 | * $credentials = PagSeguroConfig::getAccountCredentials(); |
| 103 | 103 | */ |
| 104 | 104 | |
| 105 | - // seller authentication |
|
| 106 | - $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
| 107 | - "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
| 105 | + // seller authentication |
|
| 106 | + $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
| 107 | + "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
| 108 | 108 | |
| 109 | - // application authentication |
|
| 110 | - //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
| 109 | + // application authentication |
|
| 110 | + //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
| 111 | 111 | |
| 112 | - //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
| 112 | + //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
| 113 | 113 | |
| 114 | - // Register this payment request in PagSeguro to obtain the checkout code |
|
| 115 | - $onlyCheckoutCode = true; |
|
| 116 | - $code = $paymentRequest->register($credentials, $onlyCheckoutCode); |
|
| 114 | + // Register this payment request in PagSeguro to obtain the checkout code |
|
| 115 | + $onlyCheckoutCode = true; |
|
| 116 | + $code = $paymentRequest->register($credentials, $onlyCheckoutCode); |
|
| 117 | 117 | |
| 118 | - self::printPaymentUrl($code); |
|
| 119 | - } catch (PagSeguroServiceException $e) { |
|
| 120 | - die($e->getMessage()); |
|
| 121 | - } |
|
| 122 | - } |
|
| 118 | + self::printPaymentUrl($code); |
|
| 119 | + } catch (PagSeguroServiceException $e) { |
|
| 120 | + die($e->getMessage()); |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - public static function printPaymentUrl($code) |
|
| 125 | - { |
|
| 126 | - if ($code) { |
|
| 127 | - echo "<h2>Criando requisição de pagamento</h2>"; |
|
| 128 | - echo "<p>Code: <strong>$code</strong></p>"; |
|
| 129 | - echo "<script> |
|
| 124 | + public static function printPaymentUrl($code) |
|
| 125 | + { |
|
| 126 | + if ($code) { |
|
| 127 | + echo "<h2>Criando requisição de pagamento</h2>"; |
|
| 128 | + echo "<p>Code: <strong>$code</strong></p>"; |
|
| 129 | + echo "<script> |
|
| 130 | 130 | PagSeguroLightbox('".$code."'); |
| 131 | 131 | </script>"; |
| 132 | 132 | |
| 133 | - } |
|
| 134 | - } |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | CreatePaymentRequestLightbox::main(); |
@@ -61,6 +61,9 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | + /** |
|
| 65 | + * @param string $notificationCode |
|
| 66 | + */ |
|
| 64 | 67 | private static function transactionNotification($notificationCode) |
| 65 | 68 | { |
| 66 | 69 | |
@@ -74,6 +77,9 @@ discard block |
||
| 74 | 77 | } |
| 75 | 78 | } |
| 76 | 79 | |
| 80 | + /** |
|
| 81 | + * @param string $notificationCode |
|
| 82 | + */ |
|
| 77 | 83 | private static function authorizationNotification($notificationCode) |
| 78 | 84 | { |
| 79 | 85 | |
@@ -22,82 +22,82 @@ |
||
| 22 | 22 | class NotificationListener |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - public static function main() |
|
| 26 | - { |
|
| 25 | + public static function main() |
|
| 26 | + { |
|
| 27 | 27 | |
| 28 | - $code = (isset($_POST['notificationCode']) && trim($_POST['notificationCode']) !== "" ? |
|
| 29 | - trim($_POST['notificationCode']) : null); |
|
| 30 | - $type = (isset($_POST['notificationType']) && trim($_POST['notificationType']) !== "" ? |
|
| 31 | - trim($_POST['notificationType']) : null); |
|
| 28 | + $code = (isset($_POST['notificationCode']) && trim($_POST['notificationCode']) !== "" ? |
|
| 29 | + trim($_POST['notificationCode']) : null); |
|
| 30 | + $type = (isset($_POST['notificationType']) && trim($_POST['notificationType']) !== "" ? |
|
| 31 | + trim($_POST['notificationType']) : null); |
|
| 32 | 32 | |
| 33 | - if ($code && $type) { |
|
| 33 | + if ($code && $type) { |
|
| 34 | 34 | |
| 35 | - $notificationType = new PagSeguroNotificationType($type); |
|
| 36 | - $strType = $notificationType->getTypeFromValue(); |
|
| 35 | + $notificationType = new PagSeguroNotificationType($type); |
|
| 36 | + $strType = $notificationType->getTypeFromValue(); |
|
| 37 | 37 | |
| 38 | - switch ($strType) { |
|
| 38 | + switch ($strType) { |
|
| 39 | 39 | |
| 40 | - case 'TRANSACTION': |
|
| 41 | - self::transactionNotification($code); |
|
| 42 | - break; |
|
| 40 | + case 'TRANSACTION': |
|
| 41 | + self::transactionNotification($code); |
|
| 42 | + break; |
|
| 43 | 43 | |
| 44 | - case 'APPLICATION_AUTHORIZATION': |
|
| 45 | - self::authorizationNotification($code); |
|
| 46 | - break; |
|
| 44 | + case 'APPLICATION_AUTHORIZATION': |
|
| 45 | + self::authorizationNotification($code); |
|
| 46 | + break; |
|
| 47 | 47 | |
| 48 | - default: |
|
| 49 | - LogPagSeguro::error("Unknown notification type [" . $notificationType->getValue() . "]"); |
|
| 48 | + default: |
|
| 49 | + LogPagSeguro::error("Unknown notification type [" . $notificationType->getValue() . "]"); |
|
| 50 | 50 | |
| 51 | - } |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - self::printLog($strType); |
|
| 53 | + self::printLog($strType); |
|
| 54 | 54 | |
| 55 | - } else { |
|
| 55 | + } else { |
|
| 56 | 56 | |
| 57 | - LogPagSeguro::error("Invalid notification parameters."); |
|
| 58 | - self::printLog(); |
|
| 57 | + LogPagSeguro::error("Invalid notification parameters."); |
|
| 58 | + self::printLog(); |
|
| 59 | 59 | |
| 60 | - } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - private static function transactionNotification($notificationCode) |
|
| 65 | - { |
|
| 64 | + private static function transactionNotification($notificationCode) |
|
| 65 | + { |
|
| 66 | 66 | |
| 67 | - $credentials = PagSeguroConfig::getAccountCredentials(); |
|
| 67 | + $credentials = PagSeguroConfig::getAccountCredentials(); |
|
| 68 | 68 | |
| 69 | - try { |
|
| 70 | - $transaction = PagSeguroNotificationService::checkTransaction($credentials, $notificationCode); |
|
| 71 | - // Do something with $transaction |
|
| 72 | - } catch (PagSeguroServiceException $e) { |
|
| 73 | - die($e->getMessage()); |
|
| 74 | - } |
|
| 75 | - } |
|
| 69 | + try { |
|
| 70 | + $transaction = PagSeguroNotificationService::checkTransaction($credentials, $notificationCode); |
|
| 71 | + // Do something with $transaction |
|
| 72 | + } catch (PagSeguroServiceException $e) { |
|
| 73 | + die($e->getMessage()); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - private static function authorizationNotification($notificationCode) |
|
| 78 | - { |
|
| 77 | + private static function authorizationNotification($notificationCode) |
|
| 78 | + { |
|
| 79 | 79 | |
| 80 | - $credentials = PagSeguroConfig::getApplicationCredentials(); |
|
| 80 | + $credentials = PagSeguroConfig::getApplicationCredentials(); |
|
| 81 | 81 | |
| 82 | - try { |
|
| 83 | - $authorization = PagSeguroNotificationService::checkAuthorization($credentials, $notificationCode); |
|
| 82 | + try { |
|
| 83 | + $authorization = PagSeguroNotificationService::checkAuthorization($credentials, $notificationCode); |
|
| 84 | 84 | |
| 85 | - // Do something with $authorization |
|
| 86 | - } catch (PagSeguroServiceException $e) { |
|
| 87 | - die($e->getMessage()); |
|
| 88 | - } |
|
| 89 | - } |
|
| 85 | + // Do something with $authorization |
|
| 86 | + } catch (PagSeguroServiceException $e) { |
|
| 87 | + die($e->getMessage()); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - private static function printLog($strType = null) |
|
| 92 | - { |
|
| 93 | - $count = 4; |
|
| 94 | - echo "<h2>Receive notifications</h2>"; |
|
| 95 | - if ($strType) { |
|
| 96 | - echo "<h4>notifcationType: $strType</h4>"; |
|
| 97 | - } |
|
| 98 | - echo "<p>Last <strong>$count</strong> items in <strong>log file:</strong></p><hr>"; |
|
| 99 | - echo LogPagSeguro::getHtml($count); |
|
| 100 | - } |
|
| 91 | + private static function printLog($strType = null) |
|
| 92 | + { |
|
| 93 | + $count = 4; |
|
| 94 | + echo "<h2>Receive notifications</h2>"; |
|
| 95 | + if ($strType) { |
|
| 96 | + echo "<h4>notifcationType: $strType</h4>"; |
|
| 97 | + } |
|
| 98 | + echo "<p>Last <strong>$count</strong> items in <strong>log file:</strong></p><hr>"; |
|
| 99 | + echo LogPagSeguro::getHtml($count); |
|
| 100 | + } |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | NotificationListener::main(); |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | break; |
| 47 | 47 | |
| 48 | 48 | default: |
| 49 | - LogPagSeguro::error("Unknown notification type [" . $notificationType->getValue() . "]"); |
|
| 49 | + LogPagSeguro::error("Unknown notification type [".$notificationType->getValue()."]"); |
|
| 50 | 50 | |
| 51 | 51 | } |
| 52 | 52 | |
@@ -64,6 +64,10 @@ |
||
| 64 | 64 | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | + /** |
|
| 68 | + * @param string $initialDate |
|
| 69 | + * @param string $finalDate |
|
| 70 | + */ |
|
| 67 | 71 | public static function printResult(PagSeguroTransactionSearchResult $result, $initialDate, $finalDate) |
| 68 | 72 | { |
| 69 | 73 | $finalDate = $finalDate ? $finalDate : 'now'; |
@@ -22,63 +22,63 @@ |
||
| 22 | 22 | class SearchTransactionsByDateInterval |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - public static function main() |
|
| 26 | - { |
|
| 25 | + public static function main() |
|
| 26 | + { |
|
| 27 | 27 | |
| 28 | - $initialDate = '2014-11-01T14:55'; |
|
| 29 | - $finalDate = '2014-11-30T09:55'; |
|
| 28 | + $initialDate = '2014-11-01T14:55'; |
|
| 29 | + $finalDate = '2014-11-30T09:55'; |
|
| 30 | 30 | |
| 31 | - $pageNumber = 1; |
|
| 32 | - $maxPageResults = 20; |
|
| 31 | + $pageNumber = 1; |
|
| 32 | + $maxPageResults = 20; |
|
| 33 | 33 | |
| 34 | - try { |
|
| 34 | + try { |
|
| 35 | 35 | |
| 36 | - /* |
|
| 36 | + /* |
|
| 37 | 37 | * #### Credentials ##### |
| 38 | 38 | * Substitute the parameters below with your credentials |
| 39 | 39 | * You can also get your credentials from a config file. See an example: |
| 40 | 40 | * $credentials = PagSeguroConfig::getAccountCredentials(); |
| 41 | 41 | */ |
| 42 | - // seller authentication |
|
| 43 | - $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
| 44 | - "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
| 45 | - |
|
| 46 | - // application authentication |
|
| 47 | - //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
| 48 | - |
|
| 49 | - //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
| 50 | - |
|
| 51 | - $result = PagSeguroTransactionSearchService::searchByDate( |
|
| 52 | - $credentials, |
|
| 53 | - $pageNumber, |
|
| 54 | - $maxPageResults, |
|
| 55 | - $initialDate, |
|
| 56 | - $finalDate |
|
| 57 | - ); |
|
| 58 | - |
|
| 59 | - self::printResult($result, $initialDate, $finalDate); |
|
| 60 | - |
|
| 61 | - } catch (PagSeguroServiceException $e) { |
|
| 62 | - die($e->getMessage()); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - public static function printResult(PagSeguroTransactionSearchResult $result, $initialDate, $finalDate) |
|
| 68 | - { |
|
| 69 | - $finalDate = $finalDate ? $finalDate : 'now'; |
|
| 70 | - echo "<h2>Search transactions by date</h2>"; |
|
| 71 | - echo "<h3>$initialDate to $finalDate</h3>"; |
|
| 72 | - $transactions = $result->getTransactions(); |
|
| 73 | - if (is_array($transactions) && count($transactions) > 0) { |
|
| 74 | - foreach ($transactions as $key => $transactionSummary) { |
|
| 75 | - echo "Code: " . $transactionSummary->getCode() . "<br>"; |
|
| 76 | - echo "Reference: " . $transactionSummary->getReference() . "<br>"; |
|
| 77 | - echo "amount: " . $transactionSummary->getGrossAmount() . "<br>"; |
|
| 78 | - echo "<hr>"; |
|
| 79 | - } |
|
| 80 | - } |
|
| 81 | - } |
|
| 42 | + // seller authentication |
|
| 43 | + $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
| 44 | + "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
| 45 | + |
|
| 46 | + // application authentication |
|
| 47 | + //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
| 48 | + |
|
| 49 | + //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
| 50 | + |
|
| 51 | + $result = PagSeguroTransactionSearchService::searchByDate( |
|
| 52 | + $credentials, |
|
| 53 | + $pageNumber, |
|
| 54 | + $maxPageResults, |
|
| 55 | + $initialDate, |
|
| 56 | + $finalDate |
|
| 57 | + ); |
|
| 58 | + |
|
| 59 | + self::printResult($result, $initialDate, $finalDate); |
|
| 60 | + |
|
| 61 | + } catch (PagSeguroServiceException $e) { |
|
| 62 | + die($e->getMessage()); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + public static function printResult(PagSeguroTransactionSearchResult $result, $initialDate, $finalDate) |
|
| 68 | + { |
|
| 69 | + $finalDate = $finalDate ? $finalDate : 'now'; |
|
| 70 | + echo "<h2>Search transactions by date</h2>"; |
|
| 71 | + echo "<h3>$initialDate to $finalDate</h3>"; |
|
| 72 | + $transactions = $result->getTransactions(); |
|
| 73 | + if (is_array($transactions) && count($transactions) > 0) { |
|
| 74 | + foreach ($transactions as $key => $transactionSummary) { |
|
| 75 | + echo "Code: " . $transactionSummary->getCode() . "<br>"; |
|
| 76 | + echo "Reference: " . $transactionSummary->getReference() . "<br>"; |
|
| 77 | + echo "amount: " . $transactionSummary->getGrossAmount() . "<br>"; |
|
| 78 | + echo "<hr>"; |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | SearchTransactionsByDateInterval::main(); |
| 85 | 85 | \ No newline at end of file |
@@ -72,9 +72,9 @@ |
||
| 72 | 72 | $transactions = $result->getTransactions(); |
| 73 | 73 | if (is_array($transactions) && count($transactions) > 0) { |
| 74 | 74 | foreach ($transactions as $key => $transactionSummary) { |
| 75 | - echo "Code: " . $transactionSummary->getCode() . "<br>"; |
|
| 76 | - echo "Reference: " . $transactionSummary->getReference() . "<br>"; |
|
| 77 | - echo "amount: " . $transactionSummary->getGrossAmount() . "<br>"; |
|
| 75 | + echo "Code: ".$transactionSummary->getCode()."<br>"; |
|
| 76 | + echo "Reference: ".$transactionSummary->getReference()."<br>"; |
|
| 77 | + echo "amount: ".$transactionSummary->getGrossAmount()."<br>"; |
|
| 78 | 78 | echo "<hr>"; |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -258,6 +258,10 @@ discard block |
||
| 258 | 258 | * Sets the sender hash |
| 259 | 259 | * @param string $receiverHash |
| 260 | 260 | */ |
| 261 | + |
|
| 262 | + /** |
|
| 263 | + * @param string $senderHash |
|
| 264 | + */ |
|
| 261 | 265 | public function setSenderHash($senderHash) |
| 262 | 266 | { |
| 263 | 267 | $this->senderHash = $senderHash; |
@@ -463,6 +467,10 @@ discard block |
||
| 463 | 467 | * Sets the reference of this payment request |
| 464 | 468 | * @param reference |
| 465 | 469 | */ |
| 470 | + |
|
| 471 | + /** |
|
| 472 | + * @param string $reference |
|
| 473 | + */ |
|
| 466 | 474 | public function setReference($reference) |
| 467 | 475 | { |
| 468 | 476 | $this->reference = $reference; |
@@ -689,6 +697,10 @@ discard block |
||
| 689 | 697 | * Sets the info for credit card for this payment request |
| 690 | 698 | * @param array|object $params... |
| 691 | 699 | */ |
| 700 | + |
|
| 701 | + /** |
|
| 702 | + * @param PagSeguroCreditCardCheckout $params |
|
| 703 | + */ |
|
| 692 | 704 | public function setCreditCard($params = null) |
| 693 | 705 | { |
| 694 | 706 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | $sender->setEmail($email); |
| 197 | 197 | $sender->setPhone(new PagSeguroPhone($areaCode, $number)); |
| 198 | 198 | $sender->addDocument($documentType, $documentValue); |
| 199 | - if ($ip === true){ |
|
| 199 | + if ($ip === true) { |
|
| 200 | 200 | $sender->getIP(); |
| 201 | 201 | } |
| 202 | 202 | $this->sender = $sender; |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | |
| 657 | 657 | $param = $postalCode; |
| 658 | 658 | $this->billing = new PagSeguroBilling(); |
| 659 | - if (isset($param) and is_array($param)){ |
|
| 659 | + if (isset($param) and is_array($param)) { |
|
| 660 | 660 | $this->billing->setAddress(new PagSeguroAddress($param)); |
| 661 | 661 | } elseif ($param instanceof PagSeguroAddress) { |
| 662 | 662 | $this->billing->setAddress($param); |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | $this->onlineDebit = $bankName; |
| 740 | 740 | } else if (is_array($bankName)) { |
| 741 | 741 | $this->onlineDebit = new PagSeguroOnlineDebitCheckout($bankName); |
| 742 | - }else { |
|
| 742 | + } else { |
|
| 743 | 743 | $this->onlineDebit = new PagSeguroOnlineDebitCheckout( |
| 744 | 744 | array( |
| 745 | 745 | "bankName" => $bankName |
@@ -920,7 +920,7 @@ discard block |
||
| 920 | 920 | $request['Reference'] = $this->reference; |
| 921 | 921 | $request['SenderEmail'] = $email; |
| 922 | 922 | |
| 923 | - return "PagSeguroPaymentRequest: " . var_export($request, true); |
|
| 923 | + return "PagSeguroPaymentRequest: ".var_export($request, true); |
|
| 924 | 924 | } |
| 925 | 925 | |
| 926 | 926 | /*** |
@@ -739,7 +739,7 @@ |
||
| 739 | 739 | $this->onlineDebit = $bankName; |
| 740 | 740 | } else if (is_array($bankName)) { |
| 741 | 741 | $this->onlineDebit = new PagSeguroOnlineDebitCheckout($bankName); |
| 742 | - }else { |
|
| 742 | + } else { |
|
| 743 | 743 | $this->onlineDebit = new PagSeguroOnlineDebitCheckout( |
| 744 | 744 | array( |
| 745 | 745 | "bankName" => $bankName |
@@ -27,146 +27,146 @@ discard block |
||
| 27 | 27 | class PagSeguroDirectPaymentRequest |
| 28 | 28 | { |
| 29 | 29 | |
| 30 | - /*** |
|
| 30 | + /*** |
|
| 31 | 31 | * Party that will be sending the money |
| 32 | 32 | * @var PagSeguroSender |
| 33 | 33 | */ |
| 34 | - private $sender; |
|
| 34 | + private $sender; |
|
| 35 | 35 | |
| 36 | - /*** |
|
| 36 | + /*** |
|
| 37 | 37 | * Sender hash |
| 38 | 38 | */ |
| 39 | - private $senderHash; |
|
| 39 | + private $senderHash; |
|
| 40 | 40 | |
| 41 | - /*** |
|
| 41 | + /*** |
|
| 42 | 42 | * Receiver e-mail |
| 43 | 43 | */ |
| 44 | - private $receiverEmail; |
|
| 44 | + private $receiverEmail; |
|
| 45 | 45 | |
| 46 | - /*** |
|
| 46 | + /*** |
|
| 47 | 47 | * Payment currency |
| 48 | 48 | */ |
| 49 | - private $currency; |
|
| 49 | + private $currency; |
|
| 50 | 50 | |
| 51 | - /*** |
|
| 51 | + /*** |
|
| 52 | 52 | * Products/items in this payment request |
| 53 | 53 | */ |
| 54 | - private $items; |
|
| 54 | + private $items; |
|
| 55 | 55 | |
| 56 | - /*** |
|
| 56 | + /*** |
|
| 57 | 57 | * Uri to where the PagSeguro payment page should redirect the user after the payment information is processed. |
| 58 | 58 | * Typically this is a confirmation page on your web site. |
| 59 | 59 | * @var String |
| 60 | 60 | */ |
| 61 | - private $redirectURL; |
|
| 61 | + private $redirectURL; |
|
| 62 | 62 | |
| 63 | - /*** |
|
| 63 | + /*** |
|
| 64 | 64 | * Extra amount to be added to the transaction total |
| 65 | 65 | * |
| 66 | 66 | * This value can be used to add an extra charge to the transaction |
| 67 | 67 | * or provide a discount in the case ExtraAmount is a negative value. |
| 68 | 68 | * @var float |
| 69 | 69 | */ |
| 70 | - private $extraAmount; |
|
| 70 | + private $extraAmount; |
|
| 71 | 71 | |
| 72 | - /*** |
|
| 72 | + /*** |
|
| 73 | 73 | * Reference code |
| 74 | 74 | * |
| 75 | 75 | * Optional. You can use the reference code to store an identifier so you can |
| 76 | 76 | * associate the PagSeguro transaction to a transaction in your system. |
| 77 | 77 | */ |
| 78 | - private $reference; |
|
| 78 | + private $reference; |
|
| 79 | 79 | |
| 80 | - /*** |
|
| 80 | + /*** |
|
| 81 | 81 | * Shipping information associated with this payment request |
| 82 | 82 | */ |
| 83 | - private $shipping; |
|
| 83 | + private $shipping; |
|
| 84 | 84 | |
| 85 | - /*** |
|
| 85 | + /*** |
|
| 86 | 86 | * Billing information associated with this credit card |
| 87 | 87 | */ |
| 88 | - private $billing; |
|
| 88 | + private $billing; |
|
| 89 | 89 | |
| 90 | - /*** |
|
| 90 | + /*** |
|
| 91 | 91 | * Payment mode for this payment request |
| 92 | 92 | */ |
| 93 | - private $paymentMode; |
|
| 93 | + private $paymentMode; |
|
| 94 | 94 | |
| 95 | - /*** |
|
| 95 | + /*** |
|
| 96 | 96 | * Payment method for this payment request |
| 97 | 97 | */ |
| 98 | - private $paymentMethod; |
|
| 98 | + private $paymentMethod; |
|
| 99 | 99 | |
| 100 | - /*** |
|
| 100 | + /*** |
|
| 101 | 101 | * Credit Card information associated with this payment request |
| 102 | 102 | */ |
| 103 | - private $creditCard; |
|
| 103 | + private $creditCard; |
|
| 104 | 104 | |
| 105 | - /*** |
|
| 105 | + /*** |
|
| 106 | 106 | * Bank name information associated with this payment request for online debit |
| 107 | 107 | */ |
| 108 | - private $onlineDebit; |
|
| 108 | + private $onlineDebit; |
|
| 109 | 109 | |
| 110 | - /*** |
|
| 110 | + /*** |
|
| 111 | 111 | * How long this payment request will remain valid, in seconds. |
| 112 | 112 | * |
| 113 | 113 | * Optional. After this payment request is submitted, the payment code returned |
| 114 | 114 | * will remain valid for the period specified here. |
| 115 | 115 | */ |
| 116 | - private $maxAge; |
|
| 116 | + private $maxAge; |
|
| 117 | 117 | |
| 118 | - /*** |
|
| 118 | + /*** |
|
| 119 | 119 | * How many times the payment redirect uri returned by the payment web service can be accessed. |
| 120 | 120 | * |
| 121 | 121 | * Optional. After this payment request is submitted, the payment redirect uri returned by |
| 122 | 122 | * the payment web service will remain valid for the number of uses specified here. |
| 123 | 123 | */ |
| 124 | - private $maxUses; |
|
| 124 | + private $maxUses; |
|
| 125 | 125 | |
| 126 | - /*** |
|
| 126 | + /*** |
|
| 127 | 127 | * Determines for which url PagSeguro will send the order related notifications codes. |
| 128 | 128 | * |
| 129 | 129 | * Optional. Any change happens in the transaction status, a new notification request will be send |
| 130 | 130 | * to this url. You can use that for update the related order. |
| 131 | 131 | */ |
| 132 | - private $notificationURL; |
|
| 132 | + private $notificationURL; |
|
| 133 | 133 | |
| 134 | - /*** |
|
| 134 | + /*** |
|
| 135 | 135 | * Extra parameters that user can add to a PagSeguro checkout request |
| 136 | 136 | * |
| 137 | 137 | * Optional. |
| 138 | 138 | * @var PagSeguroMetaData |
| 139 | 139 | */ |
| 140 | - private $metadata; |
|
| 140 | + private $metadata; |
|
| 141 | 141 | |
| 142 | - /*** |
|
| 142 | + /*** |
|
| 143 | 143 | * Extra parameters that user can add to a PagSeguro checkout request |
| 144 | 144 | * |
| 145 | 145 | * Optional |
| 146 | 146 | * @var PagSeguroParameter |
| 147 | 147 | */ |
| 148 | - private $parameter; |
|
| 148 | + private $parameter; |
|
| 149 | 149 | |
| 150 | - /*** |
|
| 150 | + /*** |
|
| 151 | 151 | * @return PagSeguroSender the sender |
| 152 | 152 | * |
| 153 | 153 | * Party that will be sending the Uri to where the PagSeguro payment page should redirect the |
| 154 | 154 | * user after the payment information is processed. |
| 155 | 155 | */ |
| 156 | - public function getSender() |
|
| 157 | - { |
|
| 158 | - return $this->sender; |
|
| 159 | - } |
|
| 156 | + public function getSender() |
|
| 157 | + { |
|
| 158 | + return $this->sender; |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - /*** |
|
| 161 | + /*** |
|
| 162 | 162 | * @return PagSeguroPaymentRequest |
| 163 | 163 | */ |
| 164 | - public function getThis() |
|
| 165 | - { |
|
| 166 | - return $this; |
|
| 167 | - } |
|
| 164 | + public function getThis() |
|
| 165 | + { |
|
| 166 | + return $this; |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - /*** |
|
| 169 | + /*** |
|
| 170 | 170 | * Sets the Sender, party that will be sending the money |
| 171 | 171 | * @param string $name |
| 172 | 172 | * @param string $email |
@@ -176,183 +176,183 @@ discard block |
||
| 176 | 176 | * @param PagSeguroDocument $documentValue |
| 177 | 177 | * @param mixed $ip |
| 178 | 178 | */ |
| 179 | - public function setSender( |
|
| 180 | - $name, |
|
| 181 | - $email = null, |
|
| 182 | - $areaCode = null, |
|
| 183 | - $number = null, |
|
| 184 | - $documentType = null, |
|
| 185 | - $documentValue = null, |
|
| 186 | - $ip = false |
|
| 187 | - ) { |
|
| 188 | - $param = $name; |
|
| 189 | - if (is_array($param)) { |
|
| 190 | - $this->sender = new PagSeguroSender($param); |
|
| 191 | - } elseif ($param instanceof PagSeguroSender) { |
|
| 192 | - $this->sender = $param; |
|
| 193 | - } else { |
|
| 194 | - $sender = new PagSeguroSender(); |
|
| 195 | - $sender->setName($param); |
|
| 196 | - $sender->setEmail($email); |
|
| 197 | - $sender->setPhone(new PagSeguroPhone($areaCode, $number)); |
|
| 198 | - $sender->addDocument($documentType, $documentValue); |
|
| 199 | - if ($ip === true){ |
|
| 200 | - $sender->getIP(); |
|
| 201 | - } |
|
| 202 | - $this->sender = $sender; |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - /*** |
|
| 179 | + public function setSender( |
|
| 180 | + $name, |
|
| 181 | + $email = null, |
|
| 182 | + $areaCode = null, |
|
| 183 | + $number = null, |
|
| 184 | + $documentType = null, |
|
| 185 | + $documentValue = null, |
|
| 186 | + $ip = false |
|
| 187 | + ) { |
|
| 188 | + $param = $name; |
|
| 189 | + if (is_array($param)) { |
|
| 190 | + $this->sender = new PagSeguroSender($param); |
|
| 191 | + } elseif ($param instanceof PagSeguroSender) { |
|
| 192 | + $this->sender = $param; |
|
| 193 | + } else { |
|
| 194 | + $sender = new PagSeguroSender(); |
|
| 195 | + $sender->setName($param); |
|
| 196 | + $sender->setEmail($email); |
|
| 197 | + $sender->setPhone(new PagSeguroPhone($areaCode, $number)); |
|
| 198 | + $sender->addDocument($documentType, $documentValue); |
|
| 199 | + if ($ip === true){ |
|
| 200 | + $sender->getIP(); |
|
| 201 | + } |
|
| 202 | + $this->sender = $sender; |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + /*** |
|
| 207 | 207 | * Sets the name of the sender, party that will be sending the money |
| 208 | 208 | * @param String $senderName |
| 209 | 209 | */ |
| 210 | - public function setSenderName($senderName) |
|
| 211 | - { |
|
| 212 | - if ($this->sender == null) { |
|
| 213 | - $this->sender = new PagSeguroSender(); |
|
| 214 | - } |
|
| 215 | - $this->sender->setName($senderName); |
|
| 216 | - } |
|
| 210 | + public function setSenderName($senderName) |
|
| 211 | + { |
|
| 212 | + if ($this->sender == null) { |
|
| 213 | + $this->sender = new PagSeguroSender(); |
|
| 214 | + } |
|
| 215 | + $this->sender->setName($senderName); |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - /*** |
|
| 218 | + /*** |
|
| 219 | 219 | * Sets the name of the sender, party that will be sending the money |
| 220 | 220 | * @param String $senderEmail |
| 221 | 221 | */ |
| 222 | - public function setSenderEmail($senderEmail) |
|
| 223 | - { |
|
| 224 | - if ($this->sender == null) { |
|
| 225 | - $this->sender = new PagSeguroSender(); |
|
| 226 | - } |
|
| 227 | - $this->sender->setEmail($senderEmail); |
|
| 228 | - } |
|
| 222 | + public function setSenderEmail($senderEmail) |
|
| 223 | + { |
|
| 224 | + if ($this->sender == null) { |
|
| 225 | + $this->sender = new PagSeguroSender(); |
|
| 226 | + } |
|
| 227 | + $this->sender->setEmail($senderEmail); |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - /*** |
|
| 230 | + /*** |
|
| 231 | 231 | * Sets the Sender phone number, phone of the party that will be sending the money |
| 232 | 232 | * |
| 233 | 233 | * @param areaCode |
| 234 | 234 | * @param number |
| 235 | 235 | */ |
| 236 | - public function setSenderPhone($areaCode, $number = null) |
|
| 237 | - { |
|
| 238 | - $param = $areaCode; |
|
| 239 | - if ($this->sender == null) { |
|
| 240 | - $this->sender = new PagSeguroSender(); |
|
| 241 | - } |
|
| 242 | - if ($param instanceof PagSeguroPhone) { |
|
| 243 | - $this->sender->setPhone($param); |
|
| 244 | - } else { |
|
| 245 | - $this->sender->setPhone(new PagSeguroPhone($param, $number)); |
|
| 246 | - } |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - /*** |
|
| 236 | + public function setSenderPhone($areaCode, $number = null) |
|
| 237 | + { |
|
| 238 | + $param = $areaCode; |
|
| 239 | + if ($this->sender == null) { |
|
| 240 | + $this->sender = new PagSeguroSender(); |
|
| 241 | + } |
|
| 242 | + if ($param instanceof PagSeguroPhone) { |
|
| 243 | + $this->sender->setPhone($param); |
|
| 244 | + } else { |
|
| 245 | + $this->sender->setPhone(new PagSeguroPhone($param, $number)); |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + /*** |
|
| 250 | 250 | * @return string the senderHash |
| 251 | 251 | */ |
| 252 | - public function getSenderHash() |
|
| 253 | - { |
|
| 254 | - return $this->senderHash; |
|
| 255 | - } |
|
| 252 | + public function getSenderHash() |
|
| 253 | + { |
|
| 254 | + return $this->senderHash; |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | - /*** |
|
| 257 | + /*** |
|
| 258 | 258 | * Sets the sender hash |
| 259 | 259 | * @param string $receiverHash |
| 260 | 260 | */ |
| 261 | - public function setSenderHash($senderHash) |
|
| 262 | - { |
|
| 263 | - $this->senderHash = $senderHash; |
|
| 264 | - } |
|
| 261 | + public function setSenderHash($senderHash) |
|
| 262 | + { |
|
| 263 | + $this->senderHash = $senderHash; |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | - /*** |
|
| 266 | + /*** |
|
| 267 | 267 | * @return string the receiverEmail |
| 268 | 268 | */ |
| 269 | - public function getReceiverEmail() |
|
| 270 | - { |
|
| 271 | - return $this->receiverEmail; |
|
| 272 | - } |
|
| 269 | + public function getReceiverEmail() |
|
| 270 | + { |
|
| 271 | + return $this->receiverEmail; |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - /*** |
|
| 274 | + /*** |
|
| 275 | 275 | * Sets the receiver email |
| 276 | 276 | * @param string $receiverEmail |
| 277 | 277 | */ |
| 278 | - public function setReceiverEmail($receiverEmail) |
|
| 279 | - { |
|
| 280 | - $this->receiverEmail = $receiverEmail; |
|
| 281 | - } |
|
| 278 | + public function setReceiverEmail($receiverEmail) |
|
| 279 | + { |
|
| 280 | + $this->receiverEmail = $receiverEmail; |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - /*** |
|
| 283 | + /*** |
|
| 284 | 284 | * @return String the currency |
| 285 | 285 | * Example: BRL |
| 286 | 286 | */ |
| 287 | - public function getCurrency() |
|
| 288 | - { |
|
| 289 | - return $this->currency; |
|
| 290 | - } |
|
| 287 | + public function getCurrency() |
|
| 288 | + { |
|
| 289 | + return $this->currency; |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | - /*** |
|
| 292 | + /*** |
|
| 293 | 293 | * Sets the currency |
| 294 | 294 | * @param String $currency |
| 295 | 295 | */ |
| 296 | - public function setCurrency($currency) |
|
| 297 | - { |
|
| 298 | - $this->currency = $currency; |
|
| 299 | - } |
|
| 296 | + public function setCurrency($currency) |
|
| 297 | + { |
|
| 298 | + $this->currency = $currency; |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - /*** |
|
| 301 | + /*** |
|
| 302 | 302 | * @return array the items/products list in this payment request |
| 303 | 303 | */ |
| 304 | - public function getItems() |
|
| 305 | - { |
|
| 306 | - return $this->items; |
|
| 307 | - } |
|
| 304 | + public function getItems() |
|
| 305 | + { |
|
| 306 | + return $this->items; |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - /*** |
|
| 309 | + /*** |
|
| 310 | 310 | * Sets the items/products list in this payment request |
| 311 | 311 | * @param array $items |
| 312 | 312 | */ |
| 313 | - public function setItems(array $items) |
|
| 314 | - { |
|
| 315 | - if (is_array($items)) { |
|
| 316 | - $i = array(); |
|
| 317 | - foreach ($items as $key => $item) { |
|
| 318 | - if ($item instanceof PagSeguroItem) { |
|
| 319 | - $i[$key] = $item; |
|
| 320 | - } else { |
|
| 321 | - if (is_array($item)) { |
|
| 322 | - $i[$key] = new PagSeguroItem($item); |
|
| 323 | - } |
|
| 324 | - } |
|
| 325 | - } |
|
| 326 | - $this->items = $i; |
|
| 327 | - } |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - /*** |
|
| 313 | + public function setItems(array $items) |
|
| 314 | + { |
|
| 315 | + if (is_array($items)) { |
|
| 316 | + $i = array(); |
|
| 317 | + foreach ($items as $key => $item) { |
|
| 318 | + if ($item instanceof PagSeguroItem) { |
|
| 319 | + $i[$key] = $item; |
|
| 320 | + } else { |
|
| 321 | + if (is_array($item)) { |
|
| 322 | + $i[$key] = new PagSeguroItem($item); |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | + $this->items = $i; |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + /*** |
|
| 331 | 331 | * @param array|object $items |
| 332 | 332 | * @param array|object|bool $shipping |
| 333 | 333 | * @return float sun of total items amount |
| 334 | 334 | */ |
| 335 | - public function getItemsTotalAmount($items, $shipping = false) |
|
| 336 | - { |
|
| 337 | - |
|
| 338 | - foreach ($items as $item) |
|
| 339 | - { |
|
| 340 | - if (isset($amount)) { |
|
| 341 | - $amount = $amount + ($item->getAmount() * $item->getQuantity()); |
|
| 342 | - if ($shipping) { |
|
| 343 | - $amount = $amount + $item->getShippingCost(); |
|
| 344 | - } |
|
| 345 | - } else { |
|
| 346 | - $amount = $item->getAmount() * $item->getQuantity(); |
|
| 347 | - if ($shipping) { |
|
| 348 | - $amount = $amount + $item->getShippingCost(); |
|
| 349 | - } |
|
| 350 | - } |
|
| 351 | - } |
|
| 352 | - return PagSeguroHelper::decimalFormat($amount); |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - /*** |
|
| 335 | + public function getItemsTotalAmount($items, $shipping = false) |
|
| 336 | + { |
|
| 337 | + |
|
| 338 | + foreach ($items as $item) |
|
| 339 | + { |
|
| 340 | + if (isset($amount)) { |
|
| 341 | + $amount = $amount + ($item->getAmount() * $item->getQuantity()); |
|
| 342 | + if ($shipping) { |
|
| 343 | + $amount = $amount + $item->getShippingCost(); |
|
| 344 | + } |
|
| 345 | + } else { |
|
| 346 | + $amount = $item->getAmount() * $item->getQuantity(); |
|
| 347 | + if ($shipping) { |
|
| 348 | + $amount = $amount + $item->getShippingCost(); |
|
| 349 | + } |
|
| 350 | + } |
|
| 351 | + } |
|
| 352 | + return PagSeguroHelper::decimalFormat($amount); |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + /*** |
|
| 356 | 356 | * Adds a new product/item in this payment request |
| 357 | 357 | * |
| 358 | 358 | * @param String $id |
@@ -362,60 +362,60 @@ discard block |
||
| 362 | 362 | * @param String $weight |
| 363 | 363 | * @param String $shippingCost |
| 364 | 364 | */ |
| 365 | - public function addItem( |
|
| 366 | - $id, |
|
| 367 | - $description = null, |
|
| 368 | - $quantity = null, |
|
| 369 | - $amount = null, |
|
| 370 | - $weight = null, |
|
| 371 | - $shippingCost = null |
|
| 372 | - ) { |
|
| 373 | - $param = $id; |
|
| 374 | - if ($this->items == null) { |
|
| 375 | - $this->items = array(); |
|
| 376 | - } |
|
| 377 | - if (is_array($param)) { |
|
| 378 | - array_push($this->items, new PagSeguroItem($param)); |
|
| 379 | - } else { |
|
| 380 | - if ($param instanceof PagSeguroItem) { |
|
| 381 | - array_push($this->items, $param); |
|
| 382 | - } else { |
|
| 383 | - $item = new PagSeguroItem(); |
|
| 384 | - $item->setId($param); |
|
| 385 | - $item->setDescription($description); |
|
| 386 | - $item->setQuantity($quantity); |
|
| 387 | - $item->setAmount($amount); |
|
| 388 | - $item->setWeight($weight); |
|
| 389 | - $item->setShippingCost($shippingCost); |
|
| 390 | - array_push($this->items, $item); |
|
| 391 | - } |
|
| 392 | - } |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - /*** |
|
| 365 | + public function addItem( |
|
| 366 | + $id, |
|
| 367 | + $description = null, |
|
| 368 | + $quantity = null, |
|
| 369 | + $amount = null, |
|
| 370 | + $weight = null, |
|
| 371 | + $shippingCost = null |
|
| 372 | + ) { |
|
| 373 | + $param = $id; |
|
| 374 | + if ($this->items == null) { |
|
| 375 | + $this->items = array(); |
|
| 376 | + } |
|
| 377 | + if (is_array($param)) { |
|
| 378 | + array_push($this->items, new PagSeguroItem($param)); |
|
| 379 | + } else { |
|
| 380 | + if ($param instanceof PagSeguroItem) { |
|
| 381 | + array_push($this->items, $param); |
|
| 382 | + } else { |
|
| 383 | + $item = new PagSeguroItem(); |
|
| 384 | + $item->setId($param); |
|
| 385 | + $item->setDescription($description); |
|
| 386 | + $item->setQuantity($quantity); |
|
| 387 | + $item->setAmount($amount); |
|
| 388 | + $item->setWeight($weight); |
|
| 389 | + $item->setShippingCost($shippingCost); |
|
| 390 | + array_push($this->items, $item); |
|
| 391 | + } |
|
| 392 | + } |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + /*** |
|
| 396 | 396 | * Add sender document |
| 397 | 397 | * @param string $type |
| 398 | 398 | * @param string $value |
| 399 | 399 | */ |
| 400 | - public function addSenderDocument($type, $value) |
|
| 401 | - { |
|
| 402 | - if ($this->getSender() instanceof PagSeguroSender) { |
|
| 403 | - $this->getSender()->addDocument($type, $value); |
|
| 404 | - } |
|
| 405 | - } |
|
| 400 | + public function addSenderDocument($type, $value) |
|
| 401 | + { |
|
| 402 | + if ($this->getSender() instanceof PagSeguroSender) { |
|
| 403 | + $this->getSender()->addDocument($type, $value); |
|
| 404 | + } |
|
| 405 | + } |
|
| 406 | 406 | |
| 407 | - /*** |
|
| 407 | + /*** |
|
| 408 | 408 | * URI to where the PagSeguro payment page should redirect the user after the payment information is processed. |
| 409 | 409 | * Typically this is a confirmation page on your web site. |
| 410 | 410 | * |
| 411 | 411 | * @return String the redirectURL |
| 412 | 412 | */ |
| 413 | - public function getRedirectURL() |
|
| 414 | - { |
|
| 415 | - return $this->redirectURL; |
|
| 416 | - } |
|
| 413 | + public function getRedirectURL() |
|
| 414 | + { |
|
| 415 | + return $this->redirectURL; |
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | - /*** |
|
| 418 | + /*** |
|
| 419 | 419 | * Sets the redirect URL |
| 420 | 420 | * |
| 421 | 421 | * Uri to where the PagSeguro payment page should redirect the user after the payment information is processed. |
@@ -423,91 +423,91 @@ discard block |
||
| 423 | 423 | * |
| 424 | 424 | * @param String $redirectURL |
| 425 | 425 | */ |
| 426 | - public function setRedirectURL($redirectURL) |
|
| 427 | - { |
|
| 428 | - $this->redirectURL = $this->verifyURLTest($redirectURL); |
|
| 429 | - } |
|
| 426 | + public function setRedirectURL($redirectURL) |
|
| 427 | + { |
|
| 428 | + $this->redirectURL = $this->verifyURLTest($redirectURL); |
|
| 429 | + } |
|
| 430 | 430 | |
| 431 | - /*** |
|
| 431 | + /*** |
|
| 432 | 432 | * This value can be used to add an extra charge to the transaction |
| 433 | 433 | * or provide a discount in the case ExtraAmount is a negative value. |
| 434 | 434 | * |
| 435 | 435 | * @return float the extra amount |
| 436 | 436 | */ |
| 437 | - public function getExtraAmount() |
|
| 438 | - { |
|
| 439 | - return $this->extraAmount; |
|
| 440 | - } |
|
| 437 | + public function getExtraAmount() |
|
| 438 | + { |
|
| 439 | + return $this->extraAmount; |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | - /*** |
|
| 442 | + /*** |
|
| 443 | 443 | * Sets the extra amount |
| 444 | 444 | * This value can be used to add an extra charge to the transaction |
| 445 | 445 | * or provide a discount in the case <b>extraAmount</b> is a negative value. |
| 446 | 446 | * |
| 447 | 447 | * @param extraAmount |
| 448 | 448 | */ |
| 449 | - public function setExtraAmount($extraAmount) |
|
| 450 | - { |
|
| 451 | - $this->extraAmount = $extraAmount; |
|
| 452 | - } |
|
| 449 | + public function setExtraAmount($extraAmount) |
|
| 450 | + { |
|
| 451 | + $this->extraAmount = $extraAmount; |
|
| 452 | + } |
|
| 453 | 453 | |
| 454 | - /*** |
|
| 454 | + /*** |
|
| 455 | 455 | * @return mixed the reference of this payment request |
| 456 | 456 | */ |
| 457 | - public function getReference() |
|
| 458 | - { |
|
| 459 | - return $this->reference; |
|
| 460 | - } |
|
| 457 | + public function getReference() |
|
| 458 | + { |
|
| 459 | + return $this->reference; |
|
| 460 | + } |
|
| 461 | 461 | |
| 462 | - /*** |
|
| 462 | + /*** |
|
| 463 | 463 | * Sets the reference of this payment request |
| 464 | 464 | * @param reference |
| 465 | 465 | */ |
| 466 | - public function setReference($reference) |
|
| 467 | - { |
|
| 468 | - $this->reference = $reference; |
|
| 469 | - } |
|
| 466 | + public function setReference($reference) |
|
| 467 | + { |
|
| 468 | + $this->reference = $reference; |
|
| 469 | + } |
|
| 470 | 470 | |
| 471 | - /*** |
|
| 471 | + /*** |
|
| 472 | 472 | * @return PagSeguroShipping the shipping information for this payment request |
| 473 | 473 | * @see PagSeguroShipping |
| 474 | 474 | */ |
| 475 | - public function getShipping() |
|
| 476 | - { |
|
| 477 | - return $this->shipping; |
|
| 478 | - } |
|
| 475 | + public function getShipping() |
|
| 476 | + { |
|
| 477 | + return $this->shipping; |
|
| 478 | + } |
|
| 479 | 479 | |
| 480 | - /*** |
|
| 480 | + /*** |
|
| 481 | 481 | * Sets the shipping information for this payment request |
| 482 | 482 | * @param PagSeguroShipping $address |
| 483 | 483 | * @param PagSeguroShippingType $type |
| 484 | 484 | */ |
| 485 | - public function setShipping($address, $type = null) |
|
| 486 | - { |
|
| 487 | - $param = $address; |
|
| 488 | - if ($param instanceof PagSeguroShipping) { |
|
| 489 | - $this->shipping = $param; |
|
| 490 | - } else { |
|
| 491 | - $shipping = new PagSeguroShipping(); |
|
| 492 | - if (is_array($param)) { |
|
| 493 | - $shipping->setAddress(new PagSeguroAddress($param)); |
|
| 494 | - } else { |
|
| 495 | - if ($param instanceof PagSeguroAddress) { |
|
| 496 | - $shipping->setAddress($param); |
|
| 497 | - } |
|
| 498 | - } |
|
| 499 | - if ($type) { |
|
| 500 | - if ($type instanceof PagSeguroShippingType) { |
|
| 501 | - $shipping->setType($type); |
|
| 502 | - } else { |
|
| 503 | - $shipping->setType(new PagSeguroShippingType($type)); |
|
| 504 | - } |
|
| 505 | - } |
|
| 506 | - $this->shipping = $shipping; |
|
| 507 | - } |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - /*** |
|
| 485 | + public function setShipping($address, $type = null) |
|
| 486 | + { |
|
| 487 | + $param = $address; |
|
| 488 | + if ($param instanceof PagSeguroShipping) { |
|
| 489 | + $this->shipping = $param; |
|
| 490 | + } else { |
|
| 491 | + $shipping = new PagSeguroShipping(); |
|
| 492 | + if (is_array($param)) { |
|
| 493 | + $shipping->setAddress(new PagSeguroAddress($param)); |
|
| 494 | + } else { |
|
| 495 | + if ($param instanceof PagSeguroAddress) { |
|
| 496 | + $shipping->setAddress($param); |
|
| 497 | + } |
|
| 498 | + } |
|
| 499 | + if ($type) { |
|
| 500 | + if ($type instanceof PagSeguroShippingType) { |
|
| 501 | + $shipping->setType($type); |
|
| 502 | + } else { |
|
| 503 | + $shipping->setType(new PagSeguroShippingType($type)); |
|
| 504 | + } |
|
| 505 | + } |
|
| 506 | + $this->shipping = $shipping; |
|
| 507 | + } |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + /*** |
|
| 511 | 511 | * Sets the shipping address for this payment request |
| 512 | 512 | * @param String $postalCode |
| 513 | 513 | * @param String $street |
@@ -518,121 +518,121 @@ discard block |
||
| 518 | 518 | * @param String $state |
| 519 | 519 | * @param String $country |
| 520 | 520 | */ |
| 521 | - public function setShippingAddress( |
|
| 522 | - $postalCode = null, |
|
| 523 | - $street = null, |
|
| 524 | - $number = null, |
|
| 525 | - $complement = null, |
|
| 526 | - $district = null, |
|
| 527 | - $city = null, |
|
| 528 | - $state = null, |
|
| 529 | - $country = null |
|
| 530 | - ) { |
|
| 531 | - $param = $postalCode; |
|
| 532 | - if ($this->shipping == null) { |
|
| 533 | - $this->shipping = new PagSeguroShipping(); |
|
| 534 | - } |
|
| 535 | - if (is_array($param)) { |
|
| 536 | - $this->shipping->setAddress(new PagSeguroAddress($param)); |
|
| 537 | - } elseif ($param instanceof PagSeguroAddress) { |
|
| 538 | - $this->shipping->setAddress($param); |
|
| 539 | - } else { |
|
| 540 | - $address = new PagSeguroAddress(); |
|
| 541 | - $address->setPostalCode($postalCode); |
|
| 542 | - $address->setStreet($street); |
|
| 543 | - $address->setNumber($number); |
|
| 544 | - $address->setComplement($complement); |
|
| 545 | - $address->setDistrict($district); |
|
| 546 | - $address->setCity($city); |
|
| 547 | - $address->setState($state); |
|
| 548 | - $address->setCountry($country); |
|
| 549 | - $this->shipping->setAddress($address); |
|
| 550 | - } |
|
| 551 | - } |
|
| 552 | - |
|
| 553 | - /*** |
|
| 521 | + public function setShippingAddress( |
|
| 522 | + $postalCode = null, |
|
| 523 | + $street = null, |
|
| 524 | + $number = null, |
|
| 525 | + $complement = null, |
|
| 526 | + $district = null, |
|
| 527 | + $city = null, |
|
| 528 | + $state = null, |
|
| 529 | + $country = null |
|
| 530 | + ) { |
|
| 531 | + $param = $postalCode; |
|
| 532 | + if ($this->shipping == null) { |
|
| 533 | + $this->shipping = new PagSeguroShipping(); |
|
| 534 | + } |
|
| 535 | + if (is_array($param)) { |
|
| 536 | + $this->shipping->setAddress(new PagSeguroAddress($param)); |
|
| 537 | + } elseif ($param instanceof PagSeguroAddress) { |
|
| 538 | + $this->shipping->setAddress($param); |
|
| 539 | + } else { |
|
| 540 | + $address = new PagSeguroAddress(); |
|
| 541 | + $address->setPostalCode($postalCode); |
|
| 542 | + $address->setStreet($street); |
|
| 543 | + $address->setNumber($number); |
|
| 544 | + $address->setComplement($complement); |
|
| 545 | + $address->setDistrict($district); |
|
| 546 | + $address->setCity($city); |
|
| 547 | + $address->setState($state); |
|
| 548 | + $address->setCountry($country); |
|
| 549 | + $this->shipping->setAddress($address); |
|
| 550 | + } |
|
| 551 | + } |
|
| 552 | + |
|
| 553 | + /*** |
|
| 554 | 554 | * Sets the shipping type for this payment request |
| 555 | 555 | * @param PagSeguroShippingType $type |
| 556 | 556 | */ |
| 557 | - public function setShippingType($type) |
|
| 558 | - { |
|
| 559 | - $param = $type; |
|
| 560 | - if ($this->shipping == null) { |
|
| 561 | - $this->shipping = new PagSeguroShipping(); |
|
| 562 | - } |
|
| 563 | - if ($param instanceof PagSeguroShippingType) { |
|
| 564 | - $this->shipping->setType($param); |
|
| 565 | - } else { |
|
| 566 | - $this->shipping->setType(new PagSeguroShippingType($param)); |
|
| 567 | - } |
|
| 568 | - } |
|
| 569 | - |
|
| 570 | - /*** |
|
| 557 | + public function setShippingType($type) |
|
| 558 | + { |
|
| 559 | + $param = $type; |
|
| 560 | + if ($this->shipping == null) { |
|
| 561 | + $this->shipping = new PagSeguroShipping(); |
|
| 562 | + } |
|
| 563 | + if ($param instanceof PagSeguroShippingType) { |
|
| 564 | + $this->shipping->setType($param); |
|
| 565 | + } else { |
|
| 566 | + $this->shipping->setType(new PagSeguroShippingType($param)); |
|
| 567 | + } |
|
| 568 | + } |
|
| 569 | + |
|
| 570 | + /*** |
|
| 571 | 571 | * Sets the shipping cost for this payment request |
| 572 | 572 | * @param float $shippingCost |
| 573 | 573 | */ |
| 574 | - public function setShippingCost($shippingCost) |
|
| 575 | - { |
|
| 576 | - $param = $shippingCost; |
|
| 577 | - if ($this->shipping == null) { |
|
| 578 | - $this->shipping = new PagSeguroShipping(); |
|
| 579 | - } |
|
| 574 | + public function setShippingCost($shippingCost) |
|
| 575 | + { |
|
| 576 | + $param = $shippingCost; |
|
| 577 | + if ($this->shipping == null) { |
|
| 578 | + $this->shipping = new PagSeguroShipping(); |
|
| 579 | + } |
|
| 580 | 580 | |
| 581 | - $this->shipping->setCost($param); |
|
| 582 | - } |
|
| 581 | + $this->shipping->setCost($param); |
|
| 582 | + } |
|
| 583 | 583 | |
| 584 | 584 | /*** |
| 585 | 585 | * @return String payment mode for this payment request |
| 586 | 586 | */ |
| 587 | - public function getPaymentMode() |
|
| 588 | - { |
|
| 589 | - return $this->paymentMode; |
|
| 590 | - } |
|
| 587 | + public function getPaymentMode() |
|
| 588 | + { |
|
| 589 | + return $this->paymentMode; |
|
| 590 | + } |
|
| 591 | 591 | |
| 592 | - /*** |
|
| 592 | + /*** |
|
| 593 | 593 | * Sets payment mode for this payment request |
| 594 | 594 | * @param string|object $mode |
| 595 | 595 | */ |
| 596 | - public function setPaymentMode($mode) |
|
| 597 | - { |
|
| 598 | - |
|
| 599 | - try { |
|
| 600 | - if ($mode instanceof PagSeguroPaymentMode) { |
|
| 601 | - $this->paymentMode = $mode; |
|
| 602 | - } else { |
|
| 603 | - $this->paymentMode = new PagSeguroPaymentMode($mode); |
|
| 604 | - } |
|
| 605 | - } catch (Exception $e) { |
|
| 606 | - die($e->getMessage()); |
|
| 607 | - } |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - /*** |
|
| 596 | + public function setPaymentMode($mode) |
|
| 597 | + { |
|
| 598 | + |
|
| 599 | + try { |
|
| 600 | + if ($mode instanceof PagSeguroPaymentMode) { |
|
| 601 | + $this->paymentMode = $mode; |
|
| 602 | + } else { |
|
| 603 | + $this->paymentMode = new PagSeguroPaymentMode($mode); |
|
| 604 | + } |
|
| 605 | + } catch (Exception $e) { |
|
| 606 | + die($e->getMessage()); |
|
| 607 | + } |
|
| 608 | + } |
|
| 609 | + |
|
| 610 | + /*** |
|
| 611 | 611 | * @return PagSeguroPaymentMethod payment method for this payment request |
| 612 | 612 | */ |
| 613 | - public function getPaymentMethod() |
|
| 614 | - { |
|
| 615 | - return $this->paymentMethod; |
|
| 616 | - } |
|
| 613 | + public function getPaymentMethod() |
|
| 614 | + { |
|
| 615 | + return $this->paymentMethod; |
|
| 616 | + } |
|
| 617 | 617 | |
| 618 | - /*** |
|
| 618 | + /*** |
|
| 619 | 619 | * Sets payment method for this payment request |
| 620 | 620 | * @param string|object $method |
| 621 | 621 | */ |
| 622 | - public function setPaymentMethod($method) |
|
| 623 | - { |
|
| 624 | - try { |
|
| 625 | - if ($method instanceof PagSeguroDirectPaymentMethods) { |
|
| 626 | - $this->paymentMethod = $method; |
|
| 627 | - } else { |
|
| 628 | - $this->paymentMethod = new PagSeguroDirectPaymentMethods($method); |
|
| 629 | - } |
|
| 630 | - } catch (Exception $e) { |
|
| 631 | - die($e->getMessage()); |
|
| 632 | - } |
|
| 633 | - } |
|
| 634 | - |
|
| 635 | - /*** |
|
| 622 | + public function setPaymentMethod($method) |
|
| 623 | + { |
|
| 624 | + try { |
|
| 625 | + if ($method instanceof PagSeguroDirectPaymentMethods) { |
|
| 626 | + $this->paymentMethod = $method; |
|
| 627 | + } else { |
|
| 628 | + $this->paymentMethod = new PagSeguroDirectPaymentMethods($method); |
|
| 629 | + } |
|
| 630 | + } catch (Exception $e) { |
|
| 631 | + die($e->getMessage()); |
|
| 632 | + } |
|
| 633 | + } |
|
| 634 | + |
|
| 635 | + /*** |
|
| 636 | 636 | * Sets the billing address for this payment request |
| 637 | 637 | * @param String $postalCode |
| 638 | 638 | * @param String $street |
@@ -643,146 +643,146 @@ discard block |
||
| 643 | 643 | * @param String $state |
| 644 | 644 | * @param String $country |
| 645 | 645 | */ |
| 646 | - public function setBillingAdress( |
|
| 647 | - $postalCode, |
|
| 648 | - $street = null, |
|
| 649 | - $number = null, |
|
| 650 | - $complement = null, |
|
| 651 | - $district = null, |
|
| 652 | - $city = null, |
|
| 653 | - $state = null, |
|
| 654 | - $country = null |
|
| 655 | - ) { |
|
| 656 | - |
|
| 657 | - $param = $postalCode; |
|
| 658 | - $this->billing = new PagSeguroBilling(); |
|
| 659 | - if (isset($param) and is_array($param)){ |
|
| 660 | - $this->billing->setAddress(new PagSeguroAddress($param)); |
|
| 661 | - } elseif ($param instanceof PagSeguroAddress) { |
|
| 662 | - $this->billing->setAddress($param); |
|
| 663 | - } else { |
|
| 664 | - $billindAdress = array( |
|
| 665 | - 'postalCode' => '01452002', |
|
| 666 | - 'street' => 'Av. Brig. Faria Lima', |
|
| 667 | - 'number' => '1384', |
|
| 668 | - 'complement' => 'apto. 114', |
|
| 669 | - 'district' => 'Jardim Paulistano', |
|
| 670 | - 'city' => 'São Paulo', |
|
| 671 | - 'state' => 'SP', |
|
| 672 | - 'country' => 'BRA' |
|
| 673 | - ); |
|
| 646 | + public function setBillingAdress( |
|
| 647 | + $postalCode, |
|
| 648 | + $street = null, |
|
| 649 | + $number = null, |
|
| 650 | + $complement = null, |
|
| 651 | + $district = null, |
|
| 652 | + $city = null, |
|
| 653 | + $state = null, |
|
| 654 | + $country = null |
|
| 655 | + ) { |
|
| 656 | + |
|
| 657 | + $param = $postalCode; |
|
| 658 | + $this->billing = new PagSeguroBilling(); |
|
| 659 | + if (isset($param) and is_array($param)){ |
|
| 660 | + $this->billing->setAddress(new PagSeguroAddress($param)); |
|
| 661 | + } elseif ($param instanceof PagSeguroAddress) { |
|
| 662 | + $this->billing->setAddress($param); |
|
| 663 | + } else { |
|
| 664 | + $billindAdress = array( |
|
| 665 | + 'postalCode' => '01452002', |
|
| 666 | + 'street' => 'Av. Brig. Faria Lima', |
|
| 667 | + 'number' => '1384', |
|
| 668 | + 'complement' => 'apto. 114', |
|
| 669 | + 'district' => 'Jardim Paulistano', |
|
| 670 | + 'city' => 'São Paulo', |
|
| 671 | + 'state' => 'SP', |
|
| 672 | + 'country' => 'BRA' |
|
| 673 | + ); |
|
| 674 | 674 | |
| 675 | - $this->billing->setAddress($billindAdress); |
|
| 676 | - } |
|
| 677 | - } |
|
| 675 | + $this->billing->setAddress($billindAdress); |
|
| 676 | + } |
|
| 677 | + } |
|
| 678 | 678 | |
| 679 | - /*** |
|
| 679 | + /*** |
|
| 680 | 680 | * @return PagSeguroBilling the billing information for this payment request |
| 681 | 681 | * @see PagSeguroBilling |
| 682 | 682 | */ |
| 683 | - public function getBillingAdress() |
|
| 684 | - { |
|
| 685 | - return $this->billing; |
|
| 686 | - } |
|
| 683 | + public function getBillingAdress() |
|
| 684 | + { |
|
| 685 | + return $this->billing; |
|
| 686 | + } |
|
| 687 | 687 | |
| 688 | - /*** |
|
| 688 | + /*** |
|
| 689 | 689 | * Sets the info for credit card for this payment request |
| 690 | 690 | * @param array|object $params... |
| 691 | 691 | */ |
| 692 | - public function setCreditCard($params = null) |
|
| 693 | - { |
|
| 694 | - |
|
| 695 | - if ($params instanceof PagSeguroCreditCardCheckout) { |
|
| 696 | - $this->creditCard = $params; |
|
| 697 | - } else if (isset($params) && is_array($params)) { |
|
| 698 | - $this->creditCard = new PagSeguroCreditCardCheckout(); |
|
| 699 | - if (isset($params['token'])) { |
|
| 700 | - $this->creditCard->setToken($params['token']); |
|
| 701 | - } |
|
| 702 | - if (isset($params['installment']) && $params['installment'] instanceof PagSeguroInstallment) { |
|
| 703 | - $this->creditCard->setInstallment($params['installment']); |
|
| 704 | - } |
|
| 705 | - if (isset($params['holder']) && $params['holder'] instanceof PagSeguroCreditCardHolder) { |
|
| 706 | - $this->creditCard->setHolder($params['holder']); |
|
| 707 | - } |
|
| 708 | - if (isset($params['billing']) && $params['billing'] instanceof PagSeguroBilling) { |
|
| 709 | - $this->creditCard->setBilling($params['billing']); |
|
| 710 | - } |
|
| 711 | - } |
|
| 712 | - } |
|
| 713 | - |
|
| 714 | - /*** |
|
| 692 | + public function setCreditCard($params = null) |
|
| 693 | + { |
|
| 694 | + |
|
| 695 | + if ($params instanceof PagSeguroCreditCardCheckout) { |
|
| 696 | + $this->creditCard = $params; |
|
| 697 | + } else if (isset($params) && is_array($params)) { |
|
| 698 | + $this->creditCard = new PagSeguroCreditCardCheckout(); |
|
| 699 | + if (isset($params['token'])) { |
|
| 700 | + $this->creditCard->setToken($params['token']); |
|
| 701 | + } |
|
| 702 | + if (isset($params['installment']) && $params['installment'] instanceof PagSeguroInstallment) { |
|
| 703 | + $this->creditCard->setInstallment($params['installment']); |
|
| 704 | + } |
|
| 705 | + if (isset($params['holder']) && $params['holder'] instanceof PagSeguroCreditCardHolder) { |
|
| 706 | + $this->creditCard->setHolder($params['holder']); |
|
| 707 | + } |
|
| 708 | + if (isset($params['billing']) && $params['billing'] instanceof PagSeguroBilling) { |
|
| 709 | + $this->creditCard->setBilling($params['billing']); |
|
| 710 | + } |
|
| 711 | + } |
|
| 712 | + } |
|
| 713 | + |
|
| 714 | + /*** |
|
| 715 | 715 | * @return PagSeguroCreditCard the credit card info |
| 716 | 716 | * @see PagSeguroCreditCard |
| 717 | 717 | */ |
| 718 | - public function getCreditCard() |
|
| 719 | - { |
|
| 720 | - return $this->creditCard; |
|
| 721 | - } |
|
| 718 | + public function getCreditCard() |
|
| 719 | + { |
|
| 720 | + return $this->creditCard; |
|
| 721 | + } |
|
| 722 | 722 | |
| 723 | - /*** |
|
| 723 | + /*** |
|
| 724 | 724 | * @return string the bank name of this payment request for online debit |
| 725 | 725 | */ |
| 726 | - public function getOnlineDebit() |
|
| 727 | - { |
|
| 728 | - return $this->onlineDebit; |
|
| 729 | - } |
|
| 726 | + public function getOnlineDebit() |
|
| 727 | + { |
|
| 728 | + return $this->onlineDebit; |
|
| 729 | + } |
|
| 730 | 730 | |
| 731 | - /*** |
|
| 731 | + /*** |
|
| 732 | 732 | * Sets the bank name of this payment request for online debit |
| 733 | 733 | * @param string|object $bankName |
| 734 | 734 | */ |
| 735 | - public function setOnlineDebit($bankName) |
|
| 736 | - { |
|
| 735 | + public function setOnlineDebit($bankName) |
|
| 736 | + { |
|
| 737 | 737 | |
| 738 | - if ($bankName instanceof PagSeguroOnlineDebitCheckout) { |
|
| 739 | - $this->onlineDebit = $bankName; |
|
| 740 | - } else if (is_array($bankName)) { |
|
| 741 | - $this->onlineDebit = new PagSeguroOnlineDebitCheckout($bankName); |
|
| 742 | - }else { |
|
| 743 | - $this->onlineDebit = new PagSeguroOnlineDebitCheckout( |
|
| 744 | - array( |
|
| 745 | - "bankName" => $bankName |
|
| 746 | - ) |
|
| 747 | - ); |
|
| 748 | - } |
|
| 749 | - } |
|
| 750 | - |
|
| 751 | - /*** |
|
| 738 | + if ($bankName instanceof PagSeguroOnlineDebitCheckout) { |
|
| 739 | + $this->onlineDebit = $bankName; |
|
| 740 | + } else if (is_array($bankName)) { |
|
| 741 | + $this->onlineDebit = new PagSeguroOnlineDebitCheckout($bankName); |
|
| 742 | + }else { |
|
| 743 | + $this->onlineDebit = new PagSeguroOnlineDebitCheckout( |
|
| 744 | + array( |
|
| 745 | + "bankName" => $bankName |
|
| 746 | + ) |
|
| 747 | + ); |
|
| 748 | + } |
|
| 749 | + } |
|
| 750 | + |
|
| 751 | + /*** |
|
| 752 | 752 | * @return integer the max age of this payment request |
| 753 | 753 | * |
| 754 | 754 | * After this payment request is submitted, the payment code returned |
| 755 | 755 | * will remain valid for the period specified. |
| 756 | 756 | */ |
| 757 | - public function getMaxAge() |
|
| 758 | - { |
|
| 759 | - return $this->maxAge; |
|
| 760 | - } |
|
| 757 | + public function getMaxAge() |
|
| 758 | + { |
|
| 759 | + return $this->maxAge; |
|
| 760 | + } |
|
| 761 | 761 | |
| 762 | - /*** |
|
| 762 | + /*** |
|
| 763 | 763 | * Sets the max age of this payment request |
| 764 | 764 | * After this payment request is submitted, the payment code returned |
| 765 | 765 | * will remain valid for the period specified here. |
| 766 | 766 | * |
| 767 | 767 | * @param maxAge |
| 768 | 768 | */ |
| 769 | - public function setMaxAge($maxAge) |
|
| 770 | - { |
|
| 771 | - $this->maxAge = $maxAge; |
|
| 772 | - } |
|
| 769 | + public function setMaxAge($maxAge) |
|
| 770 | + { |
|
| 771 | + $this->maxAge = $maxAge; |
|
| 772 | + } |
|
| 773 | 773 | |
| 774 | - /*** |
|
| 774 | + /*** |
|
| 775 | 775 | * After this payment request is submitted, the payment redirect uri returned by |
| 776 | 776 | * the payment web service will remain valid for the number of uses specified here. |
| 777 | 777 | * |
| 778 | 778 | * @return integer the max uses configured for this payment request |
| 779 | 779 | */ |
| 780 | - public function getMaxUses() |
|
| 781 | - { |
|
| 782 | - return $this->maxUses; |
|
| 783 | - } |
|
| 780 | + public function getMaxUses() |
|
| 781 | + { |
|
| 782 | + return $this->maxUses; |
|
| 783 | + } |
|
| 784 | 784 | |
| 785 | - /*** |
|
| 785 | + /*** |
|
| 786 | 786 | * Sets the max uses of this payment request |
| 787 | 787 | * |
| 788 | 788 | * After this payment request is submitted, the payment redirect uri returned by |
@@ -790,162 +790,162 @@ discard block |
||
| 790 | 790 | * |
| 791 | 791 | * @param maxUses |
| 792 | 792 | */ |
| 793 | - public function setMaxUses($maxUses) |
|
| 794 | - { |
|
| 795 | - $this->maxUses = $maxUses; |
|
| 796 | - } |
|
| 793 | + public function setMaxUses($maxUses) |
|
| 794 | + { |
|
| 795 | + $this->maxUses = $maxUses; |
|
| 796 | + } |
|
| 797 | 797 | |
| 798 | - /*** |
|
| 798 | + /*** |
|
| 799 | 799 | * Get the notification status url |
| 800 | 800 | * |
| 801 | 801 | * @return String |
| 802 | 802 | */ |
| 803 | - public function getNotificationURL() |
|
| 804 | - { |
|
| 805 | - return $this->notificationURL; |
|
| 806 | - } |
|
| 803 | + public function getNotificationURL() |
|
| 804 | + { |
|
| 805 | + return $this->notificationURL; |
|
| 806 | + } |
|
| 807 | 807 | |
| 808 | - /*** |
|
| 808 | + /*** |
|
| 809 | 809 | * Sets the url that PagSeguro will send the new notifications statuses |
| 810 | 810 | * |
| 811 | 811 | * @param String $notificationURL |
| 812 | 812 | */ |
| 813 | - public function setNotificationURL($notificationURL) |
|
| 814 | - { |
|
| 815 | - $this->notificationURL = $this->verifyURLTest($notificationURL); |
|
| 816 | - } |
|
| 813 | + public function setNotificationURL($notificationURL) |
|
| 814 | + { |
|
| 815 | + $this->notificationURL = $this->verifyURLTest($notificationURL); |
|
| 816 | + } |
|
| 817 | 817 | |
| 818 | - /*** |
|
| 818 | + /*** |
|
| 819 | 819 | * Sets metadata for PagSeguro checkout requests |
| 820 | 820 | * |
| 821 | 821 | * @param PagSeguroMetaData $metaData |
| 822 | 822 | */ |
| 823 | - public function setMetaData($metaData) |
|
| 824 | - { |
|
| 825 | - $this->metadata = $metaData; |
|
| 826 | - } |
|
| 823 | + public function setMetaData($metaData) |
|
| 824 | + { |
|
| 825 | + $this->metadata = $metaData; |
|
| 826 | + } |
|
| 827 | 827 | |
| 828 | - /*** |
|
| 828 | + /*** |
|
| 829 | 829 | * Gets metadata for PagSeguro checkout requests |
| 830 | 830 | * |
| 831 | 831 | * @return PagSeguroMetaData $metaData |
| 832 | 832 | */ |
| 833 | - public function getMetaData() |
|
| 834 | - { |
|
| 833 | + public function getMetaData() |
|
| 834 | + { |
|
| 835 | 835 | |
| 836 | - if ($this->metadata == null) { |
|
| 837 | - $this->metadata = new PagSeguroMetaData(); |
|
| 838 | - } |
|
| 839 | - return $this->metadata; |
|
| 840 | - } |
|
| 836 | + if ($this->metadata == null) { |
|
| 837 | + $this->metadata = new PagSeguroMetaData(); |
|
| 838 | + } |
|
| 839 | + return $this->metadata; |
|
| 840 | + } |
|
| 841 | 841 | |
| 842 | - /*** |
|
| 842 | + /*** |
|
| 843 | 843 | * add a parameter for PagSeguro metadata checkout request |
| 844 | 844 | * |
| 845 | 845 | * @param PagSeguroMetaDataItem $itemKey key |
| 846 | 846 | * @param PagSeguroMetaDataItem $itemValue value |
| 847 | 847 | * @param PagSeguroMetaDataItem $itemGroup group |
| 848 | 848 | */ |
| 849 | - public function addMetaData($itemKey, $itemValue, $itemGroup = null) |
|
| 850 | - { |
|
| 851 | - $this->getMetaData()->addItem(new PagSeguroMetaDataItem($itemKey, $itemValue, $itemGroup)); |
|
| 852 | - } |
|
| 849 | + public function addMetaData($itemKey, $itemValue, $itemGroup = null) |
|
| 850 | + { |
|
| 851 | + $this->getMetaData()->addItem(new PagSeguroMetaDataItem($itemKey, $itemValue, $itemGroup)); |
|
| 852 | + } |
|
| 853 | 853 | |
| 854 | - /*** |
|
| 854 | + /*** |
|
| 855 | 855 | * Sets parameter for PagSeguro checkout requests |
| 856 | 856 | * |
| 857 | 857 | * @param PagSeguroParameter $parameter |
| 858 | 858 | */ |
| 859 | - public function setParameter($parameter) |
|
| 860 | - { |
|
| 861 | - $this->parameter = $parameter; |
|
| 862 | - } |
|
| 859 | + public function setParameter($parameter) |
|
| 860 | + { |
|
| 861 | + $this->parameter = $parameter; |
|
| 862 | + } |
|
| 863 | 863 | |
| 864 | - /*** |
|
| 864 | + /*** |
|
| 865 | 865 | * Gets parameter for PagSeguro checkout requests |
| 866 | 866 | * |
| 867 | 867 | * @return PagSeguroParameter |
| 868 | 868 | */ |
| 869 | - public function getParameter() |
|
| 870 | - { |
|
| 871 | - if ($this->parameter == null) { |
|
| 872 | - $this->parameter = new PagSeguroParameter(); |
|
| 873 | - } |
|
| 874 | - return $this->parameter; |
|
| 875 | - } |
|
| 869 | + public function getParameter() |
|
| 870 | + { |
|
| 871 | + if ($this->parameter == null) { |
|
| 872 | + $this->parameter = new PagSeguroParameter(); |
|
| 873 | + } |
|
| 874 | + return $this->parameter; |
|
| 875 | + } |
|
| 876 | 876 | |
| 877 | - /*** |
|
| 877 | + /*** |
|
| 878 | 878 | * add a parameter for PagSeguro checkout request |
| 879 | 879 | * |
| 880 | 880 | * @param PagSeguroParameterItem $parameterName key |
| 881 | 881 | * @param PagSeguroParameterItem $parameterValue value |
| 882 | 882 | */ |
| 883 | - public function addParameter($parameterName, $parameterValue) |
|
| 884 | - { |
|
| 885 | - $this->getParameter()->addItem(new PagSeguroParameterItem($parameterName, $parameterValue)); |
|
| 886 | - } |
|
| 883 | + public function addParameter($parameterName, $parameterValue) |
|
| 884 | + { |
|
| 885 | + $this->getParameter()->addItem(new PagSeguroParameterItem($parameterName, $parameterValue)); |
|
| 886 | + } |
|
| 887 | 887 | |
| 888 | - /*** |
|
| 888 | + /*** |
|
| 889 | 889 | * add a parameter for PagSeguro checkout request |
| 890 | 890 | * |
| 891 | 891 | * @param PagSeguroParameterItem $parameterName key |
| 892 | 892 | * @param PagSeguroParameterItem $parameterValue value |
| 893 | 893 | * @param PagSeguroParameterItem $parameterIndex group |
| 894 | 894 | */ |
| 895 | - public function addIndexedParameter($parameterName, $parameterValue, $parameterIndex) |
|
| 896 | - { |
|
| 897 | - $this->getParameter()->addItem(new PagSeguroParameterItem($parameterName, $parameterValue, $parameterIndex)); |
|
| 898 | - } |
|
| 895 | + public function addIndexedParameter($parameterName, $parameterValue, $parameterIndex) |
|
| 896 | + { |
|
| 897 | + $this->getParameter()->addItem(new PagSeguroParameterItem($parameterName, $parameterValue, $parameterIndex)); |
|
| 898 | + } |
|
| 899 | 899 | |
| 900 | - /*** |
|
| 900 | + /*** |
|
| 901 | 901 | * Calls the PagSeguro web service and register this request for payment |
| 902 | 902 | * |
| 903 | 903 | * @param PagSeguroCredentials $credentials, lighbox |
| 904 | 904 | * @return String The URL to where the user needs to be redirected to in order to complete the payment process or |
| 905 | 905 | * the CODE when use lightbox |
| 906 | 906 | */ |
| 907 | - public function register(PagSeguroCredentials $credentials) |
|
| 908 | - { |
|
| 909 | - return PagSeguroDirectPaymentService::createCheckoutRequest($credentials, $this); |
|
| 910 | - } |
|
| 907 | + public function register(PagSeguroCredentials $credentials) |
|
| 908 | + { |
|
| 909 | + return PagSeguroDirectPaymentService::createCheckoutRequest($credentials, $this); |
|
| 910 | + } |
|
| 911 | 911 | |
| 912 | - /*** |
|
| 912 | + /*** |
|
| 913 | 913 | * @return String a string that represents the current object |
| 914 | 914 | */ |
| 915 | - public function toString() |
|
| 916 | - { |
|
| 917 | - $email = $this->sender ? $this->sender->getEmail() : "null"; |
|
| 915 | + public function toString() |
|
| 916 | + { |
|
| 917 | + $email = $this->sender ? $this->sender->getEmail() : "null"; |
|
| 918 | 918 | |
| 919 | - $request = array(); |
|
| 920 | - $request['Reference'] = $this->reference; |
|
| 921 | - $request['SenderEmail'] = $email; |
|
| 919 | + $request = array(); |
|
| 920 | + $request['Reference'] = $this->reference; |
|
| 921 | + $request['SenderEmail'] = $email; |
|
| 922 | 922 | |
| 923 | - return "PagSeguroPaymentRequest: " . var_export($request, true); |
|
| 924 | - } |
|
| 923 | + return "PagSeguroPaymentRequest: " . var_export($request, true); |
|
| 924 | + } |
|
| 925 | 925 | |
| 926 | - /*** |
|
| 926 | + /*** |
|
| 927 | 927 | * Verify if the adress of NotificationURL or RedirectURL is for tests and return empty |
| 928 | 928 | * @param type $url |
| 929 | 929 | * @return type |
| 930 | 930 | */ |
| 931 | - public function verifyURLTest($url) |
|
| 932 | - { |
|
| 933 | - $adress = array( |
|
| 934 | - '127.0.0.1', |
|
| 935 | - '::1' |
|
| 936 | - ); |
|
| 937 | - |
|
| 938 | - $urlReturn; |
|
| 939 | - foreach ($adress as $item) { |
|
| 940 | - $find = strpos($url, $item); |
|
| 941 | - |
|
| 942 | - if ($find) { |
|
| 943 | - $urlReturn = ''; |
|
| 944 | - break; |
|
| 945 | - } else { |
|
| 946 | - $urlReturn = $url; |
|
| 947 | - } |
|
| 948 | - } |
|
| 949 | - return $urlReturn; |
|
| 950 | - } |
|
| 931 | + public function verifyURLTest($url) |
|
| 932 | + { |
|
| 933 | + $adress = array( |
|
| 934 | + '127.0.0.1', |
|
| 935 | + '::1' |
|
| 936 | + ); |
|
| 937 | + |
|
| 938 | + $urlReturn; |
|
| 939 | + foreach ($adress as $item) { |
|
| 940 | + $find = strpos($url, $item); |
|
| 941 | + |
|
| 942 | + if ($find) { |
|
| 943 | + $urlReturn = ''; |
|
| 944 | + break; |
|
| 945 | + } else { |
|
| 946 | + $urlReturn = $url; |
|
| 947 | + } |
|
| 948 | + } |
|
| 949 | + return $urlReturn; |
|
| 950 | + } |
|
| 951 | 951 | } |
| 952 | 952 | \ No newline at end of file |
@@ -47,6 +47,11 @@ |
||
| 47 | 47 | */ |
| 48 | 48 | private $group; |
| 49 | 49 | |
| 50 | + /** |
|
| 51 | + * @param PagSeguroMetaDataItem $key |
|
| 52 | + * @param PagSeguroMetaDataItem $value |
|
| 53 | + * @param PagSeguroMetaDataItem $group |
|
| 54 | + */ |
|
| 50 | 55 | public function __construct($key = null, $value = null, $group = null) |
| 51 | 56 | { |
| 52 | 57 | |
@@ -50,13 +50,13 @@ |
||
| 50 | 50 | public function __construct($key = null, $value = null, $group = null) |
| 51 | 51 | { |
| 52 | 52 | |
| 53 | - if (isset($key) && !PagSeguroHelper::isEmpty($key)) { |
|
| 53 | + if (isset($key) && ! PagSeguroHelper::isEmpty($key)) { |
|
| 54 | 54 | $this->setKey($key); |
| 55 | 55 | } |
| 56 | - if (isset($value) && !PagSeguroHelper::isEmpty($value)) { |
|
| 56 | + if (isset($value) && ! PagSeguroHelper::isEmpty($value)) { |
|
| 57 | 57 | $this->setValue($value); |
| 58 | 58 | } |
| 59 | - if (isset($group) && !PagSeguroHelper::isEmpty($group)) { |
|
| 59 | + if (isset($group) && ! PagSeguroHelper::isEmpty($group)) { |
|
| 60 | 60 | $this->setGroup($group); |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -27,120 +27,120 @@ |
||
| 27 | 27 | class PagSeguroMetaDataItem |
| 28 | 28 | { |
| 29 | 29 | |
| 30 | - /*** |
|
| 30 | + /*** |
|
| 31 | 31 | * Allow add extra information to order |
| 32 | 32 | * |
| 33 | 33 | * @var string |
| 34 | 34 | */ |
| 35 | - private $key; |
|
| 35 | + private $key; |
|
| 36 | 36 | |
| 37 | - /*** |
|
| 37 | + /*** |
|
| 38 | 38 | * Value of corresponding key |
| 39 | 39 | * |
| 40 | 40 | * @var mixed |
| 41 | 41 | */ |
| 42 | - private $value; |
|
| 42 | + private $value; |
|
| 43 | 43 | |
| 44 | - /*** |
|
| 44 | + /*** |
|
| 45 | 45 | * Used for grouping values of metadata items |
| 46 | 46 | * @var mixed |
| 47 | 47 | */ |
| 48 | - private $group; |
|
| 48 | + private $group; |
|
| 49 | 49 | |
| 50 | - public function __construct($key = null, $value = null, $group = null) |
|
| 51 | - { |
|
| 50 | + public function __construct($key = null, $value = null, $group = null) |
|
| 51 | + { |
|
| 52 | 52 | |
| 53 | - if (isset($key) && !PagSeguroHelper::isEmpty($key)) { |
|
| 54 | - $this->setKey($key); |
|
| 55 | - } |
|
| 56 | - if (isset($value) && !PagSeguroHelper::isEmpty($value)) { |
|
| 57 | - $this->setValue($value); |
|
| 58 | - } |
|
| 59 | - if (isset($group) && !PagSeguroHelper::isEmpty($group)) { |
|
| 60 | - $this->setGroup($group); |
|
| 61 | - } |
|
| 62 | - } |
|
| 53 | + if (isset($key) && !PagSeguroHelper::isEmpty($key)) { |
|
| 54 | + $this->setKey($key); |
|
| 55 | + } |
|
| 56 | + if (isset($value) && !PagSeguroHelper::isEmpty($value)) { |
|
| 57 | + $this->setValue($value); |
|
| 58 | + } |
|
| 59 | + if (isset($group) && !PagSeguroHelper::isEmpty($group)) { |
|
| 60 | + $this->setGroup($group); |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /*** |
|
| 64 | + /*** |
|
| 65 | 65 | * Gets the metadata item key |
| 66 | 66 | * @return string |
| 67 | 67 | */ |
| 68 | - public function getKey() |
|
| 69 | - { |
|
| 70 | - return $this->key; |
|
| 71 | - } |
|
| 68 | + public function getKey() |
|
| 69 | + { |
|
| 70 | + return $this->key; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /*** |
|
| 73 | + /*** |
|
| 74 | 74 | * Sets the metadata item key |
| 75 | 75 | * |
| 76 | 76 | * @param string $key |
| 77 | 77 | */ |
| 78 | - public function setKey($key) |
|
| 79 | - { |
|
| 80 | - $this->key = $key; |
|
| 81 | - } |
|
| 78 | + public function setKey($key) |
|
| 79 | + { |
|
| 80 | + $this->key = $key; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - /*** |
|
| 83 | + /*** |
|
| 84 | 84 | * Gets metadata item value |
| 85 | 85 | * @return string |
| 86 | 86 | */ |
| 87 | - public function getValue() |
|
| 88 | - { |
|
| 89 | - return $this->value; |
|
| 90 | - } |
|
| 87 | + public function getValue() |
|
| 88 | + { |
|
| 89 | + return $this->value; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - /*** |
|
| 92 | + /*** |
|
| 93 | 93 | * Sets metadata item value |
| 94 | 94 | * |
| 95 | 95 | * @param string $value |
| 96 | 96 | */ |
| 97 | - public function setValue($value) |
|
| 98 | - { |
|
| 99 | - $this->value = $this->normalizeParameter($value); |
|
| 100 | - } |
|
| 97 | + public function setValue($value) |
|
| 98 | + { |
|
| 99 | + $this->value = $this->normalizeParameter($value); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /*** |
|
| 102 | + /*** |
|
| 103 | 103 | * Gets metadata item group |
| 104 | 104 | * |
| 105 | 105 | * @return int |
| 106 | 106 | */ |
| 107 | - public function getGroup() |
|
| 108 | - { |
|
| 109 | - return $this->group; |
|
| 110 | - } |
|
| 107 | + public function getGroup() |
|
| 108 | + { |
|
| 109 | + return $this->group; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - /*** |
|
| 112 | + /*** |
|
| 113 | 113 | * Sets metadata item group |
| 114 | 114 | * |
| 115 | 115 | * @param int $group |
| 116 | 116 | */ |
| 117 | - public function setGroup($group) |
|
| 118 | - { |
|
| 119 | - $this->group = (int) $group; |
|
| 120 | - } |
|
| 117 | + public function setGroup($group) |
|
| 118 | + { |
|
| 119 | + $this->group = (int) $group; |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - /*** |
|
| 122 | + /*** |
|
| 123 | 123 | * Normalize metadata item value |
| 124 | 124 | * @param string $parameterValue |
| 125 | 125 | * @return string |
| 126 | 126 | */ |
| 127 | - private function normalizeParameter($parameterValue) |
|
| 128 | - { |
|
| 127 | + private function normalizeParameter($parameterValue) |
|
| 128 | + { |
|
| 129 | 129 | |
| 130 | - $parameterValue = PagSeguroHelper::formatString($parameterValue, 100, ''); |
|
| 130 | + $parameterValue = PagSeguroHelper::formatString($parameterValue, 100, ''); |
|
| 131 | 131 | |
| 132 | - switch ($this->getKey()) { |
|
| 133 | - case PagSeguroMetaDataItemKeys::getItemKeyByDescription('CPF do passageiro'): |
|
| 134 | - $parameterValue = PagSeguroHelper::getOnlyNumbers($parameterValue); |
|
| 135 | - break; |
|
| 136 | - case PagSeguroMetaDataItemKeys::getItemKeyByDescription('Tempo no jogo em dias'): |
|
| 137 | - $parameterValue = PagSeguroHelper::getOnlyNumbers($parameterValue); |
|
| 138 | - break; |
|
| 139 | - case PagSeguroMetaDataItemKeys::getItemKeyByDescription('Celular de recarga'): |
|
| 140 | - break; |
|
| 141 | - default: |
|
| 142 | - break; |
|
| 143 | - } |
|
| 144 | - return $parameterValue; |
|
| 145 | - } |
|
| 132 | + switch ($this->getKey()) { |
|
| 133 | + case PagSeguroMetaDataItemKeys::getItemKeyByDescription('CPF do passageiro'): |
|
| 134 | + $parameterValue = PagSeguroHelper::getOnlyNumbers($parameterValue); |
|
| 135 | + break; |
|
| 136 | + case PagSeguroMetaDataItemKeys::getItemKeyByDescription('Tempo no jogo em dias'): |
|
| 137 | + $parameterValue = PagSeguroHelper::getOnlyNumbers($parameterValue); |
|
| 138 | + break; |
|
| 139 | + case PagSeguroMetaDataItemKeys::getItemKeyByDescription('Celular de recarga'): |
|
| 140 | + break; |
|
| 141 | + default: |
|
| 142 | + break; |
|
| 143 | + } |
|
| 144 | + return $parameterValue; |
|
| 145 | + } |
|
| 146 | 146 | } |
@@ -35,6 +35,9 @@ |
||
| 35 | 35 | |
| 36 | 36 | private $value; |
| 37 | 37 | |
| 38 | + /** |
|
| 39 | + * @param string $value |
|
| 40 | + */ |
|
| 38 | 41 | public function __construct($value = null) |
| 39 | 42 | { |
| 40 | 43 | if ($value) { |
@@ -29,45 +29,45 @@ |
||
| 29 | 29 | class PagSeguroNotificationType |
| 30 | 30 | { |
| 31 | 31 | |
| 32 | - private static $typeList = array( |
|
| 33 | - 'TRANSACTION' => 'transaction' |
|
| 34 | - ); |
|
| 32 | + private static $typeList = array( |
|
| 33 | + 'TRANSACTION' => 'transaction' |
|
| 34 | + ); |
|
| 35 | 35 | |
| 36 | - private $value; |
|
| 36 | + private $value; |
|
| 37 | 37 | |
| 38 | - public function __construct($value = null) |
|
| 39 | - { |
|
| 40 | - if ($value) { |
|
| 41 | - $this->value = $value; |
|
| 42 | - } |
|
| 43 | - } |
|
| 38 | + public function __construct($value = null) |
|
| 39 | + { |
|
| 40 | + if ($value) { |
|
| 41 | + $this->value = $value; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public function setValue($value) |
|
| 46 | - { |
|
| 47 | - $this->value = $value; |
|
| 48 | - } |
|
| 45 | + public function setValue($value) |
|
| 46 | + { |
|
| 47 | + $this->value = $value; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - public function setByType($type) |
|
| 51 | - { |
|
| 52 | - if (isset(self::$typeList[$type])) { |
|
| 53 | - $this->value = self::$typeList[$type]; |
|
| 54 | - } else { |
|
| 55 | - throw new Exception("undefined index $type"); |
|
| 56 | - } |
|
| 57 | - } |
|
| 50 | + public function setByType($type) |
|
| 51 | + { |
|
| 52 | + if (isset(self::$typeList[$type])) { |
|
| 53 | + $this->value = self::$typeList[$type]; |
|
| 54 | + } else { |
|
| 55 | + throw new Exception("undefined index $type"); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - public function getValue() |
|
| 60 | - { |
|
| 61 | - return $this->value; |
|
| 62 | - } |
|
| 59 | + public function getValue() |
|
| 60 | + { |
|
| 61 | + return $this->value; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /*** |
|
| 64 | + /*** |
|
| 65 | 65 | * @param value |
| 66 | 66 | * @return the PagSeguroNotificationType corresponding to the informed value |
| 67 | 67 | */ |
| 68 | - public function getTypeFromValue($value = null) |
|
| 69 | - { |
|
| 70 | - $value = ($value == null ? $this->value : $value); |
|
| 71 | - return array_search($this->value, self::$typeList); |
|
| 72 | - } |
|
| 68 | + public function getTypeFromValue($value = null) |
|
| 69 | + { |
|
| 70 | + $value = ($value == null ? $this->value : $value); |
|
| 71 | + return array_search($this->value, self::$typeList); |
|
| 72 | + } |
|
| 73 | 73 | } |