API reference / Analytics
Record a payment
Records a payment from a provider that Troopy does not read, or from your own webhook. Troopy ties it to the visitor who paid. It uses the visitor's id (the troopy_visitor_id cookie), or else the earlier payments of the customer, or else the email that the visitor gave to troopy("payment"). Each transactionId counts once. If Troopy cannot tie a payment to a visit yet, the payment shows as unattributed. Send it again later to try again. With refund, it records money that went back: the chart shows it beside the revenue, and revenue stays as it was.
/api/v1/analytics/paymentsOther ways to call it
troopy analytics payments recordIdempotency-Key header. A retry with the same key gets the first answer back, and the operation runs one time.Body
application/jsontransactionId*stringThe payment's id in your billing system: it counts once
At least 1 characters · At most 255 characters
amountnumberIn major units, like 29.99. 0 for a free trial. Give amount or amountMinor
At least 0 · At most 1000000000
amountMinorintegerIn minor units, like 2999 for 29.99 USD, as most webhooks send it. Give amount or amountMinor
At least 0 · At most 100000000000
currency*stringISO 4217, like USD
visitorstringThe visitor's id, as the script or SDK sent it
emailstringThe customer's email
At most 320 characters · email
namestringThe name of the customer. It names a visitor that identify did not name
At least 1 characters · At most 100 characters
customerstringThe customer's id in your billing system: a renewal finds its visitor by it
At least 1 characters · At most 255 characters
renewalbooleanA subscription that renews. It also counts as Subscription renewed
trialbooleanThe start of a free trial. true when amount is 0
refundbooleanMoney that went back to the customer, not a payment. The amount is what went back. Its transactionId is the id of the refund
atstringWhen the customer paid, or when the money went back. Without it, Troopy uses now
date-time
providerenum<string>For a payment that Troopy also reads from a connected provider. Give the provider, and the id of the payment as Troopy reads it (Lemon Squeezy: order_<id>). Then the payment counts one time, and the visitor of your webhook ties it to a visit
stripelemonsqueezypolarpaddle
Response
200 · application/jsondata*object1 properties
status*enum<string>Recorded on a visitor, already recorded, or not tied to a visit yet
recordedknownunattributed