Restful Pagseguro API returning "message": "Unauthorized"?

Asked

Viewed 98 times

1

I am trying to implement payment by card using Pagseguro’s Rest API. I have followed every step of this documentation but the return is always "message": "Unauthorized". I’m testing directly at POSTMAN

How to solve this ?

//url:  https://sandbox.api.pagseguro.com/charges
//token: "jkerjhelajkrhqleubbc...."

//headers
//Content-Type: application/json
//Authorization: {{token}}
//x-api-version: "1.0"
//x-idempotency-key: ""

//json
{
  "reference_id": "823",
  "description": "Compra de produtos site",
  "amount": {
    "value": 1000,
    "currency": "BRL"
  },
  "payment_method": {
    "type": "CREDIT_CARD",
    "installments": 1,
    "capture": true,
    "card": {
      "number": "4111111111111111",
      "exp_month": "03",
      "exp_year": "2026",
      "security_code": "123",
      "holder": {
        "name": "Jose da Silva"
      }
    }
  },
  "notification_url": "https://meusite.com/StatusPagamentoTransaction"
}

1 answer

1


Opa, these integration processes need a step called authentication, which is where you identify yourself and generate your access to services.

This doc here should help you: https://dev.pagseguro.uol.com.br/v4.0/docs/api-autenticacao

After generating the token, you need to add to your request header.

the/

  • What you’re saying is I should have a token for sandbox and one for production ? The production I already have, but the sandbox I’m not getting pq this off the air. See link https://sandbox.pagseguro.uol.com.br/

  • 1

    That, a token is required for the Sandbox as well.

Browser other questions tagged

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