I need help to add coins at my DB. Can someone help me?
SQL:
-- phpMyAdmin SQL Dump
-- version 4.9.7
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Tempo de geração: 04-Nov-2022 às 14:27
-- Versão do servidor: 5.7.23-23
-- versão do PHP: 7.4.30
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
-- --------------------------------------------------------
--
-- Estrutura da tabela `status`
--
CREATE TABLE `status` (
`id` smallint(8) NOT NULL,
`status` text CHARACTER SET latin1 NOT NULL,
`account` text CHARACTER SET latin1 NOT NULL,
`points` text CHARACTER SET latin1 NOT NULL,
`codigo` text CHARACTER SET latin1 NOT NULL,
`chave` text CHARACTER SET latin1 NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Índices para tabelas despejadas
--
--
-- Índices para tabela `status`
--
ALTER TABLE `status`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT de tabelas despejadas
--
--
-- AUTO_INCREMENT de tabela `status`
--
ALTER TABLE `status`
MODIFY `id` smallint(8) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
PHP:
<?php
// Conexao com banco de dados
$servername = "localhost";
$username = "root";
$password = "Piloto55";
$db_name = "baiakthunder";
$conexao = mysqli_connect($servername, $username, $password, $db_name);
?>
PHP:
<?php include('conexao.php');?>
<?php
$curl = curl_init();
$dados["transaction_amount"] = (int) $_POST['itemCount'];
$dados["description"] = $_POST['description'];
$dados["external_reference"] = "2";
$dados["payment_method_id"] = "pix";
$dados["notification_url"] = "http://168.197.13.250/notification.php";
$dados["payer"]["email"] = $_POST['email_cob'];
$dados["payer"]["first_name"] = "Nilza";
$dados["payer"]["last_name"] = "Guimaraes";
$dados["payer"]["identification"]["type"] = "CPF";
$dados["payer"]["identification"]["number"] = "45301859153";
$dados["payer"]["address"]["zip_code"] = "76240000";
$dados["payer"]["address"]["street_name"] = "Av. carlos gomes";
$dados["payer"]["address"]["street_number"] = "411";
$dados["payer"]["address"]["neighborhood"] = "Bela Vista";
$dados["payer"]["address"]["city"] = "Aragarcas";
$dados["payer"]["address"]["federal_unit"] = "GO";
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.mercadopago.com/v1/payments',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($dados),
CURLOPT_HTTPHEADER => array(
'accept: application/json',
'content-type: application/json',
'Authorization: Bearer APP_USR-5537080437263233-061412-48b1934890cf8f466a028359b24afd37-145704153'
),
));
$response = curl_exec($curl);
$resultado = json_decode($response);
//var_dump($response);
curl_close($curl);
?>
<img style='display:block; width:300px;height:300px;' id='base64image'
src='data:image/jpeg;base64, <?php echo $resultado->point_of_interaction->transaction_data->qr_code_base64;?>' />
<b>Copie:</b>
<?php echo $resultado->point_of_interaction->transaction_data->qr_code;?>
<?php
$sql="INSERT INTO status(status, codigo) VALUES('".$resultado->status."', '".$resultado->id."')";
mysqli_query($conexao, $sql);
?>
PHP:
<?php include('config.php');?>
<?php
$collector_id = $_REQUEST['id'];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.mercadopago.com/v1/payments/'.$collector_id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'accept: application/json',
'content-type: application/json',
'Authorization: Bearer '
),
));
$response = curl_exec($curl);
$resultado = json_decode($response);
curl_close($curl);
$update = "UPDATE status SET
status = '".$resultado->status."'
WHERE codigo='$collector_id'";
mysqli_query($conexao, $update);