Unable to Deposit Funds

Created on 3 April 2024, 8 months ago
Updated 23 April 2024, 7 months ago

Problem/Motivation

First thank you for updating this module to resolve the issue I had earlier.

I just updated to the new version via composer. The enabling process was not very smooth. It has errors as below:

TypeError: Drupal\points\Plugin\Derivative\PointsLocalTask::__construct(): Argument #1 ($route_provider) must be of type Drupal\Core\Routing\RouteProvider, Drupal\Core\Routing\RouteProviderLazyBuilder given, called in /chroo...

But the module was enabled. I added the payment gateway with the fund. Then I went to user page to test it. On paying with the balance page, I clicked "Deposit funds", entering required data, then Next, here comes error:

Error: Call to a member function getRefreshFrequency() on null in Drupal\commerce_order\OrderRefresh->needsRefresh()

I have Paypal sandbox payment set up now, works fine with regular payment method. Or this module doesn't work with Paypal?

Please advise what I may have done wrong.

Regards

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

2.1

Component

User interface

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @sdsc
  • 🇭🇷Croatia Aporie

    Hi,

    Regarding your previous install, you might have a corrupted installation of the module. If I were you, I'd uninstall it and reinstall it after updating to last version with composer.

    For order payments, this shouldn't be related to commerce_funds, and you should be able to use any payment method. This module only hooks itself around commerce payment processing, so issues might come from the module you use as a payment gateway.

    Looking into the code, your error happens here:

    /** @var \Drupal\commerce_order\Entity\OrderTypeInterface $order_type */
        $order_type = $this->orderTypeStorage->load($order->bundle());
        $refreshed_ago = $current_time - $order_time;
        if ($refreshed_ago >= $order_type->getRefreshFrequency()) {
          return TRUE;
        }
    

    It means $this->orderTypeStorage->load($order->bundle()); returns nothing. I don't know where you're at in your development process, but I would make a complete reinstallation of commerce_funds and Drupal commerce. This will force you to delete any previous entity you might have created which seem to be corrupted now.

  • Thank you for coming back on this!

    when I run "drush pm-uninstall commerce_funds", uninstall failed with errors as below:
    -------------------------

    sh: module: line 1: syntax error: unexpected end of file
    sh: error importing function definition for `BASH_FUNC_module'
    sh: module: line 1: syntax error: unexpected end of file
    sh: error importing function definition for `BASH_FUNC_module'

    In ExceptionHandler.php line 56:

    SQLSTATE[42S02]: Base table or view not found: 1146 Table 'aab0448d_jh816_new.commerce_payment_method__balance_id' doesn't exist: UPDATE "commerce_payment_method__balance_id" SET "deleted"=:db_update_placeholder_0
    WHERE "bundle" = :db_condition_placeholder_0; Array
    (
    [:db_update_placeholder_0] => 1
    [:db_condition_placeholder_0] => funds_wallet
    )

    In StatementWrapperIterator.php line 111:

    SQLSTATE[42S02]: Base table or view not found: 1146 Table 'aab0448d_jh816_new.commerce_payment_method__balance_id' doesn't exist
    ---------------------------
    I checked database, there is no table of commerce_payment_method__balance_id.

    Uninstalling the module through Drupal UI also failed with similar message:

    Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'aab0448d_jh816_new.commerce_payment_method__balance_id' doesn't exist: UPDATE "commerce_payment_method__balance_id" SET "deleted"=:db_update_placeholder_0 WHERE "bundle" = :db_condition_placeholder_0; Array ( [:db_update_placeholder_0] => 1 [:db_condition_placeholder_0] => funds_wallet ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->onFieldDefinitionDelete()

  • 🇭🇷Croatia Aporie

    Hmm, try recreating a "funds balance" payment gateway under /admin/commerce/config/payment-gateways/add (it doesn't matter the name).

    Once done, try uninstalling commerce_funds again.

  • I deleted the one I had and recreated a "funds balance" payment gateway, and then uninstalled it, the same error:

    Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'aab0448d_jh816_new.commerce_payment_method__balance_id' doesn't exist: UPDATE "commerce_payment_method__balance_id" SET "deleted"=:db_update_placeholder_0 WHERE "bundle" = :db_condition_placeholder_0; Array ( [:db_update_placeholder_0] => 1 [:db_condition_placeholder_0] => funds_wallet ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->onFieldDefinitionDelete() (line 1622 of /chroot/home/aab0448d/86038db258.nxcli.io/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

    In addition, when I tried to go to help page: https://86038db258.nxcli.io/admin/help/commerce_funds, "The website encountered an unexpected error. Try again later.", the error is:

    Symfony\Component\Routing\Exception\RouteNotFoundException: Route "commerce_funds.settings_fees" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 206 of /chroot/home/aab0448d/86038db258.nxcli.io/html/core/lib/Drupal/Core/Routing/RouteProvider.php).

    • Aporie committed 621ebc31 on 2.x
      Issue #3437994 by sdsc, Aporie: Unable to Deposit Funds
      
  • 🇭🇷Croatia Aporie

    So, I've checked, and actually these tables are created on commerce_funds installation.

    That limits your possibilities here. If you want to keep your current db, you'll have to create these table manually using phpmyadmin or Mysql commands. I'm attaching you the fields so you can quickly reproduce them.

    commerce_payment_balance_id:

    commerce_payment_currency:

    Otherwise, try to ping me on https://drupalchat.me/ during the day, I'll stay around but have limited time.

  • Thank you, Aporia, for your help!

    Here is what I did and see:

    1. created the two tables per your advice, deleted balance payment gateway and created a new one, then uninstall the module. NO PROBLEM this time. Good!

    2. reenable the module, errors as below. The module cannot be uninstalled again for the same error as before. I found that the two new tables were removed from the uninstall process (the enabling process doesn't create the two tables):

    ----error msg 1-----
    TypeError: Drupal\points\Plugin\Derivative\PointsLocalTask::__construct(): Argument #1 ($route_provider) must be of type Drupal\Core\Routing\RouteProvider, Drupal\Core\Routing\RouteProviderLazyBuilder given

    ----error msg 2-----
    RuntimeException: Recursive router rebuild detected. in Drupal\Core\Routing\RouteBuilder->rebuild()

    ----warning msg-----
    Warning: file_get_contents(themes/contrib/zeropoint/_custom/custom-style.css): Failed to open stream: No such file or directory in Drupal\Core\Asset\CssCollectionOptimizerLazy->generateHash()

    3. I then added the two tables back again. added a new balance payment gateway. go to check out and then deposit fund. Error is below:

    ----error msg 3-----
    Error: Call to a member function getRefreshFrequency() on null in Drupal\commerce_order\OrderRefresh->needsRefresh()

    4. help page still has the same error. I suppose your fix is on next release?

    Thank you very much for your help!

  • 🇭🇷Croatia Aporie

    I found that the two new tables were removed from the uninstall process (the enabling process doesn't create the two tables)

    From my tests, uninstalling and reinstalling the module created these tables. Though, it's coming from Drupal commerce plugin implementation it's not directly linked to commerce_funds.

    For all your error messages except the last one, it seems it's coming from the points module.

    The last one is because you have an order with a non-existent bundle.

    At that point, your db seems pretty much corrupted and content have been created with corrupted data I suppose. You'll have to do some cleaning, and I'd start by removing all Drupal Commerce (orders, orders types etc.) entities. Also try uninstalling this points module to check. But as long as it'll start to be non Commerce Funds related, I might not be from great help.

  • You are right, Aporie!

    I started a new test site, just to test commerce related features. I installed fund module It works as expected. Since there are quite some commence related modules, it is hard to identify which one caused problem. (I wish ubercart is still available in Drupal 10). I think I'll firs make sure what commerce modules I need to fulfill my business requirement, then I'll do uninstall / reinstall to migrate my data over.

    Thank you for your patience!

    This ticket can be closed.

  • Status changed to Fixed 7 months ago
  • 🇭🇷Croatia Aporie

    Yeah, it's a good approach sometimes to tests on a dummy installation and then work on a clean installation.

    Ok, I'm closing the ticket.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024