Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last module don't handle Log error #540

Open
kpitn opened this issue Nov 6, 2023 · 0 comments
Open

Last module don't handle Log error #540

kpitn opened this issue Nov 6, 2023 · 0 comments

Comments

@kpitn
Copy link

kpitn commented Nov 6, 2023

With the last module (5.5)

You upgrade the function getPayload :

From this :

    public function getPayload()
    {
        $this->logger->additional($this->getRequest()->getContent(), 'webhook');

        return json_decode($this->getRequest()->getContent());
    }

To this :

    /**
     * Get the request payload
     *
     * @return mixed
     */
    public function getPayload()
    {
        $this->logger->additional($this->getRequest()->getContent(), 'webhook');

        return $this->json->unserialize($this->getRequest()->getContent());
    }

As you know json_decode return method object and json->unserialize from magento return array object, you translate many part of your module, but you forget :

   public function logError($response, OrderInterface $order): void
    {
        // Assign the payment instance
        $payment = $order->getPayment();

        // Prepare the failed transaction info
        $suffix = __(
            ' for an amount of %1. Action ID: %2. Event ID: %3. Payment ID: %4. Error: %5 %6',
            $this->prepareAmount($response->data->amount, $order),
            !empty($response->data->action_id) ? $response->data->action_id : __('Not specified.'),
            !empty($response->id) ? $response->id : __('Not specified.'),
            !empty($response->data->id) ? $response->data->id : __('Not specified.'),
            !empty($response->data->response_code) ? $response->data->response_code : __('Not specified.'),
            !empty($response->data->response_summary) ? $response->data->response_summary : __('Not specified.')
        );

        // Add the order comment
        $previousComment = $this->orderHandler->getStatusHistoryByEntity('3ds Fail', $order);
        if ($previousComment && $response->type === 'payment_declined') {
            $previousComment->setEntityName('order')->setComment(
                __(self::TRANSACTION_ERROR_LABEL[$response->type]) . $suffix
            );
            $this->orderStatusHistoryRepository->save($previousComment);
        } else {
            // Add the order comment
            $order->addStatusHistoryComment(
                __(self::TRANSACTION_ERROR_LABEL[$response->type]) . $suffix
            );
        }

        // Save the data
        $this->orderPaymentRepository->save($payment);
        $this->orderRepository->save($order);
    }

Every callback with an error crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant