@@ -15,9 +15,9 @@ |
||
| 15 | 15 | return ['client_id' => '', 'error' => true, 'message' => trans('bSecure::messages.client.secret.invalid')]; |
| 16 | 16 | } else { |
| 17 | 17 | return [ |
| 18 | - 'client_id' => $merchantClientId, |
|
| 19 | - 'client_secret' => $merchantClientSecret, |
|
| 20 | - 'error' => false, |
|
| 18 | + 'client_id' => $merchantClientId, |
|
| 19 | + 'client_secret' => $merchantClientSecret, |
|
| 20 | + 'error' => false, |
|
| 21 | 21 | ]; |
| 22 | 22 | } |
| 23 | 23 | } catch (\Exception $e) { |
@@ -32,11 +32,11 @@ |
||
| 32 | 32 | if ($this->app->runningInConsole()) { |
| 33 | 33 | |
| 34 | 34 | $this->publishes([ |
| 35 | - __DIR__.'/config/config.php' => config_path('bSecure.php'), |
|
| 35 | + __DIR__.'/config/config.php' => config_path('bSecure.php'), |
|
| 36 | 36 | ], 'config'); |
| 37 | 37 | |
| 38 | 38 | $this->publishes([ |
| 39 | - __DIR__.'/lang/en/messages.php' => resource_path('lang/vendor/bSecure/en/messages.php'), |
|
| 39 | + __DIR__.'/lang/en/messages.php' => resource_path('lang/vendor/bSecure/en/messages.php'), |
|
| 40 | 40 | ]); |
| 41 | 41 | } |
| 42 | 42 | } |
@@ -20,11 +20,11 @@ discard block |
||
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | $payload = [ |
| 23 | - $contentType => $body, |
|
| 24 | - 'headers' => $headers, |
|
| 25 | - 'http_errors' => false, |
|
| 26 | - 'timeout' => 30, |
|
| 27 | - 'connect_timeout' => 30 |
|
| 23 | + $contentType => $body, |
|
| 24 | + 'headers' => $headers, |
|
| 25 | + 'http_errors' => false, |
|
| 26 | + 'timeout' => 30, |
|
| 27 | + 'connect_timeout' => 30 |
|
| 28 | 28 | ]; |
| 29 | 29 | |
| 30 | 30 | $client = new Client(); |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | $authUrl = Constant::AUTH_SERVER_URL . Constant::API_ENDPOINTS['oauth']; |
| 58 | 58 | |
| 59 | 59 | $response = $http->post($authUrl, [ |
| 60 | - 'form_params' => [ |
|
| 60 | + 'form_params' => [ |
|
| 61 | 61 | 'grant_type' => 'client_credentials', |
| 62 | 62 | 'client_id' => $data['client_id'], |
| 63 | 63 | 'client_secret' => $data['client_secret'], |
| 64 | 64 | 'scope' => "", |
| 65 | - ], |
|
| 65 | + ], |
|
| 66 | 66 | ]); |
| 67 | 67 | |
| 68 | 68 | $result = json_decode((string)$response->getBody("access_token"), true); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $authUrl = Constant::AUTH_SERVER_URL . Constant::API_ENDPOINTS['verify_client']; |
| 164 | 164 | |
| 165 | 165 | $response = $http->post($authUrl, [ |
| 166 | - 'form_params' => $ssoPayload |
|
| 166 | + 'form_params' => $ssoPayload |
|
| 167 | 167 | ]); |
| 168 | 168 | |
| 169 | 169 | $result = json_decode((string)$response->getBody("access_token"), true); |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | public static function success( $body = [], $message ="messages.general.success" ){ |
| 14 | 14 | |
| 15 | 15 | return self::send( |
| 16 | - Http::$Codes[ Http::SUCCESS ], |
|
| 17 | - [Language::getMessage( $message )], |
|
| 18 | - (object) $body, |
|
| 19 | - null |
|
| 16 | + Http::$Codes[ Http::SUCCESS ], |
|
| 17 | + [Language::getMessage( $message )], |
|
| 18 | + (object) $body, |
|
| 19 | + null |
|
| 20 | 20 | ); |
| 21 | 21 | } |
| 22 | 22 | |
@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | return self::send( |
| 44 | - Http::$Codes[ Http::INPROCESSABLE ], |
|
| 45 | - $errorMessages, |
|
| 46 | - (object) [], |
|
| 47 | - null |
|
| 44 | + Http::$Codes[ Http::INPROCESSABLE ], |
|
| 45 | + $errorMessages, |
|
| 46 | + (object) [], |
|
| 47 | + null |
|
| 48 | 48 | ); |
| 49 | 49 | } |
| 50 | 50 | |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | public static function authenticationError(){ |
| 55 | 55 | |
| 56 | 56 | return self::send( |
| 57 | - Http::$Codes[ Http::UNAUTHORISED ], |
|
| 58 | - [Language::getMessage( "general.unauthenticated" )], |
|
| 59 | - (object) [], |
|
| 60 | - null |
|
| 57 | + Http::$Codes[ Http::UNAUTHORISED ], |
|
| 58 | + [Language::getMessage( "general.unauthenticated" )], |
|
| 59 | + (object) [], |
|
| 60 | + null |
|
| 61 | 61 | ); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -69,10 +69,10 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public static function failure( $message = 'general.error', $exception=null, $body = [] ){ |
| 71 | 71 | return self::send( |
| 72 | - Http::$Codes[ Http::BAD_REQUEST ], |
|
| 73 | - (gettype($message) == "array") ? $message : [ Language::getMessage( $message ) ], |
|
| 74 | - (object) $body, |
|
| 75 | - $exception |
|
| 72 | + Http::$Codes[ Http::BAD_REQUEST ], |
|
| 73 | + (gettype($message) == "array") ? $message : [ Language::getMessage( $message ) ], |
|
| 74 | + (object) $body, |
|
| 75 | + $exception |
|
| 76 | 76 | ); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -85,10 +85,10 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | public static function exception( $code, $message, $exception=null ){ |
| 87 | 87 | return self::send( |
| 88 | - $code, |
|
| 89 | - [$message], |
|
| 90 | - [], |
|
| 91 | - $exception |
|
| 88 | + $code, |
|
| 89 | + [$message], |
|
| 90 | + [], |
|
| 91 | + $exception |
|
| 92 | 92 | ); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -102,10 +102,10 @@ discard block |
||
| 102 | 102 | private static function send( $status, $message, $body, $exception ){ |
| 103 | 103 | |
| 104 | 104 | return response()->json([ |
| 105 | - 'status' => $status, |
|
| 106 | - 'message' => $message, |
|
| 107 | - 'body' => $body, |
|
| 108 | - 'exception' => $exception |
|
| 105 | + 'status' => $status, |
|
| 106 | + 'message' => $message, |
|
| 107 | + 'body' => $body, |
|
| 108 | + 'exception' => $exception |
|
| 109 | 109 | ], $status, [], JSON_UNESCAPED_UNICODE ); |
| 110 | 110 | } |
| 111 | 111 | } |
@@ -5,12 +5,12 @@ discard block |
||
| 5 | 5 | class Constant |
| 6 | 6 | { |
| 7 | 7 | const HTTP_RESPONSE_STATUSES = [ |
| 8 | - 'success' => 200, |
|
| 9 | - 'failed' => 400, |
|
| 10 | - 'validationError' => 422, |
|
| 11 | - 'authenticationError' => 401, |
|
| 12 | - 'authorizationError' => 403, |
|
| 13 | - 'serverError' => 500, |
|
| 8 | + 'success' => 200, |
|
| 9 | + 'failed' => 400, |
|
| 10 | + 'validationError' => 422, |
|
| 11 | + 'authenticationError' => 401, |
|
| 12 | + 'authorizationError' => 403, |
|
| 13 | + 'serverError' => 500, |
|
| 14 | 14 | ]; |
| 15 | 15 | |
| 16 | 16 | const AUTH_SERVER_URL = 'https://api-dev.bsecure.app/'; |
@@ -20,26 +20,26 @@ discard block |
||
| 20 | 20 | const API_VERSION = 'v1'; |
| 21 | 21 | |
| 22 | 22 | const API_ENDPOINTS = [ |
| 23 | - 'oauth' => Constant::API_VERSION . '/oauth/token', |
|
| 24 | - 'create_order' => Constant::API_VERSION . '/order/create', |
|
| 25 | - 'order_status' => Constant::API_VERSION . '/order/status', |
|
| 26 | - 'manual_order_status_update' => Constant::API_VERSION . '/order/update-status', |
|
| 27 | - 'verify_client' => Constant::API_VERSION . '/sso/verify-client', |
|
| 28 | - 'customer_profile' => Constant::API_VERSION . '/sso/customer/profile', |
|
| 23 | + 'oauth' => Constant::API_VERSION . '/oauth/token', |
|
| 24 | + 'create_order' => Constant::API_VERSION . '/order/create', |
|
| 25 | + 'order_status' => Constant::API_VERSION . '/order/status', |
|
| 26 | + 'manual_order_status_update' => Constant::API_VERSION . '/order/update-status', |
|
| 27 | + 'verify_client' => Constant::API_VERSION . '/sso/verify-client', |
|
| 28 | + 'customer_profile' => Constant::API_VERSION . '/sso/customer/profile', |
|
| 29 | 29 | ]; |
| 30 | 30 | |
| 31 | 31 | const APP_TYPE = [ |
| 32 | - 'checkout' => 1, |
|
| 33 | - 'sdk' => 2, |
|
| 32 | + 'checkout' => 1, |
|
| 33 | + 'sdk' => 2, |
|
| 34 | 34 | ]; |
| 35 | 35 | |
| 36 | 36 | const OrderStatus = [ |
| 37 | - 'created' => 1, |
|
| 38 | - 'initiated' => 2, |
|
| 39 | - 'placed' => 3, |
|
| 40 | - 'awaiting-confirmation' => 4, |
|
| 41 | - 'canceled' => 5, |
|
| 42 | - 'expired' => 6, |
|
| 43 | - 'failed' => 7 |
|
| 37 | + 'created' => 1, |
|
| 38 | + 'initiated' => 2, |
|
| 39 | + 'placed' => 3, |
|
| 40 | + 'awaiting-confirmation' => 4, |
|
| 41 | + 'canceled' => 5, |
|
| 42 | + 'expired' => 6, |
|
| 43 | + 'failed' => 7 |
|
| 44 | 44 | ]; |
| 45 | 45 | } |
@@ -2,9 +2,9 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - 'client_id' => env('BSECURE_CLIENT_ID', ''), |
|
| 6 | - 'client_secret' => env('BSECURE_CLIENT_SECRET',''), |
|
| 5 | + 'client_id' => env('BSECURE_CLIENT_ID', ''), |
|
| 6 | + 'client_secret' => env('BSECURE_CLIENT_SECRET',''), |
|
| 7 | 7 | |
| 8 | - //use 'production' for live orders and 'sandbox' for testing orders. When left empty or `null` the sandbox environment will be used |
|
| 9 | - 'environment' => env('BSECURE_ENVIRONMENT'), |
|
| 8 | + //use 'production' for live orders and 'sandbox' for testing orders. When left empty or `null` the sandbox environment will be used |
|
| 9 | + 'environment' => env('BSECURE_ENVIRONMENT'), |
|
| 10 | 10 | ]; |
@@ -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. |
@@ -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 | |