Ir al contenido
Abrir .md
En esta página

Listar

Lista los reembolsos de facturas con paginación por cursor y filtra por ID de factura, estado o intervalo de creación.

GET/v1/refunds

Clave de API: Payment

Devuelve los reembolsos de facturas pertenecientes a los proyectos dentro del alcance de la clave Payment autenticada, ordenados por created_at DESC y luego withdrawal_id DESC. Los retiros ordinarios creados mediante POST /v1/withdrawals nunca aparecen en esta lista.

Parámetros de consulta

Parámetro Tipo Por defecto Descripción
limit integer 20 Tamaño de página de 1 a 100
cursor string — Cursor opaco next_cursor de la respuesta anterior
invoice_id string — Filtrar por identificador de factura con prefijo (inv_...)
status string — Estado exacto en snake_case (created, signed, pending_review, cancelling, completed, failed, cancelled). Repite el parámetro para consultar varios estados
created_from RFC 3339 — Límite inferior inclusivo de created_at con zona horaria (por ejemplo, 2026-08-23T00:00:00Z)
created_to RFC 3339 — Límite superior exclusivo de created_at con zona horaria. Debe ser posterior a created_from

Los parámetros desconocidos, los estados duplicados y las marcas de tiempo no válidas se rechazan con 400.

Ejemplos de código

Cada pestaña utiliza el SDK oficial de ese lenguaje con una clave Payment (pk_).

API_KEY_ID="pk_live_xxxxxxxxxxxx"
API_SECRET="sk_live_xxxxxxxxxxxx"
QUERY="?invoice_id=inv_7K2M9P4Q8R1X5Z3A0bC2dE&limit=20"

TS=$(date +%s)
# No body: the hash slot is the EMPTY STRING, not sha256("").
SIGNATURE=$(printf '%s\n%s\n%s\n%s\n%s' "$TS" GET /v1/refunds "$QUERY" '' \
  | openssl dgst -sha256 -hmac "$API_SECRET" -binary | base64)

curl -sS "https://api.paymos.io/v1/refunds$QUERY" \
  -H "Authorization: HMAC-SHA256 $API_KEY_ID:$SIGNATURE" \
  -H "X-Request-Timestamp: $TS"
import { Paymos } from '@paymos/sdk';

const paymos = new Paymos({
  apiKey: process.env.PAYMOS_API_KEY,
  apiSecret: process.env.PAYMOS_API_SECRET,
});

const page = await paymos.refunds.list({
  invoiceId: 'inv_7K2M9P4Q8R1X5Z3A0bC2dE',
  limit: 20,
});

for await (const refund of paymos.refunds.iterate({ status: ['completed'] }, 10)) {
  console.log(refund.withdrawalId);
}
import os

from paymos import Paymos

paymos = Paymos(
    api_key=os.environ["PAYMOS_API_KEY"],
    api_secret=os.environ["PAYMOS_API_SECRET"],
)

page = paymos.refunds.list(invoice_id="inv_7K2M9P4Q8R1X5Z3A0bC2dE", limit=20)

for refund in paymos.refunds.iterate(10, status=["completed"]):
    print(refund["withdrawal_id"])
<?php
use Paymos\Client;
use Paymos\ClientConfig;

$paymos = new Client(new ClientConfig(
    getenv('PAYMOS_API_KEY'),
    getenv('PAYMOS_API_SECRET')
));

$page = $paymos->refunds()->listPage(array(
    'invoice_id' => 'inv_7K2M9P4Q8R1X5Z3A0bC2dE',
    'limit' => 20,
));

foreach ($paymos->refunds()->iterate(array('status' => array('completed')), 10) as $refund) {
    echo $refund['withdrawal_id'] . PHP_EOL;
}
package main

import (
	"context"
	"fmt"
	"os"

	paymos "github.com/Paymos-labs/go-sdk/v2"
)

func main() {
	client, err := paymos.NewClient(os.Getenv("PAYMOS_API_KEY"), os.Getenv("PAYMOS_API_SECRET"))
	if err != nil {
		panic(err)
	}

	page, err := client.Refunds.List(context.Background(), paymos.RefundListParams{
		InvoiceID: "inv_7K2M9P4Q8R1X5Z3A0bC2dE",
		Limit:     20,
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(len(page.Items), page.NextCursor)

	iter := paymos.NewRefundIterator(client.Refunds, paymos.RefundListParams{
		Status: []paymos.WithdrawalStatus{paymos.WithdrawalCompleted},
	}, 10)
	for {
		refund, ok, err := iter.Next(context.Background())
		if err != nil {
			panic(err)
		}
		if !ok {
			break
		}
		fmt.Println(refund.WithdrawalID)
	}
}
using Paymos;

using var paymos = new PaymosClient(
    Environment.GetEnvironmentVariable("PAYMOS_API_KEY")!,
    Environment.GetEnvironmentVariable("PAYMOS_API_SECRET")!);

var page = await paymos.Refunds.ListAsync(new RefundListOptions(
    InvoiceId: "inv_7K2M9P4Q8R1X5Z3A0bC2dE",
    Limit: 20));

await foreach (var refund in paymos.Refunds.IterateAsync(
    new RefundListOptions(Status: [WithdrawalStatus.Completed]), maxPages: 10))
{
    Console.WriteLine(refund.WithdrawalId);
}
import io.paymos.Page;
import io.paymos.PaymosClient;
import io.paymos.Refund;
import io.paymos.RefundListOptions;
import io.paymos.WithdrawalStatus;

import java.util.List;

PaymosClient paymos = new PaymosClient(
    System.getenv("PAYMOS_API_KEY"),
    System.getenv("PAYMOS_API_SECRET"));

Page<Refund> page = paymos.refunds.list(RefundListOptions.builder()
    .invoiceId("inv_7K2M9P4Q8R1X5Z3A0bC2dE")
    .limit(20)
    .build());

for (Refund refund : paymos.refunds.iterate(
        RefundListOptions.builder().status(List.of(WithdrawalStatus.COMPLETED)).build(), 10)) {
    System.out.println(refund.withdrawalId());
}
require 'paymos'

paymos = Paymos::Client.new(
  api_key: ENV.fetch('PAYMOS_API_KEY'),
  api_secret: ENV.fetch('PAYMOS_API_SECRET')
)

page = paymos.refunds.list(invoice_id: 'inv_7K2M9P4Q8R1X5Z3A0bC2dE', limit: 20)

paymos.refunds.each(max_pages: 10, status: ['completed']) do |refund|
  puts refund.withdrawal_id
end
use paymos::{PaymosClient, RefundListParams, WithdrawalStatus};

let paymos = PaymosClient::new(
    std::env::var("PAYMOS_API_KEY")?,
    std::env::var("PAYMOS_API_SECRET")?,
)?;

let page = paymos
    .refunds()
    .list(&RefundListParams {
        invoice_id: Some("inv_7K2M9P4Q8R1X5Z3A0bC2dE".to_owned()),
        limit: Some(20),
        ..Default::default()
    })
    .await?;
println!("{} items, next_cursor={:?}", page.items.len(), page.next_cursor);

let mut pager = paymos.refunds().pager(
    RefundListParams { status: Some(vec![WithdrawalStatus::Completed]), ..Default::default() },
    Some(10),
)?;
while let Some(refund) = pager.next().await? {
    println!("{}", refund.withdrawal_id);
}

Respuesta (200 OK)

{
  "items": [
    {
      "withdrawal_id": "wdr_6Qm2fK8xR4vN7cT1bY9dL5",
      "invoice_id": "inv_7K2M9P4Q8R1X5Z3A0bC2dE",
      "mode": "full",
      "external_order_id": "refund-1042-full",
      "status": "completed",
      "is_final": true,
      "is_test": false,
      "amount": "100.00",
      "fee": "1.00",
      "currency": "USDT",
      "network": "TRC20",
      "destination_address": "TN3W4H6rK2ce4vX9YnFQHwKENnHjoxb3m9",
      "first_sender": "TN3W4H6rK2ce4vX9YnFQHwKENnHjoxb3m9",
      "tx_hash": "9f3b8c2a1d0e4f6789abc123def4567890abc123def4567890abc123def45678",
      "explorer_url": "https://tronscan.org/#/transaction/9f3b8c2a1d0e4f6789abc123def4567890abc123def4567890abc123def45678",
      "created_at": 1767225600,
      "completed_at": 1767225932,
      "type": "refund",
      "project_id": "prj_3F9xL2mN8pQ4rT6vW1yZ5b"
    }
  ],
  "next_cursor": null
}

Cada elemento de items contiene el recurso completo del reembolso, con la misma estructura que Obtener reembolso.

Reglas de paginación

  • Sigue next_cursor hasta que devuelva null.
  • El cursor está vinculado al endpoint /v1/refunds y a los filtros exactos (invoice_id, status, created_from, created_to). Mantén los mismos filtros entre páginas; limit puede cambiar.
  • Los cursores caducan a las 24 horas de su emisión.
  • Pasar un invoice_id fuera del alcance de proyectos de tu credencial devuelve una lista vacía en lugar de 404.

Errores

Una clave Payout (rk_) se rechaza con 403 payment_key_required. Los filtros no válidos devuelven 400 y un cursor caducado o incompatible devuelve 400 pagination_cursor_invalid. Consulta Códigos de error.