POST /merchants/{id}/transactions

Create a new transaction

Merchants

Description

Create a new transaction for a specific merchant.

Authentication Required: User must be authenticated and have the 'merchant' feature flag.

Authorization: Merchant users can only create transactions for their own merchant account.

Parameters

id integer path required
Merchant ID

Request Body

required

application/json

tracking_idstring
Optional tracking identifier for the transaction
Example: 3B01WYNUGO1R4G20
affiliate_idinteger
ID of the affiliate who generated this transaction (defaults to 1 if not provided)
Example: 42
basket_itemsarray [object]required
Array of items in the basket. The basket_price is automatically calculated from the sum of all item prices multiplied by quantities.
Example: [{"name":"Laptop Stand","ean":"1234567890123","price":49.99,"quantity":2,"commission_rate":10.0,"status":"pending"},{"name":"Wireless Mouse","ean":"9876543210987","price":80.0,"quantity":1,"commission_rate":12.5,"status":"pending"}]
namestring
Optional product name
Example: Laptop Stand
eanstringrequired
Product EAN code (mandatory, cannot be empty)
Example: 1234567890123
pricenumber (float)required
Item price (mandatory, must be >= 0)
Example: 49.99
quantityintegerrequired
Item quantity (mandatory, must be >= 1)
Example: 2
commission_ratenumber (float)required
Commission rate percentage (mandatory, must be >= 0.0)
Example: 10.0
statusstringenum: pending, accepted, rejected
Item status (optional, defaults to pending)
Example: pending

Responses

201 Transaction created successfully
application/json
statusstring
Example: success
messagestring
Example: Transaction created successfully
dataobject
Example:
{
  "status": "success",
  "message": "Transaction created successfully",
  "data": {
    "id": "9NJA3YVNGW8",
    "tracking_id": "3B01WYNUGO1R4G20",
    "basket_price": 129.99,
    "affiliate_id": 42,
    "merchant_id": 1,
    "status": "pending",
    "total_commission": 15.0,
    "reward": "pending",
    "created_at": "2024-12-01T10:00:00Z",
    "updated_at": "2024-12-01T10:00:00Z"
  }
}
400 Bad request - missing or invalid parameters
application/json
401 Authentication required
application/json
Example:
{
  "status": "error",
  "message": "Not authenticated or insufficient permissions"
}
404 Merchant or Affiliate not found
application/json
500 Internal server error
application/json
statusstring
Example: error
messagestring
Example: Failed to create transaction
errorstring
Example: Database connection failed