Track Custom Billing & Checkout Revenue with the Payments REST API
Send payment events from any custom billing system, crypto checkout, or internal database to DataOwl via our REST Payments API.
Using Stripe, Polar, Paddle or Dodo Payments? You don't need this: connect your provider and payments arrive on their own.
When a payment succeeds, send it to the Payment API.
1. Create a website key
Create a website key in Settings → Revenue → Other (or Settings → API). It's shown once: store it on your server as DATASENSE_API_KEY and never put it in browser code.
2. Keep the visit with the order
app/api/checkout/route.js
import { cookies } from "next/headers"
export async function POST() {
const cookieStore = await cookies()
const visit = {
datasense_visitor_id: cookieStore.get("datasense_vid")?.value,
datasense_session_id: cookieStore.get("datasense_sid")?.value,
}
// Keep the visit with the order, then send it with the payment
await db.orders.update(orderId, visit)
}3. Report the payment
api/webhook.js
await fetch("https://usedataowl.com/api/v1/payments", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.DATASENSE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
amount: 29.99, // major units, not cents
currency: "USD", // converted into your reporting currency
transaction_id: payment.id, // makes retries safe
datasense_session_id: order.datasense_session_id,
datasense_visitor_id: order.datasense_visitor_id,
customer_id: payment.customer, // optional: renewals follow the customer
email: payment.email, // optional: matches datasense("payment", { email })
renewal: false, // true for subscription renewals
// refunded: true, // send again with this for a refund
}),
})Amounts in any currency are converted into your reporting currency. To remove a test charge, delete the payment.