Anger Posted April 8, 2015 Share Posted April 8, 2015 fechei O erro aparece quando clica para enviar, isto ? 0 Quote Ajude o fórum! Antes de postar, leiam as regras de postagem aqui. Link to comment Share on other sites More sharing options...
traysistemas Posted April 8, 2015 Author Share Posted April 8, 2015 O erro aparece quando clica para enviar, isto ? esse é um modulo whmcs, quando vou em faturas ocorre erro 0 Quote Link to comment Share on other sites More sharing options...
traysistemas Posted April 8, 2015 Author Share Posted April 8, 2015 <?php function gerencianetboleto_config() { $configarray = array( "FriendlyName" => array("Type" => "System", "Value" => "Fortunus"), "username" => array("FriendlyName" => "Token", "Type" => "text", "Size" => "40",), "configVencimento" => array( "FriendlyName" => "Configurações de Vencimento", "Type" => "yesno", "Description" => "Utilizar configurações de vencimento da GerênciaNet (vencimento informado no WHMCS é ignorado)", ) ); return $configarray; } function gerencianetboleto_link($params) { $urlCallback = $params['systemurl'] . '/modules/gateways/callback/gerencianetboleto.php'; //data $table = "tblinvoices"; $fields = "duedate, userid"; $where = array( "id" => $params['invoiceid'], ); $sort = "id"; $sortorder = "ASC"; $limits = "1"; $result = select_query($table, $fields, $where, $sort, $sortorder, $limits); $invoiceData = mysql_fetch_array($result); $duedate = $invoiceData['duedate']; $camposDueDate = explode('-', $duedate); $novoDueDate = $camposDueDate[2] . '/' . $camposDueDate[1] . '/' . $camposDueDate[0]; $userId = $invoiceData['userid']; //data - tblclients $table = 'tblclients'; $fields = 'id,firstname,lastname,email, address1, address2, city, state, postcode'; $where = array( 'id' => $userId ); $sort = 'id'; $sortorder = "ASC"; $limits = 1; $usuario = select_query($table, $fields, $where, $sort, $sortorder, $limits); $usuarioData = mysql_fetch_array($usuario); $postcode = preg_replace("/[()-._]/", '', $usuarioData['postcode']); if ( strlen($usuarioData['state']) != 2 ) { $state = ''; } else { $state = $usuarioData['state']; } $xml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><boleto></boleto>'); $xml->addChild('token', $params['username']); $clientes = $xml->addChild('clientes'); $cliente = $clientes->addChild('cliente'); $nomeRazaoSocial = $cliente->addChild('nomeRazaoSocial'); gerencianetboleto_addCData($nomeRazaoSocial, $usuarioData['firstname'] . ' ' . $usuarioData['lastname']); $opcionais = $cliente->addChild('opcionais'); $email = $opcionais->addChild('email'); gerencianetboleto_addCData($email, $usuarioData['email']); $cep = preg_replace("/[()-.]/", "", $order_info['payment_postcode']); $opcionais->addChild('cep', $postcode); $rua = $opcionais->addChild('rua'); gerencianetboleto_addCData($rua, $usuarioData['address1']); $complemento = $opcionais->addChild('complemento'); gerencianetboleto_addCData($complemento, $usuarioData['address2']); $opcionais->addChild('estado', $state); $cidade = $opcionais->addChild('cidade'); gerencianetboleto_addCData($cidade, $usuarioData['city']); $opcionais->addChild('retorno', 'whmcs_' . $params['invoiceid']); $itens = $xml->addChild('itens'); //data - itens $table = "tblinvoiceitems"; $fields = "description,amount"; $where = array( "invoiceid" => $params['invoiceid'], ); $sort = "id"; $sortorder = "ASC"; $limits = ""; $result = select_query($table, $fields, $where, $sort, $sortorder, $limits); $totalItem = 0; while ($data = mysql_fetch_array($result)) { $item = $itens->addChild('item'); $descricaoItem = $item->addChild('descricao'); gerencianetboleto_addCData($descricaoItem, str_replace("'", "", $data['description'])); $valorItem = preg_replace("/[.,-]/","", $data['amount']); $totalItem += $valorItem; $item->addChild('valor', $valorItem); $item->addChild('qtde', 1); } if ($params['configVencimento'] != 'on') { $xml->addChild('vencimento', $novoDueDate); } $valor = preg_replace("/[.,-]/", "", $params['amount']); $desconto = $totalItem - $valor; if ($desconto > 0) { $bOpcionais = $xml->addChild('opcionais'); $bOpcionais->addChild('descontoSobreTotal', $desconto); } $xmlParaEnvio = $xml->saveXML(); $code = "<form method='post' action='https://integracao.gerencianet.com.br/whmcs/emitir'> <input type='hidden' name='entrada' value='" . $xmlParaEnvio . "' /> <input type='hidden' name='callback' value='" . $urlCallback . "' /> <input type='hidden' name='versao' value='2.0' /> <input type='hidden' name='tipo' value='boleto' /> <input type='hidden' name='token' value='". $params['username'] . "' /> <input type='hidden' name='valor' value='". $valor . "' /> <input type='hidden' name='configVencimento' value='". $params['configVencimento'] . "' /> <input type='hidden' name='vencimento' value='". $novoDueDate . "' /> <input type='submit' value='Realizar Pagamento' /> </form>"; return $code; } function gerencianetboleto_addCData($path, $string) { $dom = dom_import_simplexml($path); $cdata = $dom->ownerDocument->createCDATASection($string); $dom->appendChild($cdata); } 0 Quote Link to comment Share on other sites More sharing options...
Anger Posted April 8, 2015 Share Posted April 8, 2015 @traysistemas, funcionou aqui. Veja: Eu apenas deixei a função de enviar padrão ocultada, assim o botão lê a função enviar. <?php function gerencianetboleto_config() { $configarray = array( "FriendlyName" => array("Type" => "System", "Value" => "Fortunus"), "username" => array("FriendlyName" => "Token", "Type" => "text", "Size" => "40",), "configVencimento" => array( "FriendlyName" => "Configurações de Vencimento", "Type" => "yesno", "Description" => "Utilizar configurações de vencimento da GerênciaNet (vencimento informado no WHMCS é ignorado)", ) ); return $configarray; } function gerencianetboleto_link($params) { $urlCallback = $params['systemurl'] . '/modules/gateways/callback/gerencianetboleto.php'; //data $table = "tblinvoices"; $fields = "duedate, userid"; $where = array( "id" => $params['invoiceid'], ); $sort = "id"; $sortorder = "ASC"; $limits = "1"; $result = select_query($table, $fields, $where, $sort, $sortorder, $limits); $invoiceData = mysql_fetch_array($result); $duedate = $invoiceData['duedate']; $camposDueDate = explode('-', $duedate); $novoDueDate = $camposDueDate[2] . '/' . $camposDueDate[1] . '/' . $camposDueDate[0]; $userId = $invoiceData['userid']; //data - tblclients $table = 'tblclients'; $fields = 'id,firstname,lastname,email, address1, address2, city, state, postcode'; $where = array( 'id' => $userId ); $sort = 'id'; $sortorder = "ASC"; $limits = 1; $usuario = select_query($table, $fields, $where, $sort, $sortorder, $limits); $usuarioData = mysql_fetch_array($usuario); $postcode = preg_replace("/[()-._]/", '', $usuarioData['postcode']); if ( strlen($usuarioData['state']) != 2 ) { $state = ''; } else { $state = $usuarioData['state']; } $xml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><boleto></boleto>'); $xml->addChild('token', $params['username']); $clientes = $xml->addChild('clientes'); $cliente = $clientes->addChild('cliente'); $nomeRazaoSocial = $cliente->addChild('nomeRazaoSocial'); gerencianetboleto_addCData($nomeRazaoSocial, $usuarioData['firstname'] . ' ' . $usuarioData['lastname']); $opcionais = $cliente->addChild('opcionais'); $email = $opcionais->addChild('email'); gerencianetboleto_addCData($email, $usuarioData['email']); $cep = preg_replace("/[()-.]/", "", $order_info['payment_postcode']); $opcionais->addChild('cep', $postcode); $rua = $opcionais->addChild('rua'); gerencianetboleto_addCData($rua, $usuarioData['address1']); $complemento = $opcionais->addChild('complemento'); gerencianetboleto_addCData($complemento, $usuarioData['address2']); $opcionais->addChild('estado', $state); $cidade = $opcionais->addChild('cidade'); gerencianetboleto_addCData($cidade, $usuarioData['city']); $opcionais->addChild('retorno', 'whmcs_' . $params['invoiceid']); $itens = $xml->addChild('itens'); //data - itens $table = "tblinvoiceitems"; $fields = "description,amount"; $where = array( "invoiceid" => $params['invoiceid'], ); $sort = "id"; $sortorder = "ASC"; $limits = ""; $result = select_query($table, $fields, $where, $sort, $sortorder, $limits); $totalItem = 0; while ($data = mysql_fetch_array($result)) { $item = $itens->addChild('item'); $descricaoItem = $item->addChild('descricao'); gerencianetboleto_addCData($descricaoItem, str_replace("'", "", $data['description'])); $valorItem = preg_replace("/[.,-]/","", $data['amount']); $totalItem += $valorItem; $item->addChild('valor', $valorItem); $item->addChild('qtde', 1); } if ($params['configVencimento'] != 'on') { $xml->addChild('vencimento', $novoDueDate); } $valor = preg_replace("/[.,-]/", "", $params['amount']); $desconto = $totalItem - $valor; if ($desconto > 0) { $bOpcionais = $xml->addChild('opcionais'); $bOpcionais->addChild('descontoSobreTotal', $desconto); } $xmlParaEnvio = $xml->saveXML(); $code = "<form method='post' action='https://integracao.gerencianet.com.br/whmcs/emitir'> <input type='hidden' name='entrada' value='" . $xmlParaEnvio . "' /> <input type='hidden' name='callback' value='" . $urlCallback . "' /> <input type='hidden' name='versao' value='2.0' /> <input type='hidden' name='tipo' value='boleto' /> <input type='hidden' name='token' value='". $params['username'] . "' /> <input type='hidden' name='valor' value='". $valor . "' /> <input type='hidden' name='configVencimento' value='". $params['configVencimento'] . "' /> <input type='hidden' name='vencimento' value='". $novoDueDate . "' /> <!-- <input type='submit' value='Realizar Pagamento' /> --> <input type="image" src="http://www.linhadecodigo.com.br/artigos/img_artigos/AndersonWeschnhoski/BotaoCSS3/botaoCSS301.jpg" alt="Enviar" /> </form>"; return $code; } function gerencianetboleto_addCData($path, $string) { $dom = dom_import_simplexml($path); $cdata = $dom->ownerDocument->createCDATASection($string); $dom->appendChild($cdata); } 0 Quote Ajude o fórum! Antes de postar, leiam as regras de postagem aqui. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.