thalesgodoi Posted September 29, 2018 Share Posted September 29, 2018 Titulo auto explicativo, Alguém tem ideia do que pode ter mudado na atualização? O modulo funciona perfeitamente, só o sistema de callback que não. 0 Quote Link to comment Share on other sites More sharing options...
Fabio J Posted September 30, 2018 Share Posted September 30, 2018 Estou tendo o mesmo problemas desde o ia 26 meu retorno automático também parou de funcionar ! alguém tem uma luz ? Valeu ! 0 Quote Link to comment Share on other sites More sharing options...
Fabio J Posted October 2, 2018 Share Posted October 2, 2018 Boa tarde Galerinha alguem ai teve alguma noticia ? Obrigado ! 0 Quote Link to comment Share on other sites More sharing options...
thalesgodoi Posted October 3, 2018 Author Share Posted October 3, 2018 Amigos, Como era fundamental este módulo, realizei a compra de um funcionando na nova versão, realmente o módulo que todos temos não está funcionando mais. Estou vendendo o módulo funcionando com a opção de taxas e callback funcionando. Interessados: [email protected] 0 Quote Link to comment Share on other sites More sharing options...
FernandoM Posted October 3, 2018 Share Posted October 3, 2018 Colegas, boa noite. Percebi que o módulo parou de funcionar já alguns dias, eu consegui resolver o problema de uma maneira bem simples. Aparentemente a função GetStatus do módulo envia requisições POST, não sei o motivo sendo que a API trabalha com GET. Efetuei alguns testes via curl e cheguei a conclusão que o protocolo estava incorreto e que a requisição deveria ser realmente via GET. Enfim, fiz a alteração no arquivo chamado via função "include_once", no meu sistema o nome do arquivo era "lib.php". Procurem a linha "$retorno = $this->DoPost($opt = null, $url, $header, "200", "none", "post");" e alterem para "$retorno = $this->DoPost($opt = null, $url, $header, "200", "none", "get");" dentro da public "GetStatus($id)". Função GetStatus já com a correção: public function GetStatus($id) { $this->getAccessToken(); logTransaction("MERCADOPAGO LIB", $this->accesstoken, "Unsuccessful"); $url = "https://api.mercadolibre.com/collections/notifications/" . $id . "?access_token=" . $this->accesstoken; $header = array( "Accept: application/json", "Content-Type: application/x-www-form-urlencoded" ); $retorno = $this->DoPost($opt = null, $url, $header, "200", "none", "get"); return $retorno; } Me contem se resolveu para vocês, aqui já está funcionando o retorno e inserção nas transações. Ressaltando que o meu problema não estava relacionado a versão 7.6 e sim ao retorno automático após o dia 26. Vocês podem remover a linha "logTransaction("MERCADOPAGO LIB", $this->accesstoken, "Unsuccessful");", havia adicionado apenas para debug e não consegui editar o post anterior. 0 Quote Link to comment Share on other sites More sharing options...
Fabio J Posted October 3, 2018 Share Posted October 3, 2018 Parabéns Fernando Aqui funcionou também vou colar aqui todo o código lib.php do modulo do mercado pago ! Arquivo editado /public_html/modules/gateways/mercadopago/lib.php <?php class mpAuth extends mpCall { public $client_id = NULL; public $client_secret = NULL; public $refresh = NULL; public $newrefresh = null; public $accesstoken = NULL; public $error = NULL; protected $date = NULL; protected $expired = NULL; protected $b2b2c = false; public function GeAuthCore($url) { $link = "https://auth.mercadolibre.com.ar/authorization?client_id=" . $this->client_id . "&response_type=code&platform_id=mp&redirect_uri=" . $url; return $link; } public function GetRefreshToken($auth, $redict_url) { $url = "https://api.mercadolibre.com/oauth/token"; $header = array( "Accept: application/json" ); $post = array( "grant_type" => "authorization_code", "client_id" => $this->client_id, "client_secret" => $this->client_secret, "code" => $auth, "redirect_uri" => $redict_url ); $dados = $this->DoPost($post, $url, $header, "200", "post", "post"); return $dados; } public function getAccessToken() { $data = getdate(); $time = $data[0]; if( isset($this->accesstoken) && isset($this->date) ) { $timedifference = $time - $this->date; if( $timedifference < $this->expired ) { return $this->accesstoken; } } if( $this->refresh != null ) { $post = array( "client_id" => $this->client_id, "client_secret" => $this->client_secret, "grant_type" => "refresh_token", "refresh_token" => $this->refresh ); $this->b2b2c = true; $header = array( "Accept: application/json", "Content-Type: application/x-www-form-urlencoded" ); $url = "https://api.mercadolibre.com/oauth/token"; $dados = $this->DoPost($post, $url, $header, "200", "post", "post"); $this->accesstoken = $dados["access_token"]; $this->newrefresh = $dados["refresh_token"]; $this->date = $time; $this->expired = $dados["expires_in"]; return $dados["access_token"]; } $post = array( "client_id" => $this->client_id, "client_secret" => $this->client_secret, "grant_type" => "client_credentials" ); $header = array( "Accept: application/json", "Content-Type: application/x-www-form-urlencoded" ); $url = "https://api.mercadolibre.com/oauth/token"; $dados = $this->DoPost($post, $url, $header, "200", "post", "post"); $this->accesstoken = $dados["access_token"]; $this->date = $time; $this->expired = $dados["expires_in"]; return $dados["access_token"]; } } class mpCore extends mpAuth { public function __construct($client_id, $client_secret) { $this->client_id = $client_id; $this->client_secret = $client_secret; } public function GetMethods($country_id) { $url = "https://api.mercadolibre.com/sites/" . $country_id . "/payment_methods"; $header = array( "Content-Type:application/json" ); $methods = $this->DoPost($opt = null, $url, $header, "200", "none", "get"); return $methods; } public function GetCheckout($data, $excludes, $method = "lightbox") { if( $excludes != "" ) { $methods_excludes = preg_split("/[\\s,]+/", $excludes); foreach( $methods_excludes as $exclude ) { $excludemethods[] = array( "id" => $exclude ); } if( !isset($data["mkfee"]) ) { $data["mkfee"] = ""; } $data["mkfee"] = ""; $opt = array( "external_reference" => $data["external_reference"], "items" => array( array( "id" => $data["external_reference"], "title" => $data["title"], "description" => $data["quantity"] . " x " . $data["title"], "quantity" => $data["quantity"], "unit_price" => round($data["amount"], 2), "currency_id" => $data["currency"], "picture_url" => $data["image"] ) ), "payer" => array( "name" => $data["payment_firstname"], "surname" => $data["payment_lastname"], "email" => $data["email"] ), "back_urls" => array( "pending" => $data["pending"], "success" => $data["approved"] ), "payment_methods" => array( "excluded_payment_methods" => $excludemethods ) ); } else { $opt = array( "external_reference" => $data["external_reference"], "items" => array( array( "id" => $data["external_reference"], "title" => $data["title"], "description" => $data["quantity"] . " x " . $data["title"], "quantity" => $data["quantity"], "unit_price" => round($data["amount"], 2), "currency_id" => $data["currency"], "picture_url" => $data["image"] ) ), "payer" => array( "name" => $data["payment_firstname"], "surname" => $data["payment_lastname"], "email" => $data["email"] ), "back_urls" => array( "pending" => $data["pending"], "success" => $data["approved"] ) ); } $this->getAccessToken(); $url = "https://api.mercadolibre.com/checkout/preferences?access_token=" . $this->accesstoken; $header = array( "Content-Type:application/json", "Accept: application/json" ); $dados = $this->DoPost($opt, $url, $header, "201", "json", "post"); $link = $dados["init_point"]; switch( $method ) { case "lightbox": $bt = "<a href=\"" . $link . "\" name=\"MP-payButton\" class=\"blue-l-rn-ar\">Comprar</a>\n <script type=\"text/javascript\" src=\"https://www.mercadopago.com/org-img/jsapi/mptools/buttons/render.js\"></script>"; break; case "Iframe": $bt = "<iframe id=\"MP-Checkout-IFrame\" frameborder=\"0\" style=\"width: 740px; height: 480px;\" src=\"" . $link . "\">"; break; case "initpoint": $bt = $link; break; default: $bt = "<a href=\"" . $link . "\" name=\"MP-payButton\" class=\"blue-l-rn-ar\">Comprar</a>\n <script type=\"text/javascript\" src=\"https://www.mercadopago.com/org-img/jsapi/mptools/buttons/render.js\"></script>"; break; } if( $this->b2b2c ) { $return = array( $this->newrefresh, $bt ); return $return; } return $bt; } public function GetStatus($id) { $this->getAccessToken(); logTransaction("MERCADOPAGO LIB", $this->accesstoken, "Unsuccessful"); $url = "https://api.mercadolibre.com/collections/notifications/" . $id . "?access_token=" . $this->accesstoken; $header = array( "Accept: application/json", "Content-Type: application/x-www-form-urlencoded" ); $retorno = $this->DoPost($opt = null, $url, $header, "200", "none", "get"); return $retorno; } public function SearchPayment($dados = array( ), $limit = null, $offset = null, $sort = null, $order = null) { $field = ""; foreach( $dados as $key => $value ) { if( $key == "date_created" || $key == "date_approved" || $key == "last_modified" ) { $field .= "range=" . $key . "&"; foreach( $value as $keys => $dates ) { if( $keys == "start" ) { $field .= "begin_date=" . $dates . "&"; } else { if( $keys == "end" ) { $field .= "end_date=" . $dates . "&"; } } } } else { $field .= $key . "=" . $value . "&"; } } $this->getAccessToken(); if( $limit != null ) { $field .= "limit=" . $limit . "&"; } if( $offset != null ) { $field .= "offset=" . $offset . "&"; } if( $sort != null ) { $field .= "sort=" . $sort . "&"; } if( $order != null ) { $field .= "order=" . $order . "&"; } $header = array( "Accept: application/json", "Content-Type: application/x-www-form-urlencoded" ); $url = "https://api.mercadolibre.com/collections/search?access_token=" . $this->accesstoken . "&" . $field; var_dump($url); $retorno = $this->DoPost($opt = null, $url, $header, "none", "none", "get"); return $retorno; } public function RefundPayment($id) { $this->getAccessToken(); $header = array( "Content-Type:application/json", "Accept: application/json" ); $opt = "{\"status\":\"cancelled\"}"; $url = "https://api.mercadolibre.com/collections/" . $id . "?access_token=" . $this->accesstoken; $teste = $this->DoPost($opt, $url, $header, "200", "none", "put"); return $teste; } public function create_preapproval_payment($preapproval_payment, $method = "lightbox") { $this->getAccessToken(); $header = array( "Content-Type:application/json", "Accept: application/json" ); $url = "https://api.mercadolibre.com/preapproval?access_token=" . $this->accesstoken; $preapproval_payment_result = $this->DoPost($preapproval_payment, $url, $header, "201", "json", "post"); $link = $preapproval_payment_result["init_point"]; switch( $method ) { case "lightbox": $bt = "<a href=\"" . $link . "\" name=\"MP-payButton\" class=\"blue-l-rn-ar\">Comprar</a>\n<script type=\"text/javascript\" src=\"https://www.mercadopago.com/org-img/jsapi/mptools/buttons/render.js\"></script>"; break; case "Iframe": $bt = "<iframe id=\"MP-Checkout-IFrame\" frameborder=\"0\" style=\"width: 740px; height: 480px;\" src=\"" . $link . "\">"; break; case "initpoint": $bt = $link; break; default: $bt = "<a href=\"" . $link . "\" name=\"MP-payButton\" class=\"blue-l-rn-ar\">Comprar</a>\n <script type=\"text/javascript\" src=\"https://www.mercadopago.com/org-img/jsapi/mptools/buttons/render.js\"></script>"; break; } if( $this->b2b2c ) { $return = array( $this->newrefresh, $bt ); return $return; } return $bt; } } class mpCall { public static function debug($error) { echo "<br>Retorno error<br><pre>"; print_r($error); echo "</pre><br><br>"; } public function DoPost($fields, $url, $heads, $codeexpect, $type, $method) { if( $type == "json" ) { $posts = json_encode($fields); } else { if( $type == "none" ) { $posts = $fields; } else { $posts = http_build_query($fields); } } switch( $method ) { case "get": $options = array( CURLOPT_RETURNTRANSFER => "1", CURLOPT_HTTPHEADER => $heads, CURLOPT_SSL_VERIFYPEER => "false", CURLOPT_URL => $url, CURLOPT_POSTFIELDS => $posts, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_CONNECTTIMEOUT => 0 ); break; case "put": $options = array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_HTTPHEADER => $heads, CURLOPT_SSL_VERIFYPEER => "false", CURLOPT_URL => $url, CURLOPT_POSTFIELDS => $posts, CURLOPT_CUSTOMREQUEST => "PUT", CURLOPT_HEADER => 1, CURLOPT_CONNECTTIMEOUT => 0 ); break; case "post": $options = array( CURLOPT_RETURNTRANSFER => "1", CURLOPT_HTTPHEADER => $heads, CURLOPT_SSL_VERIFYPEER => "false", CURLOPT_URL => $url, CURLOPT_POSTFIELDS => $posts, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_CONNECTTIMEOUT => 0 ); break; case "delete": $options = array( CURLOPT_RETURNTRANSFER => "1", CURLOPT_HTTPHEADER => $heads, CURLOPT_SSL_VERIFYPEER => "false", CURLOPT_URL => $url, CURLOPT_POSTFIELDS => $posts, CURLOPT_CUSTOMREQUEST => "DELETE", CURLOPT_CONNECTTIMEOUT => 0 ); break; default: $options = array( CURLOPT_RETURNTRANSFER => "1", CURLOPT_HTTPHEADER => $heads, CURLOPT_SSL_VERIFYPEER => "false", CURLOPT_URL => $url, CURLOPT_POSTFIELDS => $posts, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_CONNECTTIMEOUT => 0 ); break; } $options[CURLOPT_SSLVERSION] = TLSv1; $call = curl_init(); curl_setopt_array($call, $options); $dados = curl_exec($call); $status = curl_getinfo($call); curl_close($call); if( $status["http_code"] != $codeexpect && $codeexpect != "none" ) { $this->debug($dados); return false; } return json_decode($dados, true); } } Muito Obrigado e parabéns pela iniciativa de compartilhar !!! 2 Quote Link to comment Share on other sites More sharing options...
Fabio J Posted October 10, 2018 Share Posted October 10, 2018 Bom dia Alvaro . vou mandar o modulo total compactado ! www.xxhost.com.br/Modulo_whmcs_10-10-2018.zip veja se da certo ! att, fabio 1 Quote Link to comment Share on other sites More sharing options...
Fabio J Posted October 10, 2018 Share Posted October 10, 2018 Beleza meu amigo !!!! . vlw !!!! 0 Quote Link to comment Share on other sites More sharing options...
tonybdo Posted October 18, 2018 Share Posted October 18, 2018 Em 10/10/2018 em 07:39, Fabio J disse: Bom dia Alvaro . vou mandar o modulo total compactado ! www.xxhost.com.br/Modulo_whmcs_10-10-2018.zip veja se da certo ! att, fabio Olá, Fui baixar, o link está off poderia disponibilizar novamente? 0 Quote Link to comment Share on other sites More sharing options...
Fabio J Posted October 18, 2018 Share Posted October 18, 2018 8 horas atrás, tonybdo disse: Olá, Fui baixar, o link está off poderia disponibilizar novamente? Link ta on sim amigo ! fiz o teste aqui ! 0 Quote 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.
Note: Your post will require moderator approval before it will be visible.