pronamic / wp-pay-core

Core components for the WordPress payment processing library. This library is used in the WordPress plugin Pronamic Pay: https://www.pronamicpay.com/, but also allows other plugin developers to set up a payment plugin.
https://www.wp-pay.org/
GNU General Public License v3.0
27 stars 3 forks source link

Exception on Reports page #52

Closed knit-pay closed 2 years ago

knit-pay commented 3 years ago

Getting an exception while visiting the Reports page. I am using the latest version (6.9.4) of Pronamic Pay. This exception was not there on the older version (don't remember the version number). On the fresh copy of WordPress, this error does not occur.

[19-Aug-2021 13:14:39 UTC] PHP Fatal error:  Uncaught InvalidArgumentException: The alphabetical code of a currency must consist of 3 characters: . in /var/www/dev/wp-content/plugins/pronamic-ideal/vendor/pronamic/wp-money/src/Currency.php:93
Stack trace:
#0 /var/www/dev/wp-content/plugins/pronamic-ideal/vendor/pronamic/wp-money/src/Currency.php(68): Pronamic\WordPress\Money\Currency->set_alphabetic_code()
#1 /var/www/dev/wp-content/plugins/pronamic-ideal/vendor/pronamic/wp-money/src/Currencies.php(57): Pronamic\WordPress\Money\Currency->__construct()
#2 /var/www/dev/wp-content/plugins/pronamic-ideal/vendor/pronamic/wp-money/src/Currency.php(169): Pronamic\WordPress\Money\Currencies::get_currency()
#3 /var/www/dev/wp-content/plugins/pronamic-ideal/vendor/pronamic/wp-money/src/Money.php(243): Pronamic\WordPress\Money\Currency::get_instance()
#4 /var/www/dev/wp-content/plugins/pronamic-ideal/vendor/pronamic/wp-money/src/Money.php(46): Pronamic\WordPress\Money\Money->set_currency()
#5 /var/www/dev/wp-content/plugins/pronamic-ideal/vendor/wp-pay/core/src/Pa in /var/www/dev/wp-content/plugins/pronamic-ideal/vendor/pronamic/wp-money/src/Currency.php on line 93
remcotolsma commented 3 years ago

I currently can't reproduce this issue, but i can confirm that the alphabetical code of a currency must now consist of 3 characters: https://github.com/pronamic/wp-money. Maybe some older payments don't have a currency code? Can you share a complete debug backtrace of this error/exception?

knit-pay commented 3 years ago

Yes, you are right, because this is my development environment, so some payments might have null or missing currency. Can we handle it in such a way that in case of missing currency, it uses default currency or ignore that payment in the report page, instead of throwing an exception? It will be a better user experience.

knit-pay commented 2 years ago

In the new version, I am not getting this issue. I think it's already fixed.