@@ -1,74 +1,74 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return [ |
4 | - 'general' => [ |
|
4 | + 'general' => [ |
|
5 | 5 | 'failed' => 'Request Failed', |
6 | 6 | 'success' => 'Request Successful', |
7 | 7 | 'validation' => 'Validation Error', |
8 | 8 | 'crashed' => 'Something went wrong', |
9 | 9 | 'unauthenticated' => 'Authentication Failed', |
10 | 10 | 'unauthorized' => 'Authorization Failed', |
11 | - ], |
|
12 | - 'client' => [ |
|
11 | + ], |
|
12 | + 'client' => [ |
|
13 | 13 | 'invalid' => 'Invalid client id or secret provided', |
14 | 14 | 'id' => [ |
15 | - 'invalid' => 'Invalid client id provided', |
|
15 | + 'invalid' => 'Invalid client id provided', |
|
16 | 16 | ], |
17 | 17 | 'secret' => [ |
18 | - 'invalid' => 'Invalid client secret provided', |
|
18 | + 'invalid' => 'Invalid client secret provided', |
|
19 | 19 | ], |
20 | 20 | 'environment' => [ |
21 | - 'invalid' => 'Invalid environment or secret keys provided', |
|
21 | + 'invalid' => 'Invalid environment or secret keys provided', |
|
22 | 22 | ] |
23 | - ], |
|
24 | - 'validation' => [ |
|
23 | + ], |
|
24 | + 'validation' => [ |
|
25 | 25 | 'order_ref' => [ |
26 | - 'required' => 'Order reference field is required', |
|
26 | + 'required' => 'Order reference field is required', |
|
27 | 27 | ], |
28 | 28 | 'auth_code' => [ |
29 | - 'required' => 'Auth code field is required', |
|
29 | + 'required' => 'Auth code field is required', |
|
30 | 30 | ], |
31 | 31 | 'state' => [ |
32 | - 'required' => 'State field is required', |
|
32 | + 'required' => 'State field is required', |
|
33 | 33 | ], |
34 | 34 | 'order_id' => [ |
35 | - 'required' => 'Order id field is required', |
|
36 | - 'failure' => 'Unable to set order id field. Try again later', |
|
35 | + 'required' => 'Order id field is required', |
|
36 | + 'failure' => 'Unable to set order id field. Try again later', |
|
37 | 37 | ], |
38 | 38 | 'customer' => [ |
39 | - 'required' => 'Customer object is required', |
|
40 | - 'failure' => 'Unable to set customer object field. Try again later', |
|
39 | + 'required' => 'Customer object is required', |
|
40 | + 'failure' => 'Unable to set customer object field. Try again later', |
|
41 | 41 | ], |
42 | 42 | 'products' => [ |
43 | - 'required' => 'Products object is required', |
|
44 | - 'failure' => 'Unable to set products object field. Try again later', |
|
43 | + 'required' => 'Products object is required', |
|
44 | + 'failure' => 'Unable to set products object field. Try again later', |
|
45 | 45 | ], |
46 | 46 | 'order_status' => [ |
47 | - 'required' => 'Order status field is required', |
|
48 | - 'not_matched' => 'Order status does not match with bSecure order statuses.', |
|
47 | + 'required' => 'Order status field is required', |
|
48 | + 'not_matched' => 'Order status does not match with bSecure order statuses.', |
|
49 | 49 | ], |
50 | - ], |
|
51 | - 'order' => [ |
|
50 | + ], |
|
51 | + 'order' => [ |
|
52 | 52 | 'success' => 'Order placed successfully', |
53 | 53 | 'failure' => 'Unable to place order. Try again later', |
54 | 54 | 'status' => [ |
55 | - 'success' => 'Order status updated received', |
|
56 | - 'failure' => 'Unable to receive order status update.', |
|
57 | - 'updated' => [ |
|
55 | + 'success' => 'Order status updated received', |
|
56 | + 'failure' => 'Unable to receive order status update.', |
|
57 | + 'updated' => [ |
|
58 | 58 | 'success' => 'Order status updated successfully', |
59 | 59 | 'failure' => 'Unable to update order status.', |
60 | - ] |
|
60 | + ] |
|
61 | + ], |
|
61 | 62 | ], |
62 | - ], |
|
63 | - 'sso_sco' => [ |
|
63 | + 'sso_sco' => [ |
|
64 | 64 | 'success' => 'Third-party login succeeded.', |
65 | 65 | 'failure' => 'Third-party login failed, please check the connection with bSecure.', |
66 | - ], |
|
67 | - 'customer' => [ |
|
66 | + ], |
|
67 | + 'customer' => [ |
|
68 | 68 | 'verification' => [ |
69 | - 'success' => 'Customer verified', |
|
70 | - 'failure' => 'Customer verification failed', |
|
69 | + 'success' => 'Customer verified', |
|
70 | + 'failure' => 'Customer verification failed', |
|
71 | + ] |
|
71 | 72 | ] |
72 | - ] |
|
73 | 73 | |
74 | 74 | ]; |
75 | 75 | \ No newline at end of file |
@@ -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,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | // Publishing the translation files. |
56 | 56 | $this->publishes([ |
57 | - __DIR__.'/resources/lang' => resource_path('lang/vendor/bSecure'), |
|
57 | + __DIR__.'/resources/lang' => resource_path('lang/vendor/bSecure'), |
|
58 | 58 | ],'lang'); |
59 | 59 | |
60 | 60 | // Registering package commands. |
@@ -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([]); |
@@ -12,14 +12,14 @@ |
||
12 | 12 | { |
13 | 13 | |
14 | 14 | private $orderPayload = [ |
15 | - 'order_id' => null, |
|
16 | - 'customer' => null, |
|
17 | - 'products' => null, |
|
18 | - 'shipment_charges' => null, |
|
19 | - 'shipment_method_name' => null, |
|
20 | - 'sub_total_amount' => null, |
|
21 | - 'discount_amount' => null, |
|
22 | - 'total_amount' => null |
|
15 | + 'order_id' => null, |
|
16 | + 'customer' => null, |
|
17 | + 'products' => null, |
|
18 | + 'shipment_charges' => null, |
|
19 | + 'shipment_method_name' => null, |
|
20 | + 'sub_total_amount' => null, |
|
21 | + 'discount_amount' => null, |
|
22 | + 'total_amount' => null |
|
23 | 23 | ]; |
24 | 24 | |
25 | 25 |
@@ -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; |
@@ -19,9 +19,9 @@ discard block |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | protected $validationRule = [ |
22 | - 'order_id' => 'order_id', |
|
23 | - 'customer' => 'customer', |
|
24 | - 'products' => 'products', |
|
22 | + 'order_id' => 'order_id', |
|
23 | + 'customer' => 'customer', |
|
24 | + 'products' => 'products', |
|
25 | 25 | ]; |
26 | 26 | |
27 | 27 | |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | public function _setProductsDataStructure($products) |
57 | 57 | { |
58 | 58 | $orderData = [ |
59 | - 'products' => null, |
|
60 | - 'sub_total_amount' => null, |
|
61 | - 'discount_amount' => null, |
|
62 | - 'total_amount' => null, |
|
59 | + 'products' => null, |
|
60 | + 'sub_total_amount' => null, |
|
61 | + 'discount_amount' => null, |
|
62 | + 'total_amount' => null, |
|
63 | 63 | ]; |
64 | 64 | |
65 | 65 | if(!empty($products)) |
@@ -89,18 +89,18 @@ discard block |
||
89 | 89 | $product_sub_total = ( $price + $options_price ) * $quantity; |
90 | 90 | |
91 | 91 | $orderItems['products'][] = [ |
92 | - "id" => $product['id'], |
|
93 | - "name" => $product['name'], |
|
94 | - "sku" => $product['sku'], |
|
95 | - "quantity" => $quantity, |
|
96 | - "price" => $price, |
|
97 | - "sale_price" => $sale_price, |
|
98 | - "discount" => $discount, |
|
99 | - "sub_total" => $product_price, |
|
100 | - "image" => $product['image'], |
|
101 | - "short_description" => $product['short_description'], |
|
102 | - "description" => $product['description'], |
|
103 | - "product_options" => $options |
|
92 | + "id" => $product['id'], |
|
93 | + "name" => $product['name'], |
|
94 | + "sku" => $product['sku'], |
|
95 | + "quantity" => $quantity, |
|
96 | + "price" => $price, |
|
97 | + "sale_price" => $sale_price, |
|
98 | + "discount" => $discount, |
|
99 | + "sub_total" => $product_price, |
|
100 | + "image" => $product['image'], |
|
101 | + "short_description" => $product['short_description'], |
|
102 | + "description" => $product['description'], |
|
103 | + "product_options" => $options |
|
104 | 104 | ]; |
105 | 105 | |
106 | 106 | $total_discount += $discount; |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | return [ |
144 | - 'price' => $price, |
|
145 | - 'options' => $product_options |
|
144 | + 'price' => $price, |
|
145 | + 'options' => $product_options |
|
146 | 146 | ]; |
147 | 147 | } |
148 | 148 | |
@@ -157,15 +157,15 @@ discard block |
||
157 | 157 | if( !empty( $auth_code ) ) |
158 | 158 | { |
159 | 159 | $customer = [ |
160 | - "auth_code" => $auth_code, |
|
160 | + "auth_code" => $auth_code, |
|
161 | 161 | ];; |
162 | 162 | } |
163 | 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 | } |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | public function _setShipmentDetails($shipmentData) |
179 | 179 | { |
180 | 180 | $shipmentDetail = [ |
181 | - "charges" => '', |
|
182 | - "method_name" => '', |
|
181 | + "charges" => '', |
|
182 | + "method_name" => '', |
|
183 | 183 | ]; |
184 | 184 | if(!empty($shipmentData)) |
185 | 185 | { |
@@ -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 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 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 | } |
@@ -159,8 +159,7 @@ discard block |
||
159 | 159 | $customer = [ |
160 | 160 | "auth_code" => $auth_code, |
161 | 161 | ];; |
162 | - } |
|
163 | - else{ |
|
162 | + } else{ |
|
164 | 163 | $customer = [ |
165 | 164 | "country_code" => array_key_exists('country_code',$customerData) ? $customerData['country_code'] : '', |
166 | 165 | "phone_number" => array_key_exists('phone_number',$customerData) ? $customerData['phone_number'] : '', |
@@ -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 | } |
@@ -39,7 +39,7 @@ |
||
39 | 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')); |
@@ -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 | } |
@@ -37,7 +37,7 @@ |
||
37 | 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 | } |
@@ -39,7 +39,7 @@ |
||
39 | 39 | { |
40 | 40 | $auth_url = $this->_createAuthenticationURL($ssoPayload); |
41 | 41 | $response = [ |
42 | - 'redirect_url' => $auth_url |
|
42 | + 'redirect_url' => $auth_url |
|
43 | 43 | ]; |
44 | 44 | return ApiResponseHandler::success($response, trans('bSecure::messages.sso_sco.success')); |
45 | 45 | } |
@@ -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 | } |
@@ -42,18 +42,17 @@ |
||
42 | 42 | 'redirect_url' => $auth_url |
43 | 43 | ]; |
44 | 44 | return ApiResponseHandler::success($response, trans('bSecure::messages.sso_sco.success')); |
45 | - } |
|
46 | - else if ($appType == Constant::APP_TYPE['sdk']) |
|
45 | + } else if ($appType == Constant::APP_TYPE['sdk']) |
|
47 | 46 | { |
48 | 47 | $ssoResponse = Helper::verifyClient($ssoPayload); |
49 | 48 | if($ssoResponse['error']) |
50 | 49 | { |
51 | 50 | return ApiResponseHandler::failure($ssoResponse['message']); |
52 | - }else{ |
|
51 | + } else{ |
|
53 | 52 | $response = $ssoResponse['body']; |
54 | 53 | return ApiResponseHandler::success($response, trans('bSecure::messages.sso_sco.success')); |
55 | 54 | } |
56 | - }else{ |
|
55 | + } else{ |
|
57 | 56 | return ApiResponseHandler::failure('Invalid application type', []); |
58 | 57 | } |
59 | 58 |
@@ -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 | } |