Consultar pedidos

Realizar consulta de um pedido gerado.

📘

Pesquisa de pedidos.

Você pode consultar pedidos pelo ID, uma lista de todos os pedidos ou utilizar um de nossos filtros para consultar.

<?php
  
require '../vendor/autoload.php';

use Aqbank\Apiv2\SellerAqpago;
use Aqbank\Apiv2\Aqpago\Request\AqpagoEnvironment;
use Aqbank\Apiv2\Aqpago\Aqpago;
use Aqbank\Apiv2\Aqpago\Order;

try {
    // Ambiente de homologação
    $environment = AqpagoEnvironment::sandbox();

    $seller_doc 	= '0000000000';
    $seller_token 	= 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
    $sellerAqpago   = new SellerAqpago($seller_doc, $seller_token);

    /** Pesquisa por ORDER ID **/
    $searchOrderId = (new Aqpago($sellerAqpago, $environment))->getOrder('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX');

    /**  Pesquisa geral, retorna todos os pedidos **/
    $allOrders = (new Aqpago($sellerAqpago, $environment))->getSearchOrders();

    /*** Pesquisa com filtros **/
	$filters = [
			'reference_id'  => null, // reference id
			'status'        => null, // order status
			'type'          => null, // type
			'amount'        => null, // amount
			'initial_date'  => null, // start date
			'final_date'    => null, // end date
			'limit'         => null, // limit per page
			'page'          => null, // page number
			'sort'          => null // asc or desc		
	];

    $filterOrders = (new Aqpago($sellerAqpago, $environment))->getSearchOrders($filters);

} catch(Exception $e){
    echo $e->getMessage();
    exit();
}

echo "<br>";
echo "<h2>Response order ID: </h2>";
echo "<pre>";
echo json_encode(array_filter($searchOrderId->jsonSerialize()), JSON_PRETTY_PRINT);
echo "</pre>";

echo "<br>";
echo "<h2>Response all orders: </h2>";
echo "<pre>";
echo json_encode(array_filter($allOrders->jsonSerialize()), JSON_PRETTY_PRINT);
echo "</pre>";


echo "<br>";
echo "<h2>Response filter orders: </h2>";
echo "<pre>";
echo json_encode(array_filter($filterOrders->jsonSerialize()), JSON_PRETTY_PRINT);
echo "</pre>";