Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Multipayment Gateways Laravel Package

musahmusah/laravel-multipayment-gateways

View on GitHub
Deep Wiki
Context7

Making Request to Other Endpoints

Given that our Paystack service only provide access to the most common endpoints, you can make request to other endpoints we have not added to the service by using the HttpClientWrapper class. This class is a wrapper around the GuzzleHttp\Client class and it provides a simple way to make request to any endpoint. The HttpClientWrapper class is available through the Paystack facade, paystack() helper or through dependency injection using the PaystackContract interface. The HttpClientWrapper class, is designed to extract some of the configurations from the Paystack service so you that you don't have to pass them when making request to other endpoints.

You can use the HttpClientWrapper class in any of the following ways:

Using Facade

use MusahMusah\LaravelMultipaymentGateways\Facades\Paystack;

// Example of making http post request
 $fields = [
    "email" => "customer@email.com",
     "first_name" => "Zero",
     "last_name" => "Sum",
    "phone" => "+2348123456789"
 ];
 
 // this will make a post request to https://api.paystack.co/customer as get request
$response = Paystack::httpClient()->post('customer', $fields);
dd($response);

Using Helper

// Example of making http post request
  $fields = [
    "email" => "customer@email.com",
     "first_name" => "Zero",
     "last_name" => "Sum",
    "phone" => "+2348123456789"
 ];

// this will make a post request to https://api.paystack.co/customer as post request
 $response = paystack()->httpClient()->post('customer', $fields);
 dd()

Using Dependency Injection

use MusahMusah\LaravelMultipaymentGateways\Contracts\PaystackContract;

class PaystackPaymentController extends Controller
{
    public function initiatePayment(Request $request, PaystackContract $paystack)
    {
        // Example of making http post request
        $fields = [
            "email" => "customer@email.com",
             "first_name" => "Zero",
             "last_name" => "Sum",
            "phone" => "+2348123456789"
        ];
        // this will make a post request to https://api.paystack.co/customer as post request
        $response = $paystack->httpClient()->post('customer', $fields);
    }
}

With the above example, you can make request to any Paystack endpoint you want. This ensures the package is flexible and can be used to make request to any endpoint of the payment gateway you are using.

All HTTP Methods Available

The HttpClientWrapper class provides access to all the HTTP methods available in the GuzzleHttp\Client class. The methods are:

  • get
  • post
  • put
  • patch
  • delete
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi