# Payment at the Location Account and Loyalty (Various Methods)

As a response, information about the [Sale operation](#sale-operation) is returned

Endpoint: POST /locations/{location_id}/sale/{document_id}/payment
Version: 1.0.0
Security: BearerPartnerUser

## Security:

  - `BearerPartnerUser` (unknown)
    http bearer Bearer {PartnerToken}, User {UserToken}

## Path parameters:

  - `document_id` (number, required)
    Document ID

  - `location_id` (number, required)
    Location ID

## Header parameters:

  - `Accept` (string, required)
    e.g. application/vnd.api.v2+json

  - `Content-Type` (string, required)
    application/json

  - `Authorization` (string, required)
    Bearer partner_token, User user_token

## Request body:

  - `application/json` (unknown)
    1. In the case of payment by a gift card, if the user does not have the "Pay by gift card and membership without code" right, the "number" (string) parameter containing the gift card code must also be passed in the request body.
2. In the case of payment by membership, if the user does not have the "Pay by gift card and membership without code" right, the "number" (string) parameter containing the membership code must also be passed in the request body.
3. The `prepay_hold` method (payload `method.slug = prepay_hold`, `method.hold_id = <state.deposit_holds[].id>`) confirms and applies an active prepaid hold associated with the visit. Use the corresponding entry returned in `payment_methods`; it has `is_applicable=true`, `is_partial_allowed=false`, and supplies the full `applicable_amount`. When every Service item of the Visit is covered by the hold, paying with a Membership instead returns HTTP 400 with the localized message "Membership cannot be used to pay a visit with a prepaid hold" in `meta.message`.

## Request fields (application/json):

  - `payment` (object)
    Object containing the payment method

  - `payment.method` (object)
    Payment method

  - `payment.method.slug` (string)
    Payment method type

  - `payment.method.account_id` (integer)
    Checkout ID

  - `payment.amount` (number)
    Payment amount

## Response 200:

  - `200` (unknown)
    OK

## Response 200 fields (application/json):

  - `success` (boolean)
    Execution success status (true)

  - `data` (object)
    Object with data

  - `data.state` (object)

  - `data.state.items` (array)

  - `data.state.items.id` (number)
    Selling unit ID

  - `data.state.items.type` (string)
    Type (service/product)

  - `data.state.items.title` (string)
    Name

  - `data.state.items.amount` (number)
    Quantity

  - `data.state.items.default_cost_per_unit` (number)
    Unit price

  - `data.state.items.default_cost_total` (number)
    Total default price

  - `data.state.items.client_discount_percent` (number)
    Discount percentage

  - `data.state.items.cost_to_pay_total` (number)
    Payable price

  - `data.state.loyalty_transactions` (array)
    Loyalty Payment Transaction

  - `data.state.loyalty_transactions.id` (integer)
    Loyalty transaction ID

  - `data.state.loyalty_transactions.document_id` (integer)
    Document ID

  - `data.state.loyalty_transactions.sale_item_id` (integer)
    Sold unit ID

  - `data.state.loyalty_transactions.sale_item_type` (string)
    Unit sold type

  - `data.state.loyalty_transactions.amount` (number)
    Transaction amount

  - `data.state.loyalty_transactions.type_id` (integer)
    Transaction type identifier

  - `data.state.loyalty_transactions.created_at` (string)
    date of creation

  - `data.state.loyalty_transactions.deposit_transaction_id` (integer)
    Transaction ID (depends on type)

  - `data.state.loyalty_transactions.chain` (object)
    Location chain

  - `data.state.loyalty_transactions.chain.id` (integer)
    Location chain ID

  - `data.state.loyalty_transactions.chain.title` (string)
    Location chain name

  - `data.state.loyalty_transactions.type` (object)
    Transaction type

  - `data.state.loyalty_transactions.type.id` (integer)
    Transaction type ID

  - `data.state.loyalty_transactions.type.title` (string)
    Transaction type name

  - `data.state.loyalty_transactions.deposit` (object)
    Withdrawal from personal account

  - `data.state.loyalty_transactions.deposit.id` (integer)
    Personal account ID

  - `data.state.loyalty_transactions.deposit.balance` (number)
    Available personal account balance

  - `data.state.loyalty_transactions.deposit.reserved_balance` (number)
    Amount currently reserved by active holds

  - `data.state.loyalty_transactions.deposit.type` (object)
    Client account type

  - `data.state.loyalty_transactions.deposit.type.id` (integer)
    Client account type identifier

  - `data.state.loyalty_transactions.deposit.type.title` (string)
    Name of the client account

  - `data.state.payment_transactions` (array)
    Cashier payment transaction

  - `data.state.payment_transactions.id` (integer)
    Payment transaction ID

  - `data.state.payment_transactions.document_id` (integer)
    Document ID

  - `data.state.payment_transactions.sale_item_id` (integer)
    Sold unit ID

  - `data.state.payment_transactions.sale_item_type` (string)
    Unit sold type

  - `data.state.payment_transactions.expense_id` (integer)
    Payment Item ID

  - `data.state.payment_transactions.account_id` (integer)
    Checkout ID

  - `data.state.payment_transactions.created_at` (string)
    date of creation

  - `data.state.payment_transactions.account` (object)
    Location account

  - `data.state.payment_transactions.account.id` (integer)
    Checkout ID

  - `data.state.payment_transactions.account.title` (string)
    Location account name

  - `data.state.payment_transactions.account.is_cash` (boolean)
    Is the payment in cash

  - `data.state.payment_transactions.account.is_default` (boolean)
    Is the checkout by default

  - `data.state.payment_transactions.expense` (object)
    Payment Article

  - `data.state.payment_transactions.expense.id` (integer)
    Payment Item ID

  - `data.state.payment_transactions.expense.title` (string)
    Name of payment item

  - `data.state.deposit_holds` (array)
    Prepaid holds associated with the sale. Returned when state.deposit_holds is included; completed holds remain visible with their current status.

  - `data.state.deposit_holds.id` (integer)
    Prepaid hold ID

  - `data.state.deposit_holds.deposit_id` (integer)
    Personal account ID

  - `data.state.deposit_holds.payment_policy_snapshot_id` (integer)
    Payment policy snapshot ID

  - `data.state.deposit_holds.amount_minor` (integer)
    Held amount in minor currency units

  - `data.state.deposit_holds.amount_major` (number)
    Held amount in major currency units

  - `data.state.deposit_holds.currency_iso` (string)
    ISO 4217 currency code

  - `data.state.deposit_holds.status` (string)
    Current hold status
    Enum: "active", "credited", "confirmed", "charged", "released"

  - `data.state.deposit_holds.date_create` (string)
    Hold creation date

  - `data.kkm_state` (object)

  - `data.kkm_state.last_operation_type` (integer)
    Type of last KKM operation

  - `data.kkm_state.transactions` (array)
    KKM transaction

  - `data.kkm_state.transactions.id` (integer)
    KKM transaction ID

  - `data.kkm_state.transactions.document_id` (integer)
    Document ID

  - `data.kkm_state.transactions.print_date` (string)
    Check printing date

  - `data.kkm_state.transactions.printed_count` (integer)

  - `data.kkm_state.transactions.sum` (integer)

  - `data.kkm_state.transactions.type` (object)

  - `data.kkm_state.transactions.type.id` (integer)

  - `data.kkm_state.transactions.type.title` (string)

  - `data.kkm_state.transactions.status` (object)
    Receipt printing status

  - `data.kkm_state.transactions.status.id` (integer)
    Status ID

  - `data.kkm_state.transactions.status.title` (string)
    Status name

  - `data.kkm_state.transactions.document` (object)

  - `data.kkm_state.transactions.document.id` (integer)
    Document ID

  - `data.kkm_state.transactions.document.type` (integer)
    Document Type

  - `data.kkm_state.transactions.document.type_title` (string)
    Document type name

  - `data.kkm_state.transactions.cashier` (object)
    Cashier

  - `data.kkm_state.transactions.cashier.id` (integer)
    team member ID

  - `data.kkm_state.transactions.cashier.name` (string)
    team member name

  - `data.payment_methods` (array)

  - `data.payment_methods.slug` (string)
    Payment method type

  - `data.payment_methods.is_applicable` (boolean)
    Is it possible to use this method

  - `data.payment_methods.is_partial_allowed` (boolean)
    Whether the method may be used to pay only part of the remaining amount. Defaults to true; false means the method must cover the full applicable_amount in a single payment (e.g. prepay_hold).

  - `data.payment_methods.applicable_amount` (number)
    Possible amount accepted for payment

  - `data.payment_methods.applicable_count` (integer)
    Possible number of visits (in case of membership)

  - `data.payment_methods.applicable_value` (number)
    Applicable bonus (in the case of a loyalty program)

  - `data.payment_methods.hold_id` (integer)
    Prepaid hold ID, returned for the prepay_hold method

  - `data.payment_methods.account_id` (integer)
    Checkout ID (depends on slug)

  - `data.payment_methods.account` (object)
    Location account

  - `data.payment_methods.account.id` (integer)
    Checkout ID

  - `data.payment_methods.account.title` (string)
    Location account name

  - `data.payment_methods.account.is_cash` (boolean)
    Is the location account cash

  - `meta` (array)
    Metadata (empty array)

## Response 401:

  - `401` (unknown)
    Unauthorized

## Response 401 fields (application/json):

  - `success` (boolean)
    Response status.
    Example: false

  - `data` (object | null)
    Response data.
    Example: null

  - `meta` (object)
    Additional response data.

  - `meta.message` (string)
    Error message.
    Example: Authentication needed.

## Response 403:

  - `403` (unknown)
    Forbidden

## Response 403 fields (application/json):

  - `success` (boolean)
    Response status.
    Example: false

  - `data` (object | null)
    Response data.
    Example: null

  - `meta` (object)
    Additional response data.

  - `meta.message` (string)
    Error message.
    Example: Access denied.

## Response 404:

  - `404` (unknown)
    Not Found

## Response 404 fields (application/json):

  - `success` (boolean)
    Response status.
    Example: false

  - `data` (object | null)
    Response data.
    Example: null

  - `meta` (object | array)
    Additional response data (empty object or empty array)
    Example: {}

