@@ -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 | } |