mobilpay / Magento

MAGENTO implementation - CARD Processing @mobilPay
11 stars 15 forks source link

Redirect to payment page triggers error for GUEST carts #25

Closed shuffless closed 3 years ago

shuffless commented 3 years ago

After placing an order the following error is triggered

1 exception(s): Exception #0 (Exception): Notice: Undefined variable: orderId in /home/489102.cloudwaysapps.com/vqpvkjmmdk/public_html/app/code/Netopia/Netcard/Controller/Payment/Redirect.php on line 82

Exception #0 (Exception): Notice: Undefined variable: orderId in /home/489102.cloudwaysapps.com/vqpvkjmmdk/public_html/app/code/Netopia/Netcard/Controller/Payment/Redirect.php on line 82

#1 Netopia\Netcard\Controller\Payment\Redirect->getOrder() called at [app/code/Netopia/Netcard/Controller/Payment/Redirect.php:52]
#2 Netopia\Netcard\Controller\Payment\Redirect->execute() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#3 Netopia\Netcard\Controller\Payment\Redirect\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#4 Netopia\Netcard\Controller\Payment\Redirect\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/App/Action/Plugin/ActionFlagNoDispatchPlugin.php:51]
#5 Magento\Framework\App\Action\Plugin\ActionFlagNoDispatchPlugin->aroundExecute() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#6 Netopia\Netcard\Controller\Payment\Redirect\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#7 Netopia\Netcard\Controller\Payment\Redirect\Interceptor->___callPlugins() called at [generated/code/Netopia/Netcard/Controller/Payment/Redirect/Interceptor.php:26]
#8 Netopia\Netcard\Controller\Payment\Redirect\Interceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:111]
#9 Magento\Framework\App\Action\Action->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#10 Netopia\Netcard\Controller\Payment\Redirect\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#11 Netopia\Netcard\Controller\Payment\Redirect\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#12 Netopia\Netcard\Controller\Payment\Redirect\Interceptor->___callPlugins() called at [generated/code/Netopia/Netcard/Controller/Payment/Redirect/Interceptor.php:39]
#13 Netopia\Netcard\Controller\Payment\Redirect\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:186]
#14 Magento\Framework\App\FrontController->processRequest() called at [vendor/magento/framework/App/FrontController.php:118]
#15 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#16 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#17 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php:99]
#18 Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#19 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php:71]
#20 Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#21 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/swissup/module-amp/Plugin/Framework/FrontController.php:48]
#22 Swissup\Amp\Plugin\Framework\FrontController->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#23 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#24 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26]
#25 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:116]
#26 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
#27 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:263]
#28 Magento\Framework\App\Bootstrap->run() called at [index.php:39]

--

The code responsible for this is in the getOrder function

public function getOrder()
    {
        $connection = $this->_resource->getConnection(\Magento\Framework\App\ResourceConnection::DEFAULT_CONNECTION);
        $tblSalesOrder = $this->_resource->getTableName('sales_order');
        $tblQuoteIdMask = $this->_resource->getTableName('quote_id_mask');
        $quoteId = $this->getRequest()->getParam('quote');

        /** @var ObjectManager $ */
        $obm = ObjectManager::getInstance();

        /** @var \Magento\Framework\App\Http\Context $context */
        $context = $obm->get('Magento\Framework\App\Http\Context');

        // check AUth before Payment
        /** @var bool $isLoggedIn */
        $isLoggedIn = $context->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);
        if ($isLoggedIn) {
            $orderId = $connection->fetchAll('SELECT entity_id FROM `'.$tblSalesOrder.'` WHERE quote_id='.$connection->quote($quoteId).' LIMIT 1');
        } 
        return $orderId[0]['entity_id'];
    }
shuffless commented 3 years ago

Even though the payment is not taken the order is set in Processing state so #23 is not fixed.

screenshot-m2 lamama ro-2021 01 07-10_05_22

shuffless commented 3 years ago

The problem appears only in GUEST carts. LOGGED IN customers do not encounter this issue.

navid59 commented 3 years ago

Even though the payment is not taken the order is set in Processing state so #23 is not fixed.

screenshot-m2 lamama ro-2021 01 07-10_05_22

23 , is solved

will check the send mail as well

shuffless commented 3 years ago

The problem in this scenario is that the guest carts are set to processing even though the error is thrown and actual payment is not taken. This was described in #23 as well and there this happened for all carts. Now the issue remains the same just for guests.

navid59 commented 3 years ago

Please, update from git. Guest users should be able to checkout now.

Orders from Guest users also goes to Pending payment if is not paid / processing if is paid GitPaymentGuest

So, the #23 should be fine for guest users as well, now. mail shouldn't send as well.

After Git pull if you receive the error do the following :

 - bin/magento setup:di:compile
 - bin/magento c:c
 - Remove the sub folders in generated folder if is necessary

let us know if there is something else. Thank you

shuffless commented 3 years ago

Hi, getting this in guest mode

"OOPS, something is wrong, you are not able to redirect into Payment page!"

shuffless commented 3 years ago

Authenticated users work as expected.

navid59 commented 3 years ago

Please, do the following :

shuffless commented 3 years ago
  • bin/magento setup:di:compile
  • bin/magento c:c
  • Remove the sub folders in generated folder

Did this already. We'll try some other options as well.

navid59 commented 3 years ago
shuffless commented 3 years ago

I do not know if it is related to this or not, but if the page is closed prior to the redirect the order is still set as processing while payment is not taken.

screenshot-m2 lamama ro-2021 01 08-13_22_24 screenshot-m2 lamama ro-2021 01 08-13_23_40

shuffless commented 3 years ago
  • Check the Certificates, too

I thought of this as well so I deleted all of them, readded the certificates and cleared cache. The issue persists.

navid59 commented 3 years ago

it is possible, shows you Processing , before / during redirecting to Payment page .

Please, check it like this :

and see if the status is changing to Pending Payment

navid59 commented 3 years ago

I do not know if it is related to this or not, but if the page is closed prior to the redirect the order is still set as processing while payment is not taken.

screenshot-m2 lamama ro-2021 01 08-13_22_24 screenshot-m2 lamama ro-2021 01 08-13_23_40

Is not calculated TAX ( value 12.18 Ron). For this please, open a new issue and also let us know how is defined this tax in your system . (Logic of the Tax)

shuffless commented 3 years ago

Is not calculated TAX ( value 12.18 Ron). For this please, open a new issue and also let us know how is defined this tax in your system . (Logic of the Tax)

Tax is st up as included in product price so it is listed separately for evidence for customer and does need to be added to the totals. What I meant by the arrow is that the total is set as "Total due" which means unpaid, hence the conflict with the "processing" status.

navid59 commented 3 years ago

Hello, First of all sorry for late answering you . I would like to know if you still have problem with "Total due".

I tested and in fact I didn't see any problem for "Total Due". in fact "Total Due" is not "Zero" when a payment in not completed and order status is in "Payment Reviewing" (which is Normal) .

In flowing i try to show you the steps of my testing :

If your problem regarding "Total Due" is not solved , please reopen the Issue and let us know Regard