Receiving login id

2

I'm using the PagSeguro PHP API to perform a transparent checkout. I'm having problems when I switch from sandbox to production environment.

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 PayPal account) 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 the PagSeguroData.class.php class the production data is as follows: (The production data is being called, not the sandbox data.) The email and token are correct The token was regenerated in PagSeguro 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 403

    
asked by anonymous 07.11.2014 / 20:22

2 answers

0

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

Follow the topic link in the pagseguro forum - link

    
08.09.2015 / 15:42
2

If you're using the PHP API ... I'm doing this (I'm 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>
    
23.01.2015 / 16:26