mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Add the FraudProcessorResponse to Authorization
This commit is contained in:
parent
843917f061
commit
e63baa6c43
1 changed files with 31 additions and 6 deletions
|
@ -28,19 +28,29 @@ class Authorization {
|
|||
*/
|
||||
private $authorization_status;
|
||||
|
||||
/**
|
||||
* The fraud processor response (AVS, CVV ...).
|
||||
*
|
||||
* @var FraudProcessorResponse|null
|
||||
*/
|
||||
protected $fraud_processor_response;
|
||||
|
||||
/**
|
||||
* Authorization constructor.
|
||||
*
|
||||
* @param string $id The id.
|
||||
* @param AuthorizationStatus $authorization_status The status.
|
||||
* @param string $id The id.
|
||||
* @param AuthorizationStatus $authorization_status The status.
|
||||
* @param FraudProcessorResponse|null $fraud_processor_response The fraud processor response (AVS, CVV ...).
|
||||
*/
|
||||
public function __construct(
|
||||
string $id,
|
||||
AuthorizationStatus $authorization_status
|
||||
AuthorizationStatus $authorization_status,
|
||||
?FraudProcessorResponse $fraud_processor_response
|
||||
) {
|
||||
|
||||
$this->id = $id;
|
||||
$this->authorization_status = $authorization_status;
|
||||
$this->id = $id;
|
||||
$this->authorization_status = $authorization_status;
|
||||
$this->fraud_processor_response = $fraud_processor_response;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,15 +81,30 @@ class Authorization {
|
|||
$this->authorization_status->is( AuthorizationStatus::PENDING );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fraud processor response (AVS, CVV ...).
|
||||
*
|
||||
* @return FraudProcessorResponse|null
|
||||
*/
|
||||
public function fraud_processor_response() : ?FraudProcessorResponse {
|
||||
return $this->fraud_processor_response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object as array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function to_array(): array {
|
||||
return array(
|
||||
$data = array(
|
||||
'id' => $this->id,
|
||||
'status' => $this->authorization_status->name(),
|
||||
);
|
||||
|
||||
if ( $this->fraud_processor_response ) {
|
||||
$data['fraud_processor_response'] = $this->fraud_processor_response->to_array();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue