Vouchers

With vouchers you can allow ticket buyers to receive a reduction on their transaction by applying a randomly generated or custom defined code to their total order amount.

The voucher object

Required attributes

  • Name
    code
    Type
    string
    Description

    Code used to redeem the voucher

  • Name
    amount
    Type
    number
    Description

    The amount of the voucher in seller's currency. eg. 50.0 -> 50 EUR

  • Name
    createdAt
    Type
    string
    Description

    An ISO Timestamp indicating when the voucher was created.

  • Name
    updatedAt
    Type
    string
    Description

    An ISO Timestamp indicating when the voucher was last updated.

Optional attributes

  • Name
    validUntil
    Type
    string
    Description

    The date until this voucher can be redeemed.

  • Name
    sellerId
    Type
    string
    Description

    The ID of the seller of the voucher

  • Name
    transactionId
    Type
    string
    Description

    The ID of the transaction if the voucher was a result of a transaction

  • Name
    productId
    Type
    string
    Description

    The ID of the product if the voucher was a result of a product

  • Name
    refundId
    Type
    string
    Description

    The ID of the refund if the voucher was a result of a refund

  • Name
    customerId
    Type
    string
    Description

    The ID of the customer if the voucher was created for a specific customer

  • Name
    origin
    Type
    enum(default, shop, import, upgrade, refund)
    Description

    The origin of the voucher

Example

{
  "code": "string",
  "amount": 10.5,
  "createdAt": "2030-01-23T23:00:00.123Z",
  "updatedAt": "2030-01-23T23:00:00.123Z",
  "validUntil": "2030-01-23T23:00:00.123Z",
  "sellerId": "507f191e810c19729de860ea",
  "transactionId": "507f191e810c19729de860ea",
  "productId": "507f191e810c19729de860ea",
  "refundId": "507f191e810c19729de860ea",
  "customerId": "507f191e810c19729de860ea",
  "origin": "default"
}

POST/api/vouchers

Create a Voucher

Create a Voucher

Payload

Required attributes

  • Name
    amount
    Type
    number
    Description

    The amount of the voucher in seller's currency. eg. 50.0 -> 50 EUR

Optional attributes

  • Name
    code
    Type
    string
    Description

    The code used to redeem the voucher

  • Name
    validUntil
    Type
    string
    Description

    The date until the voucher can be redeemed.

Request

POST
/api/vouchers
const response = await fetch('https://vivenu.com/api/vouchers', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer {token}',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(  {
    "amount": 10.5,
    "code": "string",
    "validUntil": "2030-01-23T23:00:00.123Z"
  }),
})

const data = await response.json()

Response (201)

{
  "code": "string",
  "amount": 10.5,
  "createdAt": "2030-01-23T23:00:00.123Z",
  "updatedAt": "2030-01-23T23:00:00.123Z",
  "validUntil": "2030-01-23T23:00:00.123Z",
  "sellerId": "507f191e810c19729de860ea",
  "transactionId": "507f191e810c19729de860ea",
  "productId": "507f191e810c19729de860ea",
  "refundId": "507f191e810c19729de860ea",
  "customerId": "507f191e810c19729de860ea",
  "origin": "default"
}

GETPUBLIC/api/vouchers/:id/:code/info

Get Voucher by id and code

Get Voucher by id and code

Request

GET
/api/vouchers/:id/:code/info
const response = await fetch('https://vivenu.com/api/vouchers/507f191e810c19729de860ea/code/info', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer {token}',
  },
})

const data = await response.json()

Response (200)

{
  "displaySettings": {
    "disclaimer": "string",
    "pdfImage": "string"
  },
  "seller": {
    "name": "Example Name",
    "city": "string",
    "street": "string",
    "postal": "string",
    "taxRate": 10.5,
    "taxNo": "string",
    "currency": "string",
    "image": "string",
    "locationName": "string",
    "brandingSettings": {
      "customBrandingEnabled": true,
      "shopLogoUrl": "https://example.com",
      "eventLogo": "string",
      "mailLogo": "string",
      "customLogo": "string",
      "walletLogo": "string",
      "googleWalletLogo": "string",
      "walletBackgroundColor": "string",
      "walletForegroundColor": "string",
      "walletLabelColor": "string",
      "ticketRibbonImage": "string"
    },
    "documentSettings": {
      "image": "string",
      "invoice": {
        "footerColumns": [
          {
            "text": "string",
            "active": true
          }
        ]
      }
    }
  },
  "timezone": "2030-01-23T23:00:00.123Z",
  "useDocumentTemplate": true
}

PUT/api/vouchers/:id

Update a Voucher

Update a Voucher

Payload

Required attributes

  • Name
    amount
    Type
    number
    Description

    The amount of the voucher in seller's currency. eg. 50.0 -> 50 EUR

Optional attributes

  • Name
    validUntil
    Type
    string
    Description

    The date until the voucher can be redeemed. If no date is specified, the voucher has no expiration

Request

PUT
/api/vouchers/:id
const response = await fetch('https://vivenu.com/api/vouchers/507f191e810c19729de860ea', {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer {token}',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(  {
    "amount": 10.5,
    "validUntil": "2030-01-23T23:00:00.123Z"
  }),
})

const data = await response.json()

Response (200)

{
  "code": "string",
  "amount": 10.5,
  "createdAt": "2030-01-23T23:00:00.123Z",
  "updatedAt": "2030-01-23T23:00:00.123Z",
  "validUntil": "2030-01-23T23:00:00.123Z",
  "sellerId": "507f191e810c19729de860ea",
  "transactionId": "507f191e810c19729de860ea",
  "productId": "507f191e810c19729de860ea",
  "refundId": "507f191e810c19729de860ea",
  "customerId": "507f191e810c19729de860ea",
  "origin": "default"
}

GET/api/vouchers

Get all Vouchers

Get all Vouchers

Query parameters

Optional query parameters

  • Name
    top
    Type
    number
    Description
  • Name
    skip
    Type
    number
    Description
  • Name
    code
    Type
    string
    Description
  • Name
    transactionId
    Type
    string
    Description

Request

GET
/api/vouchers
const response = await fetch('https://vivenu.com/api/vouchers?top=10.5&skip=10.5&code=value&transactionId=507f191e810c19729de860ea', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer {token}',
  },
})

const data = await response.json()

Response (200)

{
  "docs": [],
  "total": 1
}

Was this page helpful?