@@ -62,8 +62,9 @@ |
||
62 | 62 | { |
63 | 63 | $this->intencaoVenda = $intencaoVenda; |
64 | 64 | |
65 | - if(is_array($this->intencaoVenda)) |
|
66 | - $this->intencaoVenda = SerializerHelper::denormalize($this->intencaoVenda, IntencaoVenda::class); |
|
65 | + if(is_array($this->intencaoVenda)) { |
|
66 | + $this->intencaoVenda = SerializerHelper::denormalize($this->intencaoVenda, IntencaoVenda::class); |
|
67 | + } |
|
67 | 68 | |
68 | 69 | return $this; |
69 | 70 | } |
@@ -203,8 +203,9 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public function setProdutos($produtos) |
205 | 205 | { |
206 | - foreach ($produtos as $produto) |
|
207 | - $this->produtos[] = SerializerHelper::denormalize($produto, Produto::class); |
|
206 | + foreach ($produtos as $produto) { |
|
207 | + $this->produtos[] = SerializerHelper::denormalize($produto, Produto::class); |
|
208 | + } |
|
208 | 209 | |
209 | 210 | return $this; |
210 | 211 | } |
@@ -441,8 +442,9 @@ discard block |
||
441 | 442 | { |
442 | 443 | $this->pedidoStatus = $pedidoStatus; |
443 | 444 | |
444 | - if(is_array($this->pedidoStatus)) |
|
445 | - $this->pedidoStatus = SerializerHelper::denormalize($this->pedidoStatus, PedidoStatus::class); |
|
445 | + if(is_array($this->pedidoStatus)) { |
|
446 | + $this->pedidoStatus = SerializerHelper::denormalize($this->pedidoStatus, PedidoStatus::class); |
|
447 | + } |
|
446 | 448 | |
447 | 449 | return $this; |
448 | 450 | } |
@@ -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 | } |
@@ -66,8 +66,9 @@ |
||
66 | 66 | */ |
67 | 67 | public function setPedidos($pedidos) |
68 | 68 | { |
69 | - foreach ($pedidos as $pedido) |
|
70 | - $this->pedidos[] = SerializerHelper::denormalize($pedido, Pedido::class); |
|
69 | + foreach ($pedidos as $pedido) { |
|
70 | + $this->pedidos[] = SerializerHelper::denormalize($pedido, Pedido::class); |
|
71 | + } |
|
71 | 72 | |
72 | 73 | return $this; |
73 | 74 | } |
@@ -21,8 +21,9 @@ |
||
21 | 21 | */ |
22 | 22 | public static function getInstance(array $params, Client $client = null) |
23 | 23 | { |
24 | - if(!isset($params[ControlPayParameterConst::CONTROLPAY_OAUTH_TYPE])) |
|
25 | - throw new \Exception("Tipo de autenticação não especificado"); |
|
24 | + if(!isset($params[ControlPayParameterConst::CONTROLPAY_OAUTH_TYPE])) { |
|
25 | + throw new \Exception("Tipo de autenticação não especificado"); |
|
26 | + } |
|
26 | 27 | |
27 | 28 | switch ($params[ControlPayParameterConst::CONTROLPAY_OAUTH_TYPE]) |
28 | 29 | { |
@@ -62,8 +62,9 @@ |
||
62 | 62 | { |
63 | 63 | $this->intencaoVenda = $intencaoVenda; |
64 | 64 | |
65 | - if(is_array($this->intencaoVenda)) |
|
66 | - $this->intencaoVenda = SerializerHelper::denormalize($this->intencaoVenda, IntencaoVenda::class); |
|
65 | + if(is_array($this->intencaoVenda)) { |
|
66 | + $this->intencaoVenda = SerializerHelper::denormalize($this->intencaoVenda, IntencaoVenda::class); |
|
67 | + } |
|
67 | 68 | |
68 | 69 | return $this; |
69 | 70 | } |
@@ -44,34 +44,39 @@ 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 | 67 | foreach ($venderRequest->getProdutosVendidos() as $key => $produto) |
65 | 68 | { |
66 | - if(empty($produto->getId())) |
|
67 | - $venderRequest->getProdutosVendidos()[$key]->setId( |
|
69 | + if(empty($produto->getId())) { |
|
70 | + $venderRequest->getProdutosVendidos()[$key]->setId( |
|
68 | 71 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_ID) |
69 | 72 | ); |
73 | + } |
|
70 | 74 | |
71 | - if(empty($produto->getQuantidade())) |
|
72 | - $venderRequest->getProdutosVendidos()[$key]->setQuantidade( |
|
75 | + if(empty($produto->getQuantidade())) { |
|
76 | + $venderRequest->getProdutosVendidos()[$key]->setQuantidade( |
|
73 | 77 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_QTDE) |
74 | 78 | ); |
79 | + } |
|
75 | 80 | } |
76 | 81 | |
77 | 82 | $this->response = $this->_httpClient->post(__FUNCTION__,[ |
@@ -82,9 +87,9 @@ discard block |
||
82 | 87 | $this->response->json(), |
83 | 88 | Contracts\Venda\VenderResponse::class |
84 | 89 | ); |
85 | - }catch (RequestException $ex) { |
|
90 | + } catch (RequestException $ex) { |
|
86 | 91 | $this->requestException($ex); |
87 | - }catch (\Exception $ex){ |
|
92 | + } catch (\Exception $ex){ |
|
88 | 93 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
89 | 94 | } |
90 | 95 | } |
@@ -99,17 +104,18 @@ discard block |
||
99 | 104 | try{ |
100 | 105 | $response = $this->pedidoApi->insert($venderComPedidoRequest->getPedidoInserirRequest()); |
101 | 106 | |
102 | - if(empty($response->getPedido()->getId())) |
|
103 | - throw new \Exception("Falha ao inserir pedido"); |
|
107 | + if(empty($response->getPedido()->getId())) { |
|
108 | + throw new \Exception("Falha ao inserir pedido"); |
|
109 | + } |
|
104 | 110 | |
105 | 111 | $venderComPedidoRequest->getInventarioVenderRequest()->setPedidoId( |
106 | 112 | $response->getPedido()->getId() |
107 | 113 | ); |
108 | 114 | |
109 | 115 | return $this->vender($venderComPedidoRequest->getInventarioVenderRequest()); |
110 | - }catch (RequestException $ex) { |
|
116 | + } catch (RequestException $ex) { |
|
111 | 117 | $this->requestException($ex); |
112 | - }catch (\Exception $ex){ |
|
118 | + } catch (\Exception $ex){ |
|
113 | 119 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
114 | 120 | } |
115 | 121 | } |
@@ -123,22 +129,25 @@ discard block |
||
123 | 129 | { |
124 | 130 | try{ |
125 | 131 | |
126 | - if(empty($cancelarVendaRequest->getTerminalId())) |
|
127 | - $cancelarVendaRequest->setTerminalId( |
|
132 | + if(empty($cancelarVendaRequest->getTerminalId())) { |
|
133 | + $cancelarVendaRequest->setTerminalId( |
|
128 | 134 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID) |
129 | 135 | ); |
136 | + } |
|
130 | 137 | |
131 | - if(empty($cancelarVendaRequest->getSenhaTecnica())) |
|
132 | - $cancelarVendaRequest->setSenhaTecnica( |
|
138 | + if(empty($cancelarVendaRequest->getSenhaTecnica())) { |
|
139 | + $cancelarVendaRequest->setSenhaTecnica( |
|
133 | 140 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_SENHA_TECNICA) |
134 | 141 | ); |
142 | + } |
|
135 | 143 | |
136 | - if(empty($cancelarVendaRequest->isAguardarTefIniciarTransacao())) |
|
137 | - $cancelarVendaRequest->setAguardarTefIniciarTransacao( |
|
144 | + if(empty($cancelarVendaRequest->isAguardarTefIniciarTransacao())) { |
|
145 | + $cancelarVendaRequest->setAguardarTefIniciarTransacao( |
|
138 | 146 | boolval( |
139 | 147 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF) |
140 | 148 | ) |
141 | 149 | ); |
150 | + } |
|
142 | 151 | |
143 | 152 | |
144 | 153 | $this->response = $this->_httpClient->post(__FUNCTION__,[ |
@@ -149,9 +158,9 @@ discard block |
||
149 | 158 | $this->response->json(), |
150 | 159 | Contracts\Venda\CancelarVendaResponse::class |
151 | 160 | ); |
152 | - }catch (RequestException $ex) { |
|
161 | + } catch (RequestException $ex) { |
|
153 | 162 | $this->requestException($ex); |
154 | - }catch (\Exception $ex){ |
|
163 | + } catch (\Exception $ex){ |
|
155 | 164 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
156 | 165 | } |
157 | 166 | } |
@@ -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 | { |
@@ -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 | } |