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 | namespace tuyakhov\braintree; |
||
3 | |||
4 | use yii\base\InvalidCallException; |
||
5 | use yii\base\Model; |
||
6 | use yii\base\ModelEvent; |
||
7 | |||
8 | class BraintreeForm extends Model |
||
9 | { |
||
10 | |||
11 | public $amount; |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
12 | public $orderId; |
||
0 ignored issues
–
show
|
|||
13 | public $paymentMethodToken; |
||
0 ignored issues
–
show
|
|||
14 | |||
15 | public $creditCard_number; |
||
0 ignored issues
–
show
|
|||
16 | public $creditCard_cvv; |
||
0 ignored issues
–
show
|
|||
17 | public $creditCard_expirationMonth; |
||
0 ignored issues
–
show
|
|||
18 | public $creditCard_expirationYear; |
||
0 ignored issues
–
show
|
|||
19 | public $creditCard_expirationDate; |
||
0 ignored issues
–
show
|
|||
20 | public $creditCard_name; |
||
0 ignored issues
–
show
|
|||
21 | |||
22 | public $customer_firstName; |
||
0 ignored issues
–
show
|
|||
23 | public $customer_lastName; |
||
0 ignored issues
–
show
|
|||
24 | public $customer_company; |
||
0 ignored issues
–
show
|
|||
25 | public $customer_phone; |
||
0 ignored issues
–
show
|
|||
26 | public $customer_fax; |
||
0 ignored issues
–
show
|
|||
27 | public $customer_website; |
||
0 ignored issues
–
show
|
|||
28 | public $customer_email; |
||
0 ignored issues
–
show
|
|||
29 | |||
30 | public $billing_firstName; |
||
0 ignored issues
–
show
|
|||
31 | public $billing_lastName; |
||
0 ignored issues
–
show
|
|||
32 | public $billing_company; |
||
0 ignored issues
–
show
|
|||
33 | public $billing_streetAddress; |
||
0 ignored issues
–
show
|
|||
34 | public $billing_extendedAddress; |
||
0 ignored issues
–
show
|
|||
35 | public $billing_locality; |
||
0 ignored issues
–
show
|
|||
36 | public $billing_region; |
||
0 ignored issues
–
show
|
|||
37 | public $billing_postalCode; |
||
0 ignored issues
–
show
|
|||
38 | public $billing_countryCodeAlpha2; |
||
0 ignored issues
–
show
|
|||
39 | |||
40 | public $shipping_firstName; |
||
0 ignored issues
–
show
|
|||
41 | public $shipping_lastName; |
||
0 ignored issues
–
show
|
|||
42 | public $shipping_company; |
||
0 ignored issues
–
show
|
|||
43 | public $shipping_streetAddress; |
||
0 ignored issues
–
show
|
|||
44 | public $shipping_extendedAddress; |
||
0 ignored issues
–
show
|
|||
45 | public $shipping_locality; |
||
0 ignored issues
–
show
|
|||
46 | public $shipping_region; |
||
0 ignored issues
–
show
|
|||
47 | public $shipping_postalCode; |
||
0 ignored issues
–
show
|
|||
48 | public $shipping_countryCodeAlpha2; |
||
0 ignored issues
–
show
|
|||
49 | |||
50 | public $customerId; |
||
0 ignored issues
–
show
|
|||
51 | |||
52 | public function rules() |
||
0 ignored issues
–
show
|
|||
53 | { |
||
0 ignored issues
–
show
|
|||
54 | return [ |
||
0 ignored issues
–
show
|
|||
55 | [['customerId', 'creditCard_number', 'creditCard_cvv', 'creditCard_expirationDate'], 'required', 'on' => 'creditCard'], |
||
0 ignored issues
–
show
|
|||
56 | [['customerId'], 'required', 'on' => 'address'], |
||
0 ignored issues
–
show
|
|||
57 | [['customer_firstName', 'customer_lastName'], 'required', 'on' => 'customer'], |
||
0 ignored issues
–
show
|
|||
58 | [['amount', 'creditCard_number', 'creditCard_cvv', 'creditCard_expirationDate'], 'required', 'on' => 'sale'], |
||
0 ignored issues
–
show
|
|||
59 | [['amount', 'paymentMethodToken'], 'required', 'on' => 'saleFromVault'], |
||
0 ignored issues
–
show
|
|||
60 | [['amount'], 'double'], |
||
0 ignored issues
–
show
|
|||
61 | [['customer_email'], 'email'], |
||
0 ignored issues
–
show
|
|||
62 | [['creditCard_expirationMonth', |
||
0 ignored issues
–
show
|
|||
63 | 'creditCard_expirationYear', |
||
0 ignored issues
–
show
|
|||
64 | 'creditCard_expirationDate', |
||
0 ignored issues
–
show
|
|||
65 | 'customer_firstName', |
||
0 ignored issues
–
show
|
|||
66 | 'customer_lastName', |
||
0 ignored issues
–
show
|
|||
67 | 'customer_company', |
||
0 ignored issues
–
show
|
|||
68 | 'customer_phone', |
||
0 ignored issues
–
show
|
|||
69 | 'customer_fax', |
||
0 ignored issues
–
show
|
|||
70 | 'customer_website', |
||
0 ignored issues
–
show
|
|||
71 | 'billing_firstName', |
||
0 ignored issues
–
show
|
|||
72 | 'billing_lastName', |
||
0 ignored issues
–
show
|
|||
73 | 'billing_company', |
||
0 ignored issues
–
show
|
|||
74 | 'billing_streetAddress', |
||
0 ignored issues
–
show
|
|||
75 | 'billing_extendedAddress', |
||
0 ignored issues
–
show
|
|||
76 | 'billing_locality', |
||
0 ignored issues
–
show
|
|||
77 | 'billing_region', |
||
0 ignored issues
–
show
|
|||
78 | 'billing_postalCode', |
||
0 ignored issues
–
show
|
|||
79 | 'billing_countryCodeAlpha2', |
||
0 ignored issues
–
show
|
|||
80 | 'shipping_firstName', |
||
0 ignored issues
–
show
|
|||
81 | 'shipping_lastName', |
||
0 ignored issues
–
show
|
|||
82 | 'shipping_company', |
||
0 ignored issues
–
show
|
|||
83 | 'shipping_streetAddress', |
||
0 ignored issues
–
show
|
|||
84 | 'shipping_extendedAddress', |
||
0 ignored issues
–
show
|
|||
85 | 'shipping_locality', |
||
0 ignored issues
–
show
|
|||
86 | 'shipping_region', |
||
0 ignored issues
–
show
|
|||
87 | 'shipping_postalCode', |
||
0 ignored issues
–
show
|
|||
88 | 'shipping_countryCodeAlpha2'], 'safe'], |
||
0 ignored issues
–
show
|
|||
89 | ]; |
||
0 ignored issues
–
show
|
|||
90 | } |
||
0 ignored issues
–
show
|
|||
91 | |||
92 | public function attributeLabels() |
||
0 ignored issues
–
show
|
|||
93 | { |
||
0 ignored issues
–
show
|
|||
94 | return [ |
||
0 ignored issues
–
show
|
|||
95 | 'amount' => 'Amount($)', |
||
0 ignored issues
–
show
|
|||
96 | 'orderId' => 'Order ID', |
||
0 ignored issues
–
show
|
|||
97 | 'creditCard_number' => 'Credit Card Number', |
||
0 ignored issues
–
show
|
|||
98 | 'creditCard_cvv' => 'Security Code', |
||
0 ignored issues
–
show
|
|||
99 | 'creditCard_expirationMonth' => 'Expiration Month (MM)', |
||
0 ignored issues
–
show
|
|||
100 | 'creditCard_expirationYear' => 'Expiration Year (YYYY)', |
||
0 ignored issues
–
show
|
|||
101 | 'creditCard_expirationDate' => 'Expiration Date (MM/YYYY)', |
||
0 ignored issues
–
show
|
|||
102 | 'creditCard_name' => 'Name on Card', |
||
0 ignored issues
–
show
|
|||
103 | 'customer_firstName' => 'First Name', |
||
0 ignored issues
–
show
|
|||
104 | 'customer_lastName' => 'Last Name', |
||
0 ignored issues
–
show
|
|||
105 | 'customer_company' => 'Company Name', |
||
0 ignored issues
–
show
|
|||
106 | 'customer_phone' => 'Phone Number', |
||
0 ignored issues
–
show
|
|||
107 | 'customer_fax' => 'Fax Number', |
||
0 ignored issues
–
show
|
|||
108 | 'customer_website' => 'Website', |
||
0 ignored issues
–
show
|
|||
109 | 'customer_email' => 'Email', |
||
0 ignored issues
–
show
|
|||
110 | 'billing_firstName' => 'First Name', |
||
0 ignored issues
–
show
|
|||
111 | 'billing_lastName' => 'Last Name', |
||
0 ignored issues
–
show
|
|||
112 | 'billing_company' => 'Company Name', |
||
0 ignored issues
–
show
|
|||
113 | 'billing_streetAddress' => 'Address', |
||
0 ignored issues
–
show
|
|||
114 | 'billing_extendedAddress' => 'Address', |
||
0 ignored issues
–
show
|
|||
115 | 'billing_locality' => 'City/Locality', |
||
0 ignored issues
–
show
|
|||
116 | 'billing_region' => 'State/Region', |
||
0 ignored issues
–
show
|
|||
117 | 'billing_postalCode' => 'Zip/Postal Code', |
||
0 ignored issues
–
show
|
|||
118 | 'billing_countryCodeAlpha2' => 'Country', |
||
0 ignored issues
–
show
|
|||
119 | 'shipping_firstName' => 'First Name', |
||
0 ignored issues
–
show
|
|||
120 | 'shipping_lastName' => 'Last Name', |
||
0 ignored issues
–
show
|
|||
121 | 'shipping_company' => 'Company Name', |
||
0 ignored issues
–
show
|
|||
122 | 'shipping_streetAddress' => 'Address', |
||
0 ignored issues
–
show
|
|||
123 | 'shipping_extendedAddress' => 'Address', |
||
0 ignored issues
–
show
|
|||
124 | 'shipping_locality' => 'City/Locality', |
||
0 ignored issues
–
show
|
|||
125 | 'shipping_region' => 'State/Region', |
||
0 ignored issues
–
show
|
|||
126 | 'shipping_postalCode' => 'Zip/Postal Code', |
||
0 ignored issues
–
show
|
|||
127 | 'shipping_countryCodeAlpha2' => 'Country', |
||
0 ignored issues
–
show
|
|||
128 | ]; |
||
0 ignored issues
–
show
|
|||
129 | } |
||
0 ignored issues
–
show
|
|||
130 | |||
131 | public function getValuesFromAttributes() |
||
0 ignored issues
–
show
|
|||
132 | { |
||
0 ignored issues
–
show
|
|||
133 | $values = array(); |
||
0 ignored issues
–
show
|
|||
134 | foreach ($this->attributes as $key => $val) { |
||
0 ignored issues
–
show
|
|||
135 | if (!is_object($val) && !is_null($val) && strlen($val) > 0) { |
||
0 ignored issues
–
show
|
|||
136 | if (strpos($key, '_') === false) { |
||
0 ignored issues
–
show
|
|||
137 | $values[$key] = $val; |
||
0 ignored issues
–
show
|
|||
138 | } else { |
||
0 ignored issues
–
show
|
|||
139 | $pieces = explode('_', $key); |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 25 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
140 | $values[$pieces[0]][$pieces[1]] = $val; |
||
0 ignored issues
–
show
|
|||
141 | } |
||
0 ignored issues
–
show
|
|||
142 | } |
||
0 ignored issues
–
show
|
|||
143 | } |
||
0 ignored issues
–
show
|
|||
144 | return $values; |
||
0 ignored issues
–
show
|
|||
145 | } |
||
0 ignored issues
–
show
|
|||
146 | |||
147 | public function send() |
||
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a ![]() |
|||
148 | { |
||
0 ignored issues
–
show
|
|||
149 | \Yii::$app->get('braintree')->getOptions($this->getValuesFromAttributes()); |
||
0 ignored issues
–
show
|
|||
150 | $scenario = $this->getScenario(); |
||
0 ignored issues
–
show
|
|||
151 | return $this->$scenario(); |
||
0 ignored issues
–
show
|
|||
152 | |||
153 | } |
||
0 ignored issues
–
show
|
|||
154 | |||
155 | View Code Duplication | public function sale() |
|
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a ![]() 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. ![]() |
|||
156 | { |
||
0 ignored issues
–
show
|
|||
157 | $return = \Yii::$app->get('braintree')->singleCharge(); |
||
0 ignored issues
–
show
|
|||
158 | if ($return['status'] === false) { |
||
0 ignored issues
–
show
|
|||
159 | $this->addErrorFromResponse($return['result']); |
||
0 ignored issues
–
show
|
|||
160 | return false; |
||
0 ignored issues
–
show
|
|||
161 | } else { |
||
0 ignored issues
–
show
|
|||
162 | return $return; |
||
0 ignored issues
–
show
|
|||
163 | } |
||
0 ignored issues
–
show
|
|||
164 | } |
||
0 ignored issues
–
show
|
|||
165 | |||
166 | View Code Duplication | public function saleFromVault() |
|
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a ![]() 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. ![]() |
|||
167 | { |
||
0 ignored issues
–
show
|
|||
168 | $return = \Yii::$app->get('braintree')->singleCharge(); |
||
0 ignored issues
–
show
|
|||
169 | if ($return['status'] === false) { |
||
0 ignored issues
–
show
|
|||
170 | $this->addErrorFromResponse($return['result']); |
||
0 ignored issues
–
show
|
|||
171 | return false; |
||
0 ignored issues
–
show
|
|||
172 | } else { |
||
0 ignored issues
–
show
|
|||
173 | return $return; |
||
0 ignored issues
–
show
|
|||
174 | } |
||
0 ignored issues
–
show
|
|||
175 | } |
||
0 ignored issues
–
show
|
|||
176 | |||
177 | View Code Duplication | public function customer() |
|
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a ![]() 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. ![]() |
|||
178 | { |
||
0 ignored issues
–
show
|
|||
179 | $return = \Yii::$app->get('braintree')->saveCustomer(); |
||
0 ignored issues
–
show
|
|||
180 | if ($return['status'] === false) { |
||
0 ignored issues
–
show
|
|||
181 | $this->addErrorFromResponse($return['result']); |
||
0 ignored issues
–
show
|
|||
182 | return false; |
||
0 ignored issues
–
show
|
|||
183 | } else { |
||
0 ignored issues
–
show
|
|||
184 | return $return; |
||
0 ignored issues
–
show
|
|||
185 | } |
||
0 ignored issues
–
show
|
|||
186 | } |
||
0 ignored issues
–
show
|
|||
187 | |||
188 | View Code Duplication | public function creditCard() |
|
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a ![]() 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. ![]() |
|||
189 | { |
||
0 ignored issues
–
show
|
|||
190 | $return = \Yii::$app->get('braintree')->saveCreditCard(); |
||
0 ignored issues
–
show
|
|||
191 | if ($return['status'] === false) { |
||
0 ignored issues
–
show
|
|||
192 | $this->addErrorFromResponse($return['result']); |
||
0 ignored issues
–
show
|
|||
193 | return false; |
||
0 ignored issues
–
show
|
|||
194 | } else { |
||
0 ignored issues
–
show
|
|||
195 | return $return; |
||
0 ignored issues
–
show
|
|||
196 | } |
||
0 ignored issues
–
show
|
|||
197 | } |
||
0 ignored issues
–
show
|
|||
198 | |||
199 | View Code Duplication | public function address() |
|
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a ![]() 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. ![]() |
|||
200 | { |
||
0 ignored issues
–
show
|
|||
201 | $return = \Yii::$app->get('braintree')->saveAddress(); |
||
0 ignored issues
–
show
|
|||
202 | if ($return['status'] === false) { |
||
0 ignored issues
–
show
|
|||
203 | $this->addErrorFromResponse($return['result']); |
||
0 ignored issues
–
show
|
|||
204 | return false; |
||
0 ignored issues
–
show
|
|||
205 | } else { |
||
0 ignored issues
–
show
|
|||
206 | return $return; |
||
0 ignored issues
–
show
|
|||
207 | } |
||
0 ignored issues
–
show
|
|||
208 | } |
||
0 ignored issues
–
show
|
|||
209 | |||
210 | /** |
||
0 ignored issues
–
show
|
|||
211 | * This add error from braintree response. |
||
0 ignored issues
–
show
|
|||
212 | * @param $result \Braintree_Result_Error |
||
0 ignored issues
–
show
|
|||
213 | */ |
||
0 ignored issues
–
show
|
|||
214 | public function addErrorFromResponse($result) |
||
0 ignored issues
–
show
|
|||
215 | { |
||
0 ignored issues
–
show
|
|||
216 | $values = $this->getValuesFromAttributes(); |
||
0 ignored issues
–
show
|
|||
217 | if (!empty($result->errors)) { |
||
0 ignored issues
–
show
|
|||
218 | foreach (array_keys($values) as $key) { |
||
0 ignored issues
–
show
|
|||
219 | $keyErrors = $result->errors->forKey($key); |
||
0 ignored issues
–
show
|
|||
220 | if (isset($keyErrors)) { |
||
0 ignored issues
–
show
|
|||
221 | foreach ($keyErrors->shallowAll() as $error) { |
||
0 ignored issues
–
show
|
|||
222 | $this->addError(($key . '_' . $error->attribute), $error->message); |
||
0 ignored issues
–
show
|
|||
223 | } |
||
0 ignored issues
–
show
|
|||
224 | } |
||
0 ignored issues
–
show
|
|||
225 | } |
||
0 ignored issues
–
show
|
|||
226 | } |
||
0 ignored issues
–
show
|
|||
227 | } |
||
0 ignored issues
–
show
|
|||
228 | |||
229 | } |