Completed
Pull Request — master (#20)
by Florian
02:20
created
Helper/Api.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -142,6 +142,7 @@
 block discarded – undo
142 142
     /**
143 143
      * Generate the request url out of the params and die api url
144 144
      *
145
+     * @param string $sApiUrl
145 146
      * @return string
146 147
      */
147 148
     public function getRequestUrl($aParameters, $sApiUrl)
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
         $aParsedRequestUrl = parse_url($sRequestUrl);
96 96
 
97 97
         if ($aParsedRequestUrl === false) {
98
-            throw new \Exception("Malformed URL " . $sRequestUrl);
98
+            throw new \Exception("Malformed URL ".$sRequestUrl);
99 99
         }
100 100
         return $aParsedRequestUrl;
101 101
     }
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
             foreach ($aResponse as $iLinenum => $sLine) {// go through line by line
142 142
                 $iPos = strpos($sLine, "=");
143 143
                 if ($iPos > 0) {// is a "=" as delimiter existing?
144
-                    $aOutput[substr($sLine, 0, $iPos)] = trim(substr($sLine, $iPos+1));
144
+                    $aOutput[substr($sLine, 0, $iPos)] = trim(substr($sLine, $iPos + 1));
145 145
                 } elseif (!empty($sLine)) {// is line not empty?
146
-                    $aOutput[$iLinenum] = $sLine;// add the line unedited
146
+                    $aOutput[$iLinenum] = $sLine; // add the line unedited
147 147
                 }
148 148
             }
149 149
         }
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
     public function addPayoneOrderData(SalesOrder $oOrder, $aRequest, $aResponse)
184 184
     {
185 185
         if (isset($aResponse['txid'])) {// txid existing?
186
-            $oOrder->setPayoneTxid($aResponse['txid']);// add txid to order entity
186
+            $oOrder->setPayoneTxid($aResponse['txid']); // add txid to order entity
187 187
         }
188
-        $oOrder->setPayoneRefnr($aRequest['reference']);// add refnr to order entity
189
-        $oOrder->setPayoneAuthmode($aRequest['request']);// add authmode to order entity
190
-        $oOrder->setPayoneMode($aRequest['mode']);// add payone mode to order entity
188
+        $oOrder->setPayoneRefnr($aRequest['reference']); // add refnr to order entity
189
+        $oOrder->setPayoneAuthmode($aRequest['request']); // add authmode to order entity
190
+        $oOrder->setPayoneMode($aRequest['mode']); // add payone mode to order entity
191 191
         if (isset($aRequest['mandate_identification'])) {// mandate id existing in request?
192 192
             $oOrder->setPayoneMandateId($aRequest['mandate_identification']);
193 193
         } elseif (isset($aResponse['mandate_identification'])) {// mandate id existing in response?
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
      */
204 204
     public function isInvoiceDataNeeded(PayoneMethod $oPayment)
205 205
     {
206
-        $sType = $this->getConfigParam('request_type');// auth or preauth?
207
-        $blInvoiceEnabled = (bool)$this->getConfigParam('transmit_enabled', 'invoicing');// invoicing enabled?
206
+        $sType = $this->getConfigParam('request_type'); // auth or preauth?
207
+        $blInvoiceEnabled = (bool)$this->getConfigParam('transmit_enabled', 'invoicing'); // invoicing enabled?
208 208
         if ($oPayment->needsProductInfo() || ($sType == PayoneConfig::REQUEST_TYPE_AUTHORIZATION && $blInvoiceEnabled)) {
209
-            return true;// invoice data needed
209
+            return true; // invoice data needed
210 210
         }
211
-        return false;// invoice data not needed
211
+        return false; // invoice data not needed
212 212
     }
213 213
 }
Please login to merge, or discard this patch.
Helper/Customer.php 1 patch
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -102,7 +102,6 @@
 block discarded – undo
102 102
     /**
103 103
      * Get the region object for the state and country given by PayPal
104 104
      *
105
-     * @param  array $aResponse
106 105
      * @return Region|bool
107 106
      */
108 107
     public function getRegion($sCountry, $sState)
Please login to merge, or discard this patch.
Helper/Order.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,6 +95,7 @@  discard block
 block discarded – undo
95 95
     /**
96 96
      * Return the order related to the given TransactionStatus
97 97
      *
98
+     * @param string $sTxid
98 99
      * @return SalesOrder|null
99 100
      */
100 101
     public function getOrderByTxid($sTxid)
@@ -160,7 +161,6 @@  discard block
 block discarded – undo
160 161
      * Fill billing and shipping addresses with the needed information from the response
161 162
      *
162 163
      * @param  Address $oAddress
163
-     * @param  array   $aResponse
164 164
      * @return Address
165 165
      */
166 166
     public function fillSingleAddress(Address $oAddress, $sFirstname, $sLastname, $sStreet, $sCity, $sZip, $sCountry, $sState)
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -129,8 +129,8 @@
 block discarded – undo
129 129
         }
130 130
 
131 131
         if (!empty($aRates)) {// more than one shipping method existing?
132
-            ksort($aRates);// sort by price ascending
133
-            return array_shift($aRates);// return the cheapest shipping-method
132
+            ksort($aRates); // sort by price ascending
133
+            return array_shift($aRates); // return the cheapest shipping-method
134 134
         }
135 135
         return false;
136 136
     }
Please login to merge, or discard this patch.
Model/Api/Invoice.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@
 block discarded – undo
117 117
      * @param  Order $oOrder     Order object
118 118
      * @param  array $aPositions Is given with non-complete captures or debits
119 119
      * @param  bool  $blDebit    Is the call coming from a debit request
120
-     * @return float
120
+     * @return integer
121 121
      */
122 122
     public function addProductInfo(Base $oRequest, Order $oOrder, $aPositions = false, $blDebit = false)
123 123
     {
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
      */
101 101
     protected function addInvoicePosition($sId, $dPrice, $sItemType, $iAmount, $sDesc, $dVat)
102 102
     {
103
-        $this->oRequest->addParameter('id['.$this->iIndex.']', $sId);// add invoice item id
104
-        $this->oRequest->addParameter('pr['.$this->iIndex.']', $this->toolkitHelper->formatNumber($dPrice) * 100);// expected in smallest unit of currency
105
-        $this->oRequest->addParameter('it['.$this->iIndex.']', $sItemType);// add invoice item type
106
-        $this->oRequest->addParameter('no['.$this->iIndex.']', $iAmount);// add invoice item amount
107
-        $this->oRequest->addParameter('de['.$this->iIndex.']', $sDesc);// add invoice item description
108
-        $this->oRequest->addParameter('va['.$this->iIndex.']', $this->toolkitHelper->formatNumber($dVat * 100, 0));// expected * 100 to also handle vats with decimals
109
-        $this->dAmount += $dPrice * $iAmount;// needed for return of the main method
110
-        $this->iIndex++;// increase index for next item
103
+        $this->oRequest->addParameter('id['.$this->iIndex.']', $sId); // add invoice item id
104
+        $this->oRequest->addParameter('pr['.$this->iIndex.']', $this->toolkitHelper->formatNumber($dPrice) * 100); // expected in smallest unit of currency
105
+        $this->oRequest->addParameter('it['.$this->iIndex.']', $sItemType); // add invoice item type
106
+        $this->oRequest->addParameter('no['.$this->iIndex.']', $iAmount); // add invoice item amount
107
+        $this->oRequest->addParameter('de['.$this->iIndex.']', $sDesc); // add invoice item description
108
+        $this->oRequest->addParameter('va['.$this->iIndex.']', $this->toolkitHelper->formatNumber($dVat * 100, 0)); // expected * 100 to also handle vats with decimals
109
+        $this->dAmount += $dPrice * $iAmount; // needed for return of the main method
110
+        $this->iIndex++; // increase index for next item
111 111
     }
112 112
 
113 113
     /**
@@ -121,22 +121,22 @@  discard block
 block discarded – undo
121 121
      */
122 122
     public function addProductInfo(Base $oRequest, Order $oOrder, $aPositions = false, $blDebit = false)
123 123
     {
124
-        $this->oRequest = $oRequest;// write request to property for manipulation of the object
125
-        $sInvoiceAppendix = $this->toolkitHelper->getInvoiceAppendix($oOrder);// get invoice appendix
124
+        $this->oRequest = $oRequest; // write request to property for manipulation of the object
125
+        $sInvoiceAppendix = $this->toolkitHelper->getInvoiceAppendix($oOrder); // get invoice appendix
126 126
         if (!empty($sInvoiceAppendix)) {// invoice appendix existing?
127
-            $this->oRequest->addParameter('invoiceappendix', $sInvoiceAppendix);// add appendix to request
127
+            $this->oRequest->addParameter('invoiceappendix', $sInvoiceAppendix); // add appendix to request
128 128
         }
129 129
 
130 130
         foreach ($oOrder->getAllItems() as $oItem) {// add invoice items for all order items
131 131
             if ($oItem->isDummy() === false) {// prevent variant-products of adding 2 items
132
-                $this->addProductItem($oItem, $aPositions);// add product invoice params to request
132
+                $this->addProductItem($oItem, $aPositions); // add product invoice params to request
133 133
             }
134 134
         }
135 135
 
136
-        $blFirstCapture = true;// Is first capture?
136
+        $blFirstCapture = true; // Is first capture?
137 137
         if ($aPositions === false || $blFirstCapture === true || $blDebit === true) {
138
-            $this->addShippingItem($oOrder, $aPositions, $blDebit);// add shipping invoice params to request
139
-            $this->addDiscountItem($oOrder, $aPositions, $blDebit);// add discount invoice params to request
138
+            $this->addShippingItem($oOrder, $aPositions, $blDebit); // add shipping invoice params to request
139
+            $this->addDiscountItem($oOrder, $aPositions, $blDebit); // add discount invoice params to request
140 140
         }
141 141
         return $this->dAmount;
142 142
     }
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
     protected function addProductItem($oItem, $aPositions)
152 152
     {
153 153
         if ($aPositions === false || array_key_exists($oItem->getProductId(), $aPositions) !== false) {// full or single-invoice?
154
-            $dItemAmount = $oItem->getQtyOrdered();// get ordered item amount
154
+            $dItemAmount = $oItem->getQtyOrdered(); // get ordered item amount
155 155
             if ($aPositions !== false && array_key_exists($oItem->getProductId(), $aPositions) !== false) {// product existing in single-invoice?
156
-                $dItemAmount = $aPositions[$oItem->getProductId()]['amount'];// use amount from single-invoice
156
+                $dItemAmount = $aPositions[$oItem->getProductId()]['amount']; // use amount from single-invoice
157 157
             }
158
-            $dBrutPrice = $oItem->getBasePrice() + ($oItem->getBaseTaxAmount() / $oItem->getQtyOrdered());// cals single item price
158
+            $dBrutPrice = $oItem->getBasePrice() + ($oItem->getBaseTaxAmount() / $oItem->getQtyOrdered()); // cals single item price
159 159
             $this->addInvoicePosition($oItem->getSku(), $dBrutPrice, 'goods', $dItemAmount, $oItem->getName(), $oItem->getTaxPercent());
160 160
             if ($this->dTax === false) {// is dTax not set yet?
161
-                $this->dTax = $oItem->getTaxPercent();// set the tax for following entities which dont have the vat attached to it
161
+                $this->dTax = $oItem->getTaxPercent(); // set the tax for following entities which dont have the vat attached to it
162 162
             }
163 163
         }
164 164
     }
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
     {
176 176
         // shipping costs existing or given for partial captures/debits?
177 177
         if ($oOrder->getBaseShippingInclTax() != 0 && ($aPositions === false || ($blDebit === false || array_key_exists('oxdelcost', $aPositions) !== false))) {
178
-            $sDelDesc = __('Surcharge').' '.__('Shipping Costs');// default description
178
+            $sDelDesc = __('Surcharge').' '.__('Shipping Costs'); // default description
179 179
             if ($oOrder->getBaseShippingInclTax() < 0) {// negative shipping cost
180
-                $sDelDesc = __('Deduction').' '.__('Shipping Costs');// change item description to deduction
180
+                $sDelDesc = __('Deduction').' '.__('Shipping Costs'); // change item description to deduction
181 181
             }
182
-            $sShippingSku = $this->toolkitHelper->getConfigParam('sku', 'costs', 'payone_misc');// get configured shipping SKU
182
+            $sShippingSku = $this->toolkitHelper->getConfigParam('sku', 'costs', 'payone_misc'); // get configured shipping SKU
183 183
             $this->addInvoicePosition($sShippingSku, $oOrder->getBaseShippingInclTax(), 'shipment', 1, $sDelDesc, $this->dTax);
184 184
         }
185 185
     }
@@ -200,16 +200,16 @@  discard block
 block discarded – undo
200 200
             if ($aPositions === false) {// full invoice?
201 201
                 // The calculations broken down to single items of Magento2 are unprecise and the Payone API will send an error if
202 202
                 // the calculated positions don't match, so we compensate for rounding-problems here
203
-                $dDiff = ($this->dAmount + $oOrder->getBaseDiscountAmount()) - $oOrder->getGrandTotal();// calc rounding discrepancy
204
-                $dDiscount -= $dDiff;// subtract difference from discount
203
+                $dDiff = ($this->dAmount + $oOrder->getBaseDiscountAmount()) - $oOrder->getGrandTotal(); // calc rounding discrepancy
204
+                $dDiscount -= $dDiff; // subtract difference from discount
205 205
             }
206
-            $sDiscountSku = $this->toolkitHelper->getConfigParam('sku', 'discount', 'payone_misc');// get configured discount SKU
207
-            $sDesc = (string)__('Discount');// default description
206
+            $sDiscountSku = $this->toolkitHelper->getConfigParam('sku', 'discount', 'payone_misc'); // get configured discount SKU
207
+            $sDesc = (string)__('Discount'); // default description
208 208
             if ($oOrder->getCouponCode()) {// was a coupon code used?
209
-                $sDiscountSku = $this->toolkitHelper->getConfigParam('sku', 'voucher', 'payone_misc');// get configured voucher SKU
210
-                $sDesc = (string)__('Coupon').' - '.$oOrder->getCouponCode();// add counpon code to description
209
+                $sDiscountSku = $this->toolkitHelper->getConfigParam('sku', 'voucher', 'payone_misc'); // get configured voucher SKU
210
+                $sDesc = (string)__('Coupon').' - '.$oOrder->getCouponCode(); // add counpon code to description
211 211
             }
212
-            $this->addInvoicePosition($sDiscountSku, $dDiscount, 'voucher', 1, $sDesc, $this->dTax);// add invoice params to request
212
+            $this->addInvoicePosition($sDiscountSku, $dDiscount, 'voucher', 1, $sDesc, $this->dTax); // add invoice params to request
213 213
         }
214 214
     }
215 215
 }
Please login to merge, or discard this patch.
Helper/ConfigExport.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -177,6 +177,6 @@
 block discarded – undo
177 177
         if ($this->getPaymentConfig('allowspecific', $sPaymentCode, $sStoreCode, true) == '1') {
178 178
             return $this->getPaymentConfig('specificcountry', $sPaymentCode, $sStoreCode, true);
179 179
         }
180
-        return '';// empty return value if all countries are available
180
+        return ''; // empty return value if all countries are available
181 181
     }
182 182
 }
Please login to merge, or discard this patch.
Helper/Database.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -188,6 +188,6 @@
 block discarded – undo
188 188
         if ($iCount === null) {
189 189
             return 0;
190 190
         }
191
-        return $iCount+1;
191
+        return $iCount + 1;
192 192
     }
193 193
 }
Please login to merge, or discard this patch.
Helper/HostedIframe.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -156,15 +156,15 @@
 block discarded – undo
156 156
      */
157 157
     public function getHostedFieldConfig()
158 158
     {
159
-        $aHostedParams = $this->getHostedParams();// get hosted params from config
159
+        $aHostedParams = $this->getHostedParams(); // get hosted params from config
160 160
 
161 161
         $aFieldConfig = [];
162 162
         if (!empty($aHostedParams)) {
163
-            $aFieldConfig['fields'] = $this->getFieldConfig();// generate config for all field types
163
+            $aFieldConfig['fields'] = $this->getFieldConfig(); // generate config for all field types
164 164
             $aFieldConfig['defaultStyle'] = $this->getDefaultStyles($aHostedParams);
165 165
             if ($aHostedParams['Errors_active'] == "true") {
166
-                $aFieldConfig['error'] = 'errorOutput';// area to display error-messages (optional)
167
-                $aFieldConfig['language'] = $aHostedParams['Errors_lang'];// has to be defined in javascript
166
+                $aFieldConfig['error'] = 'errorOutput'; // area to display error-messages (optional)
167
+                $aFieldConfig['language'] = $aHostedParams['Errors_lang']; // has to be defined in javascript
168 168
             }
169 169
         }
170 170
         return $aFieldConfig;
Please login to merge, or discard this patch.
Helper/Toolkit.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         if (!empty($sText)) {
136 136
             $sText = str_replace(array_keys($aSubstitutionArray), array_values($aSubstitutionArray), $sText);
137 137
             if ($iMaxLength !== false && strlen($sText) > $iMaxLength) {
138
-                $sText = substr($sText, 0, $iMaxLength);// shorten text if too long
138
+                $sText = substr($sText, 0, $iMaxLength); // shorten text if too long
139 139
             }
140 140
             return $sText;
141 141
         }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
     public function getInvoiceAppendix(SalesOrder $oOrder)
152 152
     {
153
-        $sText = $this->getConfigParam('invoice_appendix', 'invoicing');// get invoice appendix from config
153
+        $sText = $this->getConfigParam('invoice_appendix', 'invoicing'); // get invoice appendix from config
154 154
         $aSubstitutionArray = [
155 155
             '{{order_increment_id}}' => $oOrder->getIncrementId(),
156 156
             '{{customer_id}}' => $oOrder->getCustomerId(),
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      */
169 169
     public function getNarrativeText(SalesOrder $oOrder, PayoneMethod $oPayment)
170 170
     {
171
-        $sText = $this->getConfigParam($oPayment->getCode(), 'text');// get narrative text for payment from config
171
+        $sText = $this->getConfigParam($oPayment->getCode(), 'text'); // get narrative text for payment from config
172 172
         $aSubstitutionArray = [
173 173
             '{{order_increment_id}}' => $oOrder->getIncrementId(),
174 174
         ];
Please login to merge, or discard this patch.
Model/Methods/BaseMethod.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
      */
236 236
     public function getInstructions()
237 237
     {
238
-        return trim($this->getConfigData('instructions'));// return description text
238
+        return trim($this->getConfigData('instructions')); // return description text
239 239
     }
240 240
 
241 241
     /**
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
     {
248 248
         $sRequestType = $this->getAuthorizationMode();
249 249
         if ($sRequestType == PayoneConfig::REQUEST_TYPE_PREAUTHORIZATION) {
250
-            return AbstractMethod::ACTION_AUTHORIZE;// only create order
250
+            return AbstractMethod::ACTION_AUTHORIZE; // only create order
251 251
         } elseif ($sRequestType == PayoneConfig::REQUEST_TYPE_AUTHORIZATION) {
252
-            return AbstractMethod::ACTION_AUTHORIZE_CAPTURE;// create order and capture
252
+            return AbstractMethod::ACTION_AUTHORIZE_CAPTURE; // create order and capture
253 253
         }
254 254
     }
255 255
 
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
      */
263 263
     public function authorize(InfoInterface $payment, $amount)
264 264
     {
265
-        $oReturn = parent::authorize($payment, $amount);// execute Magento parent authorization
266
-        $this->sendPayoneAuthorization($payment, $amount);// send auth request to PAYONE
267
-        return $oReturn;// return magento parent auth value
265
+        $oReturn = parent::authorize($payment, $amount); // execute Magento parent authorization
266
+        $this->sendPayoneAuthorization($payment, $amount); // send auth request to PAYONE
267
+        return $oReturn; // return magento parent auth value
268 268
     }
269 269
 
270 270
     /**
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
      */
277 277
     public function refund(InfoInterface $payment, $amount)
278 278
     {
279
-        $oReturn = parent::refund($payment, $amount);// execute Magento parent refund
280
-        $this->sendPayoneDebit($payment, $amount);// send debit request to PAYONE
281
-        return $oReturn;// return magento parent refund value
279
+        $oReturn = parent::refund($payment, $amount); // execute Magento parent refund
280
+        $this->sendPayoneDebit($payment, $amount); // send debit request to PAYONE
281
+        return $oReturn; // return magento parent refund value
282 282
     }
283 283
 
284 284
     /**
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
      */
291 291
     public function capture(InfoInterface $payment, $amount)
292 292
     {
293
-        $oReturn = parent::capture($payment, $amount);// execute Magento parent capture
293
+        $oReturn = parent::capture($payment, $amount); // execute Magento parent capture
294 294
         if ($payment->getParentTransactionId()) {// does the order already have a transaction?
295
-            $this->sendPayoneCapture($payment, $amount);// is probably admin invoice capture
295
+            $this->sendPayoneCapture($payment, $amount); // is probably admin invoice capture
296 296
         } else {
297
-            $this->sendPayoneAuthorization($payment, $amount);// is probably frontend checkout capture
297
+            $this->sendPayoneAuthorization($payment, $amount); // is probably frontend checkout capture
298 298
         }
299
-        return $oReturn;// return magento parent capture value
299
+        return $oReturn; // return magento parent capture value
300 300
     }
301 301
 
302 302
     /**
@@ -311,12 +311,12 @@  discard block
 block discarded – undo
311 311
         $iAllowSpecific = $this->shopHelper->getConfigParam('allowspecific');
312 312
         $aAvailableCountries = explode(',', $this->shopHelper->getConfigParam('specificcountry'));
313 313
         if ($this->hasCustomConfig()) {// check for non-global configuration
314
-            $iAllowSpecific = $this->getCustomConfigParam('allowspecific');// only specific countries allowed?
315
-            $aAvailableCountries = explode(',', $this->getCustomConfigParam('specificcountry'));// get allowed countries
314
+            $iAllowSpecific = $this->getCustomConfigParam('allowspecific'); // only specific countries allowed?
315
+            $aAvailableCountries = explode(',', $this->getCustomConfigParam('specificcountry')); // get allowed countries
316 316
         }
317 317
         if ($iAllowSpecific == 1 && !in_array($country, $aAvailableCountries)) {// only specific but not included
318
-            return false;// cant use for given country
318
+            return false; // cant use for given country
319 319
         }
320
-        return true;// can use for given country
320
+        return true; // can use for given country
321 321
     }
322 322
 }
Please login to merge, or discard this patch.