Proxy Servers
If your server requires HTTP requests to be made through a proxy, you can follow these steps to set up proxies for the server-side SDK.
Setup
Important
You must be using at least version 5.2.0 of the PHP SDK to set proxy server settings.
Set a proxy host and port in your gateway configuration:
- PHP
$config = new Braintree\Configuration([
'environment' => 'sandbox',
'merchantId' => 'sandbox_merchant_id',
'publicKey' => 'sandbox_public_key',
'privateKey' => 'sandbox_private_key',
'proxyHost' => 'http://your-proxy-domain.com',
'proxyPort' => '8080'
]);
$gateway = new Braintree\Gateway($config);
To use an authenticated proxy, you can additionally specify a username and password:
- PHP
$config = new Braintree\Configuration([
'environment' => 'sandbox',
'merchantId' => 'sandbox_merchant_id',
'publicKey' => 'sandbox_public_key',
'privateKey' => 'sandbox_private_key',
'proxyHost' => 'http://your-proxy-domain.com',
'proxyPort' => '8080',
'proxyUser' => 'username',
'proxyPassword' => 'password'
]);
$gateway = new Braintree\Gateway($config);
If you want to specify the type of proxy (cURL's CURLOPT_PROXYTYPE
), you can specify it by setting 'proxyType'
. For example, if you're using a SOCKS5 proxy with a hostname, it would be:
- PHP
$config = new Braintree\Configuration([
'environment' => 'sandbox',
'merchantId' => 'sandbox_merchant_id',
'publicKey' => 'sandbox_public_key',
'privateKey' => 'sandbox_private_key',
'proxyHost' => 'http://your-proxy-domain.com',
'proxyPort' => '8080',
'proxyType' => 'CURLPROXY_SOCKS5_HOSTNAME'
]);
$gateway = new Braintree\Gateway($config);