@@ -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 | |
@@ -66,15 +66,15 @@ discard block |
||
| 66 | 66 | if( !empty( $auth_code ) ) |
| 67 | 67 | { |
| 68 | 68 | $customer = [ |
| 69 | - "auth_code" => $auth_code, |
|
| 69 | + "auth_code" => $auth_code, |
|
| 70 | 70 | ];; |
| 71 | 71 | } |
| 72 | 72 | else{ |
| 73 | 73 | $customer = [ |
| 74 | - "country_code" => array_key_exists('country_code',$customerData) ? $customerData['country_code'] : '', |
|
| 75 | - "phone_number" => array_key_exists('phone_number',$customerData) ? $customerData['phone_number'] : '', |
|
| 76 | - "name" => array_key_exists('name',$customerData) ? $customerData['name'] : '', |
|
| 77 | - "email" => array_key_exists('email',$customerData) ? $customerData['email'] : '', |
|
| 74 | + "country_code" => array_key_exists('country_code',$customerData) ? $customerData['country_code'] : '', |
|
| 75 | + "phone_number" => array_key_exists('phone_number',$customerData) ? $customerData['phone_number'] : '', |
|
| 76 | + "name" => array_key_exists('name',$customerData) ? $customerData['name'] : '', |
|
| 77 | + "email" => array_key_exists('email',$customerData) ? $customerData['email'] : '', |
|
| 78 | 78 | ]; |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | try { |
| 36 | 36 | $orderResponse = Order::createMerchantOrder($orderData); |
| 37 | - if($orderResponse['error']) |
|
| 37 | + if ($orderResponse['error']) |
|
| 38 | 38 | { |
| 39 | - return ApiResponseHandler::failure($orderResponse['message'],$orderResponse['exception']); |
|
| 40 | - }else{ |
|
| 39 | + return ApiResponseHandler::failure($orderResponse['message'], $orderResponse['exception']); |
|
| 40 | + } else { |
|
| 41 | 41 | $response = $orderResponse['body']; |
| 42 | 42 | return ApiResponseHandler::success($response, trans('bSecurePayments::messages.order.success')); |
| 43 | 43 | } |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | public function _setCharges($object) |
| 51 | 51 | { |
| 52 | - $orderData['sub_total_amount'] = array_key_exists('sub_total_amount',$object ) ? $object['sub_total_amount'] : null; |
|
| 53 | - $orderData['discount_amount'] = array_key_exists('discount_amount',$object ) ? $object['discount_amount'] : null; |
|
| 54 | - $orderData['total_amount'] = array_key_exists('total_amount',$object ) ? $object['total_amount'] : null; |
|
| 52 | + $orderData['sub_total_amount'] = array_key_exists('sub_total_amount', $object) ? $object['sub_total_amount'] : null; |
|
| 53 | + $orderData['discount_amount'] = array_key_exists('discount_amount', $object) ? $object['discount_amount'] : null; |
|
| 54 | + $orderData['total_amount'] = array_key_exists('total_amount', $object) ? $object['total_amount'] : null; |
|
| 55 | 55 | return $orderData; |
| 56 | 56 | } |
| 57 | 57 | |
@@ -59,22 +59,22 @@ discard block |
||
| 59 | 59 | public function _setCustomer($customerData) |
| 60 | 60 | { |
| 61 | 61 | $customer = []; |
| 62 | - if(!empty($customerData)) |
|
| 62 | + if (!empty($customerData)) |
|
| 63 | 63 | { |
| 64 | - $auth_code = array_key_exists('auth_code',$customerData) ? $customerData['auth_code'] : '' ; |
|
| 64 | + $auth_code = array_key_exists('auth_code', $customerData) ? $customerData['auth_code'] : ''; |
|
| 65 | 65 | |
| 66 | - if( !empty( $auth_code ) ) |
|
| 66 | + if (!empty($auth_code)) |
|
| 67 | 67 | { |
| 68 | 68 | $customer = [ |
| 69 | 69 | "auth_code" => $auth_code, |
| 70 | - ];; |
|
| 70 | + ]; ; |
|
| 71 | 71 | } |
| 72 | - else{ |
|
| 72 | + else { |
|
| 73 | 73 | $customer = [ |
| 74 | - "country_code" => array_key_exists('country_code',$customerData) ? $customerData['country_code'] : '', |
|
| 75 | - "phone_number" => array_key_exists('phone_number',$customerData) ? $customerData['phone_number'] : '', |
|
| 76 | - "name" => array_key_exists('name',$customerData) ? $customerData['name'] : '', |
|
| 77 | - "email" => array_key_exists('email',$customerData) ? $customerData['email'] : '', |
|
| 74 | + "country_code" => array_key_exists('country_code', $customerData) ? $customerData['country_code'] : '', |
|
| 75 | + "phone_number" => array_key_exists('phone_number', $customerData) ? $customerData['phone_number'] : '', |
|
| 76 | + "name" => array_key_exists('name', $customerData) ? $customerData['name'] : '', |
|
| 77 | + "email" => array_key_exists('email', $customerData) ? $customerData['email'] : '', |
|
| 78 | 78 | ]; |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -85,14 +85,14 @@ discard block |
||
| 85 | 85 | public function _setCustomerAddress($customerData) |
| 86 | 86 | { |
| 87 | 87 | $customer = []; |
| 88 | - if(!empty($customerData)) |
|
| 88 | + if (!empty($customerData)) |
|
| 89 | 89 | { |
| 90 | 90 | $customer = [ |
| 91 | - "country" => array_key_exists('country',$customerData) ? $customerData['country'] : '', |
|
| 92 | - "province" => array_key_exists('province',$customerData) ? $customerData['province'] : '', |
|
| 93 | - "city" => array_key_exists('city',$customerData) ? $customerData['city'] : '', |
|
| 94 | - "area" => array_key_exists('area',$customerData) ? $customerData['area'] : '', |
|
| 95 | - "address" => array_key_exists('address',$customerData) ? $customerData['address'] : '', |
|
| 91 | + "country" => array_key_exists('country', $customerData) ? $customerData['country'] : '', |
|
| 92 | + "province" => array_key_exists('province', $customerData) ? $customerData['province'] : '', |
|
| 93 | + "city" => array_key_exists('city', $customerData) ? $customerData['city'] : '', |
|
| 94 | + "area" => array_key_exists('area', $customerData) ? $customerData['area'] : '', |
|
| 95 | + "address" => array_key_exists('address', $customerData) ? $customerData['address'] : '', |
|
| 96 | 96 | ]; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | if($orderResponse['error']) |
| 38 | 38 | { |
| 39 | 39 | return ApiResponseHandler::failure($orderResponse['message'],$orderResponse['exception']); |
| 40 | - }else{ |
|
| 40 | + } else{ |
|
| 41 | 41 | $response = $orderResponse['body']; |
| 42 | 42 | return ApiResponseHandler::success($response, trans('bSecurePayments::messages.order.success')); |
| 43 | 43 | } |
@@ -68,8 +68,7 @@ discard block |
||
| 68 | 68 | $customer = [ |
| 69 | 69 | "auth_code" => $auth_code, |
| 70 | 70 | ];; |
| 71 | - } |
|
| 72 | - else{ |
|
| 71 | + } else{ |
|
| 73 | 72 | $customer = [ |
| 74 | 73 | "country_code" => array_key_exists('country_code',$customerData) ? $customerData['country_code'] : '', |
| 75 | 74 | "phone_number" => array_key_exists('phone_number',$customerData) ? $customerData['phone_number'] : '', |
@@ -28,10 +28,10 @@ |
||
| 28 | 28 | try { |
| 29 | 29 | $orderResponse = Order::getOrderStatus($order_ref); |
| 30 | 30 | |
| 31 | - if($orderResponse['error']) |
|
| 31 | + if ($orderResponse['error']) |
|
| 32 | 32 | { |
| 33 | - return ApiResponseHandler::failure($orderResponse['message'],$orderResponse['exception']); |
|
| 34 | - }else{ |
|
| 33 | + return ApiResponseHandler::failure($orderResponse['message'], $orderResponse['exception']); |
|
| 34 | + } else { |
|
| 35 | 35 | $response = $orderResponse['body']; |
| 36 | 36 | |
| 37 | 37 | return ApiResponseHandler::success($response, trans('bSecurePayments::messages.order.status.success')); |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | if($orderResponse['error']) |
| 32 | 32 | { |
| 33 | 33 | return ApiResponseHandler::failure($orderResponse['message'],$orderResponse['exception']); |
| 34 | - }else{ |
|
| 34 | + } else{ |
|
| 35 | 35 | $response = $orderResponse['body']; |
| 36 | 36 | |
| 37 | 37 | return ApiResponseHandler::success($response, trans('bSecurePayments::messages.order.status.success')); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | public function setTransactionDetails($details) |
| 33 | 33 | { |
| 34 | 34 | try { |
| 35 | - if(empty($details)) |
|
| 35 | + if (empty($details)) |
|
| 36 | 36 | { |
| 37 | 37 | return ApiResponseHandler::validationError("Transaction details are required"); |
| 38 | 38 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | public function setCustomer($customerData) |
| 84 | 84 | { |
| 85 | 85 | try { |
| 86 | - if(empty($customerData)) |
|
| 86 | + if (empty($customerData)) |
|
| 87 | 87 | { |
| 88 | 88 | return ApiResponseHandler::validationError("Customer data is required"); |
| 89 | 89 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | public function setCustomerAddress($customerData) |
| 121 | 121 | { |
| 122 | 122 | try { |
| 123 | - if(empty($customerData)) |
|
| 123 | + if (empty($customerData)) |
|
| 124 | 124 | { |
| 125 | 125 | return ApiResponseHandler::validationError("Customer address data is required"); |
| 126 | 126 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | public function createOrder() |
| 159 | 159 | { |
| 160 | 160 | try { |
| 161 | - if(empty($this->orderPayload)) |
|
| 161 | + if (empty($this->orderPayload)) |
|
| 162 | 162 | { |
| 163 | 163 | return ApiResponseHandler::validationError("Transaction data is required"); |
| 164 | 164 | } |
@@ -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 BsecurePayments(); |
| 18 | 18 | }); |
| 19 | 19 | } |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | 'client_id' => env('BSECURE_CLIENT_ID', ''), |
| 5 | - 'integration_type' => env('BSECURE_INTEGRATION_TYPE','sandbox'), //use 'production' for live orders and 'sandbox' for testing orders. When left empty or `null` the sandbox environment will be used |
|
| 6 | - 'store_slug' => env('BSECURE_STORE_SLUG'), //If store id is not mentioned your orders will be marked against your default store |
|
| 7 | - 'merchant_id' => env('BSECURE_MERCHANT_ID'), //If store id is not mentioned your orders will be marked against your default store |
|
| 5 | + 'integration_type' => env('BSECURE_INTEGRATION_TYPE', 'sandbox'), //use 'production' for live orders and 'sandbox' for testing orders. When left empty or `null` the sandbox environment will be used |
|
| 6 | + 'store_slug' => env('BSECURE_STORE_SLUG'), //If store id is not mentioned your orders will be marked against your default store |
|
| 7 | + 'merchant_id' => env('BSECURE_MERCHANT_ID'), //If store id is not mentioned your orders will be marked against your default store |
|
| 8 | 8 | ]; |
@@ -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 |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | $http = new Client(); |
| 58 | 58 | $authUrl = Constant::AUTH_SERVER_URL . Constant::API_ENDPOINTS['oauth']; |
| 59 | 59 | |
| 60 | - $storeId = array_key_exists('store_id',$data) ? $data['store_id'] : null; |
|
| 61 | - $clientId = !empty($storeId) ? $data['client_id'].':'.$storeId : $data['client_id']; |
|
| 60 | + $storeId = array_key_exists('store_id', $data) ? $data['store_id'] : null; |
|
| 61 | + $clientId = !empty($storeId) ? $data['client_id'] . ':' . $storeId : $data['client_id']; |
|
| 62 | 62 | |
| 63 | 63 | $response = $http->post($authUrl, [ |
| 64 | 64 | 'form_params' => [ |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | |
| 156 | - static function calculateSecureHash($payload){ |
|
| 156 | + static function calculateSecureHash($payload) { |
|
| 157 | 157 | $details = [ |
| 158 | 158 | '__00trid__' => $payload['order']['order_id'], |
| 159 | 159 | '__01curr__' => $payload['order']['currency'], |
@@ -180,11 +180,11 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | $salt = config('bSecurePayments.client_id'); |
| 182 | 182 | ksort($details); |
| 183 | - $signature = $salt."&"; |
|
| 184 | - foreach($details as $key => $value) |
|
| 183 | + $signature = $salt . "&"; |
|
| 184 | + foreach ($details as $key => $value) |
|
| 185 | 185 | { |
| 186 | 186 | $signature .= preg_replace("/\s+/", "", $value); |
| 187 | - if(next($details)) { |
|
| 187 | + if (next($details)) { |
|
| 188 | 188 | $signature .= "&"; |
| 189 | 189 | } |
| 190 | 190 | } |