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
requiredapplication/json
tracking_idstring
Optional tracking identifier for the transaction
Example:
3B01WYNUGO1R4G20affiliate_idinteger
ID of the affiliate who generated this transaction (defaults to 1 if not provided)
Example:
42basket_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 Standeanstringrequired
Product EAN code (mandatory, cannot be empty)
Example:
1234567890123pricenumber (float)required
Item price (mandatory, must be >= 0)
Example:
49.99quantityintegerrequired
Item quantity (mandatory, must be >= 1)
Example:
2commission_ratenumber (float)required
Commission rate percentage (mandatory, must be >= 0.0)
Example:
10.0statusstringenum: pending, accepted, rejected
Item status (optional, defaults to pending)
Example:
pendingResponses
201
Transaction created successfully
application/jsonstatusstring
Example:
successmessagestring
Example:
Transaction created successfullydataobject
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/jsonExample:
{
"status": "error",
"message": "Not authenticated or insufficient permissions"
}
404
Merchant or Affiliate not found
application/json
500
Internal server error
application/jsonstatusstring
Example:
errormessagestring
Example:
Failed to create transactionerrorstring
Example:
Database connection failed