Fix phpunit

This commit is contained in:
Emili Castells Guasch 2023-11-23 14:53:47 +01:00
parent 687b56d8c0
commit 056cb9fcc2
5 changed files with 81 additions and 25 deletions

View file

@ -12,7 +12,7 @@ namespace WooCommerce\PayPalCommerce\Button\Helper;
use Psr\Log\LoggerInterface;
use WooCommerce\PayPalCommerce\ApiClient\Entity\CardAuthenticationResult as AuthResult;
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentSource;
use WooCommerce\PayPalCommerce\ApiClient\Factory\CardAuthenticationResultFactory;
/**
* Class ThreeDSecure
@ -24,6 +24,13 @@ class ThreeDSecure {
const REJECT = 2;
const RETRY = 3;
/**
* Card authentication result factory.
*
* @var CardAuthenticationResultFactory
*/
private $card_authentication_result_factory;
/**
* The logger.
*
@ -34,10 +41,15 @@ class ThreeDSecure {
/**
* ThreeDSecure constructor.
*
* @param LoggerInterface $logger The logger.
* @param CardAuthenticationResultFactory $card_authentication_result_factory Card authentication result factory.
* @param LoggerInterface $logger The logger.
*/
public function __construct( LoggerInterface $logger ) {
$this->logger = $logger;
public function __construct(
CardAuthenticationResultFactory $card_authentication_result_factory,
LoggerInterface $logger
) {
$this->logger = $logger;
$this->card_authentication_result_factory = $card_authentication_result_factory;
}
/**
@ -64,11 +76,7 @@ class ThreeDSecure {
$authentication_result = $payment_source->properties()->authentication_result ?? null;
if ( $authentication_result ) {
$result = new AuthResult(
$authentication_result->liability_shift ?? '',
$authentication_result->three_d_secure->enrollment_status ?? '',
$authentication_result->three_d_secure->authentication_status ?? ''
);
$result = $this->card_authentication_result_factory->from_paypal_response( $authentication_result );
$this->logger->info( '3DS authentication result: ' . wc_print_r( $result->to_array(), true ) );