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,6 +12,7 @@ namespace WooCommerce\PayPalCommerce\ApiClient;
use WooCommerce\PayPalCommerce\ApiClient\Authentication\UserIdToken;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PaymentMethodTokensEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PaymentTokensEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Entity\CardAuthenticationResult;
use WooCommerce\PayPalCommerce\ApiClient\Helper\FailureRegistry;
use WooCommerce\PayPalCommerce\Common\Pattern\SingletonDecorator;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\BillingSubscriptions;
@ -448,6 +449,9 @@ return array(
$container->get( 'api.factory.payment-preferences' )
);
},
'api.factory.card-authentication-result' => static function( ContainerInterface $container ): CardAuthenticationResult {
return new CardAuthenticationResult();
},
'api.helpers.dccapplies' => static function ( ContainerInterface $container ) : DccApplies {
return new DccApplies(
$container->get( 'api.dcc-supported-country-currency-matrix' ),

View file

@ -0,0 +1,33 @@
<?php
/**
* The card authentication result factory.
*
* @package WooCommerce\PayPalCommerce\ApiClient\Factory
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\ApiClient\Factory;
use stdClass;
use WooCommerce\PayPalCommerce\ApiClient\Entity\CardAuthenticationResult;
/**
* Class CardAuthenticationResultFactory
*/
class CardAuthenticationResultFactory {
/**
* Returns a card authentication result from the given response object.
*
* @param stdClass $authentication_result The authentication result object.
* @return CardAuthenticationResult
*/
public function from_paypal_response( stdClass $authentication_result ): CardAuthenticationResult {
return new CardAuthenticationResult(
$authentication_result->liability_shift ?? '',
$authentication_result->three_d_secure->enrollment_status ?? '',
$authentication_result->three_d_secure->authentication_status ?? ''
);
}
}