| 1 |
<?php |
| 2 |
|
| 3 |
defined( 'ABSPATH' ) || exit; |
| 4 |
|
| 5 |
class WC_Vipps_Checkout_Session_Response extends WC_Vipps_Model { |
| 6 |
protected array $required_fields = [ |
| 7 |
"token", |
| 8 |
"checkout_frontend_url", |
| 9 |
"polling_url" |
| 10 |
]; |
| 11 |
|
| 12 |
public ?string $token = null; |
| 13 |
public ?string $checkout_frontend_url = null; |
| 14 |
public ?string $polling_url = null; |
| 15 |
|
| 16 |
public function set_token( string $token ): self { |
| 17 |
$this->token = $token; |
| 18 |
|
| 19 |
return $this; |
| 20 |
} |
| 21 |
|
| 22 |
public function set_checkout_frontend_url( string $checkout_frontend_url ): self { |
| 23 |
$this->checkout_frontend_url = $checkout_frontend_url; |
| 24 |
|
| 25 |
return $this; |
| 26 |
} |
| 27 |
|
| 28 |
public function set_polling_url( string $polling_url ): self { |
| 29 |
$this->polling_url = $polling_url; |
| 30 |
|
| 31 |
return $this; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* @throws WC_Vipps_Recurring_Missing_Value_Exception |
| 36 |
*/ |
| 37 |
public function to_array( bool $check_required = false ): array { |
| 38 |
if ( $check_required ) { |
| 39 |
$this->check_required(); |
| 40 |
} |
| 41 |
|
| 42 |
return array_merge( |
| 43 |
[ |
| 44 |
"token" => $this->token, |
| 45 |
"checkoutFrontendUrl" => $this->checkout_frontend_url, |
| 46 |
"pollingUrl" => $this->polling_url, |
| 47 |
], |
| 48 |
); |
| 49 |
} |
| 50 |
} |
| 51 |
|