API Reference - Post Transactions

Link: https://support.brilliantdirectories.com/support/solutions/articles/12000108103

← Back to API Reference | Getting Started

Post Transactions

Post Transactions record purchases of post-related items such as individual posts or post limit increases. Each record ties a billing invoice to a specific user action, tracking what was purchased and whether the associated credit has been applied.

Model name in URL: post_transactions — DB table: post_transactions

The Post Transaction Object

FieldTypeDescription
post_transaction_idintegerUnique transaction ID (primary key, read-only)
invoice_idintegerThe billing invoice ID (from the billing system) associated with this transaction
bought_byintegerThe user_id of the member who made this purchase required on create
related_idintegerForeign key referencing the purchased item; the meaning depends on payment_action (EG a post type ID or post ID)
credit_usedintegerWhether this transaction credit has been applied toward a post limit: 1 yes, 0 no
payment_actionstringDescribes what was purchased; common values: buy_post (individual post purchase), buy_limit (post limit increase)
createddatetimeDate and time the transaction was recorded

List Post Transactions

GET /api/v2/post_transactions/get

Example Request

Copy
curl -X GET "https://www.yourdomain.com/api/v2/post_transactions/get?limit=25" \
  -H "X-Api-Key: your-api-key-here"

Example Response

Copy
{
  "status": "success",
  "message": [
    {
      "post_transaction_id": "1",
      "invoice_id": "2150000042",
      "bought_by": "45",
      "related_id": "3",
      "credit_used": "0",
      "payment_action": "buy_post",
      "created": "2024-03-15 09:22:10"
    },
    {
      "post_transaction_id": "2",
      "invoice_id": "2150000083",
      "bought_by": "112",
      "related_id": "7",
      "credit_used": "1",
      "payment_action": "buy_limit",
      "created": "2024-04-02 14:08:55"
    }
  ],
  "total": "11",
  "current_page": 1,
  "total_pages": 1,
  "next_page": ""
}

Retrieve a Post Transaction

GET /api/v2/post_transactions/get/{post_transaction_id}

Example Request

Copy
curl -X GET "https://www.yourdomain.com/api/v2/post_transactions/get/1" \
  -H "X-Api-Key: your-api-key-here"

Example Response

Copy
{
  "status": "success",
  "message": [
    {
      "post_transaction_id": "1",
      "invoice_id": "2150000042",
      "bought_by": "45",
      "related_id": "3",
      "credit_used": "0",
      "payment_action": "buy_post",
      "created": "2024-03-15 09:22:10"
    }
  ],
  "total": "11",
  "current_page": 1,
  "total_pages": 1
}

Create a Post Transaction

POST /api/v2/post_transactions/create

Example Request

Copy
curl -X POST "https://www.yourdomain.com/api/v2/post_transactions/create" \
  -H "X-Api-Key: your-api-key-here" \
  -d "invoice_id=2150000150" \
  -d "bought_by=45" \
  -d "related_id=3" \
  -d "credit_used=0" \
  -d "payment_action=buy_post"

Example Response

Copy
{
  "status": "success",
  "message": {
    "post_transaction_id": "12",
    "invoice_id": "2150000150",
    "bought_by": "45",
    "related_id": "3",
    "credit_used": "0",
    "payment_action": "buy_post",
    "created": null
  }
}

Update a Post Transaction

PUT /api/v2/post_transactions/update

Example Request

Copy
curl -X PUT "https://www.yourdomain.com/api/v2/post_transactions/update" \
  -H "X-Api-Key: your-api-key-here" \
  -d "post_transaction_id=12" \
  -d "credit_used=1"

Example Response

Copy
{
  "status": "success",
  "message": {
    "post_transaction_id": "12",
    "invoice_id": "2150000150",
    "bought_by": "45",
    "related_id": "3",
    "credit_used": "1",
    "payment_action": "buy_post",
    "created": "2024-05-10 11:00:00"
  }
}

Delete a Post Transaction

DELETE /api/v2/post_transactions/delete

Example Request

Copy
curl -X DELETE "https://www.yourdomain.com/api/v2/post_transactions/delete" \
  -H "X-Api-Key: your-api-key-here" \
  -d "post_transaction_id=12"

Example Response

Copy
{
  "status": "success",
  "message": "post_transactions record was deleted"
}