Cópielo, péguelo y cobre.
Una línea para instalar y unas pocas para cobrar. SDK oficiales para Node.js, Python, PHP, Go, C#, Ruby, Java, Rust y C++, recetas para Express y Next.js, y las llamadas HTTP directas que todos ellos encapsulan. Cada fragmento está escrito contra el código fuente real de la biblioteca.
const invoice = await receivify.createInvoice(
{
amount_fiat: '25.00',
currency: 'USD',
asset: 'btc',
reference: `order-${order.id}`,
},
{ idempotencyKey: `order-${order.id}` },
)Nueve SDK oficiales, una sola API
Cada uno envuelve las mismas llamadas REST y añade lo delicado: firmas, idempotencia, importes exactos.
Leer la documentaciónESM, sin dependencias en tiempo de ejecución, declaraciones TypeScript escritas a mano. Node 18+.
Código fuente en GitHubDescargar (.zip)Ejemplo: ExpressEjemplo: Next.js (App Router)
npm install receivifyimport { Receivify } from 'receivify'
export const receivify = new Receivify(
process.env.RECEIVIFY_URL,
process.env.RECEIVIFY_API_KEY,
{ webhookSecrets: [process.env.RECEIVIFY_WEBHOOK_SECRET] },
)const invoice = await receivify.createInvoice(
{
amount_fiat: '25.00',
currency: 'USD',
asset: 'btc',
reference: `order-${order.id}`,
},
{ idempotencyKey: `order-${order.id}` },
)
// Simplest path: send them to the hosted page.
redirect(invoice.checkout_url)import { formatUnits, compareAmounts } from 'receivify'
// invoice.address — where the customer sends funds
// invoice.amount_expected — base units, as a STRING
// invoice.payment_uri — BIP-21 URI for the QR code (null on EVM/SOL/TRON)
// invoice.expires_at — ISO timestamp for your countdown
const display = formatUnits(invoice.amount_expected, 8) // '0.00123456'
const paid = compareAmounts(invoice.amount_received, invoice.amount_expected) >= 0import { SIGNATURE_HEADER } from 'receivify'
app.post('/webhooks/receivify',
express.raw({ type: 'application/json' }), // a Buffer: the exact bytes we signed
(req, res) => {
let event
try {
// parseWebhook verifies AND decodes. verifyWebhook returns a boolean.
event = receivify.parseWebhook(req.body, req.get(SIGNATURE_HEADER))
} catch {
return res.sendStatus(400) // bad signature, stale timestamp, or bad JSON
}
if (event.event === 'invoice.paid') fulfil(event.data.reference)
res.sendStatus(200) // 2xx quickly, then do the work
})El SDK de Node en una app Express: ruta de pago, webhook, página del pedido.
npm install receivify express// receivify.js
import { Receivify } from 'receivify'
export const receivify = new Receivify(
process.env.RECEIVIFY_URL,
process.env.RECEIVIFY_API_KEY,
{ webhookSecrets: [process.env.RECEIVIFY_WEBHOOK_SECRET] },
)import express from 'express'
const app = express()
// The webhook route gets the RAW bytes...
app.use('/webhooks/receivify', express.raw({ type: 'application/json' }))
// ...everything else can have parsed JSON. Order matters: a global
// express.json() mounted above this line would win and the signature
// would never verify.
app.use(express.json())app.post('/checkout/:orderId', async (req, res, next) => {
try {
const invoice = await receivify.createInvoice(
{
amount_fiat: req.body.total, // '25.00'
currency: 'USD',
asset: 'btc',
reference: `order-${req.params.orderId}`,
},
{ idempotencyKey: `order-${req.params.orderId}` },
)
res.redirect(303, invoice.checkout_url)
} catch (err) { next(err) }
})import { SIGNATURE_HEADER } from 'receivify'
app.post('/webhooks/receivify', (req, res) => {
let event
try {
event = receivify.parseWebhook(req.body, req.get(SIGNATURE_HEADER))
} catch {
return res.sendStatus(400)
}
res.sendStatus(200) // acknowledge first
// (event, sequence) is the de-duplication key — there is no separate id.
if (alreadyHandled(event.event, event.sequence)) return
if (event.event === 'invoice.paid') fulfil(event.data.reference)
})Server Action para el pago y Route Handler para el webhook. Ningún secreto llega al navegador.
npm install receivify// lib/receivify.js
import 'server-only'
import { Receivify } from 'receivify'
export const receivify = new Receivify(
process.env.RECEIVIFY_URL,
process.env.RECEIVIFY_API_KEY, // never NEXT_PUBLIC_
{ webhookSecrets: [process.env.RECEIVIFY_WEBHOOK_SECRET] },
)'use server'
import { redirect } from 'next/navigation'
import { receivify } from '@/lib/receivify'
export async function startCheckout(orderId, total) {
let invoice
try {
invoice = await receivify.createInvoice(
{ amount_fiat: total, currency: 'GBP', asset: 'btc', reference: `order-${orderId}` },
{ idempotencyKey: `order-${orderId}` },
)
} catch (err) {
return { error: 'Could not start checkout.' }
}
redirect(invoice.checkout_url) // outside the try — see above
}// app/api/webhooks/receivify/route.js
import { SIGNATURE_HEADER } from 'receivify'
import { receivify } from '@/lib/receivify'
export const runtime = 'nodejs' // node:crypto — not the edge runtime
export const dynamic = 'force-dynamic' // never cache a webhook
export async function POST(request) {
const raw = await request.text() // RAW bytes, not request.json()
let event
try {
event = receivify.parseWebhook(raw, request.headers.get(SIGNATURE_HEADER))
} catch {
return new Response('bad signature', { status: 400 })
}
if (event.event === 'invoice.paid') {
await fulfil(event.data.reference)
}
return new Response('ok')
}import { revalidatePath } from 'next/cache'
// inside the webhook handler, after fulfilling:
revalidatePath(`/orders/${event.data.reference}`)Solo biblioteca estándar. Python 3.9+, totalmente tipado.
Código fuente en GitHubDescargar (.zip)Ejemplo: FlaskEjemplo: FastAPI
pip install receivifyimport os
from receivify import Receivify
rcv = Receivify(
"https://receivify.io",
os.environ["RECEIVIFY_API_KEY"],
webhook_secrets=[os.environ["RECEIVIFY_WEBHOOK_SECRET"]],
)invoice = rcv.create_invoice(
amount_fiat="25.00",
currency="USD",
asset="btc",
reference=f"order-{order.id}",
idempotency_key=f"order-{order.id}",
)
return redirect(invoice.checkout_url) # Invoice is a dataclass — attribute accessfrom receivify import money
address = invoice.address
amount = money.format_amount(invoice.amount_expected, 8) # '0.00123456'
uri = invoice.payment_uri # BIP-21, for the QR code
expires = invoice.expires_at
# Python ints are arbitrary-precision, so int() on a base-unit string is exact.
paid = int(invoice.amount_received) >= int(invoice.amount_expected)from receivify import SIGNATURE_HEADER, SignatureVerificationError, WebhookPayloadError
@app.post("/webhooks/receivify")
def webhook():
try:
# parse_webhook verifies AND decodes; verify_webhook returns a bool.
event = rcv.parse_webhook(
request.get_data(), # RAW bytes, not request.json
request.headers.get(SIGNATURE_HEADER),
)
except (SignatureVerificationError, WebhookPayloadError):
return "", 400 # bad signature, stale timestamp, or bad JSON
if event.event == "invoice.paid": # WebhookEvent is a dataclass
fulfil(event.invoice.reference)
return "", 200Un archivo, sin dependencias. Instálelo con Composer o copie Receivify.php en cualquier proyecto. PHP 7.4+.
Código fuente en GitHubDescargar (.zip)Ejemplo: LaravelEjemplo: Plain PHP
composer config repositories.receivify vcs https://github.com/receivify/receivify-php
composer require receivify/receivifyrequire __DIR__ . '/vendor/autoload.php';
$rcv = new Receivify('https://receivify.io', getenv('RECEIVIFY_API_KEY'), [
'webhook_secrets' => array_filter([
getenv('RECEIVIFY_WEBHOOK_SECRET'),
getenv('RECEIVIFY_WEBHOOK_SECRET_PREVIOUS'),
]),
'timeout' => 30,
]);$invoice = $rcv->createInvoice([
'amount_fiat' => '25.00',
'currency' => 'USD',
'asset' => 'btc',
'reference' => 'order-' . $order->id,
], ['idempotency_key' => 'order-' . $order->id]);
header('Location: ' . $invoice['checkout_url']);$address = $invoice['address'];
$amount = Receivify::fromBaseUnits($invoice['amount_expected'], 8); // '0.00123456'
$uri = $invoice['payment_uri']; // BIP-21, for the QR code
$expires = $invoice['expires_at'];
// bcmath: exact comparison of two integer strings, no float anywhere.
$paid = bccomp($invoice['amount_received'], $invoice['amount_expected']) >= 0;$raw = file_get_contents('php://input');
$sig = $_SERVER['HTTP_X_RECEIVIFY_SIGNATURE'] ?? '';
try {
// parseWebhook verifies AND decodes; verifyWebhook returns a bool.
$event = $rcv->parseWebhook($raw, $sig);
} catch (ReceivifyException $e) { // bad signature, stale timestamp, or bad JSON
http_response_code(400);
exit;
}
if ($event['event'] === 'invoice.paid') {
fulfil($event['data']['reference']);
}
http_response_code(200);.NET 8, compatible con tipos nullable, un único HttpClient compartido. Thread-safe.
Código fuente en GitHubDescargar (.zip)Ejemplo: ASP.NET Core minimal API
# From the download or a clone of the SDK repository:
dotnet add reference receivify-csharp/src/Receivify/Receivify.csprojusing Receivify;
var client = new ReceivifyClient(
apiUrl: "https://receivify.io",
apiKey: Environment.GetEnvironmentVariable("RECEIVIFY_API_KEY"),
options: new ReceivifyClientOptions
{
WebhookSecrets = new[] { Environment.GetEnvironmentVariable("RECEIVIFY_WEBHOOK_SECRET") },
});var invoice = await client.CreateInvoiceAsync(
new InvoiceCreateRequest
{
AmountFiat = "25.00",
Currency = "USD",
Asset = "btc",
Reference = $"order-{order.Id}",
},
new RequestOptions { IdempotencyKey = $"order-{order.Id}" });
return Redirect(invoice.CheckoutUrl);var address = invoice.Address;
var amount = Money.Format(invoice.AmountExpected, 8); // "0.00123456"
var uri = invoice.PaymentUri; // BIP-21, for the QR code
var expires = invoice.ExpiresAt;
bool paid = Money.Compare(invoice.AmountReceived, invoice.AmountExpected) >= 0;[HttpPost("/webhooks/receivify")]
public async Task<IActionResult> Webhook()
{
using var reader = new StreamReader(Request.Body);
var raw = await reader.ReadToEndAsync();
WebhookEvent evt;
try
{
// ParseWebhook verifies AND deserialises; VerifyWebhook returns a bool.
evt = client.ParseWebhook(raw, Request.Headers["X-Receivify-Signature"]);
}
catch (ReceivifyWebhookException)
{
return BadRequest();
}
// Data is raw JSON; AsInvoiceData() types it for invoice.*, sweep.sent and test.
if (evt.Event == "invoice.paid") Fulfil(evt.AsInvoiceData()?.Reference);
return Ok();
}Solo biblioteca estándar, compatible con context, errores tipados que puede comprobar con errors.Is. Go 1.21+.
go get github.com/receivify/receivify-sdks/[email protected]import receivify "github.com/receivify/receivify-sdks/go"
client, err := receivify.NewClient(
os.Getenv("RECEIVIFY_URL"),
os.Getenv("RECEIVIFY_API_KEY"),
receivify.WithWebhookSecrets(os.Getenv("RECEIVIFY_WEBHOOK_SECRET")),
)
if err != nil {
log.Fatal(err)
}inv, err := client.CreateInvoice(r.Context(), &receivify.CreateInvoiceParams{
AmountFiat: "25.00",
Currency: "USD",
Asset: "btc", // or Asset: "usdc", Chain: "base"
Reference: "order-" + orderID,
}, receivify.RequestOptions{IdempotencyKey: "order-" + orderID})
if err != nil {
http.Error(w, "could not create invoice", http.StatusBadGateway)
return
}
http.Redirect(w, r, inv.CheckoutURL, http.StatusSeeOther)http.HandleFunc("/webhooks/receivify", func(w http.ResponseWriter, r *http.Request) {
raw, err := io.ReadAll(http.MaxBytesReader(w, r.Body, 1<<20))
if err != nil {
http.Error(w, "bad body", http.StatusBadRequest)
return
}
event, err := client.ParseWebhook(raw, r.Header.Get(receivify.SignatureHeader))
if err != nil {
http.Error(w, "invalid signature", http.StatusBadRequest)
return
}
if event.Event == receivify.EventInvoicePaid {
data, _ := event.InvoiceData()
fulfil(data.Reference)
}
w.WriteHeader(http.StatusOK)
})Sin dependencias en tiempo de ejecución. Rails, Sinatra o Ruby puro. Ruby 2.7+.
# Build and install it from the SDK repository:
git clone https://github.com/receivify/receivify-sdks.git
cd receivify-sdks/ruby && gem build receivify.gemspec && gem install ./receivify-1.1.0.gemrequire "receivify"
RECEIVIFY = Receivify::Client.new(
api_url: ENV.fetch("RECEIVIFY_URL", "https://receivify.io"),
api_key: ENV.fetch("RECEIVIFY_API_KEY"),
webhook_secrets: [ENV.fetch("RECEIVIFY_WEBHOOK_SECRET")]
)invoice = RECEIVIFY.create_invoice(
amount_fiat: "25.00",
currency: "USD",
asset: "btc", # or asset: "usdc", chain: "base"
reference: "order-#{order.id}",
idempotency_key: "order-#{order.id}"
)
redirect_to invoice.checkout_url, allow_other_host: trueclass ReceivifyWebhooksController < ActionController::Base
skip_forgery_protection
def create
event = RECEIVIFY.parse_webhook(request.raw_post, request.headers["X-Receivify-Signature"])
fulfil(event.data["reference"]) if event.event == "invoice.paid"
head :ok
rescue Receivify::SignatureVerificationError
head :bad_request
end
endJava 11+, sin dependencias, builders en todo. Funciona desde Kotlin tal cual.
# Build it once into ~/.m2 from the SDK repository:
git clone https://github.com/receivify/receivify-sdks.git
cd receivify-sdks/java && mvn -q install
# then depend on io.receivify:receivify-java:1.1.0import io.receivify.*;
import java.util.List;
ReceivifyClient client = ReceivifyClient.builder()
.apiUrl(System.getenv("RECEIVIFY_URL"))
.apiKey(System.getenv("RECEIVIFY_API_KEY"))
.webhookSecrets(List.of(System.getenv("RECEIVIFY_WEBHOOK_SECRET")))
.build();Invoice invoice = client.createInvoice(
CreateInvoiceParams.builder()
.amountFiat("25.00").currency("USD")
.asset("btc") // or .asset("usdc").chain("base")
.reference("order-" + orderId)
.build(),
RequestOptions.idempotencyKey("order-" + orderId));
response.sendRedirect(invoice.getCheckoutUrl());@PostMapping(value = "/webhooks/receivify", consumes = "application/json")
public ResponseEntity<String> handle(
@RequestBody byte[] rawBody,
@RequestHeader(value = "X-Receivify-Signature", required = false) String signature) {
WebhookEvent event;
try {
event = Webhooks.parse(rawBody, signature, secrets);
} catch (SignatureVerificationException e) {
return ResponseEntity.status(400).body("bad signature");
}
if (EventNames.INVOICE_PAID.equals(event.getEvent())) {
fulfil(event.getInvoiceData().getReference());
}
return ResponseEntity.ok("ok");
}Cliente bloqueante con transporte intercambiable; intégrelo en axum, actix o una CLI. Rust 1.70+.
cargo add receivify --git https://github.com/receivify/receivify-sdksuse receivify::{Client, CreateInvoice, RequestOptions};
let client = Client::builder(std::env::var("RECEIVIFY_URL")?)
.api_key(std::env::var("RECEIVIFY_API_KEY")?)
.webhook_secrets(vec![std::env::var("RECEIVIFY_WEBHOOK_SECRET")?])
.build()?;let invoice = client.create_invoice(
&CreateInvoice {
amount_fiat: Some("25.00".into()),
currency: Some("USD".into()),
asset: Some("btc".into()), // or "usdc" with chain: Some("base".into())
reference: Some(format!("order-{order_id}")),
..Default::default()
},
Some(&RequestOptions::idempotency_key(format!("order-{order_id}"))),
)?;
// send the customer to invoice.checkout_urlasync fn receivify_webhook(State(client): State<Client>, headers: HeaderMap, body: Bytes) -> StatusCode {
let signature = headers.get("x-receivify-signature").and_then(|v| v.to_str().ok()).unwrap_or("");
let Ok(event) = client.parse_webhook(&body, signature) else {
return StatusCode::BAD_REQUEST;
};
if event.event == "invoice.paid" {
if let Ok(data) = event.invoice_data() {
fulfil(data.reference);
}
}
StatusCode::OK
}C++17, header-first, CMake. libcurl y OpenSSL son las únicas dependencias externas.
add_subdirectory(receivify-cpp)
target_link_libraries(app PRIVATE receivify)#include <receivify/receivify.hpp>
#include <cstdlib>
receivify::ClientOptions options;
options.webhook_secrets = { std::getenv("RECEIVIFY_WEBHOOK_SECRET") };
auto client = receivify::make_client(
"https://receivify.io",
std::getenv("RECEIVIFY_API_KEY"),
options);receivify::RequestOptions opts;
opts.idempotency_key = "order-" + std::to_string(order.id);
auto invoice = client.create_invoice(receivify::Json::object({
{"amount_fiat", receivify::Json("25.00")},
{"currency", receivify::Json("USD")},
{"asset", receivify::Json("btc")},
{"reference", receivify::Json("order-" + std::to_string(order.id))},
}), opts);
redirect(invoice.checkout_url);const auto& address = invoice.address;
const auto amount = receivify::units::format_units(invoice.amount_expected, 8);
const auto& uri = invoice.payment_uri; // std::optional — BIP-21, for the QR code
const auto& expires = invoice.expires_at;
bool paid = receivify::units::compare_amounts(
invoice.amount_received, invoice.amount_expected) >= 0;// verify_webhook returns a bool; parse_webhook returns the envelope.
if (!client.verify_webhook(raw_body, signature_header)) {
respond(400);
return;
}
const auto event = client.parse_webhook(raw_body, signature_header);
if (event.event == "invoice.paid") {
// event.data is raw Json; type it before reading fields.
const auto data = receivify::InvoiceEventData::from_json(event.data);
fulfil(data.reference.value_or(data.id));
}
respond(200);HTTP directo. Cada SDK anterior es una capa fina sobre exactamente estas llamadas.
curl https://receivify.io/llms-full.txtcurl -X POST https://receivify.io/api/v1/invoices \
-H "Authorization: Bearer $RECEIVIFY_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1234" \
-d '{
"amount_fiat": "25.00",
"currency": "USD",
"asset": "btc",
"reference": "order-1234"
}'{
"id": "b1f2…",
"status": "pending",
"address": "bc1q…",
"asset": "btc",
"amount_expected": "123456",
"amount_received": "0",
"amount_fiat": "25.00",
"fiat_currency": "USD",
"payment_uri": "bitcoin:bc1q…?amount=0.00123456",
"checkout_url": "https://receivify.io/pay/b1f2…",
"expires_at": "2026-01-01T12:00:00.000Z"
}curl https://receivify.io/api/v1/invoices/b1f2… \
-H "Authorization: Bearer $RECEIVIFY_API_KEY"# x-receivify-signature: t=1735689600,v1=9f86d0…
# signed payload is exactly: <t> + "." + <raw request body>
printf '%s' "$T.$RAW_BODY" \
| openssl dgst -sha256 -hmac "$RECEIVIFY_WEBHOOK_SECRET"Una pequeña librería entre tu código y la API.
Tu código llama al SDK, el SDK llama a la API de Receivify y, cuando la factura se paga, vuelve un webhook firmado que el mismo SDK verifica con una sola llamada.
¿Tiene una tienda? Instale un plugin.
Cada uno es una implementación completa con verificación HMAC de webhooks, el mismo contrato que los SDK anteriores, sin que usted tenga que escribir nada.
WooCommerce
WordPress · suba el ZIP en Plugins → Añadir nuevo
OpenCart
OpenCart 3.0.x · copie upload/ sobre la raíz de la tienda
Magento 2
Magento Open Source 2.4 · app/code/Receivify
PrestaShop
PrestaShop 8 · Módulos → Subir un módulo
Empieza con una tienda que ya funciona.
Cada SDK tiene una pequeña tienda de ejemplo en el repositorio receivify-sdks.
node-express
- .env.exampleTu clave de API y secreto de webhook
- orders.jsActualiza el pedido: solo el webhook lo marca pagado
- package.jsonEl SDK de receivify
- server.jsRutas de compra, redirección de pago y webhook
- // Receivify + Express: a complete, tiny shop.
- //
- // GET / product page with a "Pay with crypto" form
- // POST /checkout creates the order + a Receivify invoice, redirects to
- // checkout
- // GET /orders/:id order status page (where the customer comes back to)
- // POST /webhooks/receivify Receivify tells us what happened; the ONLY place an order is
- // marked paid
- //
- // Run: cp .env.example .env (fill it in) -> npm install -> npm start
- import express from 'express'
- import { Receivify, ReceivifyApiError, ReceivifyWebhookError, SIGNATURE_HEADER } from 'receivify'
- import { createOrder, getOrder, updateOrder } from './orders.js'
Preguntas sobre los SDK
¿Qué lenguajes tienen un SDK oficial?
Node.js, Python, PHP, Go, C#, Ruby, Java (y Kotlin), Rust y C++. También hay recetas listas para Express y Next.js, y cualquier otro lenguaje puede llamar directamente a la API REST.
¿Los SDK son gratuitos y de código abierto?
Sí. Cada SDK es gratuito, tiene licencia MIT y está publicado en GitHub, para que pueda leer, bifurcar y auditar el código que instala.
¿Necesito un SDK para aceptar pagos en cripto?
No. Un SDK le ahorra escribir usted mismo lo delicado, como la verificación de firmas de webhooks y las claves de idempotencia. Cualquier lenguaje con un cliente HTTP puede usar la API directamente.
¿Dónde están publicados los SDK?
Módulos de npm, PyPI y Go para Node.js, Python y Go. Los demás SDK se instalan directamente desde su repositorio de GitHub: cada tarjeta y cada guía muestra el comando exacto.
¿Cómo verifico webhooks con un SDK?
Pase el cuerpo original de la petición y la cabecera de firma al ayudante de webhooks del SDK. Comprueba la firma HMAC y devuelve el evento decodificado, o falla para que pueda responder 400.
¿Puede un agente de programación con IA crear la integración por mí?
Sí. Apúntelo a /llms-full.txt: toda la API en un solo documento Markdown, generado a partir del mismo contrato OpenAPI que siguen los SDK.
¿Le queda alguna pregunta? Preguntar en el chat · Ver todas las preguntas
Empiece a aceptar cripto hoy.
Cree una cuenta gratuita, añada la dirección de su billetera y reciba su primer pago en minutos.