Get Receipt by Token

Query Parameters

input
string
required
URL-encoded JSON containing the token or short codeExample: {"token":"rcpt_abc123_def456"} or {"token":"ABC123"}

Example Request

curl "https://receeco.com/api/trpc/getReceipt?input=%7B%22token%22%3A%22rcpt_abc123_def456%22%7D"

Response

result.data
object
Complete receipt information

Example Response

{
  "result": {
    "data": {
      "id": 123,
      "token": "rcpt_abc123_def456",
      "short_code": "ABC123",
      "merchant_id": 10,
      "merchant_name": "Fresh Foods Supermarket",
      "merchant_logo": "https://example.com/logo.png",
      "accent_color": "#22c55e",
      "total_amount": 12650,
      "currency": "NGN",
      "transaction_date": "2024-01-15T14:30:00Z",
      "items": [
        {
          "name": "Premium Rice (5kg)",
          "quantity": 1,
          "unit_price": 9500,
          "total_price": 9500
        },
        {
          "name": "Fresh Milk (1L)",
          "quantity": 2,
          "unit_price": 1575,
          "total_price": 3150
        }
      ],
      "category": "Groceries",
      "payment_method": "card",
      "location": "Lagos Island Branch",
      "status": "completed",
      "customer_email": null,
      "customer_phone": null,
      "created_at": "2024-01-15T14:30:05Z",
      "updated_at": "2024-01-15T14:30:05Z"
    }
  }
}

Update Receipt Contact

Request Body

token
string
required
Receipt token or short code
email
string
Customer email address
phone
string
Customer phone number
At least one of email or phone must be provided.

Example Request

{
  "token": "rcpt_abc123_def456",
  "email": "customer@example.com",
  "phone": "+2348012345678"
}

Response

result.data.success
boolean
Indicates if the update was successful
{
  "result": {
    "data": {
      "success": true
    }
  }
}

Error Responses

Customer Access Flow

1

Customer Receives Receipt

Customer gets QR code or short code from merchant
2

Access Receipt

Customer scans QR or enters short code at receeco.com/app/scan
3

View Receipt

Digital receipt displays with all transaction details
4

Optional: Add Contact Info

Customer can provide email/phone for receipt delivery and notifications

Integration Examples

Receipt Lookup Widget

// Simple receipt lookup widget
class ReceiptLookup {
  constructor(containerId) {
    this.container = document.getElementById(containerId);
    this.render();
  }

  render() {
    this.container.innerHTML = `
      <div class="receipt-lookup">
        <input type="text" id="receiptCode" placeholder="Enter receipt code" />
        <button onclick="this.lookupReceipt()">Find Receipt</button>
        <div id="receiptDisplay"></div>
      </div>
    `;
  }

  async lookupReceipt() {
    const code = document.getElementById("receiptCode").value;
    const display = document.getElementById("receiptDisplay");

    try {
      const receipt = await this.getReceipt(code);
      this.displayReceipt(receipt, display);
    } catch (error) {
      display.innerHTML = "<p>Receipt not found</p>";
    }
  }

  async getReceipt(token) {
    const input = encodeURIComponent(JSON.stringify({ token }));
    const response = await fetch(
      `https://receeco.com/api/trpc/getReceipt?input=${input}`
    );
    const data = await response.json();
    return data.result.data;
  }

  displayReceipt(receipt, container) {
    container.innerHTML = `
      <div class="receipt">
        <h3>${receipt.merchant_name}</h3>
        <p>Total: ₦${(receipt.total_amount / 100).toFixed(2)}</p>
        <p>Date: ${new Date(receipt.transaction_date).toLocaleDateString()}</p>
        <ul>
          ${receipt.items
            .map(
              (item) =>
                `<li>${item.name} x${item.quantity} - ₦${(
                  item.total_price / 100
                ).toFixed(2)}</li>`
            )
            .join("")}
        </ul>
      </div>
    `;
  }
}

// Initialize widget
new ReceiptLookup("receipt-lookup-container");

Best Practices

Token Validation

Always validate token format before API calls

Error Handling

Provide clear error messages to customers

Caching

Cache receipt data to improve performance

Privacy

Handle customer contact info securely
Both full tokens (rcpt_abc123_def456) and short codes (ABC123) work with the same endpoints for maximum flexibility.