Sign up

Revenue

Payments API

On this page

Use this for a custom payment system. Stripe and RevenueCat connectors already send their supported payments, so choose one path per purchase.

Send a payment

  1. Set your secret key on the server

    Store the site secret as METRICRAVEN_SECRET_KEY. Call this API only from your backend.

  2. POST the payment after it succeeds

    terminal
    curl --request POST 'https://metricraven.com/api/v1/payments' \
      --header "Authorization: Bearer $METRICRAVEN_SECRET_KEY" \
      --header 'Content-Type: application/json' \
      --data '{
      "amount": 29,
      "currency": "USD",
      "transaction_id": "order_123",
      "visitor_id": "0123456789abcdef0123456789abcdef",
      "user_id": "user_42",
      "plan": "pro",
      "renewal": false
    }'

    amount is in major currency units: 29 means $29, not 29 cents. Include the three-letter currency, a unique transaction ID, and a visitor ID or a previously identified user ID for attribution.

Verify it works

The payment appears in Revenue when you select its currency. Repeat deliveries with the same transaction ID don't add a second payment.

Record a refund

Send the original transaction ID with refunded: true and the cumulative amount refunded. For example, a $10 refund followed by another $5 refund means sending amount: 15 on the second request.

Partial refund example
curl --request POST 'https://metricraven.com/api/v1/payments' \
  --header "Authorization: Bearer $METRICRAVEN_SECRET_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "amount": 10,
  "currency": "USD",
  "transaction_id": "order_123",
  "refunded": true
}'

Details

  • The visitor ID comes from window.analytics.getVisitorId() in the buyer's browser; pass it through your checkout to your backend.