1.12.2 • Published 6 months ago

ticketengine-checkout-sdk v1.12.2

Weekly downloads
47
License
ISC
Repository
github
Last release
6 months ago

Ticket Engine Checkout SDK

JavaScript SDK checkout web client for TicketEngine. Can be used to create your own shopping cart implementation.

Installation

npm install ticketengine-checkout-sdk

Setup

Create an new instance of the cart.

const options = {};
const cart = new Cart(options);

Cart options

OptionDescription
salesChannelId*Uuid of the sales channel
registerId*Uuid of the register
customerIdUuid of the customer
preferredLanguageCodeISO 639-1 language code
clientIdOauth client id
clientSecretOauth client secret
scopeOauth requested scopes
authUrlUrl of the auth api, production url is default
adminApiUrlUrl of the admin api, production url is default
graphApiUrlUrl of the graph api, production url is default
  • Required options

Usage

Methods

login

cart.login(username, password)

isTokenExpired

cart.isTokenExpired() Returns true if oauth token is expired

getEvent

cart.getEvent(eventId)

Returns
{
    "id": "dfe2243c-a2b6-11eb-bac0-0242ac12001c",
    "eventManagerId": "de567e74-a2b6-11eb-b2ec-0242ac12001c",
    "name": "My event",
    "description": "Lorum ipsum",
    "location": "Some place",
    "start": "2025-08-06T18:00:00+00:00",
    "end": "2025-08-06T20:00:00+00:00",
    "totalCapacity": 220,
    "availableCapacity": 201
}

getEventPrices

cart.getEventPrices(eventId, customerId, salesChannelId, preferredLanguageCode)

Parameters
ParameterDescription
eventId*Uuid of the event
customerIdUuid of the customer
salesChannelIdUuid of the sales channel
preferredLanguageCodeISO 639-1 language code
Returns
[
    {
        "conditionId": "e2d4283e-a2b6-11eb-ab10-0242ac12001c",
        "price": 10,
        "currency": {
            "code": "EUR",
            "name": "Euro",
            "exponent": 2,
            "symbol": "€"
        },
        "tax": 0.57,
        "description": "Regular",
        "conditionPath": ["e2d87074-a2b6-11eb-a5fc-0242ac12001c", "e2d77282-a2b6-11eb-a91d-0242ac12001c", "e2d4283e-a2b6-11eb-ab10-0242ac12001c"],
        "limit": null,
        "accessDefinition": {
            "id": "e2b2cf68-a2b6-11eb-b369-0242ac12001c",
            "name": "Regular access",
            "description": null,
            "capacityLocations": ["root.regular"]
        }
    }
]

getProductDefinition

cart.getProductDefinition(productDefinitionId)

Returns
{
    "id": "f5088f54-a2b6-11eb-a791-0242ac12001b",
    "name": "My product",
    "description": "Lorum ipsum"
}

getProductPrices

cart.getProductPrices(productDefinitionId, customerId, salesChannelId, preferredLanguageCode)

Parameters
ParameterDescription
productDefinitionId*Uuid of the product definition
customerIdUuid of the customer
salesChannelIdUuid of the sales channel
preferredLanguageCodeISO 639-1 language code
Returns
{
    "conditionId": "f51bcc04-a2b6-11eb-b9e3-0242ac12001b",
    "price": 50.0,
    "currency": {
        "code": "EUR",
        "name": "Euro",
        "exponent": 2,
        "symbol": "€"
    },
    "tax": 0.0,
    "description": "",
    "conditionPath": ["f522991c-a2b6-11eb-a688-0242ac12001b", "f520f580-a2b6-11eb-b358-0242ac12001b", "f51bcc04-a2b6-11eb-b9e3-0242ac12001b"],
    "limit": null,
    "productDefinition": {
        "id": "f5088f54-a2b6-11eb-a791-0242ac12001b",
        "name": "My product",
        "description": "Lorum ipsum"
    }
}

getCustomer

cart.getCustomer(customerId)

Returns
{
    "id": "db20cd40-a2b6-11eb-a0f0-0242ac12001a",
    "firstName": "John",
    "lastName": "Doe",
    "fullName": "John Doe",
    "sortName": "Doe, John",
    "birthDate": null,
    "email": null,
    "gender": "male",
    "tags": null
}

getOrder

cart.getOrder(orderId, validator, retryPolicy, forceReload)

Parameters
ParameterDescription
orderId*Uuid of the order
validatorInstance of class that implements the OrderValidator interface. See order validators.
retryPolicyArray of values in milliseconds to wait until retry. Continue retry until validator returns true. Value is shifted from array and then wait value amount of milliseconds before next try.
forceReloadIf set to true force to call the api and not get cached order from localstorage.
Returns
{
    "id": "0580948e-a2b8-11eb-ba91-0242ac12001d",
    "status": "completed",
    "number": "2105D12C2433",
    "email": null,
    "customer": {
        "id": "25f74082-a2b8-11eb-b81b-0242ac12001a",
        "fullName": null
    },
    "paymentStatus": "paid",
    "paymentUrl": null,
    "payments": [],
    "totalPrice": 0,
    "totalTax": 0,
    "createDate": "2021-04-21T15:41:21+00:00",
    "expiresOn": null,
    "tokens": [],
    "requiredPayments": [],
    "requiredLoyaltyCardPayments": [],
    "lineItems": [
        {
            "id": "db416b0c-a2b8-11eb-98a2-0242ac12001d",
            "type": "access",
            "status": "completed",
            "price": 0,
            "tax": 0,
            "currency": {
                "code": "EUR",
                "name": "Euro",
                "exponent": 2,
                "symbol": "€"
            },
            "limit": 1,
            "name": "Regular",
            "capacityLocationPath": "venue-1.floor",
            "requestedConditionPath": ["348b0d32-a2b7-11eb-806b-0242ac12001c", "348b090e-a2b7-11eb-82b3-0242ac12001c", "348b0170-a2b7-11eb-ac8f-0242ac12001c"],
            "accessId": "dc703436-a2b8-11eb-aa4a-0242ac12001c",
            "event": {
                "id": "dfe2243c-a2b6-11eb-bac0-0242ac12001c",
                "eventManagerId": "de567e74-a2b6-11eb-b2ec-0242ac12001c",
                "name": "My event",
                "location": null,
                "start": "2025-08-06T18:00:00+00:00",
                "end": "2025-08-06T20:00:00+00:00",
                "availableCapacity": 201
            }
        }
    ]
}

createOrder

cart.createOrder() Create a new empty order.

getOrderId

cart.getOrderId() Returns order id from cache order in localstorage.

cancelOrder

cart.cancelOrder(orderId) Cancel order. If no orderId is supplied cancel order cached in localstorage.

cancelReservation

cart.cancelReservation(orderId) Cancel reserved order. If no orderId is supplied cancel order cached in localstorage.

addItems

cart.addItems(items)

Parameters
[
  {
    "eventManagerId": "de567e74-a2b6-11eb-b2ec-0242ac12001c",
    "eventId": "dfe2243c-a2b6-11eb-bac0-0242ac12001c",
    "accessDefinitionId": "e2b2cf68-a2b6-11eb-b369-0242ac12001c",
    "requestedConditionPath": ["348b0d32-a2b7-11eb-806b-0242ac12001c", "348b090e-a2b7-11eb-82b3-0242ac12001c", "348b0170-a2b7-11eb-ac8f-0242ac12001c"]
  },
  {
    "productDefinitionId": "f5088f54-a2b6-11eb-a791-0242ac12001b",
    "requestedConditionPath": ["348b0d32-a2b7-11eb-806b-0242ac12001c", "348b090e-a2b7-11eb-82b3-0242ac12001c", "348b0170-a2b7-11eb-ac8f-0242ac12001c"]
  }
]

removeItems

cart.removeItems(items)

Parameters
[
  {
    "orderLineItemId": "ac088f54-a2b6-11eb-a791-0242ac12001b"
  }
]

changeItems

cart.changeItems(addItems, removeItems)

Parameters
ParameterDescription
addItemssee cart.addItems
removeItemssee cart.removeItems

getItemCount

cart.getItemCount() Returns the number of items in cart

addToken

cart.addToken(token) Add a coupon code to cached order in localstorage.

Parameters
ParameterDescription
tokenCoupon code

clearOrder

cart.clearOrder() Removes cached order from localstorage, does not cancel order.

Order validators

Order validators implement the OrderValidator interface. The validate method returns true if the order is valid.

export interface OrderValidator {
    validate(order: Order): Boolean;
}

List validators

  • IsCompleted
  • IsTimeout
  • IsCanceled
  • IsPending
  • IsCheckedOut
  • IsReserved
  • IsPaid
  • IsEmpty
  • IsInFinalState
  • IsProcessingPayment
  • HasCustomer
  • HasToken(token: string)
  • HasStatus(status: OrderStatus[])
  • HasPaymentWithCurrencyCode(currencyCodes: string[])
  • HasItemsWithStatus(status: LineItemStatus[])
  • ItemsHaveStatus(orderLineIds: string[], status: LineItemStatus)
  • NeedsPaymentWithCurrency(currencyCode: string)
  • NeedsPaymentWithIsoCurrency
  • NeedsPaymentWithCustomCurrency
  • NeedsLoyaltyCardPayment
  • CanReserve
  • CanCheckout
  • CanPay
  • CanPayOnline
  • ValidateItemsStatus(reservedOrderLineIds: string[], removedOrderLineIds: string[], completedOrderLineIds: string[])
1.11.1

6 months ago

1.12.2

6 months ago

1.12.1

6 months ago

1.12.0

6 months ago

1.11.0

6 months ago

1.10.0

9 months ago

1.9.1

12 months ago

1.9.0

1 year ago

1.8.3

3 years ago

1.8.2

3 years ago

1.8.1

3 years ago

1.8.0

3 years ago

1.7.6

3 years ago

1.7.5

3 years ago

1.7.4

3 years ago

1.7.3

3 years ago

1.7.2

3 years ago

1.7.1

3 years ago

1.7.0

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.5.0

3 years ago

1.4.9

3 years ago

1.4.8

3 years ago

1.4.7

3 years ago

1.4.6

3 years ago

1.4.5

3 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.11

3 years ago

1.3.9

3 years ago

1.3.8

3 years ago

1.3.10

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.16

3 years ago

1.2.17

3 years ago

1.2.18

3 years ago

1.2.15

3 years ago

1.2.13

3 years ago

1.2.14

3 years ago

1.2.12

4 years ago

1.2.10

4 years ago

1.2.11

4 years ago

1.2.9

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.13.0

4 years ago

0.12.8

4 years ago

0.12.7

4 years ago

0.12.6

4 years ago

0.12.5

4 years ago

0.12.4

4 years ago

0.12.3

4 years ago

0.12.0

4 years ago

0.12.1

4 years ago

0.12.2

4 years ago

0.11.14

4 years ago

0.11.13

4 years ago

0.11.12

4 years ago

0.11.11

4 years ago

0.11.10

4 years ago

0.11.7

4 years ago

0.11.5

4 years ago

0.11.4

4 years ago

0.11.3

4 years ago

0.11.2

4 years ago

0.11.1

4 years ago

0.11.0

4 years ago

0.10.2

4 years ago

0.10.3

4 years ago

0.10.1

4 years ago

0.10.0

4 years ago

0.9.0

4 years ago

0.8.0

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.4.8

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.7

4 years ago

0.4.6

4 years ago

0.5.0

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.8

4 years ago

0.2.5

4 years ago

0.1.10

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.4

4 years ago

0.1.8

4 years ago

0.1.9

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.2

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago