mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Pass the fraud to Authorization
This commit is contained in:
parent
1acf16a878
commit
843917f061
2 changed files with 23 additions and 2 deletions
|
@ -417,7 +417,7 @@ return array(
|
|||
return new PaymentsFactory( $authorizations_factory, $capture_factory, $refund_factory );
|
||||
},
|
||||
'api.factory.authorization' => static function ( ContainerInterface $container ): AuthorizationFactory {
|
||||
return new AuthorizationFactory();
|
||||
return new AuthorizationFactory( $container->get( 'api.factory.fraud-processor-response' ) );
|
||||
},
|
||||
'api.factory.exchange-rate' => static function ( ContainerInterface $container ): ExchangeRateFactory {
|
||||
return new ExchangeRateFactory();
|
||||
|
|
|
@ -19,6 +19,22 @@ use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
|||
*/
|
||||
class AuthorizationFactory {
|
||||
|
||||
/**
|
||||
* The FraudProcessorResponseFactory factory.
|
||||
*
|
||||
* @var FraudProcessorResponseFactory
|
||||
*/
|
||||
protected $fraud_processor_response_factory;
|
||||
|
||||
/**
|
||||
* AuthorizationFactory constructor.
|
||||
*
|
||||
* @param FraudProcessorResponseFactory $fraud_processor_response_factory The FraudProcessorResponseFactory factory.
|
||||
*/
|
||||
public function __construct( FraudProcessorResponseFactory $fraud_processor_response_factory ) {
|
||||
$this->fraud_processor_response_factory = $fraud_processor_response_factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Authorization based off a PayPal response.
|
||||
*
|
||||
|
@ -42,12 +58,17 @@ class AuthorizationFactory {
|
|||
|
||||
$reason = $data->status_details->reason ?? null;
|
||||
|
||||
$fraud_processor_response = isset( $data->processor_response ) ?
|
||||
$this->fraud_processor_response_factory->from_paypal_response( $data->processor_response )
|
||||
: null;
|
||||
|
||||
return new Authorization(
|
||||
$data->id,
|
||||
new AuthorizationStatus(
|
||||
$data->status,
|
||||
$reason ? new AuthorizationStatusDetails( $reason ) : null
|
||||
)
|
||||
),
|
||||
$fraud_processor_response
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue