Generate Token Credit Card Pagseguro

0

I'm using the PayPal API Git and I can not figure out how to generate the credit card token to do the transparent checkout.

In the sample project you have the following command:

// Sets a credit card token.
        checkout.Token = "9a476b3a36124756a343712754638c7c";

In the PagSeguro documentation you have to generate the token you have who make the following request via JavaScript

PagSeguroDirectPayment.createCardToken({
    cardNumber: NUMERO_DO_CARTAO,
    brand: BANDEIRA,
    cvv: CODIGO_DE_SEGURANCA,
    expirationMonth: MES_DE_EXPIRACAO,
    expirationYear: ANO_DE_EXPIRACAO,
    success: FUNCAO_DE_CALLBACK_PARA_SUCESSO,
    error: FUNCAO_DE_CALLBACK_PARA_FALHA,
    complete: FUNCAO_DE_CALLBACK_PARA_TODAS_AS_CHAMADAS
});

Does anyone know if it is possible to generate the Token via the PagSeguro API?

    
asked by anonymous 22.06.2017 / 14:22

1 answer

1

The PagSeguroDirectPayment.createCardToken is used to generate the Token that you need to perform a transaction on the Secure Pag. In your example, you did not create a function for callback success. Here is a simple example to get it:

PagSeguroDirectPayment.createCardToken({
    cardNumber: NUMERO_DO_CARTAO,
    brand: BANDEIRA,
    cvv: CODIGO_DE_SEGURANCA,
    expirationMonth: MES_DE_EXPIRACAO,
    expirationYear: ANO_DE_EXPIRACAO,
    success: function(response){
        var objToken = response;
        var TOKEN = objToken["card"].token;
        //Atribuo o token recebido para uma um campo para finalizar o pagamento (Você poderá chamar um método diretamente também se preferir)
        $("#ALGUM_CAMPO_PARA_RECEBER_O_TOKEN").val(TOKEN);
    },
    error: FUNCAO_DE_CALLBACK_PARA_FALHA,
    complete: FUNCAO_DE_CALLBACK_PARA_TODAS_AS_CHAMADAS
});

After assigning the token to some field or selector you can retrieve it to post or an ajax there in the Pagseguro to complete the transaction.

    
22.06.2017 / 21:26