Receiving the login id

Asked

Viewed 3,704 times

2

I’m using the PHP API for Secure Paging to perform a transparent checkout. I am having problems when I change from test environment (sandbox) to production.

Below the code snippet

jQuery

jQuery.ajax({
    url: "url/GetSessionId",
    type:"GET",
    cache: false,
    success: function(response) {
        PagSeguroDirectPayment.setSessionId(response);

PHP

public function getsessionid(){
    $checkout = new Checkout(false); // Se for false, esta no ambiente de produção
    $checkout->printSessionId();
}

In the Checkout class (from the Pagseguro api) the method printSessionId()

public function printSessionId() {

    // Creating a http connection (CURL abstraction)
    $httpConnection = new HttpConnection();

    // Request to PagSeguro Session API using Credentials
    $httpConnection->post($this->pagSeguroData->getSessionURL(), $this->pagSeguroData->getCredentials());

    // Request OK getting the result
    if ($httpConnection->getStatus() === 200) {

        $data = $httpConnection->getResponse();

        $sessionId = $this->parseSessionIdFromXml($data);

        echo $sessionId;
    } else {
        throw new Exception("API Request Error: ".$httpConnection->getStatus());
    }
}

And in class PagSeguroData.class.php production data are thus: (This is called the production data, not the sandbox data. The email and token are correct. The token was generated again in the Secure Page and updated)

'credentials' => array(
    "email" => "[email protected]",
    "token" => "00000000011111111112222222222"
),

'sessionURL' => "https://ws.pagseguro.uol.com.br/v2/sessions",
'transactionsURL' => "https://ws.pagseguro.uol.com.br/v2/transactions",
'javascriptURL' => "https://stc.pagseguro.uol.com.br/pagseguro/api/v2/checkout/pagseguro.directpayment.js"

The error that occurs is the 403

Erro

2 answers

3

If you are using the PHP API... I am doing so (I am still doing...)

<?php
require_once ("PagSeguroLibrary/PagSeguroLibrary.php");

$credentials = PagSeguroConfig::getAccountCredentials();  
$IDsession = PagSeguroSessionService::getSession($credentials);
?>

Then the whole process (ajax):

        <script type="text/javascript">
    $(function(){
    $('button[name=finalizar]').click(function(){
        $.ajax({
            success : function(){

                //*******************************************//
                //***** Inicializando a sessão checkout *****//
                //*******************************************//
                PagSeguroDirectPayment.setSessionId('<?php echo $IDsession; ?>');

                //***************************************//
                //***** Obtendo o hash do comprador *****//
                //***************************************//
                var hashComprador = PagSeguroDirectPayment.getSenderHash();

                //******************************************//
                //***** Obtendo os métodos de pagamento *****//
                //*******************************************//
                PagSeguroDirectPayment.getPaymentMethods({ 
                    success: function(resposta) { 

                        //*******************//
                        //***** CARTÕES *****//
                        //*******************//
                        var cartoes = resposta.paymentMethods.CREDIT_CARD.options;
                        var ArrayCartoes = Object.keys(cartoes).map(function(cartao){
                            return {
                                codigo: cartoes[cartao].code,
                                nome: cartoes[cartao].displayName,
                                sigla: cartoes[cartao].name,
                                path: cartoes[cartao].images.SMALL.path,
                                status: cartoes[cartao].status
                            };
                            //Tenho em "ArrayCartoes" todos os cartões retornados do PagSeguro
                            //Por exemplo os dados do primeiro cartão:
                            //ArrayCartoes[0].codigo
                            //ArrayCartoes[0].nome
                            //ArrayCartoes[0].sigla
                            //ArrayCartoes[0].path
                            //ArrayCartoes[0].status
                            //*O mesmo vale para os outros métodos de pagamento.
                        });

                        //*******************//
                        //***** BOLETO *****//
                        //*******************//
                        var boletos = resposta.paymentMethods.BOLETO.options;
                        var ArrayBoletos = Object.keys(boletos).map(function(boleto){
                            return {
                                codigo: boletos[boleto].code,
                                nome: boletos[boleto].displayName,
                                sigla: boletos[boleto].name,
                                path: boletos[boleto].images.SMALL.path,
                                status: boletos[boleto].status
                            };
                        });

                        //*************************//
                        //***** DÉBITO ONLINE *****//
                        //*************************//
                        var debitOnline = resposta.paymentMethods.ONLINE_DEBIT.options;
                        var ArrayDebitOnline = Object.keys(debitOnline).map(function(debito){
                            return {
                                codigo: debitOnline[debito].code,
                                nome: debitOnline[debito].displayName,
                                sigla: debitOnline[debito].name,
                                path: debitOnline[debito].images.SMALL.path,
                                status: debitOnline[debito].status
                            };
                        });

                    },
                    error: function(resposta) { 
                        //tratamento do erro 
                    }, 
                    complete: function(resposta) { 
                        //tratamento comum para todas chamadas 
                    } 
                });

            },
            error: function(resposta) { 
                //tratamento do erro 
                console.log(resposta);
            }
        });
    });
});
</script>

0


According to a user of pagseguro developers forum in the transparent checkout example topic, this error occurs due to you not being allowed to perform transparent checkout in production environment, you should contact the pagseguro website stating that you need to checkout.

Follow the topic link in the pagseguro forum - http://forum.pagseguro.uol.com.br/t/10203457/exemplo-de-checkout-transparente

Browser other questions tagged

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