PagSeguro getPaymentMethods Error

0
  

59001 - "unknown web session id"

I'm implementing Transparent PagSeguro Checkout using PHP v2 API, however I always get the error above in the JavaScript part. Their support is horrible, there is nowhere else to go.

Edited: I've added the actual link so that testing can be done.

Download Files

Follow the code:

function cartao(){
  $(document).ready(function(){
    var senderHash;
	$.post('http://plimplimfestas.com/rafael/checkout.php', { sessao: "sessao" }, function(returnedData){
    //TESTES
    //*******************************************//
	//***** Inicializando a sessão checkout *****//		//*******************************************//
	var xml = returnedData,
	xmlDoc = $.parseXML(xml),
	$xml = $(xmlDoc),
	$title = $xml.find("id");
		
	var idSess = $title.text();
	console.log("SessionId");
    console.log(idSess);
    PagSeguroDirectPayment.setSessionId(idSess);
      
    //***************************************//
    //***** Obtendo o hash do comprador *****//
    //***************************************//
    var hashComprador = PagSeguroDirectPayment.getSenderHash();
    senderHash = hashComprador;
    //FIM TESTES
  }).done(function(){
    PagSeguroDirectPayment.getPaymentMethods({
				success: function(response){ console.log(response); },
				error: function(response){ console.log(response); },
				complete: function(response){ console.log(response); }
			});
			throw "Stop forçado.";
      //Os consoles de error e complete acima retornam o erro
      /*
      existem mais trechos, porém não passa do ponto acima
      */
      
      }).fail(function(e){
			console.error(e);
	  });
   }); //document ready
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    
asked by anonymous 23.08.2016 / 03:32

2 answers

2

It seems that it is not recognizing the Session ID used. How are you doing to get the Session Id?

The correct one, which should be done on the server side, would look like this (example in PHP, using their SDK):

$credentials = PagSeguroConfig::getAccountCredentials();    
$idSession = PagSeguroSessionService::getSession($credentials);

Then, in JS, you receive this data. If your PHP code is together with JS (not recommended, but this example is for clarification purposes only), you can do something like this:

var idSess = '<?= $idSession ?>';

If this is not the case, pass the code where you get the Session ID

Note: Sample link to JS: link

    
24.08.2016 / 19:00
-1

This really is not described in the documentation, sad ...

After getting the session ID through the vc API, you should set it to the object of the PagSeguro lib

PagSeguroDirectPayment.setSessionId ('d2bd8672814kkkkkka67b44e872172')

Then you can call the other methods quiet: D

    
27.03.2018 / 18:30