Create Transaction
Creates a transaction (payment or refund) associated with a booking.
/api/integration/transactionRequest
curl -X POST "https://dev.integration.cl.sodtrack-shared.sodtrack.com/api/integration/transaction" \
-H "Authorization: Bearer $SODTRACK_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "string", // Possible values: payment | refund
"extra_info": "string", // ej. "Payment from client in store"
"reference": "string", // external reference, like: invoice number, credit note number or others.
"booking": {
"type": "string", // bookingReference | bookingId
"value": "string", // value of the type
"variant": {
"type": "string",
"value": "string"
}
},
"transactionDetail": {
"variant": {
"quantityAdjustment": "number", //Optional. Only applies to refund type of the transaction. A decimal number greater than 0 less or equals than the total quantity of the variant of the booking
"amount": "number" //decimal number greater than 0 less or equals than the total price of the variant
},
"addon": [
{
"type": "string", // Possible values: addonId | addonReference
"value": "string", // value of the type
"quantityAdjustment": "number", //Optional. Only applies to refund type of the transaction. A decimal number greater than 0 less or equals than the total quantity of the addon of the booking
"amount": "number" //decimal number greater than 0 less or equals than the total price of the addon
}
]
},
"cancelBookingIfTotallyRefunded": "boolean" // If transaction type is refund and is a total refund, the booking will be canceled after the refund creation.
}'Base URL: https://dev.integration.cl.sodtrack-shared.sodtrack.com · other environments
Request body
{
"type": "string", // Possible values: payment | refund
"extra_info": "string", // ej. "Payment from client in store"
"reference": "string", // external reference, like: invoice number, credit note number or others.
"booking": {
"type": "string", // bookingReference | bookingId
"value": "string", // value of the type
"variant": {
"type": "string",
"value": "string"
}
},
"transactionDetail": {
"variant": {
"quantityAdjustment": "number", //Optional. Only applies to refund type of the transaction. A decimal number greater than 0 less or equals than the total quantity of the variant of the booking
"amount": "number" //decimal number greater than 0 less or equals than the total price of the variant
},
"addon": [
{
"type": "string", // Possible values: addonId | addonReference
"value": "string", // value of the type
"quantityAdjustment": "number", //Optional. Only applies to refund type of the transaction. A decimal number greater than 0 less or equals than the total quantity of the addon of the booking
"amount": "number" //decimal number greater than 0 less or equals than the total price of the addon
}
]
},
"cancelBookingIfTotallyRefunded": "boolean" // If transaction type is refund and is a total refund, the booking will be canceled after the refund creation.
}Purpose
Creates a transaction (payment or refund) associated with a booking. Optionally breaks down amounts by variant (main service) and addons. The shopping cart is determined from the specified booking.
Field Definitions
Booking
| Field | Type | Required | Description |
|---|---|---|---|
| booking | object | ✅ | Object that identifies the booking |
| booking.type | enum | ✅ | Identifier: bookingId, bookingReference, shoppingCartId, subscriptionId |
| booking.value | string | ✅ | Value by type (numeric ID or reference) |
| booking.variant | object | ❌ | Variant information to specify if booking referene is used |
| booking.variant.type | string | ✅ | Identifier: variantId or variantSku |
| booking.variant.value | string | ✅ | Value by type (numeric ID or reference) |
Transaction Detail
| Field | Type | Required | Description |
|---|---|---|---|
| transactionDetail | object | ❌ | Breakdown by variant and addons |
| transactionDetail.variant | object | ✅ | Variant details |
| transactionDetail.variant.ammount | number | ✅ | Variant amount |
| transactionDetail.variant.quantityAdjustment | number | ❌ | Variant quantity adjustment |
| transactionDetail.addon | array | ❌ | Addons array |
| transactionDetail.addon[].type | enum | ✅ | addonId or addonReference |
| transactionDetail.addon[].value | string | ✅ | Addon ID or SKU |
| transactionDetail.addon[].ammount | number | ❌ | Addon amount |
| transactionDetail.addon[].quantityAdjustment | number | ❌ | Addon quantity adjustment |
Metadata
| Field | Type | Required | Description |
|---|---|---|---|
| type | enum | ✅ | Transaction type: payment or refund |
| reference | string | ❌ | External reference |
| extraInfo | string | ❌ | Additional info |
| cancelBookingIfTotallyRefunded | boolean | ❌ | Defines cancel policy for total refund of a booking |
Response Example
{
"id": 346,
"type": "refund",
"reference": "NR-00000000003",
"amount": 5000
}
Response Fields
| Field | Type | Description |
|---|---|---|
id | number | Unique Sodtrack transaction ID. |
type | number | Transaction type: payment or refund |
reference | string | External reference |
ammount | number | Total transaction amount |
Error Responses
| HTTP Status | Error | Description |
|---|---|---|
400 Bad Request | InvalidParameters | One or more required fields are missing or invalid. |
401 Unauthorized | — | Authentication token missing or expired. |
403 Forbidden | — | The API key or origin is not authorized. |
500 Internal Server Error | — | Unexpected server error. Contact Sodtrack support. |
Business Logic Notes
-
If transaction type is refund and cancelBookingIfTotallyRefunded is set to true:
- If the refund is for the total payment amount of the booking, it will cancel the booking after the transaction creation.
-
The quantityAdjustment only works for refund type transactions with the following constraints:
-
The quantityAdjustment for the booking's variant, has always to be less than the quantity of the booking.
-
The quantityAdjustmen for an addon has to be equal or less than the quantity of that addon in the booking.
-
-
Constraints:
-
A payment cannot exeed the amount that remains unpaid for each element; variant or addon.
-
In order to post a refund, there should exist a previous payment transaction.
- The amount of a refund cannot exceed the already payed amount for each instance.
-
The quantity of a booking variant cannot be 0 as a result of the transaction.
-
The quantity of a booking addon can go to 0, eliminating the relation between addon and booking.
-