curl --request GET \
--url https://api-beta.pepay.io/api/v1/invoices/{invoiceId} \
--header 'x-api-key: <api-key>'import requests
url = "https://api-beta.pepay.io/api/v1/invoices/{invoiceId}"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api-beta.pepay.io/api/v1/invoices/{invoiceId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-beta.pepay.io/api/v1/invoices/{invoiceId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-beta.pepay.io/api/v1/invoices/{invoiceId}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-beta.pepay.io/api/v1/invoices/{invoiceId}")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-beta.pepay.io/api/v1/invoices/{invoiceId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_bodyRetrieve an Invoice
Fetch a single invoice by id.
curl --request GET \
--url https://api-beta.pepay.io/api/v1/invoices/{invoiceId} \
--header 'x-api-key: <api-key>'import requests
url = "https://api-beta.pepay.io/api/v1/invoices/{invoiceId}"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api-beta.pepay.io/api/v1/invoices/{invoiceId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-beta.pepay.io/api/v1/invoices/{invoiceId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-beta.pepay.io/api/v1/invoices/{invoiceId}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-beta.pepay.io/api/v1/invoices/{invoiceId}")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-beta.pepay.io/api/v1/invoices/{invoiceId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_bodyOverview
Use this endpoint to fetch an invoice by id. Prefer usingexpand to request any related fields you need in one call.
Authentication
- Merchant server auth:
x-api-keyorAuthorization: Bearer <jwt>
Request
SDK
const invoice = await pepay.invoices.retrieve('550e8400-e29b-41d4-a716-446655440000', {
expand: ['latest_payment', 'payments'],
payments_limit: 10
});
cURL
INVOICE_ID="550e8400-e29b-41d4-a716-446655440000"
curl "https://api-beta.pepay.io/api/v1/invoices/$INVOICE_ID?expand=latest_payment,payments&payments_limit=10" \
-H "x-api-key: sk_live_..."
Response
{
"object": "invoice",
"id": "550e8400-e29b-41d4-a716-446655440000",
"merchant_id": 123,
"status": "unpaid",
"invoice_type": "standard",
"currency": "usd",
"amount": 49990,
"amount_decimal": "49.990",
"amount_unit": "usd_millis",
"environment": "devnet",
"expires_at": 1766322000,
"created_at": 1766318400,
"metadata": {
"order_id": "ORD-123"
}
}
Errors
400invalid parameters (including unsupportedexpandvalues)401missing/invalid merchant auth404invoice not found
Examples
Retrieve an invoice with the latest payment attached:const invoice = await pepay.invoices.retrieve(invoiceId, { expand: ['latest_payment'] });
const latestPayment = invoice.latest_payment;
Authorizations
API key for server-to-server operations (scope=merchant or commerce)
Path Parameters
Invoice ID
Query Parameters
Comma-separated expansions (latest_payment, payments).
Max payments per invoice when expand includes payments.
1 <= x <= 100Response
Invoice retrieved successfully
Canonical invoice object (snake_case, usd_millis amounts).
"invoice"
"550e8400-e29b-41d4-a716-446655440000"
123
"paid"
"standard"
"usd"
Total invoice amount in USD mills (1 USD = 1000 mills). For UI display, use amount_decimal.
10000
Display-friendly USD string with 3 decimals (derived from amount).
"10.000"
Total amount paid in USD mills (1 USD = 1000 mills). For UI display, use amount_paid_decimal.
10000
Display-friendly USD string with 3 decimals (derived from amount_paid).
"10.000"
Remaining amount in USD mills (1 USD = 1000 mills). For UI display, use amount_remaining_decimal.
0
Display-friendly USD string with 3 decimals (derived from amount_remaining).
"0.000"
Always usd_millis (amount fields are USD * 1000).
"usd_millis"
devnet, mainnet Canonical invoice_payment object (merchant surfaces include settlement fields; payor surfaces strip them).
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?

