Generate Credit Card Token

Asked

Viewed 2,499 times

0

I am using the Pagseguro API Git and I’m unable to find how to generate the credit card token to make the checkout transparent.

In the example project you have the following command:

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

In the documentation of Pagseguro have to generate the token have to 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 they have how to generate the Token via the Pagseguro API?

  • According to the documentation, to do this you need to use their Javascript library. However I think you can use a Webbrowser in your app to try to embed this.

1 answer

1

Pagsegurodirectpayment.createCardToken is used to generate the Token you need to perform a transaction on Secure Pag. In your example, you did not create a function for callback Success. See below for 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 do the post or an ajax there in Pagseguro to complete the transaction.

  • I think the AP wanted to consume the API in C#.

  • 1

    But the Pagseguro API for transparent checkout which is the case is JS... By C# will not scroll. At least I haven’t seen any of their API to consume with C#...

  • 1

    AP mentioned that it uses a C# API available on Github. The API he mentions was created by a member of this OS as a source of the original UOL API. So there are at least two ;)

  • Really what I wanted was to generate this code through the API in C#, I was able to contact the guy who created the API and he directed me to do it via javascript.

Browser other questions tagged

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