### Node.js Basic Auth Header Example Source: https://freepaybrasil.readme.io/reference/introdu%C3%A7%C3%A3o This snippet demonstrates how to create the 'Authorization' header for authenticated requests to the FreePay Brasil API using Node.js. It involves constructing a string with public and secret keys, encoding it to Base64, and prepending 'Basic '. ```javascript const options = { method: "POST", url: "https://api.freepaybrasil.com/v1/payment-transactions/create", headers: { authorization: "Basic " + Buffer.from("{PUBLIC_KEY}:{SECRET_KEY}").toString("base64"), }, }; ``` -------------------------------- ### FreePay Brasil API OpenAPI Definition Source: https://freepaybrasil.readme.io/reference/dados-da-empresa This JSON document defines the OpenAPI 3.0.3 specification for the FreePay Brasil API. It includes API metadata, authentication details using Basic Auth, server endpoints, and the '/v1/company' GET endpoint for retrieving company information. ```json { "openapi": "3.0.3", "info": { "title": "FreePay API", "version": "1.0.0", "description": "API para criação de transações de pagamento via cartão, boleto e PIX. \nA autenticação é feita via **Basic Auth**, utilizando:\n```\nAuthorization: Basic base64(public_key:secret_key)\n```\n" }, "servers": [ { "url": "https://api.freepaybrasil.com", "description": "Ambiente local de testes" } ], "security": [ { "basicAuth": [] } ], "paths": { "/v1/company": { "get": { "description": "", "operationId": "get_company{companyId]", "responses": { "200": { "description": "", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "fantasy_name": { "type": "string" }, "postal_code": { "type": "string" }, "address": { "type": "string" }, "number": { "type": "string" }, "cnpj": { "type": "string" }, "complement": { "type": "string" }, "city": { "type": "string" }, "state": { "type": "string" }, "status": { "type": "string" }, "created_at": { "type": "string", "format": "date-time", "description": "Ex: 2025-11-12T18:15:10.891Z" }, "updated_at": { "type": "string", "format": "date-time", "description": "Ex: 2025-11-12T21:05:36.910Z" } } } } } } }, "parameters": [] } } }, "components": { "securitySchemes": { "basicAuth": { "type": "http", "scheme": "basic" } } }, "x-readme": {} } ``` -------------------------------- ### GET /v1/payment-transaction/info/{id} Source: https://freepaybrasil.readme.io/reference/post_idrefund-1 Retrieves information about a specific payment transaction by its ID. ```APIDOC ## GET /v1/payment-transaction/info/{id} ### Description Retrieves information about a specific payment transaction by its ID. ### Method GET ### Endpoint /v1/payment-transaction/info/{id} #### Path Parameters - **id** (string) - Required - The unique identifier of the transaction. ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **id** (string) - The transaction ID. - **created_at** (string) - The timestamp when the transaction was created (date-time format). - **updated_at** (string) - The timestamp when the transaction was last updated (date-time format). - **company_id** (string) - The ID of the company associated with the transaction. - **acquirer_id** (string) - The ID of the acquirer. - **external_id** (string) - An external identifier for the transaction. - **paid_at** (string) - The timestamp when the transaction was paid (date-time format). - **amount** (integer) - The transaction amount in cents. - **refunded_amount** (integer) - The amount that has been refunded in cents. - **installments** (integer) - The number of installments. - **payment_method** (string) - The method used for payment (e.g., CARD, BOLETO, PIX). - **status** (string) - The current status of the transaction. Possible values: PAID, PENDING, REFUNDED, FAILED, REFUSED. - **anticipation_status** (string) - The status of anticipation. - **postback_url** (string) - The URL for postback notifications. - **metadata** (string) - Additional metadata associated with the transaction (JSON format). #### Response Example ```json { "id": "txn_12345abcde", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:05:00Z", "company_id": "comp_fgh678", "acquirer_id": "aqr_90123", "external_id": "ext_xyz987", "paid_at": "2023-10-27T10:02:00Z", "amount": 10000, "refunded_amount": 0, "installments": 1, "payment_method": "CARD", "status": "PAID", "anticipation_status": "NONE", "postback_url": "https://example.com/postback", "metadata": "{\"order_id\": \"ORD-5678\"}" } ``` ``` -------------------------------- ### Get Company Data Source: https://freepaybrasil.readme.io/reference/dados-da-empresa Retrieves information about the company associated with the API key. This endpoint allows you to fetch details such as company name, address, CNPJ, and status. ```APIDOC ## GET /v1/company ### Description Retrieves company data including ID, fantasy name, address, CNPJ, status, and creation/update timestamps. ### Method GET ### Endpoint /v1/company ### Parameters #### Query Parameters This endpoint does not have any query parameters. #### Request Body This endpoint does not accept a request body. ### Request Example No request body is needed for this GET request. ### Response #### Success Response (200) - **id** (string) - Unique identifier for the company. - **fantasy_name** (string) - The fantasy name of the company. - **postal_code** (string) - The postal code of the company's address. - **address** (string) - The street address of the company. - **number** (string) - The street number of the company's address. - **cnpj** (string) - The CNPJ (Brazilian taxpayer registry number) of the company. - **complement** (string) - Additional address information. - **city** (string) - The city where the company is located. - **state** (string) - The state where the company is located. - **status** (string) - The current status of the company (e.g., active, inactive). - **created_at** (string) - The date and time when the company record was created (ISO 8601 format). - **updated_at** (string) - The date and time when the company record was last updated (ISO 8601 format). #### Response Example ```json { "id": "cmp_abc123", "fantasy_name": "FreePay Brasil", "postal_code": "12345-678", "address": "Avenida Paulista", "number": "1000", "cnpj": "11.222.333/0001-44", "complement": "Sala 101", "city": "São Paulo", "state": "SP", "status": "active", "created_at": "2025-11-12T18:15:10.891Z", "updated_at": "2025-11-12T21:05:36.910Z" } ``` ``` -------------------------------- ### Authentication Source: https://freepaybrasil.readme.io/reference Information on how to authenticate with the Freepay Brasil API using Basic Auth. ```APIDOC ## Authentication ### Description Our API follows the REST standard, and all responses are sent in JSON format. To make authenticated requests, you must send your credentials using the Basic Auth method. You can find your credentials in the dashboard on the 'API Credentials' page. ### Method Basic Auth ### Header Format `authorization: Basic Base64(PUBLIC_KEY:SECRET_KEY)` ### Example (Node.js) ```javascript const options = { method: "POST", url: "https://api.freepaybrasil.com/v1/payment-transactions/create", headers: { authorization: "Basic " + Buffer.from("{PUBLIC_KEY}:{SECRET_KEY}").toString("base64"), }, }; ``` ``` -------------------------------- ### POST /v1/payment-transaction/create Source: https://freepaybrasil.readme.io/reference/createpaymenttransaction-1 Creates a new payment transaction with card, boleto, or PIX. ```APIDOC ## POST /v1/payment-transaction/create ### Description Creates a new payment transaction with card, boleto, or PIX. ### Method POST ### Endpoint https://api.freepaybrasil.com/v1/payment-transaction/create ### Parameters #### Query Parameters None #### Request Body - **amount** (integer) - Required - Total amount in cents - **payment_method** (string) - Required - Enum: pix, credit_card, boleto - **postback_url** (string) - Optional - URL to receive transaction updates - **customer** (object) - Required - **name** (string) - Required - **email** (string) - Required - **document** (object) - Required - **number** (string) - Required - **type** (string) - Required - Enum: cpf, cnpj - **phone** (string) - Required - **items** (array) - Required - **items[].title** (string) - Required - **items[].unit_price** (integer) - Required - **items[].quantity** (integer) - Required - **items[].tangible** (boolean) - Required - Defines if the product is physical or not - **items[].external_ref** (string) - Optional - **shipping** (object) - Optional - **fee** (number) - Optional - **address** (object) - Optional - **street** (string) - Optional - **street_number** (string) - Optional ### Request Example ```json { "amount": 12050, "payment_method": "credit_card", "postback_url": "https://meusite.com/webhook", "customer": { "name": "Joao Silva", "email": "joao.silva@email.com", "document": { "number": "11111111111", "type": "cpf" }, "phone": "+5511999999999" }, "items": [ { "title": "Produto Exemplo 1", "unit_price": 10000, "quantity": 1, "tangible": true, "external_ref": "SKU123" }, { "title": "Serviço Exemplo 2", "unit_price": 2050, "quantity": 1, "tangible": false } ], "shipping": { "fee": 1000, "address": { "street": "Rua das Palmeiras", "street_number": "10" } } } ``` ### Response #### Success Response (200) - **transaction_id** (string) - Unique identifier for the transaction - **status** (string) - Current status of the transaction (e.g., pending, processing, completed, failed) - **payment_url** (string) - URL to complete the payment (for credit card or boleto) - **pix_code** (string) - PIX payment code (for PIX) #### Response Example ```json { "transaction_id": "txn_12345abcde", "status": "pending", "payment_url": "https://pay.freepaybrasil.com/pay?token=abcdef12345", "pix_code": null } ``` ``` -------------------------------- ### OpenAPI Definition for FreePay API Source: https://freepaybrasil.readme.io/reference/post_idrefund This is the OpenAPI 3.0.3 definition for the FreePay API. It outlines the API's structure, including endpoints for payment transactions (card, boleto, PIX), refund operations, authentication methods (Basic Auth), and server details. It serves as a contract for API interactions. ```json { "openapi": "3.0.3", "info": { "title": "FreePay API", "version": "1.0.0", "description": "API para criação de transações de pagamento via cartão, boleto e PIX. \nA autenticação é feita via **Basic Auth**, utilizando:\n```\nAuthorization: Basic base64(public_key:secret_key)\n```\n" }, "servers": [ { "url": "https://api.freepaybrasil.com", "description": "Ambiente local de testes" } ], "security": [ { "basicAuth": [] } ], "paths": { "/v1/{id}/refund": { "post": { "description": "", "operationId": "post_{id}refund", "responses": { "200": { "description": "" } }, "parameters": [ { "in": "path", "name": "id", "schema": { "type": "string" }, "required": true } ] } } }, "components": { "securitySchemes": { "basicAuth": { "type": "http", "scheme": "basic" } } }, "x-readme": {} } ``` -------------------------------- ### POST /transactions Source: https://freepaybrasil.readme.io/reference/createpaymenttransaction-1 Creates a new transaction with Freepay Brasil. Supports various payment methods and includes detailed response data for success and error cases. ```APIDOC ## POST /transactions ### Description Creates a new transaction with Freepay Brasil. This endpoint allows for initiating payments, specifying details such as amount, payment method, and callback URLs. It returns a transaction ID and status upon successful creation. ### Method POST ### Endpoint /transactions ### Parameters #### Request Body - **postback_url** (string) - Required - The URL to receive postback notifications. - **traceable** (boolean) - Required - Indicates if the transaction should be traceable. - **ip** (string) - Required - The IP address of the user initiating the transaction. ### Request Example ```json { "postback_url": "https://webhook.freepaybrasil.com", "traceable": true, "ip": "127.0.0.1" } ``` ### Response #### Success Response (200) - **data** (array) - Contains transaction details. - **id** (string) - The unique identifier for the transaction. - **amount** (integer) - The transaction amount. - **installments** (integer) - The number of installments for the payment. - **payment_method** (string) - The method used for payment. - **status** (string) - The current status of the transaction (e.g., PENDING, PAID, REFUNDED). - **postback_url** (string) - The configured postback URL for this transaction. - **card** (object) - Details of the card used, if applicable. - **hash** (string) - Card hash. - **number** (string) - Last 4 digits of the card number. - **holder_name** (string) - Name of the cardholder. - **expiration_month** (integer) - Card expiration month. - **expiration_year** (integer) - Card expiration year. - **cvv** (string) - CVV code. - **boleto** (object) - Details for boleto payments, if applicable. - **expires_in_days** (integer) - Number of days until the boleto expires. - **pix** (object) - Details for Pix payments, if applicable. - **expiration_date** (string) - Date and time when the Pix QR code expires. - **qr_code** (string) - The Pix QR code data. - **e2_e** (string) - E2E identifier for the Pix transaction. - **url** (string) - URL for Pix payment. #### Response Example ```json { "id": "pay_abc123", "status": "approved", "payment_method": "credit_card", "amount": 120.5, "created_at": "2025-11-03T16:00:00Z" } ``` #### Error Responses - **400**: Bad Request - Validation error in the request payload. - **401**: Unauthorized - Authentication failed. - **500**: Internal Server Error - An unexpected error occurred on the server. ``` -------------------------------- ### Internal Server Error Handling Source: https://freepaybrasil.readme.io/reference/createpaymenttransaction-1 Details on how the API responds to internal server errors. ```APIDOC ## Internal Server Error Handling ### Description This section describes the standard response for internal server errors within the FreePay Brasil API. ### Method Applies to all HTTP methods. ### Endpoint Applies to all endpoints. ### Response #### Error Response (500) - **description** (string) - "Erro interno do servidor" (Internal server error). ### Response Example ```json { "error": { "code": "INTERNAL_SERVER_ERROR", "message": "Erro interno do servidor" } } ``` ``` -------------------------------- ### OpenAPI 3.0.3 Definition for FreePay API Source: https://freepaybrasil.readme.io/reference/createpaymenttransaction-1 This is the main OpenAPI 3.0.3 definition for the FreePay API. It includes API information, server URLs, security schemes, and detailed path specifications for creating payment transactions. Authentication is handled via Basic Auth. ```json { "openapi": "3.0.3", "info": { "title": "FreePay API", "version": "1.0.0", "description": "API para criação de transações de pagamento via cartão, boleto e PIX. \nA autenticação é feita via **Basic Auth**, utilizando:\n```\nAuthorization: Basic base64(public_key:secret_key)\n```\n" }, "servers": [ { "url": "https://api.freepaybrasil.com", "description": "Ambiente local de testes" } ], "security": [ { "basicAuth": [] } ], "paths": { "/v1/payment-transaction/create": { "post": { "summary": "Criar transação de pagamento", "description": "Cria uma nova transação de pagamento com cartão, boleto ou PIX.", "operationId": "createPaymentTransaction", "security": [ { "basicAuth": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "amount": { "type": "integer", "example": 120.5, "description": "Total amount in cents", "default": "" }, "payment_method": { "type": "string", "enum": [ "pix", "credit_card", "boleto" ], "example": "credit_card", "default": "" }, "postback_url": { "type": "string", "description": "URL Para receber atualizações da transação" }, "customer": { "type": "object", "properties": { "name": { "type": "string", "default": "" }, "email": { "type": "string", "default": "" }, "document": { "type": "object", "properties": { "number": { "type": "string", "default": "" }, "type": { "type": "string", "default": "", "enum": [ "cpf", "cnpj" ] } }, "required": [ "number", "type" ] }, "phone": { "type": "string", "default": "" } }, "required": [ "name", "email", "document", "phone" ] }, "items": { "type": "array", "items": { "type": "object", "properties": { "title": { "type": "string", "default": "" }, "unit_price": { "type": "integer", "default": "" }, "quantity": { "type": "integer", "default": "" }, "tangible": { "type": "boolean", "default": "", "description": "Define se o produto é físico ou não" }, "external_ref": { "type": "string" } }, "required": [ "title", "unit_price", "quantity", "tangible" ] } }, "shipping": { "type": "object", "properties": { "fee": { "type": "number" }, "address": { "type": "object", "properties": { "street": { "type": "string" }, "street_number": { "type": "string" } } } } } } } } } } } } } } ``` -------------------------------- ### POST /transaction Source: https://freepaybrasil.readme.io/reference/createpaymenttransaction-1 Creates a new payment transaction. Supports payment methods including credit card, boleto, and PIX. ```APIDOC ## POST /transaction ### Description Creates a new payment transaction with options for card, boleto, or PIX. ### Method POST ### Endpoint /transaction ### Parameters #### Request Body - **payment_method** (string) - Required - The method of payment ('card', 'boleto', 'pix'). - **amount** (number) - Required - The transaction amount. - **customer_details** (object) - Required - Details about the customer. - **name** (string) - Required - Customer's full name. - **email** (string) - Required - Customer's email address. - **document** (string) - Required - Customer's document number (CPF/CNPJ). - **order_id** (string) - Optional - Your internal order identifier. ### Request Example ```json { "payment_method": "card", "amount": 100.50, "customer_details": { "name": "John Doe", "email": "john.doe@example.com", "document": "12345678900" }, "order_id": "ORDER123" } ``` ### Response #### Success Response (200) - **transaction_id** (string) - The unique identifier for the created transaction. - **status** (string) - The current status of the transaction (e.g., 'pending', 'approved', 'rejected'). - **payment_url** (string) - A URL for completing the payment (especially for boleto or PIX). #### Response Example ```json { "transaction_id": "txn_abc123xyz", "status": "pending", "payment_url": "https://freepay.com/pay/txn_abc123xyz" } ``` ``` -------------------------------- ### Node.js Basic Auth Header for Freepay Brasil API Source: https://freepaybrasil.readme.io/index Demonstrates how to create the authorization header for authenticated requests to the Freepay Brasil API using Node.js. It requires the user's PUBLIC_KEY and SECRET_KEY, which are base64 encoded and prepended with 'Basic '. ```javascript const options = { method: "POST", url: "https://api.freepaybrasil.com/v1/payment-transactions/create", headers: { authorization: "Basic " + Buffer.from("{PUBLIC_KEY}:{SECRET_KEY}").toString("base64"), }, }; ``` -------------------------------- ### FreePay Brasil API Authentication Source: https://freepaybrasil.readme.io/reference/createpaymenttransaction-1 This section outlines the authentication methods supported by the FreePay Brasil API, focusing on Basic Authentication. ```APIDOC ## FreePay Brasil API Authentication ### Description This API utilizes Basic Authentication for securing its endpoints. Clients must provide valid credentials in the `Authorization` header. ### Method All requests require authentication. ### Endpoint N/A (Applies to all endpoints) ### Parameters #### Header Parameters - **Authorization** (string) - Required - Contains the base64 encoded "username:password" pair. ### Request Example ```bash Authorization: Basic ``` ### Response #### Error Response (401) - **message** (string) - Unauthorized. Invalid credentials provided. #### Response Example ```json { "message": "Unauthorized" } ``` ``` -------------------------------- ### Authentication Source: https://freepaybrasil.readme.io/index Freepay Brasil API follows RESTful principles and returns JSON responses. Authentication is handled using Basic Auth with provided API credentials. ```APIDOC ## Authentication ### Description Our API follows the REST standard, and all responses are sent in JSON format. To make authenticated requests, you must send your credentials using the Basic Auth method. You can find your credentials within the dashboard on the "API Credentials" page. ### Method All authenticated requests require an `Authorization` header. ### Endpoint N/A (Header based authentication) ### Parameters #### Headers - **Authorization** (string) - Required - Should be in the format `Basic Base64(PUBLIC_KEY:SECRET_KEY)`. ### Request Example (Node.js) ```javascript const options = { method: "POST", url: "https://api.freepaybrasil.com/v1/payment-transactions/create", headers: { authorization: "Basic " + Buffer.from("{PUBLIC_KEY}:{SECRET_KEY}").toString("base64"), }, }; ``` ### Response N/A (Authentication is verified before processing requests). ``` -------------------------------- ### POST /v1/payment-transactions/create (Authentication) Source: https://freepaybrasil.readme.io/reference/introdu%C3%A7%C3%A3o This endpoint requires authenticated requests. Authentication is performed using Basic Auth, where your Public Key and Secret Key are base64 encoded and sent in the Authorization header. ```APIDOC ## POST /v1/payment-transactions/create ### Description This endpoint is used to create payment transactions and requires authentication via Basic Auth. Your API credentials (Public Key and Secret Key) must be encoded and included in the Authorization header. ### Method POST ### Endpoint /v1/payment-transactions/create ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body (Details of the request body for creating a payment transaction would typically be listed here, but are not provided in the input text.) ### Request Example ```javascript const options = { method: "POST", url: "https://api.freepaybrasil.com/v1/payment-transactions/create", headers: { authorization: "Basic " + Buffer.from("{PUBLIC_KEY}:{SECRET_KEY}").toString("base64"), }, }; ``` ### Response #### Success Response (200) - **(Details of the success response would typically be listed here, but are not provided in the input text.)** #### Response Example ```json { "example": "(Response body example not provided)" } ``` ``` -------------------------------- ### POST /v1/{id}/refund Source: https://freepaybrasil.readme.io/reference/post_idrefund This endpoint allows for the refund of a transaction. It requires the transaction ID as a path parameter. ```APIDOC ## POST /v1/{id}/refund ### Description Allows for the refund of a specific transaction using its unique identifier. ### Method POST ### Endpoint /v1/{id}/refund ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the transaction to be refunded. ### Request Example (No request body defined in the OpenAPI spec for this endpoint) ### Response #### Success Response (200) (No specific response body defined in the OpenAPI spec for this endpoint) #### Response Example (No specific response body defined in the OpenAPI spec for this endpoint) ``` -------------------------------- ### C# JSON Webhook Transaction Update Format Source: https://freepaybrasil.readme.io/reference/formato-dos-webhooks This snippet shows the JSON structure for transaction updates sent via webhooks. It includes details like transaction ID, timestamps, amount, payment method, status, and associated items. The 'Status' field indicates the current state of the transaction. ```csharp { "Id": "a24207e615224923bf4a68265d519fc6", "CreatedAt": "05/11/2025 21:19:42", "UpdatedAt": "2025-11-05T21:19:42.3648396", "ExternalId": "27615041", "PaidAt": "0001-01-01T00:00:00", "Amount": 100, // Em reais "Installments": 0, "PaymentMethod": "pix", "Status": "PAID", "PostbackUrl": "https://webhook.site/d69ba6ed-3b46-40eb-9e9f-15e66a57161d", "Traceable": true, "Items": [] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.