Autenticación
El SDK maneja automáticamente la autenticación con OAuth2 y las firmas RSA.
Autenticación automática
El cliente obtiene y renueva tokens de acceso sin que tengas que manejar el flujo manualmente.
Credenciales requeridas
Necesitas estas credenciales para autenticarte:
RETORNA_CLIENT_ID
RETORNA_CLIENT_SECRET
RETORNA_PRIVATE_KEY
Obtener un token manualmente (opcional)
const token = await client.authService.fetchAccessToken();
Ejemplo completo
import dotenv from "dotenv";
import { RetornaEnvironment, RetornaTypeScriptSDKConfigBuilder } from "retorna-typescript-sdk";
dotenv.config();
const clientId = process.env.RETORNA_CLIENT_ID!;
const clientSecret = process.env.RETORNA_CLIENT_SECRET!;
const privateKey = process.env.RETORNA_PRIVATE_KEY!;
const environment = process.env.RETORNA_ENV as RetornaEnvironment;
const client = new RetornaTypeScriptSDKConfigBuilder()
.environment(environment)
.clientId(clientId)
.clientSecret(clientSecret)
.privateKey(privateKey)
// .loggingLevel("debug")
.buildClient();
// 1) Auth
const token = await client.authService.fetchAccessToken();
// 2) Create quotation
const quotation = await client.createQuotation.create({
sourceCurrency: "USDT",
targetCountry: "VE",
targetCurrency: "VES",
amount: 1000,
amountType: "TARGET",
payoutType: "P2P_PHONE_TRANSFER",
});
const quotationId = (quotation as any).id ?? (quotation as any).quotationId;
// 3) Create payout order
const payoutOrder = await client.createPayoutOrder.create({
pogQuotationId: quotationId,
externalId: "your-external-id",
senderNames: "Alice",
senderLastNames: "Brown",
senderEmail: "alicebrown@example.com",
senderPhone: "+1-3456789012",
senderDocumentId: "123456789",
senderDocumentType: "cc",
senderCountry: "CO",
beneficiaryCountry: "CO",
beneficiaryNames: "PEDRO ANTONIO",
beneficiaryLastNames: "CARRASQUERO RANGEL",
beneficiaryEmail: "test@example.com",
beneficiaryDocumentId: "18184460",
beneficiaryDocumentType: "V",
purpose: "PAYMENT_OF_BILLS",
payoutType: "P2P_PHONE_TRANSFER",
paymentInstructions: {
bankName: "BANCO_PLAZA_VE",
phoneNumber: "+58-4244445566",
accountNumber: "01340012345678901234",
accountType: "SAVINGS",
branchId: "001",
},
});
// 4) GETs útiles
const routes = await client.getRoutes.list({ country: "MX" });
const balance = await client.getBalance.list();
const order = await client.getOrder.getById("11657");
const quote = await (client as any).getQuotation.getById(5205);



