@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function register() |
15 | 15 | { |
16 | - $this->app->bind("sso_facade", function(){ |
|
16 | + $this->app->bind("sso_facade", function() { |
|
17 | 17 | return new BsecureSSO(); |
18 | 18 | }); |
19 | 19 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * Optional methods to load your package assets |
30 | 30 | */ |
31 | 31 | |
32 | - $this->loadTranslationsFrom( __DIR__.('./resources/lang/'),'bSecure'); |
|
32 | + $this->loadTranslationsFrom(__DIR__ . ('./resources/lang/'), 'bSecure'); |
|
33 | 33 | |
34 | 34 | // $this->loadViewsFrom(__DIR__.'/../resources/views', 'universal-checkout'); |
35 | 35 | // $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | if ($this->app->runningInConsole()) { |
39 | 39 | |
40 | 40 | $this->publishes([ |
41 | - __DIR__.'/config/config.php' => config_path('bSecure.php'), |
|
41 | + __DIR__ . '/config/config.php' => config_path('bSecure.php'), |
|
42 | 42 | ], 'config'); |
43 | 43 | |
44 | 44 | |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | |
55 | 55 | // Publishing the translation files. |
56 | 56 | $this->publishes([ |
57 | - __DIR__.'/resources/lang' => resource_path('lang/vendor/bSecure'), |
|
58 | - ],'lang'); |
|
57 | + __DIR__ . '/resources/lang' => resource_path('lang/vendor/bSecure'), |
|
58 | + ], 'lang'); |
|
59 | 59 | |
60 | 60 | // Registering package commands. |
61 | 61 | // $this->commands([]); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | try { |
102 | 102 | $order = new CreateOrderController(); |
103 | 103 | $result = $order->create($this->orderPayload); |
104 | - return json_decode($result->getContent(),true); |
|
104 | + return json_decode($result->getContent(), true); |
|
105 | 105 | // return $result->getContent(); |
106 | 106 | //code... |
107 | 107 | } catch (\Throwable $th) { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | try { |
119 | 119 | $customer = new IOPNController(); |
120 | 120 | $result = $customer->orderStatus($order_ref); |
121 | - return json_decode($result->getContent(),true); |
|
121 | + return json_decode($result->getContent(), true); |
|
122 | 122 | //code... |
123 | 123 | } catch (\Throwable $th) { |
124 | 124 | throw $th; |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | $orderResponse = Order::createMerchantOrder($orderData); |
43 | - if($orderResponse['error']) |
|
43 | + if ($orderResponse['error']) |
|
44 | 44 | { |
45 | 45 | return ApiResponseHandler::failure($orderResponse['message']); |
46 | - }else{ |
|
46 | + } else { |
|
47 | 47 | $response = $orderResponse['body']; |
48 | 48 | return ApiResponseHandler::success($response, trans('bSecure::messages.order.success')); |
49 | 49 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | 'total_amount' => null, |
63 | 63 | ]; |
64 | 64 | |
65 | - if(!empty($products)) |
|
65 | + if (!empty($products)) |
|
66 | 66 | { |
67 | 67 | |
68 | 68 | $orderItems = []; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | foreach ($products as $key => $product) { |
74 | 74 | //Product Price |
75 | - $price = $product['price'] ; |
|
75 | + $price = $product['price']; |
|
76 | 76 | $sale_price = $product['sale_price']; |
77 | 77 | $quantity = $product['quantity'] ?? 1; |
78 | 78 | |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | |
85 | 85 | |
86 | 86 | #Product charges |
87 | - $discount = ( $price - $sale_price ) * $quantity; |
|
88 | - $product_price = ( $price + $options_price ) * $quantity; |
|
89 | - $product_sub_total = ( $price + $options_price ) * $quantity; |
|
87 | + $discount = ($price - $sale_price) * $quantity; |
|
88 | + $product_price = ($price + $options_price) * $quantity; |
|
89 | + $product_sub_total = ($price + $options_price) * $quantity; |
|
90 | 90 | |
91 | 91 | $orderItems['products'][] = [ |
92 | 92 | "id" => $product['id'], |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $sub_total_amount += $product_sub_total; |
108 | 108 | } |
109 | 109 | |
110 | - $order_grand_total = $sub_total_amount-$total_discount; |
|
110 | + $order_grand_total = $sub_total_amount - $total_discount; |
|
111 | 111 | |
112 | 112 | $orderData['products'] = $orderItems['products']; |
113 | 113 | $orderData['sub_total_amount'] = $sub_total_amount; |
@@ -120,18 +120,18 @@ discard block |
||
120 | 120 | |
121 | 121 | public function _setProductOptionsDataStructure($product) |
122 | 122 | { |
123 | - $product_options = array_key_exists('product_options',$product) ? $product['product_options'] : []; |
|
123 | + $product_options = array_key_exists('product_options', $product) ? $product['product_options'] : []; |
|
124 | 124 | |
125 | 125 | $price = 0; |
126 | - if( isset($product_options) && !empty($product_options) ) |
|
126 | + if (isset($product_options) && !empty($product_options)) |
|
127 | 127 | { |
128 | - foreach( $product_options as $productOption ) |
|
128 | + foreach ($product_options as $productOption) |
|
129 | 129 | { |
130 | - $productValue = array_key_exists('value',$productOption) ? $productOption['value'] : []; |
|
131 | - foreach( $productValue as $key => $optionValue ) |
|
130 | + $productValue = array_key_exists('value', $productOption) ? $productOption['value'] : []; |
|
131 | + foreach ($productValue as $key => $optionValue) |
|
132 | 132 | { |
133 | - $optionPrice = array_key_exists('price',$optionValue) ? $optionValue['price'] : []; |
|
134 | - if(!empty($optionPrice)) |
|
133 | + $optionPrice = array_key_exists('price', $optionValue) ? $optionValue['price'] : []; |
|
134 | + if (!empty($optionPrice)) |
|
135 | 135 | { |
136 | 136 | #Price ++ |
137 | 137 | $price += $optionPrice; |
@@ -150,22 +150,22 @@ discard block |
||
150 | 150 | public function _setCustomer($customerData) |
151 | 151 | { |
152 | 152 | $customer = []; |
153 | - if(!empty($customerData)) |
|
153 | + if (!empty($customerData)) |
|
154 | 154 | { |
155 | - $auth_code = array_key_exists('auth_code',$customerData) ? $customerData['auth_code'] : '' ; |
|
155 | + $auth_code = array_key_exists('auth_code', $customerData) ? $customerData['auth_code'] : ''; |
|
156 | 156 | |
157 | - if( !empty( $auth_code ) ) |
|
157 | + if (!empty($auth_code)) |
|
158 | 158 | { |
159 | 159 | $customer = [ |
160 | 160 | "auth_code" => $auth_code, |
161 | - ];; |
|
161 | + ]; ; |
|
162 | 162 | } |
163 | - else{ |
|
163 | + else { |
|
164 | 164 | $customer = [ |
165 | - "country_code" => array_key_exists('country_code',$customerData) ? $customerData['country_code'] : '', |
|
166 | - "phone_number" => array_key_exists('phone_number',$customerData) ? $customerData['phone_number'] : '', |
|
167 | - "name" => array_key_exists('name',$customerData) ? $customerData['name'] : '', |
|
168 | - "email" => array_key_exists('email',$customerData) ? $customerData['email'] : '', |
|
165 | + "country_code" => array_key_exists('country_code', $customerData) ? $customerData['country_code'] : '', |
|
166 | + "phone_number" => array_key_exists('phone_number', $customerData) ? $customerData['phone_number'] : '', |
|
167 | + "name" => array_key_exists('name', $customerData) ? $customerData['name'] : '', |
|
168 | + "email" => array_key_exists('email', $customerData) ? $customerData['email'] : '', |
|
169 | 169 | ]; |
170 | 170 | } |
171 | 171 | } |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | "charges" => '', |
182 | 182 | "method_name" => '', |
183 | 183 | ]; |
184 | - if(!empty($shipmentData)) |
|
184 | + if (!empty($shipmentData)) |
|
185 | 185 | { |
186 | - $shipmentDetail['charges'] = array_key_exists('charges',$shipmentData) ? $shipmentData['charges'] : ''; |
|
187 | - $shipmentDetail['method_name'] = array_key_exists('method_name',$shipmentData) ? $shipmentData['method_name'] : ''; |
|
186 | + $shipmentDetail['charges'] = array_key_exists('charges', $shipmentData) ? $shipmentData['charges'] : ''; |
|
187 | + $shipmentDetail['method_name'] = array_key_exists('method_name', $shipmentData) ? $shipmentData['method_name'] : ''; |
|
188 | 188 | } |
189 | 189 | return $shipmentDetail; |
190 | 190 | } |
@@ -27,19 +27,19 @@ discard block |
||
27 | 27 | { |
28 | 28 | try { |
29 | 29 | |
30 | - $validationErrors = $this->_checkForValidationRule( $order_ref ); |
|
30 | + $validationErrors = $this->_checkForValidationRule($order_ref); |
|
31 | 31 | |
32 | - if( count( $validationErrors ) > 0 ) |
|
32 | + if (count($validationErrors) > 0) |
|
33 | 33 | { |
34 | - return ApiResponseHandler::validationError( $validationErrors ); |
|
34 | + return ApiResponseHandler::validationError($validationErrors); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $orderResponse = Order::getOrderStatus($order_ref); |
38 | 38 | |
39 | - if($orderResponse['error']) |
|
39 | + if ($orderResponse['error']) |
|
40 | 40 | { |
41 | 41 | return ApiResponseHandler::failure($orderResponse['message']); |
42 | - }else{ |
|
42 | + } else { |
|
43 | 43 | $response = $orderResponse['body']; |
44 | 44 | |
45 | 45 | return ApiResponseHandler::success($response, trans('bSecure::messages.order.status.success')); |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - private function _checkForValidationRule($order_ref ) |
|
52 | + private function _checkForValidationRule($order_ref) |
|
53 | 53 | { |
54 | 54 | $errors = []; |
55 | 55 | |
56 | 56 | |
57 | - if( empty($order_ref) ) |
|
57 | + if (empty($order_ref)) |
|
58 | 58 | { |
59 | 59 | $errors[] = trans('bSecure::messages.validation.order_ref.required'); |
60 | 60 | } |
@@ -23,21 +23,21 @@ discard block |
||
23 | 23 | public function verifyCustomer($auth_code) |
24 | 24 | { |
25 | 25 | try { |
26 | - $validationErrors = $this->_checkForValidationRule( $auth_code ); |
|
26 | + $validationErrors = $this->_checkForValidationRule($auth_code); |
|
27 | 27 | |
28 | - if( count( $validationErrors ) > 0 ) |
|
28 | + if (count($validationErrors) > 0) |
|
29 | 29 | { |
30 | - return ApiResponseHandler::validationError( $validationErrors ); |
|
30 | + return ApiResponseHandler::validationError($validationErrors); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | $ssoCustomerProfile = $this->createSSOProfileStructure($auth_code); |
34 | 34 | |
35 | 35 | $ssoResponse = Helper::customerProfile($ssoCustomerProfile); |
36 | 36 | |
37 | - if($ssoResponse['error']) |
|
37 | + if ($ssoResponse['error']) |
|
38 | 38 | { |
39 | 39 | return ApiResponseHandler::failure($ssoResponse['message']); |
40 | - }else{ |
|
40 | + } else { |
|
41 | 41 | $response = $ssoResponse['body']; |
42 | 42 | return ApiResponseHandler::success($response, trans('bSecure::messages.customer.verification.success')); |
43 | 43 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | { |
57 | 57 | $errors = []; |
58 | 58 | |
59 | - if( empty($auth_code) ) |
|
59 | + if (empty($auth_code)) |
|
60 | 60 | { |
61 | 61 | $errors[] = trans('bSecure::messages.validation.auth_code.required'); |
62 | 62 | } |
@@ -21,21 +21,21 @@ discard block |
||
21 | 21 | * Author: Sara Hasan |
22 | 22 | * Date: 26-November-2020 |
23 | 23 | */ |
24 | - public function verifyClient($state,$appType) |
|
24 | + public function verifyClient($state, $appType) |
|
25 | 25 | { |
26 | 26 | try { |
27 | 27 | |
28 | - $validationErrors = $this->_checkForValidationRule( $state ); |
|
28 | + $validationErrors = $this->_checkForValidationRule($state); |
|
29 | 29 | |
30 | - if( count( $validationErrors ) > 0 ) |
|
30 | + if (count($validationErrors) > 0) |
|
31 | 31 | { |
32 | - return ApiResponseHandler::validationError( $validationErrors ); |
|
32 | + return ApiResponseHandler::validationError($validationErrors); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
36 | 36 | $ssoPayload = $this->createSSODataStructure($state); |
37 | 37 | |
38 | - if($appType == Constant::APP_TYPE['checkout']) |
|
38 | + if ($appType == Constant::APP_TYPE['checkout']) |
|
39 | 39 | { |
40 | 40 | $auth_url = $this->_createAuthenticationURL($ssoPayload); |
41 | 41 | $response = [ |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | else if ($appType == Constant::APP_TYPE['sdk']) |
47 | 47 | { |
48 | 48 | $ssoResponse = Helper::verifyClient($ssoPayload); |
49 | - if($ssoResponse['error']) |
|
49 | + if ($ssoResponse['error']) |
|
50 | 50 | { |
51 | 51 | return ApiResponseHandler::failure($ssoResponse['message']); |
52 | - }else{ |
|
52 | + } else { |
|
53 | 53 | $response = $ssoResponse['body']; |
54 | 54 | return ApiResponseHandler::success($response, trans('bSecure::messages.sso_sco.success')); |
55 | 55 | } |
56 | - }else{ |
|
56 | + } else { |
|
57 | 57 | return ApiResponseHandler::failure('Invalid application type', []); |
58 | 58 | } |
59 | 59 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $response_type = $sso_client['response_type']; |
92 | 92 | $state = $sso_client['state']; |
93 | 93 | |
94 | - return $login_app_url.'?scope='.$scope.'&response_type='.$response_type.'&client_id='.$client_id.'&state='.$state; |
|
94 | + return $login_app_url . '?scope=' . $scope . '&response_type=' . $response_type . '&client_id=' . $client_id . '&state=' . $state; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | * Author: Sara Hasan |
100 | 100 | * Date: 27-November-2020 |
101 | 101 | */ |
102 | - private function _checkForValidationRule($state ) |
|
102 | + private function _checkForValidationRule($state) |
|
103 | 103 | { |
104 | 104 | $errors = []; |
105 | 105 | |
106 | 106 | |
107 | - if( empty($state) ) |
|
107 | + if (empty($state)) |
|
108 | 108 | { |
109 | 109 | $errors[] = trans('bSecure::messages.validation.state.required'); |
110 | 110 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | ], |
67 | 67 | ]); |
68 | 68 | |
69 | - $result = json_decode((string)$response->getBody("access_token"), true); |
|
69 | + $result = json_decode((string) $response->getBody("access_token"), true); |
|
70 | 70 | |
71 | 71 | if (isset($result['status']) && $result['status'] == Constant::HTTP_RESPONSE_STATUSES['success']) { |
72 | 72 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | 'form_params' => $ssoPayload |
167 | 167 | ]); |
168 | 168 | |
169 | - $result = json_decode((string)$response->getBody("access_token"), true); |
|
169 | + $result = json_decode((string) $response->getBody("access_token"), true); |
|
170 | 170 | |
171 | 171 | if (isset($result['status']) && $result['status'] == Constant::HTTP_RESPONSE_STATUSES['success']) { |
172 | 172 | $response = ['error' => false, 'body' => $result['body']]; |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | return self::send( |
19 | 19 | Http::$Codes[Http::SUCCESS], |
20 | 20 | [Language::getMessage($message)], |
21 | - (object)$body, |
|
21 | + (object) $body, |
|
22 | 22 | null |
23 | 23 | ); |
24 | 24 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | return self::send( |
45 | 45 | Http::$Codes[Http::INPROCESSABLE], |
46 | 46 | $errorMessages, |
47 | - (object)[], |
|
47 | + (object) [], |
|
48 | 48 | null |
49 | 49 | ); |
50 | 50 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | return self::send( |
59 | 59 | Http::$Codes[Http::UNAUTHORISED], |
60 | 60 | [Language::getMessage("general.unauthenticated")], |
61 | - (object)[], |
|
61 | + (object) [], |
|
62 | 62 | null |
63 | 63 | ); |
64 | 64 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | return self::send( |
75 | 75 | Http::$Codes[Http::BAD_REQUEST], |
76 | 76 | (gettype($message) == "array") ? $message : [Language::getMessage($message)], |
77 | - (object)$body, |
|
77 | + (object) $body, |
|
78 | 78 | $exception |
79 | 79 | ); |
80 | 80 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function register() |
15 | 15 | { |
16 | - $this->app->bind("bSecure_facade", function () { |
|
16 | + $this->app->bind("bSecure_facade", function() { |
|
17 | 17 | return new BsecureCheckout(); |
18 | 18 | }); |
19 | 19 | } |