Skip to content

Instantly share code, notes, and snippets.

@rafaelgou
Created May 30, 2013 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaelgou/5675466 to your computer and use it in GitHub Desktop.
Save rafaelgou/5675466 to your computer and use it in GitHub Desktop.
Proxy para notificações do PagSeguro Permite configurar apenas uma conta do PagSeguro que repassa notificações para várias lojas
<?php
$logfile = '/var/log/pagseguro/notifications.log';
$handler = fopen($logfile, 'a');
$message = $_SERVER['REMOTE_ADDR'] . ' - ' . date('Y-m-d H:i:s') . ' - ' .
serialize($_REQUEST) . PHP_EOL;
fwrite($handler, $message);
fclose($handler);
$urls = array(
'http://loja1.dominio.com.br/customer/pagseguro_notification.php',
'http://loja2.dominio.com.br/customer/pagseguro_notification.php',
// quantas lojas necessitar
);
foreach ($urls as $url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
curl_exec($ch);
curl_close($ch);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment