This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Ogone\Subscription; |
||
4 | |||
5 | use InvalidArgumentException; |
||
6 | use DateTime; |
||
7 | use Ogone\Ecommerce\EcommercePaymentRequest; |
||
8 | |||
9 | class SubscriptionPaymentRequest extends EcommercePaymentRequest |
||
10 | { |
||
11 | |||
12 | /** |
||
13 | * Set amount in cents, eg EUR 12.34 is written as 1234 |
||
14 | * For subscriptions an amount of 0 can be selected, however this feature must first be enabled by ogone for your account |
||
15 | */ |
||
16 | 6 | View Code Duplication | public function setAmount($amount) |
0 ignored issues
–
show
|
|||
17 | { |
||
18 | 6 | if (!is_int($amount)) { |
|
19 | 1 | throw new InvalidArgumentException("Integer expected. Amount is always in cents"); |
|
20 | } |
||
21 | 5 | if ($amount < 0) { |
|
22 | 1 | throw new InvalidArgumentException("Amount must be a positive number or 0"); |
|
23 | } |
||
24 | 4 | if ($amount >= 1.0E+15) { |
|
25 | 1 | throw new InvalidArgumentException("Amount is too high"); |
|
26 | } |
||
27 | |||
28 | 3 | $this->parameters['amount'] = $amount; |
|
29 | |||
30 | 3 | } |
|
31 | |||
32 | /** |
||
33 | * Unique identifier of the subscription. The subscription id must be assigned dynamically. |
||
34 | * @author René de Kat <[email protected]> |
||
35 | * |
||
36 | * @param string $subscriptionId (maxlength 50) |
||
37 | */ |
||
38 | 3 | View Code Duplication | public function setSubscriptionId($subscriptionId) |
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
39 | { |
||
40 | 3 | if (strlen($subscriptionId) > 50) { |
|
41 | 1 | throw new InvalidArgumentException("Subscription id cannot be longer than 50 characters"); |
|
42 | } |
||
43 | 2 | if (preg_match('/[^a-zA-Z0-9_-]/', $subscriptionId)) { |
|
44 | 1 | throw new InvalidArgumentException("Subscription id cannot contain special characters"); |
|
45 | } |
||
46 | 1 | $this->parameters['subscription_id'] = $subscriptionId; |
|
47 | 1 | } |
|
48 | |||
49 | /** |
||
50 | * Amount of the subscription (can be different from the amount of the original transaction) |
||
51 | * multiplied by 100, since the format of the amount must not contain any decimals or other separators. |
||
52 | * |
||
53 | * @author René de Kat <[email protected]> |
||
54 | * |
||
55 | * @param integer $amount |
||
56 | */ |
||
57 | 5 | View Code Duplication | public function setSubscriptionAmount($amount) |
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
58 | { |
||
59 | 5 | if (!is_int($amount)) { |
|
60 | 1 | throw new InvalidArgumentException("Integer expected. Amount is always in cents"); |
|
61 | } |
||
62 | 4 | if ($amount <= 0) { |
|
63 | 2 | throw new InvalidArgumentException("Amount must be a positive number"); |
|
64 | } |
||
65 | 2 | if ($amount >= 1.0E+15) { |
|
66 | 1 | throw new InvalidArgumentException("Amount is too high"); |
|
67 | } |
||
68 | 1 | $this->parameters['sub_amount'] = $amount; |
|
69 | 1 | } |
|
70 | |||
71 | /** |
||
72 | * Order description |
||
73 | * @author René de Kat <[email protected]> |
||
74 | * |
||
75 | * @param string $description (maxlength 100) |
||
76 | */ |
||
77 | 3 | View Code Duplication | public function setSubscriptionDescription($description) |
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
78 | { |
||
79 | 3 | if (strlen($description) > 100) { |
|
80 | 1 | throw new InvalidArgumentException("Subscription description cannot be longer than 100 characters"); |
|
81 | } |
||
82 | 2 | if (preg_match('/[^a-zA-Z0-9_ -]/', $description)) { |
|
83 | 1 | throw new InvalidArgumentException("Subscription description cannot contain special characters"); |
|
84 | } |
||
85 | 1 | $this->parameters['sub_com'] = $description; |
|
86 | 1 | } |
|
87 | |||
88 | /** |
||
89 | * OrderID for subscription payments |
||
90 | * @author René de Kat <[email protected]> |
||
91 | * |
||
92 | * @param string $orderId (maxlength 40) |
||
93 | */ |
||
94 | 3 | View Code Duplication | public function setSubscriptionOrderId($orderId) |
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
95 | { |
||
96 | 3 | if (strlen($orderId) > 40) { |
|
97 | 1 | throw new InvalidArgumentException("Subscription order id cannot be longer than 40 characters"); |
|
98 | } |
||
99 | 2 | if (preg_match('/[^a-zA-Z0-9_-]/', $orderId)) { |
|
100 | 1 | throw new InvalidArgumentException("Subscription order id cannot contain special characters"); |
|
101 | } |
||
102 | 1 | $this->parameters['sub_orderid'] = $orderId; |
|
103 | 1 | } |
|
104 | |||
105 | /** |
||
106 | * Set subscription payment interval |
||
107 | * @author René de Kat <[email protected]> |
||
108 | */ |
||
109 | 1 | public function setSubscriptionPeriod(SubscriptionPeriod $period) |
|
110 | { |
||
111 | 1 | $this->parameters['sub_period_unit'] = $period->getUnit(); |
|
112 | 1 | $this->parameters['sub_period_number'] = $period->getInterval(); |
|
113 | 1 | $this->parameters['sub_period_moment'] = $period->getMoment(); |
|
114 | 1 | } |
|
115 | |||
116 | |||
117 | /** |
||
118 | * Subscription start date |
||
119 | * @author René de Kat <[email protected]> |
||
120 | * |
||
121 | * @param DateTime $date Startdate of the subscription. |
||
122 | */ |
||
123 | 1 | public function setSubscriptionStartdate(DateTime $date) |
|
124 | { |
||
125 | 1 | $this->parameters['sub_startdate'] = $date->format('Y-m-d'); |
|
126 | 1 | } |
|
127 | |||
128 | /** |
||
129 | * Subscription end date |
||
130 | * @author René de Kat <[email protected]> |
||
131 | * |
||
132 | * @param DateTime $date Enddate of the subscription. |
||
133 | */ |
||
134 | 1 | public function setSubscriptionEnddate(DateTime $date) |
|
135 | { |
||
136 | 1 | $this->parameters['sub_enddate'] = $date->format('Y-m-d'); |
|
137 | 1 | } |
|
138 | |||
139 | /** |
||
140 | * Set subscription status |
||
141 | * @author René de Kat <[email protected]> |
||
142 | * |
||
143 | * @param integer $status 0 = inactive, 1 = active |
||
144 | */ |
||
145 | 2 | public function setSubscriptionStatus($status) |
|
146 | { |
||
147 | 2 | if (!in_array($status, array(0, 1))) { |
|
148 | 1 | throw new InvalidArgumentException("Invalid status specified for subscription. Possible values: 0 = inactive, 1 = active"); |
|
149 | } |
||
150 | 1 | $this->parameters['sub_status'] = $status; |
|
151 | 1 | } |
|
152 | |||
153 | /** |
||
154 | * Set comment for merchant |
||
155 | * @author René de Kat <[email protected]> |
||
156 | * |
||
157 | * @param string $comment |
||
158 | */ |
||
159 | 3 | View Code Duplication | public function setSubscriptionComment($comment) |
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
160 | { |
||
161 | 3 | if (strlen($comment) > 200) { |
|
162 | 1 | throw new InvalidArgumentException("Subscription comment cannot be longer than 200 characters"); |
|
163 | } |
||
164 | 2 | if (preg_match('/[^a-zA-Z0-9_ -]/', $comment)) { |
|
165 | 1 | throw new InvalidArgumentException("Subscription comment cannot contain special characters"); |
|
166 | } |
||
167 | 1 | $this->parameters['sub_comment'] = $comment; |
|
168 | 1 | } |
|
169 | |||
170 | 2 | public function getRequiredFields() |
|
171 | { |
||
172 | return array( |
||
173 | 2 | 'pspid', 'currency', 'orderid', |
|
174 | 'subscription_id', 'sub_amount', 'sub_com', 'sub_orderid', 'sub_period_unit', |
||
175 | 'sub_period_number', 'sub_period_moment','sub_startdate', 'sub_status' |
||
176 | ); |
||
177 | } |
||
178 | } |
||
179 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.