Skip to content

Instantly share code, notes, and snippets.

@elminson
Created March 26, 2025 03:28
Show Gist options
  • Save elminson/43e25d22d2b5bab718f096d8c6f9d517 to your computer and use it in GitHub Desktop.
Save elminson/43e25d22d2b5bab718f096d8c6f9d517 to your computer and use it in GitHub Desktop.
<?php
namespace FerminNamespace\Traits;
use Srmklive\PayPal\Traits\PayPalHttpClient;
use Symfony\Component\HttpClient\HttpClient;
trait CustomPayPalHttpClient
{
// Use the original trait
use PayPalHttpClient;
// Override the setClient method completely
public function setClient(?HttpClient $client = null): self
{
// Your custom implementation here
if ($client !== null) {
// Custom logic for when a specific client is provided
$this->client = $client;
return $this;
}
// Custom client creation logic
$this->client = HttpClient::create([
// Your custom configuration
'base_uri' => 'https://custom-paypal-endpoint.com',
'timeout' => 10,
// Add any other specific configurations
]);
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment