> ## Documentation Index
> Fetch the complete documentation index at: https://help.revgems.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Track Payments

> How to send payment messages to RevGems

## Stripe Payments

If you're using Stripe, you can simply install the RevGems App into your Stripe Account as described in the [Setup Guide](https://app.revgems.com/tracking/setup/payments). Once you've done so, charges processed by Stripe will appear in your [Message Log](https://app.revgems.com/tracking/messages?q%5Bmessage_id_or_anonymous_id_or_user_id_or_account_id_or_ip_or_properties_or_context_or_authentication_or_account_hash_cont%5D=\&q%5Bmessage_type_eq%5D=payment\&q%5Btest_mode_eq%5D=\&button=) with type <code>payment</code>.

## Other Payment Processors

You can track payments from all other platforms (PayPal, Chargebee, etc) by sending a <code>payment</code> message to the Tracking API. To do this you'll need your [Push Key Secret](https://app.revgems.com/tracking/push_keys) from your RevGems dashboard. When you make payment requests to the Tracking API, the payments will appear in your [Message Log](https://app.revgems.com/tracking/messages?q%5Bmessage_id_or_anonymous_id_or_user_id_or_account_id_or_ip_or_properties_or_context_or_authentication_or_account_hash_cont%5D=\&q%5Bmessage_type_eq%5D=payment\&q%5Btest_mode_eq%5D=\&button=) with type <code>payment</code>.

<ul>
  <li><strong>API Endpoint:</strong> <code>[https://t.revgems.com/messages](https://t.revgems.com/messages)</code></li>
  <li><strong>Method:</strong> <code>POST</code></li>
</ul>

### Request Headers

Requests made to this endpoint must have the following request headers.

<ParamField header="Authorization" required>
  Your Push Key Secret provided as a Bearer token.
  See [Authentication](/tracking-api/server/authentication) for details.
</ParamField>

<ParamField header="Content-Type" required>
  Must be `application/json`
</ParamField>

### Required Parameters

Requests made to this endpoint must have the following parameters in the JSON request body.

<ParamField body="message_id" type="string" required>
  An arbitrary string identifier that functions as an [idempotency key](https://en.wikipedia.org/wiki/Idempotence).
  Used to prevent the same message from being inadvertantly processed multiple times. We recommend using the payments unique ID in your own database or external payment process for this value.

  <strong>Example:</strong> Imagine a scenario where your payments are sent to RevGems on a background job. If the API request succeeds but the job fails for another reason, the job may be automatically retried in your system — possibly many times. As long as the same <code>message\_id</code> is sent, RevGems will only track the payment once, regardless of how many times the request is sent.
</ParamField>

<ParamField body="account_id" type="string" required>
  The Account ID in your system that the payment is associated with. This must be the same ID you pass when [tracking accounts](https://app.revgems.com/tracking/setup/accounts).
</ParamField>

<ParamField body="type" type="string" required>
  Must be the literal value <code>"payment"</code>.
</ParamField>

<ParamField body="properties.amount_cents" type="integer" required>
  Amount collected by this payment. Must be a positive integer representing the amount in the smallest currency unit (e.g., 100 cents to charge \$1.00 USD).
  For example, if the payment amount is \$245.99, pass <code>24599</code>.
</ParamField>

<ParamField body="properties.currency" type="string" required>
  The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code in which `amount_cents` is denominated (USD, EUR, etc).
</ParamField>

Here's an example request body using only the required parameters:

```json theme={null}
{
  "message_id": "payment-ABCD-DEFG",
  "accountId": "42",
  "type": "payment",
  "properties": {
    "amount_cents": 12300,
    "currency": "USD"
  }
}
```

### Optional Parameters

The following parameters may optionally be in the JSON request body.

<ParamField body="properties.id" type="string">
  The ID of the payment in your own database or external payment processor.
</ParamField>

<ParamField body="properties.description" type="string">
  A short description of the payment.
</ParamField>

Here's an example request body using the optional parameters:

```json theme={null}
{
  "message_id": "payment-ABCD-DEFG",
  "accountId": "42",
  "type": "payment",
  "properties": {
    "amount_cents": 12300,
    "currency": "USD",
    "id": "payment-ABCD-DEFG",
    "description": "Premium Subscription Renewal"
  }
}
```

### Example Request

Here's an example of a complete request using cURL:

```shell theme={null}
curl -X POST 'https://t.revgems.com/messages' \
  --header 'Content-Type: application/json' \
  --data-raw $'{
  "message_id": "payment-ABCD-DEFG",
  "accountId": "42",
  "type": "payment",
  "properties": {
    "amount_cents": 12300,
    "currency": "USD",
    "id": "payment-ABCD-DEFG",
    "description": "Premium Subscription Renewal"
  }
}' \
  --header 'Authorization: Bearer push_secret_test_ABCD1234'
```

### Example Responses

```json 201 Created theme={null}
{
  "success": true,
  "authentication": "secret",
  "test_mode": true
}
```

```json 401 Unauthorized theme={null}
{
  "success": false,
  "errors": [
    "Invalid push key."
  ]
}
```

```json 422 Unprocessable Content theme={null}
{
  "success": false,
  "errors": [
    "Properties `amount_cents` is not an integer",
    "Properties `currency` is not a valid currency"
  ]
}
```
