Skip to content

Commit 82119ed

Browse files
committed
updated docs with newly added httpClient Wrapper usage
1 parent ba3e875 commit 82119ed

File tree

4 files changed

+183
-0
lines changed

4 files changed

+183
-0
lines changed

docs/.vitepress/config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export default {
4545
{text: "Banks", link: "/paystack/banks.html"},
4646
{text: "Transfers", link: "/paystack/transfers.html"},
4747
{text: "Transactions", link: "/paystack/transactions.html"},
48+
{text: "Other Endpoints", link: "/paystack/other-endpoints.html"},
4849
],
4950
},
5051

@@ -63,6 +64,7 @@ export default {
6364
{text: "OTPs", link: "/flutterwave/otps.html"},
6465
{text: "Charge", link: "/flutterwave/charge.html"},
6566
{text: "Preauthorization", link: "/flutterwave/preauthorization.html"},
67+
{text: "Other Endpoints", link: "/flutterwave/other-endpoints.html"},
6668
],
6769
},
6870

@@ -72,6 +74,7 @@ export default {
7274
items: [
7375
{text: "Setup", link: "/stripe/setup.html"},
7476
{text: "Transactions", link: "/stripe/transactions.html"},
77+
{text: "Other Endpoints", link: "/stripe/other-endpoints.html"},
7578
],
7679
},
7780

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Making Request to Other Endpoints
2+
Given that our `Flutterwave` service only provide access to the most common endpoints, you can make request to other endpoints
3+
we have not added to the service by using the `HttpClientWrapper` class. This class is a wrapper around the `GuzzleHttp\Client`
4+
class and it provides a simple way to make request to any endpoint. The `HttpClientWrapper` class is available through the
5+
`Flutterwave` facade, `flutterwave()` helper or through dependency injection using the `FlutterwaveContract` interface.
6+
The `HttpClientWrapper` class, is designed to extract some of the configurations from the `Flutterwave` service such as the `secret_key`
7+
and the `base_url` of the payment gateway. This means you don't have to pass the `secret_key` and the `base_url` when using the
8+
`HttpClientWrapper` as it will be automatically be extracted from the `Flutterwave` service.
9+
10+
# You can use the `HttpClientWrapper` class in any of the following ways:
11+
## Using Facade
12+
```php
13+
use MusahMusah\LaravelMultipaymentGateways\Facades\Flutterwave;
14+
15+
// Example of making get request
16+
$response = Flutterwave::httpClient()->get('/banks/056');
17+
dd($response);
18+
19+
```
20+
21+
## Using Helper
22+
```php
23+
24+
// all payment gateways provided by the package can use the httpClient
25+
$response = flutterwave()->httpClient()->get('/banks/056');
26+
dd($response);
27+
28+
```
29+
30+
## Using Dependency Injection
31+
```php
32+
use MusahMusah\LaravelMultipaymentGateways\Contracts\FlutterwaveContract;
33+
34+
class FlutterwavePaymentController extends Controller
35+
{
36+
public function initiatePayment(Request $request, FlutterwaveContract $flutterwave)
37+
{
38+
$response = $flutterwave->httpClient()->get('/banks/056');
39+
dd($response);
40+
}
41+
}
42+
43+
```
44+
45+
With the above example, you can make request to any `Flutterwave` endpoint you want. This ensures the package is flexible and can be used
46+
to make request to any endpoint of the payment gateway you are using.
47+
48+
# All HTTP Methods Available
49+
The `HttpClientWrapper` class provides access to all the HTTP methods available in the `GuzzleHttp\Client` class. The methods are:
50+
- `get`
51+
- `post`
52+
- `put`
53+
- `patch`
54+
- `delete`

docs/paystack/other-endpoints.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Making Request to Other Endpoints
2+
Given that our `Paystack` service only provide access to the most common endpoints, you can make request to other endpoints
3+
we have not added to the service by using the `HttpClientWrapper` class. This class is a wrapper around the `GuzzleHttp\Client`
4+
class and it provides a simple way to make request to any endpoint. The `HttpClientWrapper` class is available through the
5+
`Paystack` facade, `paystack()` helper or through dependency injection using the `PaystackContract` interface.
6+
The `HttpClientWrapper` class, is designed to extract some of the configurations from the `Paystack` service such as the `secret_key`
7+
and the `base_url` of the payment gateway. This means you don't have to pass the `secret_key` and the `base_url` when using the
8+
`HttpClientWrapper` as it will be automatically be extracted from the `Paystack` service.
9+
10+
# You can use the `HttpClientWrapper` class in any of the following ways:
11+
## Using Facade
12+
```php
13+
use MusahMusah\LaravelMultipaymentGateways\Facades\Paystack;
14+
15+
// Example of making http post request
16+
$fields = [
17+
"email" => "customer@email.com",
18+
"first_name" => "Zero",
19+
"last_name" => "Sum",
20+
"phone" => "+2348123456789"
21+
];
22+
23+
$response = Paystack::httpClient()->post('customer', $fields);
24+
25+
```
26+
27+
## Using Helper
28+
```php
29+
// Example of making http post request
30+
$fields = [
31+
"email" => "customer@email.com",
32+
"first_name" => "Zero",
33+
"last_name" => "Sum",
34+
"phone" => "+2348123456789"
35+
];
36+
37+
$response = paystack()->httpClient()->post('customer', $fields);
38+
39+
```
40+
41+
## Using Dependency Injection
42+
```php
43+
use MusahMusah\LaravelMultipaymentGateways\Contracts\PaystackContract;
44+
45+
class PaystackPaymentController extends Controller
46+
{
47+
public function initiatePayment(Request $request, PaystackContract $paystack)
48+
{
49+
// Example of making http post request
50+
$fields = [
51+
"email" => "customer@email.com",
52+
"first_name" => "Zero",
53+
"last_name" => "Sum",
54+
"phone" => "+2348123456789"
55+
];
56+
57+
$response = $paystack->httpClient()->post('customer', $fields);
58+
}
59+
}
60+
61+
```
62+
63+
With the above example, you can make request to any `Paystack` endpoint you want. This ensures the package is flexible and can be used
64+
to make request to any endpoint of the payment gateway you are using.
65+
66+
# All HTTP Methods Available
67+
The `HttpClientWrapper` class provides access to all the HTTP methods available in the `GuzzleHttp\Client` class. The methods are:
68+
- `get`
69+
- `post`
70+
- `put`
71+
- `patch`
72+
- `delete`

docs/stripe/other-endpoints.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Making Request to Other Endpoints
2+
Given that our `Stripe` service only provide access to the most common endpoints, you can make request to other endpoints
3+
we have not added to the service by using the `HttpClientWrapper` class. This class is a wrapper around the `GuzzleHttp\Client`
4+
class and it provides a simple way to make request to any endpoint. The `HttpClientWrapper` class is available through the
5+
`Stripe` facade, `stripe()` helper or through dependency injection using the `StripeContract` interface.
6+
The `HttpClientWrapper` class, is designed to extract some of the configurations from the `Stripe` service such as the `secret_key`
7+
and the `base_url` of the payment gateway. This means you don't have to pass the `secret_key` and the `base_url` when using the
8+
`HttpClientWrapper` as it will be automatically be extracted from the `Stripe` service.
9+
10+
# You can use the `HttpClientWrapper` class in any of the following ways:
11+
## Using Facade
12+
```php
13+
use MusahMusah\LaravelMultipaymentGateways\Facades\Stripe;
14+
15+
// Example of making get request
16+
$response = Stripe::httpClient()->get('v1/customers/cus_4QFOF3xrvBT2nU');
17+
dd($response);
18+
19+
```
20+
21+
## Using Helper
22+
```php
23+
24+
// all payment gateways provided by the package can use the httpClient
25+
$response = stripe()->httpClient()->get('v1/customers/cus_4QFOF3xrvBT2nU');
26+
dd($response);
27+
28+
```
29+
30+
## Using Dependency Injection
31+
```php
32+
use MusahMusah\LaravelMultipaymentGateways\Contracts\StripeContract;
33+
34+
class StripePaymentController extends Controller
35+
{
36+
public function initiatePayment(Request $request, StripeContract $stripe)
37+
{
38+
$response = $stripe->httpClient()->get('v1/customers/cus_4QFOF3xrvBT2nU');
39+
dd($response);
40+
}
41+
}
42+
43+
```
44+
45+
With the above example, you can make request to any `Stripe` endpoint you want. This ensures the package is flexible and can be used
46+
to make request to any endpoint of the payment gateway you are using.
47+
48+
# All HTTP Methods Available
49+
The `HttpClientWrapper` class provides access to all the HTTP methods available in the `GuzzleHttp\Client` class. The methods are:
50+
- `get`
51+
- `post`
52+
- `put`
53+
- `patch`
54+
- `delete`

0 commit comments

Comments
 (0)