Transactions by PHP Pagseguro date

Asked

Viewed 173 times

0

Hello, I need to check the transactions made in a pagseguro account, I’m using:

$initialDate = '2016-05-10';
$finalDate = '2016-06-10';
$email_pagseguro = '[email protected]';
$token_pagseguro = '**************************';


$url = 
'
    https://ws.pagseguro.uol.com.br/v2/transactions
    ?initialDate='.$initialDate.'T00:00
    &finalDate='.$finalDate.'T00:00
    &page=1
    &maxPageResults=100
    &email='.$email_pagseguro.'
    &token='.$token_pagseguro
;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch) or curl_error($ch);
curl_close ($ch);
return $output;

$transaction = simplexml_load_string($output);

echo $transaction -> transactions -> transaction -> status."<BR />";
echo $transaction -> transactions -> transaction -> paymentMethod."<BR />";
echo $transaction -> transactions -> transaction -> type."<BR />";

Documentation

Returns nothing, where is the error?

  • What’s the mistake you’re making? You’re using the sandbox to test?

  • In case, does not return me anything, this is only to consult the transactions performed.

1 answer

3


Assuming Curl is installed and with the SSL protocols required by pay-off, the only mistake I find in your code is:

return $output;

If you do return, the following code is not executed!
Delete that line and you should already have access to the contents of the variable $output in the code you use to make the parse.

Debug

To see what is collected by Curl, you can do as suggested in the comments:

// ...
$output = curl_exec ($ch) or curl_error($ch);
var_dump($output);

You can also see if Curl is installed :

if (!function_exists('curl_init')) {
  die("Falta o cURL!");
}
  • It really seems to be the problem with the return +1

  • Opa buddy, initially had done a function, I forgot to remove the Return. Return removed, I gave a echo curl_errno($ch), returned me error in the url, fixed. Thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.