From b32490aba6c8ab22c4a465504d464dff05f4f442 Mon Sep 17 00:00:00 2001 From: knit-pay Date: Fri, 15 May 2026 14:21:43 +0530 Subject: [PATCH] refactor: remove unnecessary leading backslash from Http facade calls in payment classes Problem: Several gateway classes were using \\Http:: with a leading backslash, while the same files already imported the facade via 'use Illuminate\Support\Facades\Http;'. This is inconsistent and redundant. Impact on non-Laravel frameworks: The leading backslash forces PHP to resolve \Http in the global namespace, which breaks usage in environments (e.g. WordPress, Symfony, CodeIgniter) that register Illuminate\Support\Facades\Http but do NOT alias it globally as \Http. Changes: - Replaced all \\Http:: occurrences with Http:: in 15 gateway files. - All affected files already have the proper 'use' import, so this is a zero-breaking change for existing Laravel users. Benefits: - Improves code consistency within the codebase. - Increases portability to non-Laravel frameworks. - Reduces dependency on global class aliases. --- src/Classes/BinancePayment.php | 2 +- src/Classes/ChangellyPayment.php | 2 +- src/Classes/ClickPayPayment.php | 4 ++-- src/Classes/MamoPayment.php | 4 ++-- src/Classes/NowPaymentsInvoicePayment.php | 2 +- src/Classes/NowPaymentsPayment.php | 4 ++-- src/Classes/OneLatPayment.php | 4 ++-- src/Classes/PayPalCreditPayment.php | 4 ++-- src/Classes/PaycecPayment.php | 4 ++-- src/Classes/PaylinkPayment.php | 8 ++++---- src/Classes/PaymobPayment.php | 2 +- src/Classes/PayopPayment.php | 4 ++-- src/Classes/PrimePayment.php | 2 +- src/Classes/WisePayment.php | 6 +++--- src/Classes/YallaPayPayment.php | 2 +- 15 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Classes/BinancePayment.php b/src/Classes/BinancePayment.php index 1626b78..b0c4d74 100644 --- a/src/Classes/BinancePayment.php +++ b/src/Classes/BinancePayment.php @@ -81,7 +81,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u $binance_pay_key = $this->binance_api; $binance_pay_secret = $this->binance_secret; $signature = strtoupper(hash_hmac('SHA512',$payload,$binance_pay_secret)); - $response = \Http::withHeaders([ + $response = Http::withHeaders([ "Content-Type"=>"application/json", "BinancePay-Timestamp"=>$timestamp, "BinancePay-Nonce"=>$nonce, diff --git a/src/Classes/ChangellyPayment.php b/src/Classes/ChangellyPayment.php index 3cca81b..0e2487c 100644 --- a/src/Classes/ChangellyPayment.php +++ b/src/Classes/ChangellyPayment.php @@ -68,7 +68,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u //dd($key); - $response = \Http::withHeaders([ + $response = Http::withHeaders([ "X-Api-Key" => $this->changelly_api_key, 'X-Signature'=> $key, 'Content-type'=>'application/json' diff --git a/src/Classes/ClickPayPayment.php b/src/Classes/ClickPayPayment.php index c79d632..bc9169f 100644 --- a/src/Classes/ClickPayPayment.php +++ b/src/Classes/ClickPayPayment.php @@ -60,7 +60,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u else $unique_id = $this->payment_id; - $response = \Http::withHeaders([ + $response = Http::withHeaders([ 'authorization' => $this->clickpay_server_key ])->post('https://secure.clickpay.com.sa/payment/request', [ "profile_id" => $this->clickpay_profile_id, @@ -125,7 +125,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u public function verify(Request $request) { - $response = \Http::withHeaders([ + $response = Http::withHeaders([ 'authorization' => $this->clickpay_server_key ])->post('https://secure.clickpay.com.sa/payment/query', [ 'profile_id' => $this->clickpay_profile_id, diff --git a/src/Classes/MamoPayment.php b/src/Classes/MamoPayment.php index aa0b6a3..f5b8375 100644 --- a/src/Classes/MamoPayment.php +++ b/src/Classes/MamoPayment.php @@ -62,7 +62,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u ]; try{ - $response = \Http::withToken($this->mamopayment_api_key) + $response = Http::withToken($this->mamopayment_api_key) ->post($this->mamopayment_base_url."/manage_api/v1/links",$payload); if ($response->failed()) { return [ @@ -111,7 +111,7 @@ public function verify(Request $request) $payment_id = cache('mamo_payment_'.$request['payment_id']); if(isset($payment_id)){ - $response = \Http::withToken($this->mamopayment_api_key) + $response = Http::withToken($this->mamopayment_api_key) ->get($this->mamopayment_base_url."/manage_api/v1/links/".$payment_id); if ($response->failed()) { return [ diff --git a/src/Classes/NowPaymentsInvoicePayment.php b/src/Classes/NowPaymentsInvoicePayment.php index ab56c4b..fdaceb3 100644 --- a/src/Classes/NowPaymentsInvoicePayment.php +++ b/src/Classes/NowPaymentsInvoicePayment.php @@ -77,7 +77,7 @@ public function verify(Request $request) { $invoice_id = $request->NP_id??$request->payment_id; - $response = \Http::withHeaders([ + $response = Http::withHeaders([ 'x-api-key'=>$this->nowpayments_api_key ])->get('https://api.nowpayments.io/v1/invoice/'.$invoice_id)->json(); diff --git a/src/Classes/NowPaymentsPayment.php b/src/Classes/NowPaymentsPayment.php index dcbdea2..dd648d1 100644 --- a/src/Classes/NowPaymentsPayment.php +++ b/src/Classes/NowPaymentsPayment.php @@ -82,7 +82,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u public function verify(Request $request) { $payment_id = $request->NP_id??$request->payment_id; - $response = \Http::withHeaders([ + $response = Http::withHeaders([ 'x-api-key'=>$this->nowpayments_api_key ])->get('https://api.nowpayments.io/v1/payment/'.$payment_id)->json(); @@ -104,7 +104,7 @@ public function verify(Request $request) } public function get_minimum_amount($from,$to,$fiat_equivalent="usd"){ try{ - $response = \Http::withHeaders(['x-api-key'=>$this->nowpayments_api_key])->get('https://api.nowpayments.io/v1/min-amount?currency_from='.$from.'¤cy_to='.$to.'&fiat_equivalent='.$fiat_equivalent)->json(); + $response = Http::withHeaders(['x-api-key'=>$this->nowpayments_api_key])->get('https://api.nowpayments.io/v1/min-amount?currency_from='.$from.'¤cy_to='.$to.'&fiat_equivalent='.$fiat_equivalent)->json(); return $response['fiat_equivalent']; }catch(\Exception $e){ return 10000000; diff --git a/src/Classes/OneLatPayment.php b/src/Classes/OneLatPayment.php index e832359..e6eccf9 100644 --- a/src/Classes/OneLatPayment.php +++ b/src/Classes/OneLatPayment.php @@ -42,7 +42,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u try{ - $payment_methods = \Http::withHeaders([ + $payment_methods = Http::withHeaders([ 'x-api-key' => $this->onelat_key, 'x-api-secret' => $this->onelat_secret, 'Content-Type' => 'application/json', @@ -51,7 +51,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u if(null !== collect($payment_methods['payment_methods'])->where('type','CARD')->where('currency','USD')->first() ){ $method = collect($payment_methods['payment_methods'])->where('type','CARD')->where('currency','USD')->first(); - $response = \Http::withHeaders([ + $response = Http::withHeaders([ 'x-api-key' => $this->onelat_key, 'x-api-secret' => $this->onelat_secret, 'Content-Type' => 'application/json', diff --git a/src/Classes/PayPalCreditPayment.php b/src/Classes/PayPalCreditPayment.php index f6cae89..979d3ab 100644 --- a/src/Classes/PayPalCreditPayment.php +++ b/src/Classes/PayPalCreditPayment.php @@ -74,7 +74,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u 'countryCode'=>"" ]; try{ - $fetch_address = \Http::get('http://ip-api.com/json/'.$this->get_ip())->json(); + $fetch_address = Http::get('http://ip-api.com/json/'.$this->get_ip())->json(); if(is_array($fetch_address)) $country = array_replace_recursive($country,$fetch_address); }catch(\Exception $e){} @@ -242,7 +242,7 @@ public function get_ip(){ else $ipaddress = 'UNKNOWN'; if($ipaddress=="127.0.0.1"){ - $ip = \Http::get('https://api.ipify.org/?format=json')->json(); + $ip = Http::get('https://api.ipify.org/?format=json')->json(); return $ip['ip']; } return $ipaddress; diff --git a/src/Classes/PaycecPayment.php b/src/Classes/PaycecPayment.php index b04e8a6..186abc0 100644 --- a/src/Classes/PaycecPayment.php +++ b/src/Classes/PaycecPayment.php @@ -60,7 +60,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u try{ - $country = \Http::get('http://ip-api.com/json/'.$this->get_ip())->json(); + $country = Http::get('http://ip-api.com/json/'.$this->get_ip())->json(); $params = [ 'merchantName' => $this->paycec_merchant_username, 'merchantSecretKey' => $this->paycec_merchant_secret, @@ -180,7 +180,7 @@ public function get_ip(){ else $ipaddress = 'UNKNOWN'; if($ipaddress=="127.0.0.1"){ - $ip = \Http::get('https://api.ipify.org/?format=json')->json(); + $ip = Http::get('https://api.ipify.org/?format=json')->json(); return $ip['ip']; } return $ipaddress; diff --git a/src/Classes/PaylinkPayment.php b/src/Classes/PaylinkPayment.php index 8b097a3..572c99e 100644 --- a/src/Classes/PaylinkPayment.php +++ b/src/Classes/PaylinkPayment.php @@ -51,13 +51,13 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u else $payment_id = $this->payment_id; - $get_token_id = \Http::post($url."/api/auth",[ + $get_token_id = Http::post($url."/api/auth",[ 'apiId'=>$this->paylink_app_id, 'secretKey'=>$this->paylink_api_key, 'persistToken'=>false ])->json(); if(isset($get_token_id['id_token'])){ - $response = \Http::withHeaders([ + $response = Http::withHeaders([ 'Authorization'=>"Bearer ".$get_token_id['id_token'], 'Content-Type'=>"application/JSON", ])->post($url."/api/addInvoice",[ @@ -104,13 +104,13 @@ public function verify(Request $request): array $url = "https://restpilot.paylink.sa"; $payment_id = uniqid().rand(10000,99999); - $get_token_id = \Http::post($url."/api/auth",[ + $get_token_id = Http::post($url."/api/auth",[ 'apiId'=>$this->paylink_app_id, 'secretKey'=>$this->paylink_api_key, 'persistToken'=>false ])->json(); if(isset($get_token_id['id_token'])){ - $response = \Http::withHeaders([ + $response = Http::withHeaders([ 'Authorization'=>"Bearer ".$get_token_id['id_token'], 'Content-Type'=>"application/json", ])->get($url."/api/getInvoice/".$request['transactionNo'])->json(); diff --git a/src/Classes/PaymobPayment.php b/src/Classes/PaymobPayment.php index a105222..d89b870 100644 --- a/src/Classes/PaymobPayment.php +++ b/src/Classes/PaymobPayment.php @@ -58,7 +58,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u else $unique_id = $this->payment_id; - $res = \Http::withHeaders([ + $res = Http::withHeaders([ 'Authorization'=>"Token ".$this->paymob_secret_key, ])->post('https://accept.paymob.com/v1/intention/',[ 'amount'=>$this->amount*100, diff --git a/src/Classes/PayopPayment.php b/src/Classes/PayopPayment.php index b0b8809..ebe2905 100644 --- a/src/Classes/PayopPayment.php +++ b/src/Classes/PayopPayment.php @@ -89,7 +89,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u "failPath" => route($this->verify_route_name,['payment'=>"payop",'payment_id'=>$unique_id]), ]; - $response = \Http::withHeaders([ + $response = Http::withHeaders([ 'Content-Type' => 'application/json', ])->post('https://api.payop.com/v1/invoices/create', $payload); $json_response = $response->json(); @@ -130,7 +130,7 @@ public function verify(Request $request): array } if($invoice_id != ""){ - $response = \Http::get('https://api.payop.com/v1/invoices/'.$invoice_id); + $response = Http::get('https://api.payop.com/v1/invoices/'.$invoice_id); $response_json = $response->json(); if(isset($response_json['data']['status']) && in_array($response_json['data']['status'], ['success','paid'])){ return [ diff --git a/src/Classes/PrimePayment.php b/src/Classes/PrimePayment.php index 39f72a4..4596cf5 100644 --- a/src/Classes/PrimePayment.php +++ b/src/Classes/PrimePayment.php @@ -79,7 +79,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u $secret1 = $this->prime_secret_word_1; $data['sign'] =md5($secret1.$data['action'].$data['project'].$data['sum'].$data['currency'].$data['innerID'].$data['email'].$data['payWay']); - $response = \Http::asForm()->post('https://pay.primepayments.io/API/v2/',$data)->json(); + $response = Http::asForm()->post('https://pay.primepayments.io/API/v2/',$data)->json(); dd($response); diff --git a/src/Classes/WisePayment.php b/src/Classes/WisePayment.php index 42a1067..2c829b1 100644 --- a/src/Classes/WisePayment.php +++ b/src/Classes/WisePayment.php @@ -53,7 +53,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u if(is_array($this->source)) $selectedPaymentMethods_init=$this->source; - $init = \Http::withHeaders([ + $init = Http::withHeaders([ 'Cookie'=>"oauthToken=".$this->wise_api_key, 'Authorization'=>"Bearer ".$this->wise_api_key ])->get('https://wise.com/gateway/v3/profiles/'.$this->wise_profile_id.'/acquiring/payment-methods', [ @@ -67,7 +67,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u if(in_array($check_available_method,collect($init->json()['content'])->where('available',true)->pluck('paymentMethodType')->toArray())) $available_payment_methods[]=$check_available_method; - $create_payment = \Http::withHeaders([ + $create_payment = Http::withHeaders([ 'Host' => 'wise.com', 'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0', 'Accept' => 'application/json, text/plain, */*', @@ -94,7 +94,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u 'selectedPaymentMethods' => $available_payment_methods, ]); $create_payment_response = $create_payment->json(); - $publish_payment_response = \Http::withHeaders([ + $publish_payment_response = Http::withHeaders([ 'Host' => 'wise.com', 'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0', 'Accept' => 'application/json, text/plain, */*', diff --git a/src/Classes/YallaPayPayment.php b/src/Classes/YallaPayPayment.php index 76ad8ff..b9c6be8 100644 --- a/src/Classes/YallaPayPayment.php +++ b/src/Classes/YallaPayPayment.php @@ -106,7 +106,7 @@ public function verify(Request $request): array } }elseif(isset($request['trx_id'])){ - $res = \Http::post('https://yallapay.net/api/transaction/verify',[ + $res = Http::post('https://yallapay.net/api/transaction/verify',[ 'private_key'=>$this->yallapay_secret_key, 'trx_id'=> $payment_id ]);