@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function getByFiltros(Contracts\IntencaoVenda\GetByFiltrosRequest $getByFiltrosRequest) |
33 | 33 | { |
34 | - try{ |
|
35 | - $this->response = $this->_httpClient->post(__FUNCTION__,[ |
|
34 | + try { |
|
35 | + $this->response = $this->_httpClient->post(__FUNCTION__, [ |
|
36 | 36 | 'body' => json_encode($getByFiltrosRequest), |
37 | 37 | ]); |
38 | 38 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | ); |
43 | 43 | }catch (RequestException $ex) { |
44 | 44 | $this->requestException($ex); |
45 | - }catch (\Exception $ex){ |
|
45 | + }catch (\Exception $ex) { |
|
46 | 46 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
47 | 47 | } |
48 | 48 | } |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function getById($intencaoVendaId) |
56 | 56 | { |
57 | - try{ |
|
58 | - $this->response = $this->_httpClient->post(__FUNCTION__,[ |
|
57 | + try { |
|
58 | + $this->response = $this->_httpClient->post(__FUNCTION__, [ |
|
59 | 59 | 'query' => $this->addQueryAdditionalParameters([ |
60 | 60 | 'intencaoVendaId' => $intencaoVendaId |
61 | 61 | ]) |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | ); |
68 | 68 | }catch (RequestException $ex) { |
69 | 69 | $this->requestException($ex); |
70 | - }catch (\Exception $ex){ |
|
70 | + }catch (\Exception $ex) { |
|
71 | 71 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
72 | 72 | } |
73 | 73 | } |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | $this->response->json(), |
41 | 41 | Contracts\IntencaoVenda\GetByFiltrosResponse::class |
42 | 42 | ); |
43 | - }catch (RequestException $ex) { |
|
43 | + } catch (RequestException $ex) { |
|
44 | 44 | $this->requestException($ex); |
45 | - }catch (\Exception $ex){ |
|
45 | + } catch (\Exception $ex){ |
|
46 | 46 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
47 | 47 | } |
48 | 48 | } |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | $this->response->json(), |
66 | 66 | Contracts\IntencaoVenda\GetByIdResponse::class |
67 | 67 | ); |
68 | - }catch (RequestException $ex) { |
|
68 | + } catch (RequestException $ex) { |
|
69 | 69 | $this->requestException($ex); |
70 | - }catch (\Exception $ex){ |
|
70 | + } catch (\Exception $ex){ |
|
71 | 71 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
72 | 72 | } |
73 | 73 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function getParameter($key) |
72 | 72 | { |
73 | - return isset($this->_params[$key]) ? $this->_params[$key] : null; |
|
73 | + return isset($this->_params[ $key ]) ? $this->_params[ $key ] : null; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function setParameter($key, $value) |
84 | 84 | { |
85 | - $this->_params[$key] = $value; |
|
85 | + $this->_params[ $key ] = $value; |
|
86 | 86 | $this->loadParameters($this->_params, $this->authentication); |
87 | 87 | return $this; |
88 | 88 | } |
@@ -96,25 +96,25 @@ discard block |
||
96 | 96 | */ |
97 | 97 | private function loadParameters($params, IAuthentication $authentication = null) |
98 | 98 | { |
99 | - $this->_params[ControlPayParameterConst::CONTROLPAY_HOST] = getenv('CONTROLPAY_HOST'); |
|
100 | - $this->_params[ControlPayParameterConst::CONTROLPAY_TIMEOUT] = getenv('CONTROLPAY_TIMEOUT'); |
|
101 | - $this->_params[ControlPayParameterConst::CONTROLPAY_USER] = getenv('CONTROLPAY_USER'); |
|
102 | - $this->_params[ControlPayParameterConst::CONTROLPAY_PWD] = getenv('CONTROLPAY_PWD'); |
|
103 | - $this->_params[ControlPayParameterConst::CONTROLPAY_KEY] = getenv('CONTROLPAY_KEY'); |
|
104 | - $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_PESSOA_ID] = getenv('CONTROLPAY_DEFAULT_PESSOA_ID'); |
|
105 | - $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_QTDE] = getenv('CONTROLPAY_DEFAULT_PRODUTO_QTDE'); |
|
106 | - $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID] = getenv('CONTROLPAY_DEFAULT_TERMINAL_ID'); |
|
107 | - $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_ID] = getenv('CONTROLPAY_DEFAULT_PRODUTO_ID'); |
|
108 | - $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID] = getenv('CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID'); |
|
109 | - $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF] = getenv('CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF'); |
|
110 | - $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_SENHA_TECNICA] = getenv('CONTROLPAY_DEFAULT_SENHA_TECNICA'); |
|
111 | - $this->_params[ControlPayParameterConst::CONTROLPAY_OAUTH_TYPE] = KeyQueryStringAuthentication::class; |
|
112 | - |
|
113 | - |
|
114 | - if(!is_null($params)) |
|
99 | + $this->_params[ ControlPayParameterConst::CONTROLPAY_HOST ] = getenv('CONTROLPAY_HOST'); |
|
100 | + $this->_params[ ControlPayParameterConst::CONTROLPAY_TIMEOUT ] = getenv('CONTROLPAY_TIMEOUT'); |
|
101 | + $this->_params[ ControlPayParameterConst::CONTROLPAY_USER ] = getenv('CONTROLPAY_USER'); |
|
102 | + $this->_params[ ControlPayParameterConst::CONTROLPAY_PWD ] = getenv('CONTROLPAY_PWD'); |
|
103 | + $this->_params[ ControlPayParameterConst::CONTROLPAY_KEY ] = getenv('CONTROLPAY_KEY'); |
|
104 | + $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_PESSOA_ID ] = getenv('CONTROLPAY_DEFAULT_PESSOA_ID'); |
|
105 | + $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_QTDE ] = getenv('CONTROLPAY_DEFAULT_PRODUTO_QTDE'); |
|
106 | + $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID ] = getenv('CONTROLPAY_DEFAULT_TERMINAL_ID'); |
|
107 | + $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_ID ] = getenv('CONTROLPAY_DEFAULT_PRODUTO_ID'); |
|
108 | + $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID ] = getenv('CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID'); |
|
109 | + $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF ] = getenv('CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF'); |
|
110 | + $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_SENHA_TECNICA ] = getenv('CONTROLPAY_DEFAULT_SENHA_TECNICA'); |
|
111 | + $this->_params[ ControlPayParameterConst::CONTROLPAY_OAUTH_TYPE ] = KeyQueryStringAuthentication::class; |
|
112 | + |
|
113 | + |
|
114 | + if (!is_null($params)) |
|
115 | 115 | foreach ($params as $key => $param) |
116 | 116 | { |
117 | - if(!in_array($key, [ |
|
117 | + if (!in_array($key, [ |
|
118 | 118 | ControlPayParameterConst::CONTROLPAY_HOST, |
119 | 119 | ControlPayParameterConst::CONTROLPAY_TIMEOUT, |
120 | 120 | ControlPayParameterConst::CONTROLPAY_USER, |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | throw new \Exception(sprintf("Parâmetro %s inválido", $key)); |
133 | 133 | } |
134 | 134 | |
135 | - if(!is_null($params) && is_array($params)) |
|
135 | + if (!is_null($params) && is_array($params)) |
|
136 | 136 | foreach ($params as $key => $value) |
137 | - $this->_params[$key] = $value; |
|
137 | + $this->_params[ $key ] = $value; |
|
138 | 138 | |
139 | - if(is_null($authentication)) |
|
139 | + if (is_null($authentication)) |
|
140 | 140 | { |
141 | 141 | $this->authentication = AuthenticationFactory::getInstance($this->_params, $this); |
142 | 142 | return; |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | $this->_params[ControlPayParameterConst::CONTROLPAY_OAUTH_TYPE] = KeyQueryStringAuthentication::class; |
112 | 112 | |
113 | 113 | |
114 | - if(!is_null($params)) |
|
115 | - foreach ($params as $key => $param) |
|
114 | + if(!is_null($params)) { |
|
115 | + foreach ($params as $key => $param) |
|
116 | 116 | { |
117 | 117 | if(!in_array($key, [ |
118 | 118 | ControlPayParameterConst::CONTROLPAY_HOST, |
@@ -130,11 +130,13 @@ discard block |
||
130 | 130 | ControlPayParameterConst::CONTROLPAY_DEFAULT_SENHA_TECNICA |
131 | 131 | ])) |
132 | 132 | throw new \Exception(sprintf("Parâmetro %s inválido", $key)); |
133 | + } |
|
133 | 134 | } |
134 | 135 | |
135 | - if(!is_null($params) && is_array($params)) |
|
136 | - foreach ($params as $key => $value) |
|
136 | + if(!is_null($params) && is_array($params)) { |
|
137 | + foreach ($params as $key => $value) |
|
137 | 138 | $this->_params[$key] = $value; |
139 | + } |
|
138 | 140 | |
139 | 141 | if(is_null($authentication)) |
140 | 142 | { |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace Integracao\ControlPay\Contracts\Pedido; |
4 | 4 | |
5 | 5 | use Integracao\ControlPay\Helpers\SerializerHelper; |
6 | -use Integracao\ControlPay\Model\IntencaoVenda; |
|
7 | 6 | use Integracao\ControlPay\Model\Pedido; |
8 | 7 | |
9 | 8 | /** |
@@ -63,7 +63,7 @@ |
||
63 | 63 | { |
64 | 64 | $this->pedido = $pedido; |
65 | 65 | |
66 | - if(is_array($this->pedido)) |
|
66 | + if (is_array($this->pedido)) |
|
67 | 67 | $this->pedido = SerializerHelper::denormalize($this->pedido, Pedido::class); |
68 | 68 | |
69 | 69 | return $this; |
@@ -63,8 +63,9 @@ |
||
63 | 63 | { |
64 | 64 | $this->pedido = $pedido; |
65 | 65 | |
66 | - if(is_array($this->pedido)) |
|
67 | - $this->pedido = SerializerHelper::denormalize($this->pedido, Pedido::class); |
|
66 | + if(is_array($this->pedido)) { |
|
67 | + $this->pedido = SerializerHelper::denormalize($this->pedido, Pedido::class); |
|
68 | + } |
|
68 | 69 | |
69 | 70 | return $this; |
70 | 71 | } |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function getByAtivosByPessoaId($pessoaId) |
32 | 32 | { |
33 | - try{ |
|
34 | - $this->response = $this->_httpClient->post(__FUNCTION__,[ |
|
33 | + try { |
|
34 | + $this->response = $this->_httpClient->post(__FUNCTION__, [ |
|
35 | 35 | 'query' => $this->addQueryAdditionalParameters([ |
36 | 36 | 'pessoaId' => $pessoaId |
37 | 37 | ]) |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | ); |
44 | 44 | }catch (RequestException $ex) { |
45 | 45 | $this->requestException($ex); |
46 | - }catch (\Exception $ex){ |
|
46 | + }catch (\Exception $ex) { |
|
47 | 47 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
48 | 48 | } |
49 | 49 | } |
@@ -41,9 +41,9 @@ |
||
41 | 41 | $this->response->json(), |
42 | 42 | Contracts\Produto\GetByAtivosByPessoaIdResponse::class |
43 | 43 | ); |
44 | - }catch (RequestException $ex) { |
|
44 | + } catch (RequestException $ex) { |
|
45 | 45 | $this->requestException($ex); |
46 | - }catch (\Exception $ex){ |
|
46 | + } catch (\Exception $ex){ |
|
47 | 47 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
48 | 48 | } |
49 | 49 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | { |
46 | 46 | $this->data = \DateTime::createFromFormat('d/m/Y H:i:s.u', $data); |
47 | 47 | |
48 | - if(!$this->data) |
|
48 | + if (!$this->data) |
|
49 | 49 | $this->data = \DateTime::createFromFormat('d/m/Y H:i:s', $data); |
50 | 50 | |
51 | 51 | return $this; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | { |
68 | 68 | $this->terminal = $terminal; |
69 | 69 | |
70 | - if(is_array($this->terminal)) |
|
70 | + if (is_array($this->terminal)) |
|
71 | 71 | $this->terminal = SerializerHelper::denormalize($this->terminal, Terminal::class); |
72 | 72 | |
73 | 73 | return $this; |
@@ -45,8 +45,9 @@ discard block |
||
45 | 45 | { |
46 | 46 | $this->data = \DateTime::createFromFormat('d/m/Y H:i:s.u', $data); |
47 | 47 | |
48 | - if(!$this->data) |
|
49 | - $this->data = \DateTime::createFromFormat('d/m/Y H:i:s', $data); |
|
48 | + if(!$this->data) { |
|
49 | + $this->data = \DateTime::createFromFormat('d/m/Y H:i:s', $data); |
|
50 | + } |
|
50 | 51 | |
51 | 52 | return $this; |
52 | 53 | } |
@@ -67,8 +68,9 @@ discard block |
||
67 | 68 | { |
68 | 69 | $this->terminal = $terminal; |
69 | 70 | |
70 | - if(is_array($this->terminal)) |
|
71 | - $this->terminal = SerializerHelper::denormalize($this->terminal, Terminal::class); |
|
71 | + if(is_array($this->terminal)) { |
|
72 | + $this->terminal = SerializerHelper::denormalize($this->terminal, Terminal::class); |
|
73 | + } |
|
72 | 74 | |
73 | 75 | return $this; |
74 | 76 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | { |
63 | 63 | |
64 | 64 | foreach ($intencoesVendas as $intencaoVenda) |
65 | - $this->intencoesVendas[] = SerializerHelper::denormalize($intencaoVenda, IntencaoVenda::class); |
|
65 | + $this->intencoesVendas[ ] = SerializerHelper::denormalize($intencaoVenda, IntencaoVenda::class); |
|
66 | 66 | |
67 | 67 | return $this; |
68 | 68 | } |
@@ -61,8 +61,9 @@ |
||
61 | 61 | public function setIntencoesVendas($intencoesVendas) |
62 | 62 | { |
63 | 63 | |
64 | - foreach ($intencoesVendas as $intencaoVenda) |
|
65 | - $this->intencoesVendas[] = SerializerHelper::denormalize($intencaoVenda, IntencaoVenda::class); |
|
64 | + foreach ($intencoesVendas as $intencaoVenda) { |
|
65 | + $this->intencoesVendas[] = SerializerHelper::denormalize($intencaoVenda, IntencaoVenda::class); |
|
66 | + } |
|
66 | 67 | |
67 | 68 | return $this; |
68 | 69 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | { |
63 | 63 | |
64 | 64 | foreach ($intencoesVendas as $intencaoVenda) |
65 | - $this->intencoesVendas[] = SerializerHelper::denormalize($intencaoVenda, IntencaoVenda::class); |
|
65 | + $this->intencoesVendas[ ] = SerializerHelper::denormalize($intencaoVenda, IntencaoVenda::class); |
|
66 | 66 | |
67 | 67 | return $this; |
68 | 68 | } |
@@ -61,8 +61,9 @@ |
||
61 | 61 | public function setIntencoesVendas($intencoesVendas) |
62 | 62 | { |
63 | 63 | |
64 | - foreach ($intencoesVendas as $intencaoVenda) |
|
65 | - $this->intencoesVendas[] = SerializerHelper::denormalize($intencaoVenda, IntencaoVenda::class); |
|
64 | + foreach ($intencoesVendas as $intencaoVenda) { |
|
65 | + $this->intencoesVendas[] = SerializerHelper::denormalize($intencaoVenda, IntencaoVenda::class); |
|
66 | + } |
|
66 | 67 | |
67 | 68 | return $this; |
68 | 69 | } |
@@ -42,40 +42,40 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function vender(Contracts\Venda\VenderRequest $venderRequest) |
44 | 44 | { |
45 | - try{ |
|
45 | + try { |
|
46 | 46 | |
47 | - if(empty($venderRequest->getTerminalId())) |
|
47 | + if (empty($venderRequest->getTerminalId())) |
|
48 | 48 | $venderRequest->setTerminalId( |
49 | 49 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID) |
50 | 50 | ); |
51 | 51 | |
52 | - if(empty($venderRequest->getFormaPagamentoId())) |
|
52 | + if (empty($venderRequest->getFormaPagamentoId())) |
|
53 | 53 | $venderRequest->setFormaPagamentoId( |
54 | 54 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID) |
55 | 55 | ); |
56 | 56 | |
57 | - if(empty($venderRequest->isAguardarTefIniciarTransacao())) |
|
57 | + if (empty($venderRequest->isAguardarTefIniciarTransacao())) |
|
58 | 58 | $venderRequest->setAguardarTefIniciarTransacao( |
59 | 59 | boolval( |
60 | 60 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF) |
61 | 61 | ) |
62 | 62 | ); |
63 | 63 | |
64 | - if(!empty($venderRequest->getProdutosVendidos())) |
|
64 | + if (!empty($venderRequest->getProdutosVendidos())) |
|
65 | 65 | foreach ($venderRequest->getProdutosVendidos() as $key => $produto) |
66 | 66 | { |
67 | - if(empty($produto->getId())) |
|
68 | - $venderRequest->getProdutosVendidos()[$key]->setId( |
|
67 | + if (empty($produto->getId())) |
|
68 | + $venderRequest->getProdutosVendidos()[ $key ]->setId( |
|
69 | 69 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_ID) |
70 | 70 | ); |
71 | 71 | |
72 | - if(empty($produto->getQuantidade())) |
|
73 | - $venderRequest->getProdutosVendidos()[$key]->setQuantidade( |
|
72 | + if (empty($produto->getQuantidade())) |
|
73 | + $venderRequest->getProdutosVendidos()[ $key ]->setQuantidade( |
|
74 | 74 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_QTDE) |
75 | 75 | ); |
76 | 76 | } |
77 | 77 | |
78 | - $this->response = $this->_httpClient->post(__FUNCTION__,[ |
|
78 | + $this->response = $this->_httpClient->post(__FUNCTION__, [ |
|
79 | 79 | 'body' => json_encode($venderRequest), |
80 | 80 | ]); |
81 | 81 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | ); |
86 | 86 | }catch (RequestException $ex) { |
87 | 87 | $this->requestException($ex); |
88 | - }catch (\Exception $ex){ |
|
88 | + }catch (\Exception $ex) { |
|
89 | 89 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
90 | 90 | } |
91 | 91 | } |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function venderComPedido(Contracts\Venda\VenderComPedidoRequest $venderComPedidoRequest) |
99 | 99 | { |
100 | - try{ |
|
100 | + try { |
|
101 | 101 | $response = $this->pedidoApi->insert($venderComPedidoRequest->getPedidoInserirRequest()); |
102 | 102 | |
103 | - if(empty($response->getPedido()->getId())) |
|
103 | + if (empty($response->getPedido()->getId())) |
|
104 | 104 | throw new \Exception("Falha ao inserir pedido"); |
105 | 105 | |
106 | 106 | $venderComPedidoRequest->getInventarioVenderRequest()->setPedidoId( |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | return $this->vender($venderComPedidoRequest->getInventarioVenderRequest()); |
111 | 111 | }catch (RequestException $ex) { |
112 | 112 | $this->requestException($ex); |
113 | - }catch (\Exception $ex){ |
|
113 | + }catch (\Exception $ex) { |
|
114 | 114 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
115 | 115 | } |
116 | 116 | } |
@@ -122,19 +122,19 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function cancelarVenda(Contracts\Venda\CancelarVendaRequest $cancelarVendaRequest) |
124 | 124 | { |
125 | - try{ |
|
125 | + try { |
|
126 | 126 | |
127 | - if(empty($cancelarVendaRequest->getTerminalId())) |
|
127 | + if (empty($cancelarVendaRequest->getTerminalId())) |
|
128 | 128 | $cancelarVendaRequest->setTerminalId( |
129 | 129 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID) |
130 | 130 | ); |
131 | 131 | |
132 | - if(empty($cancelarVendaRequest->getSenhaTecnica())) |
|
132 | + if (empty($cancelarVendaRequest->getSenhaTecnica())) |
|
133 | 133 | $cancelarVendaRequest->setSenhaTecnica( |
134 | 134 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_SENHA_TECNICA) |
135 | 135 | ); |
136 | 136 | |
137 | - if(empty($cancelarVendaRequest->isAguardarTefIniciarTransacao())) |
|
137 | + if (empty($cancelarVendaRequest->isAguardarTefIniciarTransacao())) |
|
138 | 138 | $cancelarVendaRequest->setAguardarTefIniciarTransacao( |
139 | 139 | boolval( |
140 | 140 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF) |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | ); |
143 | 143 | |
144 | 144 | |
145 | - $this->response = $this->_httpClient->post(__FUNCTION__,[ |
|
145 | + $this->response = $this->_httpClient->post(__FUNCTION__, [ |
|
146 | 146 | 'body' => json_encode($cancelarVendaRequest), |
147 | 147 | ]); |
148 | 148 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | ); |
153 | 153 | }catch (RequestException $ex) { |
154 | 154 | $this->requestException($ex); |
155 | - }catch (\Exception $ex){ |
|
155 | + }catch (\Exception $ex) { |
|
156 | 156 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
157 | 157 | } |
158 | 158 | } |
@@ -44,35 +44,40 @@ discard block |
||
44 | 44 | { |
45 | 45 | try{ |
46 | 46 | |
47 | - if(empty($venderRequest->getTerminalId())) |
|
48 | - $venderRequest->setTerminalId( |
|
47 | + if(empty($venderRequest->getTerminalId())) { |
|
48 | + $venderRequest->setTerminalId( |
|
49 | 49 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID) |
50 | 50 | ); |
51 | + } |
|
51 | 52 | |
52 | - if(empty($venderRequest->getFormaPagamentoId())) |
|
53 | - $venderRequest->setFormaPagamentoId( |
|
53 | + if(empty($venderRequest->getFormaPagamentoId())) { |
|
54 | + $venderRequest->setFormaPagamentoId( |
|
54 | 55 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID) |
55 | 56 | ); |
57 | + } |
|
56 | 58 | |
57 | - if(empty($venderRequest->isAguardarTefIniciarTransacao())) |
|
58 | - $venderRequest->setAguardarTefIniciarTransacao( |
|
59 | + if(empty($venderRequest->isAguardarTefIniciarTransacao())) { |
|
60 | + $venderRequest->setAguardarTefIniciarTransacao( |
|
59 | 61 | boolval( |
60 | 62 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF) |
61 | 63 | ) |
62 | 64 | ); |
65 | + } |
|
63 | 66 | |
64 | - if(!empty($venderRequest->getProdutosVendidos())) |
|
65 | - foreach ($venderRequest->getProdutosVendidos() as $key => $produto) |
|
67 | + if(!empty($venderRequest->getProdutosVendidos())) { |
|
68 | + foreach ($venderRequest->getProdutosVendidos() as $key => $produto) |
|
66 | 69 | { |
67 | 70 | if(empty($produto->getId())) |
68 | 71 | $venderRequest->getProdutosVendidos()[$key]->setId( |
69 | 72 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_ID) |
70 | 73 | ); |
74 | + } |
|
71 | 75 | |
72 | - if(empty($produto->getQuantidade())) |
|
73 | - $venderRequest->getProdutosVendidos()[$key]->setQuantidade( |
|
76 | + if(empty($produto->getQuantidade())) { |
|
77 | + $venderRequest->getProdutosVendidos()[$key]->setQuantidade( |
|
74 | 78 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_QTDE) |
75 | 79 | ); |
80 | + } |
|
76 | 81 | } |
77 | 82 | |
78 | 83 | $this->response = $this->_httpClient->post(__FUNCTION__,[ |
@@ -83,9 +88,9 @@ discard block |
||
83 | 88 | $this->response->json(), |
84 | 89 | Contracts\Venda\VenderResponse::class |
85 | 90 | ); |
86 | - }catch (RequestException $ex) { |
|
91 | + } catch (RequestException $ex) { |
|
87 | 92 | $this->requestException($ex); |
88 | - }catch (\Exception $ex){ |
|
93 | + } catch (\Exception $ex){ |
|
89 | 94 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
90 | 95 | } |
91 | 96 | } |
@@ -100,17 +105,18 @@ discard block |
||
100 | 105 | try{ |
101 | 106 | $response = $this->pedidoApi->insert($venderComPedidoRequest->getPedidoInserirRequest()); |
102 | 107 | |
103 | - if(empty($response->getPedido()->getId())) |
|
104 | - throw new \Exception("Falha ao inserir pedido"); |
|
108 | + if(empty($response->getPedido()->getId())) { |
|
109 | + throw new \Exception("Falha ao inserir pedido"); |
|
110 | + } |
|
105 | 111 | |
106 | 112 | $venderComPedidoRequest->getInventarioVenderRequest()->setPedidoId( |
107 | 113 | $response->getPedido()->getId() |
108 | 114 | ); |
109 | 115 | |
110 | 116 | return $this->vender($venderComPedidoRequest->getInventarioVenderRequest()); |
111 | - }catch (RequestException $ex) { |
|
117 | + } catch (RequestException $ex) { |
|
112 | 118 | $this->requestException($ex); |
113 | - }catch (\Exception $ex){ |
|
119 | + } catch (\Exception $ex){ |
|
114 | 120 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
115 | 121 | } |
116 | 122 | } |
@@ -124,22 +130,25 @@ discard block |
||
124 | 130 | { |
125 | 131 | try{ |
126 | 132 | |
127 | - if(empty($cancelarVendaRequest->getTerminalId())) |
|
128 | - $cancelarVendaRequest->setTerminalId( |
|
133 | + if(empty($cancelarVendaRequest->getTerminalId())) { |
|
134 | + $cancelarVendaRequest->setTerminalId( |
|
129 | 135 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID) |
130 | 136 | ); |
137 | + } |
|
131 | 138 | |
132 | - if(empty($cancelarVendaRequest->getSenhaTecnica())) |
|
133 | - $cancelarVendaRequest->setSenhaTecnica( |
|
139 | + if(empty($cancelarVendaRequest->getSenhaTecnica())) { |
|
140 | + $cancelarVendaRequest->setSenhaTecnica( |
|
134 | 141 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_SENHA_TECNICA) |
135 | 142 | ); |
143 | + } |
|
136 | 144 | |
137 | - if(empty($cancelarVendaRequest->isAguardarTefIniciarTransacao())) |
|
138 | - $cancelarVendaRequest->setAguardarTefIniciarTransacao( |
|
145 | + if(empty($cancelarVendaRequest->isAguardarTefIniciarTransacao())) { |
|
146 | + $cancelarVendaRequest->setAguardarTefIniciarTransacao( |
|
139 | 147 | boolval( |
140 | 148 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF) |
141 | 149 | ) |
142 | 150 | ); |
151 | + } |
|
143 | 152 | |
144 | 153 | |
145 | 154 | $this->response = $this->_httpClient->post(__FUNCTION__,[ |
@@ -150,9 +159,9 @@ discard block |
||
150 | 159 | $this->response->json(), |
151 | 160 | Contracts\Venda\CancelarVendaResponse::class |
152 | 161 | ); |
153 | - }catch (RequestException $ex) { |
|
162 | + } catch (RequestException $ex) { |
|
154 | 163 | $this->requestException($ex); |
155 | - }catch (\Exception $ex){ |
|
164 | + } catch (\Exception $ex){ |
|
156 | 165 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
157 | 166 | } |
158 | 167 | } |