PluginProbe
seQura / trunk
seQura vtrunk
4.3.4 4.3.3 4.3.2 4.3.1 trunk 2.0.0 2.0.10 2.0.11 2.0.12 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 3.0.0 3.0.2 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 4.0.0 All 30 releases
sequra / src / Dto / class-payment-method-option.php

class-payment-method-option.php in seQura trunk, at src/Dto/class-payment-method-option.php

120 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Payment Method Option DTO
4 *
5 * @package SeQura/WC
6 */
7
8 namespace SeQura\WC\Dto;
9
10 /**
11 * Payment Method Option DTO.
12 */
13 class Payment_Method_Option extends Payment_Method_Data {
14
15 /**
16 * SeQura product long title
17 *
18 * @var string
19 */
20 public $long_title;
21
22 /**
23 * SeQura product claim
24 *
25 * @var string
26 */
27 public $claim;
28
29 /**
30 * Unix timestamp when the payment method starts being available
31 *
32 * @var int
33 */
34 public $starts_at;
35
36 /**
37 * Unix timestamp when the payment method stops being available
38 *
39 * @var int
40 */
41 public $ends_at;
42
43 /**
44 * Payment method description
45 *
46 * @var string
47 */
48 public $description;
49
50 /**
51 * Payment method icon in svg format
52 *
53 * @var string
54 */
55 public $icon;
56
57 /**
58 * Payment method cost description
59 *
60 * @var string
61 */
62 public $cost_description;
63
64 /**
65 * Minimum amount for the payment method to be available
66 *
67 * @var int|null
68 */
69 public $min_amount;
70
71 /**
72 * Maximum amount for the payment method to be available
73 *
74 * @var int|null
75 */
76 public $max_amount;
77
78 /**
79 * Payment method cost. Contains the following keys:
80 * - setupFee: int
81 * - instalmentFee: int
82 * - downPaymentFees: int
83 * - instalmentTotal: int
84 *
85 * @var array<string, int>
86 */
87 public $cost;
88
89
90 /**
91 * Check if the instance matches a payment method
92 *
93 * @param Payment_Method_Data $data
94 */
95 public function match( $data ): bool {
96 return $data instanceof Payment_Method_Data && $this->product === $data->product && $this->campaign === $data->campaign;
97 }
98
99 /**
100 * Check if the payment method should show more info
101 */
102 public function should_show_more_info(): bool {
103 return ! in_array( $this->product, array( 'fp1' ), true );
104 }
105
106 /**
107 * Check if the payment method should show cost description
108 */
109 public function should_show_cost_description(): bool {
110 return $this->cost_description && strtolower( $this->cost_description ) !== strtolower( $this->claim );
111 }
112
113 /**
114 * Encode the parent DTO instance into a raw string. Returns a base64 encoded JSON string.
115 */
116 public function encode_data(): string {
117 return parent::encode();
118 }
119 }
120