/** * Retrieves an existing order by ID * @param int $order_id Order ID * @return APP_Order Object representing the order */ public static function retrieve($order_id) { if (!is_int($order_id)) { trigger_error('Order ID must be numeric', E_USER_WARNING); } $order = APP_Order_Factory::retrieve($order_id); return new APP_Order_Receipt($order); }
/** * Returns an instance of APP_Order for the given Order ID * @param int $order_id An order ID * @return APP_Order An order object representing the order */ function appthemes_get_order($order_id, $force_refresh = false) { return APP_Order_Factory::retrieve($order_id, $force_refresh); }
function pagseguro_create_payment_listener() { $code = isset($_POST['notificationCode']) && trim($_POST['notificationCode']) !== "" ? trim($_POST['notificationCode']) : null; $type = isset($_POST['notificationType']) && trim($_POST['notificationType']) !== "" ? trim($_POST['notificationType']) : null; if ($code && $type) { pagseguro_log('::::: Notificação PagSeguro recebida :::::'); $options = APP_Gateway_Registry::get_gateway_options('pagseguro'); $email = $options['user_email']; $token = $options['use_sandbox'] ? $options['user_token_sandbox'] : $options['user_token']; $url = $options['use_sandbox'] ? 'https://ws.sandbox.pagseguro.uol.com.br/v2/transactions/notifications/' : 'https://ws.pagseguro.uol.com.br/v2/transactions/notifications/'; $url = $url . $code . '?email=' . $email . '&token=' . $token; $ch = curl_init($url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $transaction = curl_exec($ch); if ($transaction == 'Unauthorized') { pagseguro_log('Transação não autorizada. Token: ' . $token); exit; } curl_close($ch); $transaction = simplexml_load_string($transaction); $status = $transaction->status; $order = APP_Order_Factory::retrieve(intval($transaction->reference)); if (false === $order) { pagseguro_log('ERRO: Não foi encontrado pedido com ID_TRANSACAO == ' . $transaction->reference); return; } switch ($status) { case 3: if ($order->get_status() == 'tr_activated') { pagseguro_log('Notificação repetida para ' . $transaction->reference . '. Ignorando...'); return; } $order->activate(); pagseguro_log('Pedido ' . $transaction->reference . ' foi ativado'); break; case 7: if ($order->get_status() == 'tr_failed') { pagseguro_log('Notificação repetida para ' . $transaction->reference . '. Ignorando...'); } $order->failed(); pagseguro_log('Pedido ' . $transaction->reference . ' foi cancelado'); } } }
public function test_retrieve_order() { $this->order_id = $this->order->get_id(); $new_order = APP_Order_Factory::retrieve($this->order_id); $this->assertEquals($this->order, $new_order); }
function appthemes_get_order($order_id) { return APP_Order_Factory::retrieve($order_id); }