-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
Hi,
I'm having an issue on my production environment when validating the hosts and getting the "Not a valid host Exception'.
I see that all other environments return true when running validateHost, and the actual check only takes place in the production environment.
I've ensured the hosts in config match what Payfast provides, I've even added https:// to the hosts in the config (knowing full well this won't work), but no joy at all.
The payfast documentation uses HTTP_REFERER but this package is using REMOTE_ADDR. Could this be the issue, or is there something else at work here that I'm not seeing?
public function validateHost($request)
{
// alow local testing
if (env('APP_ENV') !== 'production') {
return true;
}
$hosts = $this->getHosts();
if( !in_array( $request->server('REMOTE_ADDR'), $hosts ) )
{
throw new Exception('Not a valid Host');
}
return true;
}
public function getHosts()
{
$hosts = [];
foreach(config('payfast.hosts') as $host) {
$ips = gethostbynamel($host);
if(count($ips) > 0) {
foreach($ips as $ip) {
$hosts[] = $ip;
}
}
}
return array_unique($hosts);
}
'hosts' => [
'www.payfast.co.za',
'sandbox.payfast.co.za',
'w1w.payfast.co.za',
'w2w.payfast.co.za',
],
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels