Called on callback.

@param Order $order Order.
@param mixed $data  Request input from callback.

@return bool
191618
public function onCallbackSuccess($order, $data = null)
    {
        $paymentId  = is_array($data) ? $data['paymentId'] : $data->paymentId;

        $payerId    = is_array($data) ? $data['PayerID'] : $data->PayerID;

        $this->statusCode = 'failed';

        $this->detail = sprintf('Payment failed. Ref: %s', $paymentId);

        // Begin paypal
        try {

            $this->setContext();

            $payment = Payment::get($paymentId, $this->apiContext);
            
            $execution = new PaymentExecution();

            $execution->setPayerId($payerId);

            $payment->execute($execution, $this->apiContext);

            $payment = Payment::get($paymentId, $this->apiContext);

            $this->statusCode = 'completed';

            $this->transactionId = $payment->id;

            $this->detail = 'Success';

        } catch (PayPalConnectionException $e) {

            $response = json_decode($e->getData());

            throw new GatewayException(
                sprintf(
                    '%s: %s',
                    $response->name,
                    isset($response->message) ? $response->message : 'Paypal payment Failed.'
                ),
                1001,
                $e
            );

        } catch (\Exception $e) {

            throw new GatewayException(
                $e->getMessage(),
                1000,
                $e
            );

        }
    }
1112359
public function releaseAction(Order $order)
    {
        $order->releaseToBuyer();

        $em = $this->getDoctrine()->getEntityManager();
        $em->persist($order);
        $em->flush();

        return $this->redirect($this->generateUrl('Order_show', array(
            'id' => $order->getNumberForPath()
        )));
    }
220480
public function checkByOrderId($orderId)
    {
        // Clear the error variable
        $this->error = '';

        /**
         * Check value is string
         * If string return false and set error message on error variable
         */
        if (
        !self::__validateString($orderId, 1, 50)
        )
            return false;

        $param = array(
            "apikey" => $this->apiKey,
            "mob" => $this->mobile,
            "id" => $orderId
        );

        return self::__sendCheckRequest('invoice/byorderid', $param);
    }
870473
private function setOrderType($data, ApiOrderInterface $order, $patch = false)
    {
        // get OrderType
        $type = $this->getProperty($data, 'type', $order->getType());
        // set order type
        if (isset($data['type'])) {
            if (is_array($type) && isset($type['id'])) {
                // if provided as array
                $typeId = $type['id'];
            } elseif (is_numeric($type)) {
                // if is numeric
                $typeId = $type;
            } else {
                throw new OrderException('No typeid given');
            }
        } elseif (!$patch) {
            // default type is manual
            $typeId = OrderType::MANUAL;
        } else {
            // keep current type
            return;
        }

        // get entity
        $orderType = $this->getOrderTypeEntityById($typeId);
        if (!$orderType) {
            throw new EntityNotFoundException(static::$orderTypeEntityName, $typeId);
        }

        // set order type
        $order->setType($orderType);
    }
892462
public function cancelAction(Order $order)
    {
        $order->cancelByBuyer();

        $em = $this->getDoctrine()->getEntityManager();
        $em->persist($order);
        $em->flush();

        return $this->redirect($this->generateUrl('Order_show', array(
            'id' => $order->getNumberForPath()
        )));
    }
1091150
public function callback($data)
    {
        $payload = $data;
        $this->logger->debug($payload);
        $decoded  = JWT::decode($payload, $this->payapiApiKey, ['HS256']);
        $jsonData = json_decode($decoded);
        $result   = null;

        if ($jsonData->payment->status == 'processing') {
            //Processing async payment
            $this->logger->debug("PROCESSING CALLBACK...");
            $order_id = $this->helper->createOrder($jsonData);
            $result   = ['platform' => 'magento', 'order_id' => $order_id];
        } else {
            $orderId = $this->getOrderId($jsonData);
            if ($orderId) {
                if ($jsonData->payment->status == 'successful') {
                    $this->logger->debug("SUCCESSFUL CALLBACK...");
                    //Payment success
                    $order_id = $this->helper->addPayment($orderId);
                    $result   = ['platform' => 'magento', 'order_id' => $order_id];
                } elseif ($jsonData->payment->status == 'failed') {
                    //Payment failure
                    $this->logger->debug("FAILED CALLBACK...");
                    $order_id = $this->helper->changeStatus($orderId, "canceled", "canceled", "failed");
                    $result   = ['platform' => 'magento', 'order_id' => $order_id];
                } elseif ($jsonData->payment->status == 'cancelled') {
                    //Payment failure
                    $this->logger->debug("CANCELLED CALLBACK...");
                    $order_id = $this->helper->changeStatus($orderId, "canceled", "canceled", "cancelled");
                    $result   = ['platform' => 'magento', 'order_id' => $order_id]; 
                } elseif ($jsonData->payment->status == 'chargeback') {
                    $this->logger->debug("CHARGEBACK CALLBACK...");
                    $order_id = $this->helper->changeStatus(
                        $orderId,
                        "payment_review",
                        "payment_review",
                        "chargeback"
                    );

                    $result = ['platform' => 'magento', 'order_id' => $order_id];
                } else {
                    //Payment cancelled
                    $this->logger->debug("STATUS CALLBACK: ".$jsonData->payment->status);
                    $order_id = $this->helper->changeStatus(
                        $orderId,
                        "payment_review",
                        "payment_review",
                        $jsonData->payment->status
                    );

                    $result = ['platform' => 'magento', 'order_id' => $order_id];
                }
            }
        }

        if (isset($result)) {
            $this->logger->debug(json_encode($result));
            return json_encode($result);
        } else {
            $this->logger->debug("KO. COULD NOT CREATE ORDER OR ADD PAYMENT");
            throw new \Magento\Framework\Exception\LocalizedException(__('Could not create the order correctly.'));
        }
    }
543538
public function receiveAction(Order $order)
    {
        $order->receiveByHub();

        $em = $this->getDoctrine()->getEntityManager();
        $em->persist($order);
        $em->flush();

        return $this->redirect($this->generateUrl('Order_show', array(
            'id' => $order->getNumberForPath()
        )));
    }
136485
protected function setOrder($order_id)
    {
        $this->data_order = array();

        if (is_numeric($order_id)) {

            $this->data_order = $this->order->get($order_id);

            if (empty($this->data_order)) {
                $this->outputHttpStatus(404);
            }

            $this->order_history->setViewed($this->data_order);
            $this->prepareOrder($this->data_order);
        }
    }
549547
public function deleteOrder(int $orderId) : bool
    {
        Assert::that($orderId)->greaterThan(0, 'The $orderId has to be positive');

        return (bool)$this->master->doRequest('DELETE', sprintf('/admin/WEBAPI/Endpoints/v1_0/OrderService/{KEY}/%d', $orderId));
    }
347056
protected function _order(Zend_Db_Table_Select $select, $order)
    {
        if (!is_array($order)) {
            $order = array($order);
        }

        foreach ($order as $val) {
            $select->order($val);
        }

        return $select;
    }
289804
public function thenByDesc($order)
    {
        $order = LambdaUtils::toSelectCallable($order);
        $this->orders[] = array("property" => $order, "direction" => self::ORDER_DESC);
        return $this;
    }
363566
public function order(array $condition, array $data)
    {
        $is_order = (int) isset($data['order_id']);
        $value = (int) filter_var(reset($condition['value']), FILTER_VALIDATE_BOOLEAN);
        return $this->compare($is_order, $value, $condition['operator']);
    }
1250855
public function order($order)
    {
        $order = $this->prepareNames(func_get_args(),false);
        $this->order = $order;
        return $this;
    }
72617
protected function prepareOrderAccountOrder(array &$order)
    {
        $this->setItemTotalFormatted($order, $this->price);
        $this->setItemOrderAddress($order, $this->address);
        $this->setItemOrderStoreName($order, $this->store);
        $this->setItemOrderStatusName($order, $this->order);
        $this->setItemOrderPaymentName($order, $this->payment);
        $this->setItemOrderShippingName($order, $this->shipping);
    }
657346
public function setOrder($order)
    {
        if (!empty($order)) {
            $this->query['order'] = $order;
        } else {
            unset($this->query['order']);
        }
        return $this;
    }
239118
private function checkConciliation($payment, $order)
    {
        if ($order->getStatus() == $this->getStatusFromPaymentKey($payment->getStatus()))
            return true;
        return false;
    }
1083440
protected function canViewOrder(Order $order)
    {
        return $this->httpContext->getValue(Context::CONTEXT_AUTH)
            && $this->isVisible($order);
    }