@@ -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 | } |
@@ -44,29 +44,33 @@ 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 | 75 | |
| 72 | 76 | $this->response = $this->_httpClient->post(__FUNCTION__,[ |
@@ -77,9 +81,9 @@ discard block |
||
| 77 | 81 | $this->response->json(), |
| 78 | 82 | Contracts\Venda\VenderResponse::class |
| 79 | 83 | ); |
| 80 | - }catch (RequestException $ex) { |
|
| 84 | + } catch (RequestException $ex) { |
|
| 81 | 85 | $this->requestException($ex); |
| 82 | - }catch (\Exception $ex){ |
|
| 86 | + } catch (\Exception $ex){ |
|
| 83 | 87 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
| 84 | 88 | } |
| 85 | 89 | } |
@@ -94,17 +98,18 @@ discard block |
||
| 94 | 98 | try{ |
| 95 | 99 | $response = $this->pedidoApi->insert($venderComPedidoRequest->getPedidoInserirRequest()); |
| 96 | 100 | |
| 97 | - if(empty($response->getPedido()->getId())) |
|
| 98 | - throw new \Exception("Falha ao inserir pedido"); |
|
| 101 | + if(empty($response->getPedido()->getId())) { |
|
| 102 | + throw new \Exception("Falha ao inserir pedido"); |
|
| 103 | + } |
|
| 99 | 104 | |
| 100 | 105 | $venderComPedidoRequest->getInventarioVenderRequest()->setPedidoId( |
| 101 | 106 | $response->getPedido()->getId() |
| 102 | 107 | ); |
| 103 | 108 | |
| 104 | 109 | return $this->vender($venderComPedidoRequest->getInventarioVenderRequest()); |
| 105 | - }catch (RequestException $ex) { |
|
| 110 | + } catch (RequestException $ex) { |
|
| 106 | 111 | $this->requestException($ex); |
| 107 | - }catch (\Exception $ex){ |
|
| 112 | + } catch (\Exception $ex){ |
|
| 108 | 113 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
| 109 | 114 | } |
| 110 | 115 | } |
@@ -118,22 +123,25 @@ discard block |
||
| 118 | 123 | { |
| 119 | 124 | try{ |
| 120 | 125 | |
| 121 | - if(empty($cancelarVendaRequest->getTerminalId())) |
|
| 122 | - $cancelarVendaRequest->setTerminalId( |
|
| 126 | + if(empty($cancelarVendaRequest->getTerminalId())) { |
|
| 127 | + $cancelarVendaRequest->setTerminalId( |
|
| 123 | 128 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID) |
| 124 | 129 | ); |
| 130 | + } |
|
| 125 | 131 | |
| 126 | - if(empty($cancelarVendaRequest->getSenhaTecnica())) |
|
| 127 | - $cancelarVendaRequest->setSenhaTecnica( |
|
| 132 | + if(empty($cancelarVendaRequest->getSenhaTecnica())) { |
|
| 133 | + $cancelarVendaRequest->setSenhaTecnica( |
|
| 128 | 134 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_SENHA_TECNICA) |
| 129 | 135 | ); |
| 136 | + } |
|
| 130 | 137 | |
| 131 | - if(empty($cancelarVendaRequest->isAguardarTefIniciarTransacao())) |
|
| 132 | - $cancelarVendaRequest->setAguardarTefIniciarTransacao( |
|
| 138 | + if(empty($cancelarVendaRequest->isAguardarTefIniciarTransacao())) { |
|
| 139 | + $cancelarVendaRequest->setAguardarTefIniciarTransacao( |
|
| 133 | 140 | boolval( |
| 134 | 141 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF) |
| 135 | 142 | ) |
| 136 | 143 | ); |
| 144 | + } |
|
| 137 | 145 | |
| 138 | 146 | |
| 139 | 147 | $this->response = $this->_httpClient->post(__FUNCTION__,[ |
@@ -144,9 +152,9 @@ discard block |
||
| 144 | 152 | $this->response->json(), |
| 145 | 153 | Contracts\Venda\CancelarVendaResponse::class |
| 146 | 154 | ); |
| 147 | - }catch (RequestException $ex) { |
|
| 155 | + } catch (RequestException $ex) { |
|
| 148 | 156 | $this->requestException($ex); |
| 149 | - }catch (\Exception $ex){ |
|
| 157 | + } catch (\Exception $ex){ |
|
| 150 | 158 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
| 151 | 159 | } |
| 152 | 160 | } |
@@ -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 | } |