PayEvo REST API

website·Indexed 31 days ago

https://docs.payevo.com.br

REST API for integration with the PayEvo payment gateway. Provides endpoints for managing customers (/customers), processing transactions (/transactions), checking balances (/balance), and retrieving company data (/company). Supports credit card and boleto payments, transaction refunds, and postback notifications.

Tokens
4.4K
Snippets
36
Records
42
Agent score
46%

What's inside PayEvo

  1. Authenticate requests to the PayEvo REST API

    The PayEvo API uses REST architecture and returns all responses in JSON format. To access API resources, use Basic Authentication by providing your secret key. The secret key is located in the PayEvo control panel under Settings → API Credentials. The key must be Base64 encoded and included in the Authorization request header.
    const options = {
        method: "POST",
        url: "https://apiv2.payevo.com.br/functions/v1/transactions",
        headers: {
            authorization: 'Basic ' + new Buffer("{SECRET_KEY}").toString('base64')
        }
    }
  2. Retrieve a specific customer by ID

    Use the GET /customers/:id endpoint to retrieve detailed information about a specific customer registered on the Payevo platform. The :id parameter in the URL must be the unique identifier of the customer.
    curl -X GET "https://api.payevo.com.br/customers/{id}"
  3. Retrieve a specific transaction by ID

    Use the GET /transactions/:id endpoint to retrieve detailed information about a specific transaction. You must provide the transaction ID as a path parameter.
    curl -X GET "https://api.payevo.com.br/transactions/{transaction_id}"
  4. Retrieve a specific transaction by ID

    Use the GET /transactions/:id endpoint to retrieve detailed information about a specific transaction. You must provide the transaction ID as a path parameter.
    GET /transactions/{id}
  5. Retrieve general company information via /company endpoint

    Use the GET /company endpoint to retrieve general information and details about the company registered on the Payevo platform. The endpoint returns a 200 status code upon success or a 400 status code if the request is invalid.
    GET /company
  6. Authenticate requests to the PayEvo REST API

    The PayEvo API uses REST architecture and returns all responses in JSON format. To access API resources, you must use Basic Authentication. Your secret key, which serves as the credential, can be found in the control panel under Settings → API Credentials (Configurações → Credenciais de API). The secret key must be Base64 encoded and included in the Authorization header of the request.
    const options = {
        method: "POST",
        url: "https://apiv2.payevo.com.br/functions/v1/transactions",
        headers: {
            authorization: 'Basic ' + new Buffer("{SECRET_KEY}").toString('base64')
        }
    }
  7. Retrieve general company information via /company endpoint

    Use the GET /company endpoint to obtain general information about the company registered on the Payevo platform. The endpoint returns a 200 status code upon successful retrieval of company data or a 400 status code if the request is invalid.
    GET /company
  8. Install the PayEvo Origin Verifier script

    The Origin Verifier script collects transaction data such as page URL, store domain, and buyer browser info to generate a digital fingerprint for validation. This script must be included in the checkout page before the payment code. It uses your existing API Token for authentication.
    <script
        src="https://cdn.payevo.com.br/origin/v1/payevo-origin.min.js"
        data-token="{SECRET_KEY}">
    </script>
  9. Capture and send origin data in transaction requests

    To include origin data in a transaction, use the window.PayEvoOrigin.getData() function. The resulting data should be assigned to the metadata.origin field in the request body. It is recommended to use a null check to ensure the transaction processes normally even if the script fails to load.
    const origin = window.PayEvoOrigin ? window.PayEvoOrigin.getData() : null;
    
    const options = {
        method: "POST",
        url: "https://apiv2.payevo.com.br/functions/v1/transactions",
        headers: {
            "Content-Type": "application/json",
            authorization: 'Basic ' + new Buffer("{SECRET_KEY}").toString('base64')
        },
        body: JSON.stringify({
            amount: 5000,
            paymentMethod: "CARD",
            card: { hash: "token_do_cartao_tokenizado" },
            customer: {
                name: "João Silva",
                email: "joao@email.com",
                document: { type: "CPF", number: "12345678900" }
            },
            metadata: {
                order_id: "PEDIDO-456",
                ...(origin && { origin })
            }
        })
    };
  10. Configure and handle transaction postbacks

    To receive real-time notifications when a transaction status changes, define a specific URL in the postbackUrl field when registering a transaction. Payevo will send a JSON payload to this URL containing the full transaction details, including payment method, status, customer information, and fee breakdowns.
    {
      "id": "XDOH3YTF9GER",
      "type": "transaction",
      "objectId": "c856345e-23d6-471d-bb7e-75dfe340c26d",
      "data": {
        "id": "c856345e-23d6-471d-bb7e-75dfe340c26d",
        "amount": 500,
        "refundedAmount": null,
        "description": "Descrição",
        "companyId": "8e34bece-fed7-4b45-b725-effe6ddef895",
        "installments": 1,
        "paymentMethod": "PIX",
        "status": "waiting_payment",
        "postbackUrl": null,
        "metadata": "{}",
        "createdAt": "2024-08-09T10:51:07.144-03:00",
        "updatedAt": "2024-08-09T10:51:07.144-03:00",
        "paidAt": null,
        "ip": "2121.123123.1123",
        "customer": {
          "id": "4efd19a3-cace-4036-abee-d57fb7260f65",
          "name": "teste",
          "email": "teste@gmail.com",
          "phone": "11991301322",
          "createdAt": "2024-08-09T10:51:06.691107"
        },
        "card": null,
        "boleto": null,
        "pix": {
          "qrcode": "https://digital.mundipagg.com/pix/",
          "expirationDate": "2024-08-09T11:11:07.144-03:00",
          "end2EndId": null,
          "receiptUrl": null
        },
        "shipping": {
          "neighborhood": "Ilhinha",
          "zipCode": "65076632",
          "city": "São Luís",
          "complement": "casa",
          "streetNumber": "165",
          "street": "Rua São Jorge",
          "state": "MA"
        },
        "refusedReason": null,
        "items": [
          {
            "title": "Teste 2",
            "unitPrice": 500,
            "quantity": 1,
            "externalRef": "teste"
          }
        ],
        "splits": [
          {
            "recipientId": "909c81fe-0511-442c-b2a8-ca06b0fd8042",
            "percentage": 100,
            "netAmount": 200
          }
        ],
        "fee": {
          "fixedAmount": 3,
          "spreadPercentage": 3,
          "estimatedFee": 300,
          "netAmount": 200
        }
      }
    }
  11. Integrate Origin Verifier with Shopify

    For standard Shopify themes, add the script tag to the theme.liquid file before the </head> tag via Online Store → Themes → Edit code. For Shopify Plus, the script can be added in Settings → Checkout under the Additional scripts field.
    <script
        src="https://cdn.payevo.com.br/origin/v1/payevo-origin.min.js"
        data-token="{SECRET_KEY}">
    </script>
  12. Integrate Origin Verifier with Shopify

    For standard Shopify themes, add the script tag to the theme.liquid file before the </head> tag. For Shopify Plus stores, the script can be added via Settings → Checkout in the Additional scripts field.
    <script
        src="https://cdn.payevo.com.br/origin/v1/payevo-origin.min.js"
        data-token="{SECRET_KEY}">
    </script>