PDF Receipt

Payment receipt (PDF)

In this section, you will learn how to generate and download PDF receipts for completed payments (payouts).

Available Endpoint

  • Sandbox: https://sandbox.pixtopay.com.br/v2/payout/receipt
  • Production: https://api.pixtopay.com.br/v2/payout/receipt

Get PDF receipt

Generate and download the receipt for an approved payment in PDF format.

Route

GET /v2/payout/receipt

Headers

{
  "Authorization": "YOUR_API_KEY"
}

Query Parameters

Important: Use only one of the parameters below (not both):

ParameterTypeRequiredDescription
idintegerYes*Internal payment ID generated by PixToPay
transaction_idstringYes*Unique transaction identifier on your platform

* Use only id or transaction_id, never both

Request example by ID

curl --location 'https://api.pixtopay.com.br/v2/payout/receipt?id=685' \
--header 'Authorization: API_KEY' \
--output receipt.pdf

Request example by transaction_id

curl --location 'https://api.pixtopay.com.br/v2/payout/receipt?transaction_id=12345678911' \
--header 'Authorization: API_KEY' \
--output receipt.pdf

Response 200 - Success

The response is a binary PDF file.

Response headers:

{
  "Content-Type": "application/pdf",
  "Content-Disposition": "inline; filename='payout_E20018183202507030306IVCXWQNh0fQ.pdf'"
}

The file name is returned in the Content-Disposition header.

Response 400 - Invalid parameters

{
  "type": "ValidationError",
  "message": "Use only id or transaction_id, not both"
}

Response 404 - Payment not found

{
  "message": "Payout not found"
}

Response 400 - Payment not approved

{
  "type": "ValidationError",
  "message": "Receipt is only available for paid payouts"
}

Requirements

To generate a receipt, the payment must meet the following requirements:

  • Approved status: Payment must have status 1 (approved/completed)
  • Processing complete: The paid_at field must be set
  • Valid identification: Provide a valid id or transaction_id

Using in web applications

JavaScript/TypeScript

async function downloadReceipt(transactionId) {
  const response = await fetch(
    `https://api.pixtopay.com.br/v2/payout/receipt?transaction_id=${transactionId}`,
    {
      headers: {
        Authorization: "YOUR_API_KEY",
      },
    }
  );
 
  if (response.ok) {
    const blob = await response.blob();
    const url = window.URL.createObjectURL(blob);
    const a = document.createElement("a");
    a.href = url;
    a.download = "receipt.pdf";
    document.body.appendChild(a);
    a.click();
    a.remove();
  }
}

Python

import requests
 
def download_receipt(transaction_id):
    url = f"https://api.pixtopay.com.br/v2/payout/receipt?transaction_id={transaction_id}"
    headers = {
        "Authorization": "YOUR_API_KEY"
    }
 
    response = requests.get(url, headers=headers)
 
    if response.status_code == 200:
        with open("receipt.pdf", "wb") as f:
            f.write(response.content)
        print("Receipt downloaded successfully!")
    else:
        print(f"Error: {response.json()}")

PHP

<?php
$transactionId = "12345678911";
$url = "https://api.pixtopay.com.br/v2/payout/receipt?transaction_id=" . $transactionId;
 
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: YOUR_API_KEY'
]);
 
$output = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
 
if ($httpCode === 200) {
    file_put_contents("receipt.pdf", $output);
    echo "Receipt downloaded successfully!";
} else {
    echo "Error downloading receipt";
}
?>

Receipt Contents

The PDF receipt includes the following information:

  • 📄 Payment data: Amount, date, and time
  • 👤 Beneficiary data: Name, document
  • 🏦 Bank data: Bank, branch, account
  • 🔐 Identifiers: Transaction ID, internal ID
  • Proof: Transaction hash and status

Important Notes

  • Availability: Receipts are only available for payments with status 1 (approved)
  • Format: The file is returned as a standard PDF
  • Size: Usually between 50KB and 200KB
  • Validity: The receipt is legally valid and can be used as proof of payment
  • Generation: The receipt is generated in real time on each request
  • Cache: No local caching is required; the endpoint returns the same PDF for the same payment

Use Cases

1. Customer portal

Let your customers download receipts for payments they received

2. Accounting systems

Integrate with your accounting system for automatic receipt archiving

3. Email delivery

Send receipts automatically by email after payment approval

4. Audit

Keep records of all payments with their corresponding receipts