PluginProbe
Pay with Vipps and MobilePay for WooCommerce / 5.4.2
Pay with Vipps and MobilePay for WooCommerce v5.4.2
6.2.1 6.2.0 6.1.10 6.1.9 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1.0 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 6.0.0 5.4.3 5.4.2 5.4.1 5.4.0 5.3.4 trunk All 183 releases
woo-vipps / recurring / includes / models / WC_Vipps_Checkout_Session_Subscription.php

WC_Vipps_Checkout_Session_Subscription.php in Pay with Vipps and MobilePay for WooCommerce 5.4.2, at recurring/includes/models/WC_Vipps_Checkout_Session_Subscription.php

72 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined( 'ABSPATH' ) || exit;
4
5 class WC_Vipps_Checkout_Session_Subscription extends WC_Vipps_Model {
6 protected array $required_fields = [
7 "reference",
8 "product_name",
9 "pricing",
10 "interval",
11 "merchant_agreement_url"
12 ];
13
14 public ?string $product_name = null;
15 public ?string $product_description = null;
16 public ?WC_Vipps_Checkout_Session_Amount $amount = null;
17 public ?WC_Vipps_Agreement_Interval $interval = null;
18 public ?string $merchant_agreement_url = null;
19 public ?WC_Vipps_Agreement_Initial_Charge $initial_charge = null;
20 public ?WC_Vipps_Agreement_Campaign $campaign = null;
21
22 public function set_product_name( string $product_name ): self {
23 $this->product_name = $product_name;
24
25 return $this;
26 }
27
28 public function set_product_description( string $product_description ): self {
29 $this->product_description = $product_description;
30
31 return $this;
32 }
33
34 public function set_amount( $amount ): self {
35 return $this->_set_value( 'amount', $amount, WC_Vipps_Checkout_Session_Amount::class );
36 }
37
38 public function set_interval( $interval ): self {
39 return $this->_set_value( 'interval', $interval, WC_Vipps_Agreement_Interval::class );
40 }
41
42 public function set_merchant_agreement_url( string $merchant_agreement_url ): self {
43 $this->merchant_agreement_url = $merchant_agreement_url;
44
45 return $this;
46 }
47
48 public function set_campaign( $campaign ): self {
49 return $this->_set_value( 'campaign', $campaign, WC_Vipps_Agreement_Campaign::class );
50 }
51
52 /**
53 * @throws WC_Vipps_Recurring_Missing_Value_Exception
54 */
55 public function to_array( bool $check_required = false ): array {
56 if ( $check_required ) {
57 $this->check_required();
58 }
59
60 return array_merge(
61 [
62 "productName" => $this->product_name,
63 "amount" => $this->amount,
64 "interval" => $this->interval,
65 "merchantAgreementUrl" => $this->merchant_agreement_url,
66 ],
67 $this->conditional( "productDescription", $this->product_description ),
68 $this->conditional( "campaign", $this->campaign ),
69 );
70 }
71 }
72