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

BUGFIX - payment methods provider filters fixed #28

Closed
wants to merge 1 commit into from
Closed

BUGFIX - payment methods provider filters fixed #28

wants to merge 1 commit into from

Conversation

ebaranauskas
Copy link

@ebaranauskas ebaranauskas commented Jul 17, 2024

  • Payment methods provider fix.

null amount when searching for payment methods was treated as 0 so it did not return any payment methods. I think, it should return all enabled project payment methods instead. Null currency did not work, no point to allow searching by it.

Fixed both issues, yet I suggest adapting my PR according your standards. It's quite strange that resulting file WebToPay.php got so different for me...

Issue demonstration:

erikas@zen:~/Projects/test$ cat test.php 
<?php

require_once 'WebToPay.php';


explainResult(WebToPay::getPaymentMethodList(6028, null, 'EUR'));
explainResult(WebToPay::getPaymentMethodList(6028, 0, 'EUR'));
explainResult(WebToPay::getPaymentMethodList(6028, 100, 'EUR'));
explainResult(WebToPay::getPaymentMethodList(6028, 100, null));

function explainResult(WebToPay_PaymentMethodList $list): void
{
    printf("LT payment methods found: %d\n", count((array) $list->getCountry('lt')?->getPaymentMethods()));
}
erikas@zen:~/Projects/test$ php test.php #before my changes
LT payment methods found: 0
LT payment methods found: 0
LT payment methods found: 13
PHP Fatal error:  Uncaught TypeError: WebToPay_PaymentMethodList::__construct(): Argument #2 ($currency) must be of type string, null given, called in /home/erikas/Projects/test/WebToPay.php on line 1557 and defined in /home/erikas/Projects/test/WebToPay.php:1258
Stack trace:
#0 /home/erikas/Projects/test/WebToPay.php(1557): WebToPay_PaymentMethodList->__construct()
#1 /home/erikas/Projects/test/WebToPay.php(253): WebToPay_PaymentMethodListProvider->getPaymentMethodList()
#2 /home/erikas/Projects/test/test.php(9): WebToPay::getPaymentMethodList()
#3 {main}
  thrown in /home/erikas/Projects/test/WebToPay.php on line 1258

erikas@zen:~/Projects/test$ php test.php #after my changes
LT payment methods found: 16
LT payment methods found: 0
LT payment methods found: 13
PHP Fatal error:  Uncaught TypeError: WebToPay_PaymentMethodListProvider::getPaymentMethodList(): Argument #2 ($currency) must be of type string, null given, called in /home/erikas/Projects/test/WebToPay.php on line 253 and defined in /home/erikas/Projects/test/WebToPay.php:1082
Stack trace:
#0 /home/erikas/Projects/test/WebToPay.php(253): WebToPay_PaymentMethodListProvider->getPaymentMethodList()
#1 /home/erikas/Projects/test/test.php(9): WebToPay::getPaymentMethodList()
#2 {main}
  thrown in /home/erikas/Projects/test/WebToPay.php on line 1082
erikas@zen:~/Projects/test$

@ebaranauskas
Copy link
Author

ebaranauskas commented Jul 18, 2024

Found some problems with it. Will present new changes latter. Closing this one till then.

@ebaranauskas ebaranauskas deleted the bugfix/payment-methods-getter-treats-amount-null-as-0 branch July 18, 2024 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant