2
2
3
3
namespace MusahMusah \LaravelMultipaymentGateways \Traits \Flutterwave ;
4
4
5
- use GuzzleHttp \Exception \GuzzleException ;
6
5
use MusahMusah \LaravelMultipaymentGateways \Constants \FlutterwaveConstant ;
7
- use MusahMusah \LaravelMultipaymentGateways \Exceptions \HttpMethodFoundException ;
8
6
use MusahMusah \LaravelMultipaymentGateways \Exceptions \InvalidConfigurationException ;
9
7
10
8
trait ChargeTrait
@@ -14,15 +12,15 @@ trait ChargeTrait
14
12
*
15
13
* @param array $formParams An associative array of payment data.
16
14
*
17
- * @throws InvalidConfigurationException|GuzzleException|HttpMethodFoundException
15
+ * @throws InvalidConfigurationException
18
16
*/
19
17
public function initiateCardCharge (array $ formParams ): array
20
18
{
21
19
$ queryParams = [
22
20
'type ' => FlutterwaveConstant::CARD_PAYMENT_CHARGE_TYPE ,
23
21
];
24
22
25
- return flutterwave () ->httpClient ()->post (
23
+ return $ this ->httpClient ()->post (
26
24
url: FlutterwaveConstant::CHARGE_ENDPOINT ,
27
25
formParams: $ this ->encryptPayload ($ formParams ),
28
26
query: $ queryParams
@@ -33,8 +31,6 @@ public function initiateCardCharge(array $formParams): array
33
31
* Initiate a bank transfer payment.
34
32
*
35
33
* @param array $formParams An associative array of transfer data.
36
- *
37
- * @throws GuzzleException|HttpMethodFoundException
38
34
*/
39
35
public function initiateBankTransfer (array $ formParams ): array
40
36
{
@@ -48,8 +44,6 @@ public function initiateBankTransfer(array $formParams): array
48
44
* amount, email address and transaction reference to be provided in the request body.
49
45
*
50
46
* @param array $formParams An associative array of transfer data.
51
- *
52
- * @throws GuzzleException|HttpMethodFoundException
53
47
*/
54
48
public function chargeNigerianBankAccount (array $ formParams ): array
55
49
{
@@ -63,8 +57,6 @@ public function chargeNigerianBankAccount(array $formParams): array
63
57
* We recommend you read the method overview before you proceed.
64
58
*
65
59
* @param array $formParams An associative array of charge data.
66
- *
67
- * @throws GuzzleException|HttpMethodFoundException
68
60
*/
69
61
public function chargeUkBankAccount (array $ formParams ): array
70
62
{
@@ -77,8 +69,6 @@ public function chargeUkBankAccount(array $formParams): array
77
69
* This payment method allows you to collect USD and ZAR payments via ACH.
78
70
*
79
71
* @param array $formParams An associative array of charge data.
80
- *
81
- * @throws GuzzleException|HttpMethodFoundException
82
72
*/
83
73
public function chargeAchPayment (array $ formParams ): array
84
74
{
@@ -92,8 +82,6 @@ public function chargeAchPayment(array $formParams): array
92
82
* We recommend you read the method overview before you proceed.
93
83
*
94
84
* @param array $formParams An associative array of charge data.
95
- *
96
- * @throws GuzzleException|HttpMethodFoundException
97
85
*/
98
86
public function chargeApplePay (array $ formParams ): array
99
87
{
@@ -107,8 +95,6 @@ public function chargeApplePay(array $formParams): array
107
95
* We recommend you read the method overview before you proceed.
108
96
*
109
97
* @param array $formParams An associative array of charge data.
110
- *
111
- * @throws GuzzleException|HttpMethodFoundException
112
98
*/
113
99
public function chargeGooglePay (array $ formParams ): array
114
100
{
@@ -121,8 +107,6 @@ public function chargeGooglePay(array $formParams): array
121
107
* This payment method allows you to accept payments from your customers via Fawry Pay.
122
108
*
123
109
* @param array $formParams An associative array of charge data.
124
- *
125
- * @throws GuzzleException|HttpMethodFoundException
126
110
*/
127
111
public function chargeFawryPay (array $ formParams ): array
128
112
{
@@ -135,8 +119,6 @@ public function chargeFawryPay(array $formParams): array
135
119
* This payment method allows you to accept payments from your customers via PayPal.
136
120
*
137
121
* @param array $formParams An associative array of charge data.
138
- *
139
- * @throws GuzzleException|HttpMethodFoundException
140
122
*/
141
123
public function chargePaypal (array $ formParams ): array
142
124
{
@@ -149,8 +131,6 @@ public function chargePaypal(array $formParams): array
149
131
* This payment method allows you to accept payments from your customers via M-Pesa.
150
132
*
151
133
* @param array $formParams An associative array of charge data.
152
- *
153
- * @throws GuzzleException|HttpMethodFoundException
154
134
*/
155
135
public function chargeMpesa (array $ formParams ): array
156
136
{
@@ -163,8 +143,6 @@ public function chargeMpesa(array $formParams): array
163
143
* This payment method allows you to accept payments from your customers via mobile money in Ghana.
164
144
*
165
145
* @param array $formParams An associative array of charge data.
166
- *
167
- * @throws GuzzleException|HttpMethodFoundException
168
146
*/
169
147
public function chargeGhanaMobileMoney (array $ formParams ): array
170
148
{
@@ -177,8 +155,6 @@ public function chargeGhanaMobileMoney(array $formParams): array
177
155
* This payment method allows you to accept payments from your customers via mobile money in Uganda.
178
156
*
179
157
* @param array $formParams An associative array of charge data.
180
- *
181
- * @throws GuzzleException|HttpMethodFoundException
182
158
*/
183
159
public function chargeUgandaMobileMoney (array $ formParams ): array
184
160
{
@@ -191,8 +167,6 @@ public function chargeUgandaMobileMoney(array $formParams): array
191
167
* This payment method allows you to accept payments from your customers via Mobile Money Franco.
192
168
*
193
169
* @param array $formParams An associative array of charge data.
194
- *
195
- * @throws GuzzleException|HttpMethodFoundException
196
170
*/
197
171
public function chargeMobileMoneyFranco (array $ formParams ): array
198
172
{
@@ -205,8 +179,6 @@ public function chargeMobileMoneyFranco(array $formParams): array
205
179
* This payment method allows you to accept payments from your customers via Mobile Money Rwanda.
206
180
*
207
181
* @param array $formParams An associative array of charge data.
208
- *
209
- * @throws GuzzleException|HttpMethodFoundException
210
182
*/
211
183
public function chargeMobileMoneyRwanda (array $ formParams ): array
212
184
{
@@ -219,8 +191,6 @@ public function chargeMobileMoneyRwanda(array $formParams): array
219
191
* This payment method allows you to accept payments from your customers via mobile money in Zambia.
220
192
*
221
193
* @param array $formParams An associative array of charge data.
222
- *
223
- * @throws GuzzleException|HttpMethodFoundException
224
194
*/
225
195
public function chargeZambiaMobileMoney (array $ formParams ): array
226
196
{
@@ -233,8 +203,6 @@ public function chargeZambiaMobileMoney(array $formParams): array
233
203
* This payment method allows you to accept payments from your customers via USSD.
234
204
*
235
205
* @param array $formParams An associative array of charge data.
236
- *
237
- * @throws GuzzleException|HttpMethodFoundException
238
206
*/
239
207
public function chargeUssd (array $ formParams ): array
240
208
{
@@ -246,16 +214,14 @@ public function chargeUssd(array $formParams): array
246
214
*
247
215
* @param string $paymentMethod The payment method to use.
248
216
* @param array $formParams An associative array of charge data.
249
- *
250
- * @throws GuzzleException|HttpMethodFoundException
251
217
*/
252
218
private function chargePayment (string $ paymentMethod , array $ formParams ): array
253
219
{
254
220
$ queryParams = [
255
221
'type ' => $ paymentMethod ,
256
222
];
257
223
258
- return flutterwave () ->httpClient ()->post (
224
+ return $ this ->httpClient ()->post (
259
225
url: FlutterwaveConstant::CHARGE_ENDPOINT ,
260
226
formParams: $ formParams ,
261
227
query: $ queryParams
@@ -287,12 +253,10 @@ private function encryptPayload(array $payload): string
287
253
* Validate a charge.
288
254
*
289
255
* @param array $formParams An associative array of charge validation data.
290
- *
291
- * @throws GuzzleException|HttpMethodFoundException
292
256
*/
293
257
public function validateCharge (array $ formParams ): array
294
258
{
295
- return flutterwave () ->httpClient ()->post (
259
+ return $ this ->httpClient ()->post (
296
260
url: FlutterwaveConstant::VALIDATE_CHARGE_ENDPOINT ,
297
261
formParams: $ formParams ,
298
262
);
@@ -303,12 +267,10 @@ public function validateCharge(array $formParams): array
303
267
*
304
268
* @param string $flwRef The data.flw_ref returned in the charge response.
305
269
* @param array $formParams An associative array of charge validation data.
306
- *
307
- * @throws GuzzleException|HttpMethodFoundException
308
270
*/
309
271
public function captureCharge (string $ flwRef , array $ formParams ): array
310
272
{
311
- return flutterwave () ->httpClient ()->post (
273
+ return $ this ->httpClient ()->post (
312
274
url: FlutterwaveConstant::CHARGE_ENDPOINT .$ flwRef .'/capture ' ,
313
275
formParams: $ formParams
314
276
);
@@ -318,12 +280,10 @@ public function captureCharge(string $flwRef, array $formParams): array
318
280
* Void a previously captured charge to release the hold on the funds.
319
281
*
320
282
* @param string $flwRef The data.flw_ref returned in the charge response.
321
- *
322
- * @throws GuzzleException|HttpMethodFoundException
323
283
*/
324
284
public function voidCharge (string $ flwRef ): array
325
285
{
326
- return flutterwave () ->httpClient ()->post (
286
+ return $ this ->httpClient ()->post (
327
287
url: FlutterwaveConstant::CHARGE_ENDPOINT .$ flwRef .'/void ' ,
328
288
);
329
289
}
@@ -333,12 +293,10 @@ public function voidCharge(string $flwRef): array
333
293
*
334
294
* @param string $flwRef The data.flw_ref returned in the charge response.
335
295
* @param array $formParams An associative array of charge validation data.
336
- *
337
- * @throws GuzzleException|HttpMethodFoundException
338
296
*/
339
297
public function createRefund (string $ flwRef , array $ formParams ): array
340
298
{
341
- return flutterwave () ->httpClient ()->post (
299
+ return $ this ->httpClient ()->post (
342
300
url: FlutterwaveConstant::CHARGE_ENDPOINT .$ flwRef .'/refund ' ,
343
301
formParams: $ formParams ,
344
302
);
@@ -348,12 +306,10 @@ public function createRefund(string $flwRef, array $formParams): array
348
306
* Capture the payment of a previously uncaptured PayPal charge
349
307
*
350
308
* @param array $formParams An associative array of charge validation data.
351
- *
352
- * @throws GuzzleException|HttpMethodFoundException
353
309
*/
354
310
public function capturePaypalCharge (array $ formParams ): array
355
311
{
356
- return flutterwave () ->httpClient ()->post (
312
+ return $ this ->httpClient ()->post (
357
313
url: FlutterwaveConstant::CHARGE_ENDPOINT .'/paypal-capture ' ,
358
314
formParams: $ formParams ,
359
315
);
@@ -363,12 +319,10 @@ public function capturePaypalCharge(array $formParams): array
363
319
* Void a previously captured charge to release the hold on the funds.
364
320
*
365
321
* @param array $formParams An associative array of charge validation data.
366
- *
367
- * @throws GuzzleException|HttpMethodFoundException
368
322
*/
369
323
public function voidPaypalCharge (array $ formParams ): array
370
324
{
371
- return flutterwave () ->httpClient ()->post (
325
+ return $ this ->httpClient ()->post (
372
326
url: FlutterwaveConstant::CHARGE_ENDPOINT .'/void ' ,
373
327
formParams: $ formParams ,
374
328
);
0 commit comments