Create Transaction

Creates a transaction (payment or refund) associated with a booking.

POST/api/integration/transaction

Request

cURL
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

application/json
{
    "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

FieldTypeRequiredDescription
bookingobjectObject that identifies the booking
booking.typeenumIdentifier: bookingId, bookingReference, shoppingCartId, subscriptionId
booking.valuestringValue by type (numeric ID or reference)
booking.variantobjectVariant information to specify if booking referene is used
booking.variant.typestringIdentifier: variantId or variantSku
booking.variant.valuestringValue by type (numeric ID or reference)

Transaction Detail

FieldTypeRequiredDescription
transactionDetailobjectBreakdown by variant and addons
transactionDetail.variantobjectVariant details
transactionDetail.variant.ammountnumberVariant amount
transactionDetail.variant.quantityAdjustmentnumberVariant quantity adjustment
transactionDetail.addonarrayAddons array
transactionDetail.addon[].typeenumaddonId or addonReference
transactionDetail.addon[].valuestringAddon ID or SKU
transactionDetail.addon[].ammountnumberAddon amount
transactionDetail.addon[].quantityAdjustmentnumberAddon quantity adjustment

Metadata

FieldTypeRequiredDescription
typeenumTransaction type: payment or refund
referencestringExternal reference
extraInfostringAdditional info
cancelBookingIfTotallyRefundedbooleanDefines cancel policy for total refund of a booking

Response Example

json
{
    "id": 346,
    "type": "refund",
    "reference": "NR-00000000003",
    "amount": 5000
}

Response Fields

FieldTypeDescription
idnumberUnique Sodtrack transaction ID.
typenumberTransaction type: payment or refund
referencestringExternal reference
ammountnumberTotal transaction amount

Error Responses

HTTP StatusErrorDescription
400 Bad RequestInvalidParametersOne or more required fields are missing or invalid.
401 UnauthorizedAuthentication token missing or expired.
403 ForbiddenThe API key or origin is not authorized.
500 Internal Server ErrorUnexpected 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.