Skip to content

Commit d09a3c0

Browse files
committed
fixed issues with static analysis
1 parent 7bddc2c commit d09a3c0

13 files changed

+65
-267
lines changed

src/Gateways/StripeService.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
namespace MusahMusah\LaravelMultipaymentGateways\Gateways;
44

5-
use GuzzleHttp\Exception\GuzzleException;
65
use MusahMusah\LaravelMultipaymentGateways\Abstracts\BaseGateWay;
76
use MusahMusah\LaravelMultipaymentGateways\Contracts\StripeContract;
8-
use MusahMusah\LaravelMultipaymentGateways\Exceptions\HttpMethodFoundException;
97
use MusahMusah\LaravelMultipaymentGateways\Exceptions\InvalidConfigurationException;
108

119
class StripeService extends BaseGateWay implements StripeContract
@@ -61,32 +59,22 @@ public function decodeResponse(): array
6159

6260
/**
6361
* Create a new payment intent
64-
*
65-
*
66-
* @throws GuzzleException
67-
* @throws HttpMethodFoundException
6862
*/
6963
public function createIntent(array $data): array
7064
{
71-
return $this->makeRequest(
72-
'POST',
73-
'/v1/payment_intents',
74-
$data,
65+
return $this->httpClient()->post(
66+
url: '/v1/payment_intents',
67+
formParams: $data,
7568
);
7669
}
7770

7871
/**
7972
* Confirm a payment intent
80-
*
81-
*
82-
* @throws GuzzleException
83-
* @throws HttpMethodFoundException
8473
*/
8574
public function confirmIntent(string $paymentIntentId): array
8675
{
87-
return $this->makeRequest(
88-
'POST',
89-
"/v1/payment_intents/{$paymentIntentId}/confirm",
76+
return $this->httpClient()->post(
77+
url: "/v1/payment_intents/{$paymentIntentId}/confirm",
9078
);
9179
}
9280
}

src/Traits/Flutterwave/BankTrait.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
namespace MusahMusah\LaravelMultipaymentGateways\Traits\Flutterwave;
44

5-
use GuzzleHttp\Exception\GuzzleException;
65
use MusahMusah\LaravelMultipaymentGateways\Constants\FlutterwaveConstant;
7-
use MusahMusah\LaravelMultipaymentGateways\Exceptions\HttpMethodFoundException;
86

97
trait BankTrait
108
{
@@ -13,7 +11,7 @@ trait BankTrait
1311
*/
1412
public function getBanks(string $countryCode): array
1513
{
16-
$banks = flutterwave()->httpClient()->get(
14+
$banks = $this->httpClient()->get(
1715
url: FlutterwaveConstant::BANK_ENDPOINT.$countryCode,
1816
);
1917

@@ -27,12 +25,10 @@ public function getBanks(string $countryCode): array
2725
* Get all branches of a bank
2826
*
2927
* @param int $bankId The ID of the bank for which to retrieve branches
30-
*
31-
* @throws GuzzleException|HttpMethodFoundException
3228
*/
3329
public function getBankBranches(int $bankId): array
3430
{
35-
return flutterwave()->httpClient()->get(
31+
return $this->httpClient()->get(
3632
url: FlutterwaveConstant::BANK_ENDPOINT.$bankId.'/branches',
3733
);
3834
}

src/Traits/Flutterwave/ChargeTrait.php

Lines changed: 9 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
namespace MusahMusah\LaravelMultipaymentGateways\Traits\Flutterwave;
44

5-
use GuzzleHttp\Exception\GuzzleException;
65
use MusahMusah\LaravelMultipaymentGateways\Constants\FlutterwaveConstant;
7-
use MusahMusah\LaravelMultipaymentGateways\Exceptions\HttpMethodFoundException;
86
use MusahMusah\LaravelMultipaymentGateways\Exceptions\InvalidConfigurationException;
97

108
trait ChargeTrait
@@ -14,15 +12,15 @@ trait ChargeTrait
1412
*
1513
* @param array $formParams An associative array of payment data.
1614
*
17-
* @throws InvalidConfigurationException|GuzzleException|HttpMethodFoundException
15+
* @throws InvalidConfigurationException
1816
*/
1917
public function initiateCardCharge(array $formParams): array
2018
{
2119
$queryParams = [
2220
'type' => FlutterwaveConstant::CARD_PAYMENT_CHARGE_TYPE,
2321
];
2422

25-
return flutterwave()->httpClient()->post(
23+
return $this->httpClient()->post(
2624
url: FlutterwaveConstant::CHARGE_ENDPOINT,
2725
formParams: $this->encryptPayload($formParams),
2826
query: $queryParams
@@ -33,8 +31,6 @@ public function initiateCardCharge(array $formParams): array
3331
* Initiate a bank transfer payment.
3432
*
3533
* @param array $formParams An associative array of transfer data.
36-
*
37-
* @throws GuzzleException|HttpMethodFoundException
3834
*/
3935
public function initiateBankTransfer(array $formParams): array
4036
{
@@ -48,8 +44,6 @@ public function initiateBankTransfer(array $formParams): array
4844
* amount, email address and transaction reference to be provided in the request body.
4945
*
5046
* @param array $formParams An associative array of transfer data.
51-
*
52-
* @throws GuzzleException|HttpMethodFoundException
5347
*/
5448
public function chargeNigerianBankAccount(array $formParams): array
5549
{
@@ -63,8 +57,6 @@ public function chargeNigerianBankAccount(array $formParams): array
6357
* We recommend you read the method overview before you proceed.
6458
*
6559
* @param array $formParams An associative array of charge data.
66-
*
67-
* @throws GuzzleException|HttpMethodFoundException
6860
*/
6961
public function chargeUkBankAccount(array $formParams): array
7062
{
@@ -77,8 +69,6 @@ public function chargeUkBankAccount(array $formParams): array
7769
* This payment method allows you to collect USD and ZAR payments via ACH.
7870
*
7971
* @param array $formParams An associative array of charge data.
80-
*
81-
* @throws GuzzleException|HttpMethodFoundException
8272
*/
8373
public function chargeAchPayment(array $formParams): array
8474
{
@@ -92,8 +82,6 @@ public function chargeAchPayment(array $formParams): array
9282
* We recommend you read the method overview before you proceed.
9383
*
9484
* @param array $formParams An associative array of charge data.
95-
*
96-
* @throws GuzzleException|HttpMethodFoundException
9785
*/
9886
public function chargeApplePay(array $formParams): array
9987
{
@@ -107,8 +95,6 @@ public function chargeApplePay(array $formParams): array
10795
* We recommend you read the method overview before you proceed.
10896
*
10997
* @param array $formParams An associative array of charge data.
110-
*
111-
* @throws GuzzleException|HttpMethodFoundException
11298
*/
11399
public function chargeGooglePay(array $formParams): array
114100
{
@@ -121,8 +107,6 @@ public function chargeGooglePay(array $formParams): array
121107
* This payment method allows you to accept payments from your customers via Fawry Pay.
122108
*
123109
* @param array $formParams An associative array of charge data.
124-
*
125-
* @throws GuzzleException|HttpMethodFoundException
126110
*/
127111
public function chargeFawryPay(array $formParams): array
128112
{
@@ -135,8 +119,6 @@ public function chargeFawryPay(array $formParams): array
135119
* This payment method allows you to accept payments from your customers via PayPal.
136120
*
137121
* @param array $formParams An associative array of charge data.
138-
*
139-
* @throws GuzzleException|HttpMethodFoundException
140122
*/
141123
public function chargePaypal(array $formParams): array
142124
{
@@ -149,8 +131,6 @@ public function chargePaypal(array $formParams): array
149131
* This payment method allows you to accept payments from your customers via M-Pesa.
150132
*
151133
* @param array $formParams An associative array of charge data.
152-
*
153-
* @throws GuzzleException|HttpMethodFoundException
154134
*/
155135
public function chargeMpesa(array $formParams): array
156136
{
@@ -163,8 +143,6 @@ public function chargeMpesa(array $formParams): array
163143
* This payment method allows you to accept payments from your customers via mobile money in Ghana.
164144
*
165145
* @param array $formParams An associative array of charge data.
166-
*
167-
* @throws GuzzleException|HttpMethodFoundException
168146
*/
169147
public function chargeGhanaMobileMoney(array $formParams): array
170148
{
@@ -177,8 +155,6 @@ public function chargeGhanaMobileMoney(array $formParams): array
177155
* This payment method allows you to accept payments from your customers via mobile money in Uganda.
178156
*
179157
* @param array $formParams An associative array of charge data.
180-
*
181-
* @throws GuzzleException|HttpMethodFoundException
182158
*/
183159
public function chargeUgandaMobileMoney(array $formParams): array
184160
{
@@ -191,8 +167,6 @@ public function chargeUgandaMobileMoney(array $formParams): array
191167
* This payment method allows you to accept payments from your customers via Mobile Money Franco.
192168
*
193169
* @param array $formParams An associative array of charge data.
194-
*
195-
* @throws GuzzleException|HttpMethodFoundException
196170
*/
197171
public function chargeMobileMoneyFranco(array $formParams): array
198172
{
@@ -205,8 +179,6 @@ public function chargeMobileMoneyFranco(array $formParams): array
205179
* This payment method allows you to accept payments from your customers via Mobile Money Rwanda.
206180
*
207181
* @param array $formParams An associative array of charge data.
208-
*
209-
* @throws GuzzleException|HttpMethodFoundException
210182
*/
211183
public function chargeMobileMoneyRwanda(array $formParams): array
212184
{
@@ -219,8 +191,6 @@ public function chargeMobileMoneyRwanda(array $formParams): array
219191
* This payment method allows you to accept payments from your customers via mobile money in Zambia.
220192
*
221193
* @param array $formParams An associative array of charge data.
222-
*
223-
* @throws GuzzleException|HttpMethodFoundException
224194
*/
225195
public function chargeZambiaMobileMoney(array $formParams): array
226196
{
@@ -233,8 +203,6 @@ public function chargeZambiaMobileMoney(array $formParams): array
233203
* This payment method allows you to accept payments from your customers via USSD.
234204
*
235205
* @param array $formParams An associative array of charge data.
236-
*
237-
* @throws GuzzleException|HttpMethodFoundException
238206
*/
239207
public function chargeUssd(array $formParams): array
240208
{
@@ -246,16 +214,14 @@ public function chargeUssd(array $formParams): array
246214
*
247215
* @param string $paymentMethod The payment method to use.
248216
* @param array $formParams An associative array of charge data.
249-
*
250-
* @throws GuzzleException|HttpMethodFoundException
251217
*/
252218
private function chargePayment(string $paymentMethod, array $formParams): array
253219
{
254220
$queryParams = [
255221
'type' => $paymentMethod,
256222
];
257223

258-
return flutterwave()->httpClient()->post(
224+
return $this->httpClient()->post(
259225
url: FlutterwaveConstant::CHARGE_ENDPOINT,
260226
formParams: $formParams,
261227
query: $queryParams
@@ -287,12 +253,10 @@ private function encryptPayload(array $payload): string
287253
* Validate a charge.
288254
*
289255
* @param array $formParams An associative array of charge validation data.
290-
*
291-
* @throws GuzzleException|HttpMethodFoundException
292256
*/
293257
public function validateCharge(array $formParams): array
294258
{
295-
return flutterwave()->httpClient()->post(
259+
return $this->httpClient()->post(
296260
url: FlutterwaveConstant::VALIDATE_CHARGE_ENDPOINT,
297261
formParams: $formParams,
298262
);
@@ -303,12 +267,10 @@ public function validateCharge(array $formParams): array
303267
*
304268
* @param string $flwRef The data.flw_ref returned in the charge response.
305269
* @param array $formParams An associative array of charge validation data.
306-
*
307-
* @throws GuzzleException|HttpMethodFoundException
308270
*/
309271
public function captureCharge(string $flwRef, array $formParams): array
310272
{
311-
return flutterwave()->httpClient()->post(
273+
return $this->httpClient()->post(
312274
url: FlutterwaveConstant::CHARGE_ENDPOINT.$flwRef.'/capture',
313275
formParams: $formParams
314276
);
@@ -318,12 +280,10 @@ public function captureCharge(string $flwRef, array $formParams): array
318280
* Void a previously captured charge to release the hold on the funds.
319281
*
320282
* @param string $flwRef The data.flw_ref returned in the charge response.
321-
*
322-
* @throws GuzzleException|HttpMethodFoundException
323283
*/
324284
public function voidCharge(string $flwRef): array
325285
{
326-
return flutterwave()->httpClient()->post(
286+
return $this->httpClient()->post(
327287
url: FlutterwaveConstant::CHARGE_ENDPOINT.$flwRef.'/void',
328288
);
329289
}
@@ -333,12 +293,10 @@ public function voidCharge(string $flwRef): array
333293
*
334294
* @param string $flwRef The data.flw_ref returned in the charge response.
335295
* @param array $formParams An associative array of charge validation data.
336-
*
337-
* @throws GuzzleException|HttpMethodFoundException
338296
*/
339297
public function createRefund(string $flwRef, array $formParams): array
340298
{
341-
return flutterwave()->httpClient()->post(
299+
return $this->httpClient()->post(
342300
url: FlutterwaveConstant::CHARGE_ENDPOINT.$flwRef.'/refund',
343301
formParams: $formParams,
344302
);
@@ -348,12 +306,10 @@ public function createRefund(string $flwRef, array $formParams): array
348306
* Capture the payment of a previously uncaptured PayPal charge
349307
*
350308
* @param array $formParams An associative array of charge validation data.
351-
*
352-
* @throws GuzzleException|HttpMethodFoundException
353309
*/
354310
public function capturePaypalCharge(array $formParams): array
355311
{
356-
return flutterwave()->httpClient()->post(
312+
return $this->httpClient()->post(
357313
url: FlutterwaveConstant::CHARGE_ENDPOINT.'/paypal-capture',
358314
formParams: $formParams,
359315
);
@@ -363,12 +319,10 @@ public function capturePaypalCharge(array $formParams): array
363319
* Void a previously captured charge to release the hold on the funds.
364320
*
365321
* @param array $formParams An associative array of charge validation data.
366-
*
367-
* @throws GuzzleException|HttpMethodFoundException
368322
*/
369323
public function voidPaypalCharge(array $formParams): array
370324
{
371-
return flutterwave()->httpClient()->post(
325+
return $this->httpClient()->post(
372326
url: FlutterwaveConstant::CHARGE_ENDPOINT.'/void',
373327
formParams: $formParams,
374328
);

src/Traits/Flutterwave/OtpTrait.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,18 @@
22

33
namespace MusahMusah\LaravelMultipaymentGateways\Traits\Flutterwave;
44

5-
use GuzzleHttp\Exception\GuzzleException;
65
use MusahMusah\LaravelMultipaymentGateways\Constants\FlutterwaveConstant;
7-
use MusahMusah\LaravelMultipaymentGateways\Exceptions\HttpMethodFoundException;
86

97
trait OtpTrait
108
{
119
/**
1210
* Create an OTP
1311
*
1412
* This method allows you to generate an OTP via Flutterwave for any validation.
15-
*
16-
* @throws GuzzleException|HttpMethodFoundException
1713
*/
1814
public function createOtp(array $formParams): array
1915
{
20-
return flutterwave()->httpClient()->post(
16+
return $this->httpClient()->post(
2117
url: FlutterwaveConstant::OTP_ENDPOINT,
2218
formParams: $formParams
2319
);
@@ -27,12 +23,10 @@ public function createOtp(array $formParams): array
2723
* Validate an OTP
2824
*
2925
* This method allows you to validate OTPs generated by the /create endpoint.
30-
*
31-
* @throws GuzzleException|HttpMethodFoundException
3226
*/
3327
public function verifyOtp(string $reference, array $formParams): array
3428
{
35-
return flutterwave()->httpClient()->post(
29+
return $this->httpClient()->post(
3630
url: FlutterwaveConstant::OTP_ENDPOINT.$reference.'/validate',
3731
formParams: $formParams
3832
);

0 commit comments

Comments
 (0)