| 1 |
<?php |
| 2 |
|
| 3 |
defined( 'ABSPATH' ) || exit; |
| 4 |
|
| 5 |
class WC_Vipps_Checkout_Session_Transaction extends WC_Vipps_Model { |
| 6 |
protected array $required_fields = [ |
| 7 |
"amount", |
| 8 |
"reference", |
| 9 |
"payment_description" |
| 10 |
]; |
| 11 |
|
| 12 |
public ?WC_Vipps_Checkout_Session_Amount $amount = null; |
| 13 |
public ?string $reference = null; |
| 14 |
public ?string $payment_description = null; |
| 15 |
public ?WC_Vipps_Checkout_Session_Transaction_Order_Summary $order_summary = null; |
| 16 |
|
| 17 |
public function set_amount( $amount ): self { |
| 18 |
return $this->_set_value( "amount", $amount, WC_Vipps_Checkout_Session_Amount::class ); |
| 19 |
} |
| 20 |
|
| 21 |
public function set_reference( string $reference ): self { |
| 22 |
$this->reference = $reference; |
| 23 |
|
| 24 |
return $this; |
| 25 |
} |
| 26 |
|
| 27 |
public function set_payment_description( string $payment_description ): self { |
| 28 |
$this->payment_description = $payment_description; |
| 29 |
|
| 30 |
return $this; |
| 31 |
} |
| 32 |
|
| 33 |
public function set_order_summary( $order_summary ): self { |
| 34 |
return $this->_set_value( "order_summary", $order_summary, WC_Vipps_Checkout_Session_Transaction_Order_Summary::class ); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* @throws WC_Vipps_Recurring_Missing_Value_Exception |
| 39 |
*/ |
| 40 |
public function to_array( bool $check_required = false ): array { |
| 41 |
if ( $check_required ) { |
| 42 |
$this->check_required(); |
| 43 |
} |
| 44 |
|
| 45 |
return array_merge( |
| 46 |
[ |
| 47 |
"amount" => $this->amount, |
| 48 |
"reference" => $this->reference, |
| 49 |
"paymentDescription" => $this->payment_description, |
| 50 |
], |
| 51 |
$this->conditional( "orderSummary", $this->order_summary ), |
| 52 |
); |
| 53 |
} |
| 54 |
} |
| 55 |
|