Skip to content

Commit

Permalink
Fixed regex and wrong customerId type
Browse files Browse the repository at this point in the history
  • Loading branch information
L3RAZ committed Feb 13, 2024
1 parent c3083e4 commit 4e6b714
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
namespace PrestaShop\Module\PrestashopCheckout\PaymentMethodToken\Query;

use PrestaShop\Module\PrestashopCheckout\Customer\ValueObject\CustomerId;
use PrestaShop\Module\PrestashopCheckout\PayPal\Customer\ValueObject\PayPalCustomerId;

class GetCustomerPaymentMethodTokensQuery
{
/**
* @var PayPalCustomerId
* @var CustomerId
*/
private $customerId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(PayPalCustomerRepository $customerRepository, Paymen
*/
public function handle(GetCustomerPaymentMethodTokensQuery $query)
{
$customerIdPayPal = $query->getCustomerId() ? $this->customerRepository->findPayPalCustomerIdByCustomerId($query->getCustomerId()) : null;
$customerIdPayPal = $query->getCustomerId()->getValue() ? $this->customerRepository->findPayPalCustomerIdByCustomerId($query->getCustomerId()) : null;
$paymentTokens = $this->paymentMethodTokenRepository->findByCustomerId($customerIdPayPal, $query->getPageSize(), $query->getPageNumber());

if ($query->isTotalCountRequired()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class GetCustomerPaymentMethodTokensQueryResult
* @param array $paymentTokens
* @param CustomerId $customerId
* @param int $totalItems
* @param int $totalPages
* @param int|null $totalPages
*/
public function __construct(array $paymentTokens, CustomerId $customerId, $totalItems, $totalPages)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private function assertIsValid($id)
throw new InvalidArgumentException('PayPal Vault ID must be between 1 and 36 characters long.');
}

if (preg_match('^[0-9a-zA-Z_-]+$', $id) !== 1) {
if (preg_match('/^[0-9a-zA-Z_-]+$/', $id) !== 1) {
throw new InvalidArgumentException('PayPal Vault ID must be alphanumeric.');
}
}
Expand Down

0 comments on commit 4e6b714

Please sign in to comment.