> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stylepay.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Realizar Pagamento PIX

> Envia um pagamento PIX para qualquer chave

## Autenticação

Esta requisição requer autenticação via headers customizados:

<ParamField header="stpi" type="string" required>
  Seu Client ID
</ParamField>

<ParamField header="stps" type="string" required>
  Seu Client Secret
</ParamField>

<ParamField header="Content-Type" type="string" required default="application/json">
  Tipo do conteúdo da requisição
</ParamField>

## Corpo da Requisição

<ParamField body="amount" type="number" required>
  Valor do pagamento em reais (ex: 50.00)
</ParamField>

<ParamField body="description" type="string" required>
  Descrição ou finalidade do pagamento
</ParamField>

<ParamField body="creditParty" type="object" required>
  Informações do beneficiário que receberá o pagamento

  <Expandable title="Propriedades">
    <ParamField body="creditParty.name" type="string" required>
      Nome completo do beneficiário
    </ParamField>

    <ParamField body="creditParty.keyType" type="string" required>
      Tipo da chave PIX. Valores aceitos: `CPF`, `CNPJ`, `EMAIL`, `PHONE`, `EVP` (chave aleatória)
    </ParamField>

    <ParamField body="creditParty.key" type="string" required>
      Chave PIX do beneficiário conforme o tipo especificado
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="callbackUrl" type="string" required>
  URL para receber notificações de webhook sobre o status do pagamento
</ParamField>

## Resposta

<ResponseField name="statusCode" type="number">
  Código de status HTTP da operação
</ResponseField>

<ResponseField name="transaction_id" type="string">
  UUID único da transação de pagamento
</ResponseField>

<ResponseField name="amount" type="number">
  Valor do pagamento realizado
</ResponseField>

<ResponseField name="tax" type="number">
  Taxa cobrada pela transação
</ResponseField>

<ResponseField name="status" type="string">
  Status atual do pagamento. Valores possíveis: `PENDING`, `COMPLETED`, `FAILED`
</ResponseField>

## Tipos de Chave PIX

A API aceita os seguintes tipos de chave PIX:

| Tipo    | Descrição                            | Formato                                       |
| ------- | ------------------------------------ | --------------------------------------------- |
| `CPF`   | Cadastro de Pessoa Física            | 11 dígitos (somente números)                  |
| `CNPJ`  | Cadastro Nacional de Pessoa Jurídica | 14 dígitos (somente números)                  |
| `EMAIL` | Endereço de e-mail                   | [email@exemplo.com](mailto:email@exemplo.com) |
| `PHONE` | Número de telefone                   | +5511999999999                                |
| `EVP`   | Chave aleatória (End-to-end)         | UUID no formato padrão                        |

<RequestExample>
  ```bash cURL theme={null}
  curl --location 'https://api.stylepay.com.br/api/v1/gateway/pix-payment' \
  --header 'stpi: seu_client_id' \
  --header 'stps: seu_client_secret' \
  --header 'Content-Type: application/json' \
  --data '{
    "amount": 50.00,
    "description": "Pagamento para fornecedor",
    "creditParty": {
      "name": "Maria Santos",
      "keyType": "CPF",
      "key": "98765432100"
    },
    "callbackUrl": "https://seusite.com/webhook/pix-payment"
  }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.stylepay.com.br/api/v1/gateway/pix-payment', {
    method: 'POST',
    headers: {
      'stpi': 'seu_client_id',
      'stps': 'seu_client_secret',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      amount: 50.00,
      description: "Pagamento para fornecedor",
      creditParty: {
        name: "Maria Santos",
        keyType: "CPF",
        key: "98765432100"
      },
      callbackUrl: "https://seusite.com/webhook/pix-payment"
    })
  });

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests
  import json

  url = "https://api.stylepay.com.br/api/v1/gateway/pix-payment"

  headers = {
      "stpi": "seu_client_id",
      "stps": "seu_client_secret",
      "Content-Type": "application/json"
  }

  payload = {
      "amount": 50.00,
      "description": "Pagamento para fornecedor",
      "creditParty": {
          "name": "Maria Santos",
          "keyType": "CPF",
          "key": "98765432100"
      },
      "callbackUrl": "https://seusite.com/webhook/pix-payment"
  }

  response = requests.post(url, headers=headers, data=json.dumps(payload))
  ```

  ```php PHP theme={null}
  <?php

  $url = "https://api.stylepay.com.br/api/v1/gateway/pix-payment";

  $headers = [
      "stpi: seu_client_id",
      "stps: seu_client_secret",
      "Content-Type: application/json"
  ];

  $payload = [
      "amount" => 50.00,
      "description" => "Pagamento para fornecedor",
      "creditParty" => [
          "name" => "Maria Santos",
          "keyType" => "CPF",
          "key" => "98765432100"
      ],
      "callbackUrl" => "https://seusite.com/webhook/pix-payment"
  ];

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

  $response = curl_exec($ch);
  curl_close($ch);
  ?>
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "net/http"
  )

  func main() {
      url := "https://api.stylepay.com.br/api/v1/gateway/pix-payment"
      
      payload := map[string]interface{}{
          "amount": 50.00,
          "description": "Pagamento para fornecedor",
          "creditParty": map[string]string{
              "name": "Maria Santos",
              "keyType": "CPF",
              "key": "98765432100",
          },
          "callbackUrl": "https://seusite.com/webhook/pix-payment",
      }
      
      jsonData, _ := json.Marshal(payload)
      
      req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      req.Header.Set("stpi", "seu_client_id")
      req.Header.Set("stps", "seu_client_secret")
      req.Header.Set("Content-Type", "application/json")
      
      client := &http.Client{}
      resp, _ := client.Do(req)
      defer resp.Body.Close()
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - Success theme={null}
  {
    "statusCode": 200,
    "transaction_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "amount": 50.00,
    "tax": 1.50,
    "status": "PENDING"
  }
  ```

  ```json 400 - Bad Request theme={null}
  {
    "statusCode": 400,
    "message": "Invalid key format",
    "error": "Bad Request"
  }
  ```

  ```json 401 - Unauthorized theme={null}
  {
    "statusCode": 401,
    "message": "Invalid credentials",
    "error": "Unauthorized"
  }
  ```

  ```json 500 - Internal Server Error theme={null}
  {
    "statusCode": 500,
    "message": "Internal server error",
    "error": "Internal Server Error"
  }
  ```
</ResponseExample>

## Notas Importantes

<Note>
  O pagamento é processado de forma assíncrona. Use a `callbackUrl` para receber atualizações sobre o status da transação.
</Note>

<Warning>
  Certifique-se de validar a chave PIX do beneficiário antes de enviar o pagamento. Pagamentos enviados para chaves inválidas podem resultar em falhas ou valores não recuperáveis.
</Warning>

<Tip>
  A taxa (`tax`) é calculada automaticamente com base no valor da transação e nas regras da sua conta.
</Tip>
