Receiving API POST

Asked

Viewed 182 times

1

I’m having trouble receiving data via POST from the Cielo API. I’ve already spoken to King Host and everything is right about the certificates and so on.

I did some research on Github and found a similar topic: https://github.com/DeveloperCielo/Checkout-Cielo/issues/8

I followed the recommendations but without success, the Database does not Update.

I’m using the Codeigniter 3 framework, and I put the notification and status pages in the Public folder

Follow the code of the pages

$order_number = $_POST['order_number'];
if(isset($order_number)){
//as variaveis de conexão eu escondi
$pdo = new PDO("mysql:host=$host; dbname=$dbname", $userdb, $userpass);
$pdo->exec("SET CHARACTER SET utf8");      // Sets encoding UTF-8
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$sql = 'UPDATE `tb_store_orders` SET `details_ship` = :details_ship, `order_shipping` = :price_ship, `order_status` = :order_status, `order_tid` = :order_tid WHERE `order_number` = :order_number';

        $mod_ship = $_POST['shipping_type'];
        $name_ship = $_POST['shipping_name'];
        $price_ship = $_POST['shipping_price'];
        $cep_ship = $_POST['shipping_adress_zipcode'];
        $dist_ship = $_POST['shipping_adress_district'];
        $city_ship = $_POST['shipping_adress_city'];
        $state_ship = $_POST['shipping_state'];
        $adre_ship1 = $_POST['shipping_adress_line1'];
        $adre_ship2 = $_POST['shipping_adress_line2'];
        $number_ship = $_POST['shipping_adress_number'];
        $details_ship = $mod_ship.'<br>'.
                        $name_ship.'<br>'.
                        $price_ship.'<br>'.
                        $cep_ship.'<br>'.
                        $state_ship.'<br>'.
                        $city_ship.'<br>'.
                        $adre_ship1.', '.$number_ship.', '.$adre_ship2.', '.$dist_ship;
        $order_status = $_POST['payment_status'];
        $order_tid = $_POST['tid'];

 $statement = $pdo->prepare($sql);
 $statement->bindValue(":details_ship", $details_ship);
 $statement->bindValue(":price_ship", $price_ship);
 $statement->bindValue(":order_status", $order_status);
 $statement->bindValue(":order_tid", $order_tid);
 $statement->bindValue(":order_number", $order_number);

$count = $statement->execute();
  $pdo = null; 
        echo '<status>OK</status>';
        }
        echo 'Nenhum';
?>

Does anyone have any suggestions?

  • What error are you getting?

  • There it is, I have no way of knowing. Why does not update the table. and I do not know if the parameters are going to that page.

  • 1

    See the PHP log. Add var_dump to see values of variables. Use phpdebug to analyze what happens when executing the script. See the request generated by the browser in the developer tools if there is any abnormal data. And add any information you deem relevant to your question. Check the database to see if there is a tuple in the table being modified with the value passed in order_number.

  • Vinícius Gobbo, thank you very much. It was very helpful, I hadn’t even thought about it. I wasn’t getting the password and the connection with the comic didn’t work. If you want to use this comment as a reply then I will give as solved. Thank you very much. Do not imagine how it helped.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.