Operations

Create operation

Perform operation in UDS. On success operation appears in operations list in UDS Admin and customer receives push notification about purchase.

Marketing policy

Depends on company discount policy (baseDiscountPolicy field) in company settings. Two values are supported:

  • APPLY_DISCOUNT — reduce the bill amount: the customer receives a discount in currency units at the rate specified in participant.discountRate;
  • CHARGE_SCORES — accrue bonus points: the customer receives bonus points at the rate specified in participant.cashbackRate.

Key points

  • Fields total and points should come from user input but cash field should be calculated using POST /operations/calc;
  • Customer will be identified with either promo code passed in parameter code or with participant uid in parameter participant -> uid or by participant's phone in parameter participant -> phone; Difference between them is that with participant -> uid or participant -> phone is not permitted to withdraw points; If given parameter is participant -> uid or participant -> phone then points must be equal to 0.0; Otherwise an error will occurs with code withdrawNotPermitted;
  • Only one identifier parameter must be passed: either code, or phone, or uid;
  • All numbers should be scaled to two decimal places with "round half up" method. The points value can only be rounded down;
  • cash, points and total fields MUST correlate with the "Discount method" setting in UDS;
  • The nonce field is a UUID-like string that can only be used once. It is recommended to prevent duplicate operations in case of request retries;
  • The externalId field is the cashier identifier. It may only contain Latin letters, digits, and the characters _, -;
  • If the register sends cashier information, enable the Staff module in UDS to view detailed cashier data;
  • If UDS returns an error, do not finalize the payment in your system until the issue is corrected and a new request is sent successfully.

Errors

StatusError CodeDescription
400badRequestForm validation errors occurred. See JSON errors property for detailed information about errors.
400invalidChecksumGiven total, cash and points fields don't correlate with company marketing settings.
400 withdrawNotPermittedMethod was called with participant -> uid or participant -> phone parameter and points field doesn't equal to 0.0.
400insufficientFundsGiven points value greater than actual customer reward point balance.
400priceListOnlyCompany marketing settings forbid purchases with using reward points, except of price list operations.
400discountLimitExceedGiven points/total rate more than allowed by marketing settings.
400purchaseByPhoneDisabledTrying to make purchase by phone when it is disabled in company settings.
401unauthorizedInvalid company ID or API Key.
404notFoundCustomer related to given code or ID is not found.
404cashierNotFoundexternalCashierId is specified but cashier related to it is not found.
post/operations

Request body

codestring nullable

UDS promo-code.

noncestring nullable

Nonce for operation (UUID)

tagsTagId[] nullable

List of tag ids to be set to customer, null means no changes

Example request

{
  "tags": [
    1
  ]
}

Response

Operation

idinteger

Transaction ID in the UDS database.

dateCreatedstring date-time

Transaction date.

action'PURCHASE' required

Transaction type.

state'NORMAL' | 'CANCELED' | 'REVERSAL'

Transaction lifecycle status:

  • NORMAL — active transaction, loyalty benefits applied
  • CANCELED — transaction was canceled, no loyalty impact
  • REVERSAL — transaction was refunded, loyalty benefits reversed (points returned, cashback deducted)
pointsnumber

The amount of points which changed customer balance as a result of the operation.

A negative value means write-off of bonus points and a positive value means point accrual.

certificatePointsnumber nullable

Number of deducted certificate points.

receiptNumberstring nullable

Receipt number.

Changes