Automate key replacements with "Declared Stock"

You can read more about "Declared Stock" feature here

In case your provided keys results in a customer ticket and resolution of it is key replacement - You can do it with declared stock

Key replacements with "Declared Stock" works almost the same way as key provision works with "Declared Stock"

Steps to enable key replacements through declared stock

  1. Enable "Declared Stock" integration as described in here
  2. Register DECLARED_STOCK_REPLACEMENT_RESERVATION and DECLARED_STOCK_REPLACEMENT_PROVISION callbacks as described in here
  3. Enable your "Declared Stock" key replacements integration as described here

Sequence diagram

Following sequence diagram displays the interaction between the Buyer, Eneba, and Merchant when using the "Declared Stock" key replacements feature. This example illustrates the successful communication between Eneba and Merchant when key replacement is made.

MerchantEnebaBuyerloop[3x timeout: 120s, sleep: 5s]Approves key replacementMakes one "Reservation" callbackSuccessfully reserves keysMakes the "Provision" callbackSuccessfully provides keyDelivers keyMerchantEnebaBuyer

Callback payloads

Reservation

The system will make one request with a payload below to the Reservation endpoint with a 120s timeout.

In case of error, the buyer will receive a refund instead of key replacement

Callback fields:

FieldTypeDescription
actionStringRESERVE indicates the Reservation request
orderIdUUID v1Unique order ID for which replacement is requested
auctionIdUUID v1Your auction (stock) ID the key is being replaced for
keyIdUUID v1Your key ID that is being replaced

Example of "Declared Stock" key replacement reservation callback request:

{
  "action": "RESERVE",
  "orderId": "6ce660cc-4abe-11ed-b878-0242ac120002",
  "auctionId": "6ce664fa-4abe-11ed-b878-0242ac120002",
  "keyId": "6ce660cc-4abe-11ed-b878-0242ac120002"
}
Response

By successfully responding (HTTP status 200) to the Reservation request with the payload structure below, you indicate that you can fully fulfill the reservation.

Response fields:

FieldTypeDescription
actionStringRESERVE indicates the Reservation response
orderIdUUID v1Unique order ID
successBooleanConfirmation that the reservation was successful

Example:

{
  "action": "RESERVE",
  "orderId": "6ce660cc-4abe-11ed-b878-0242ac120002",
  "success": true
}

Provision

The system will make three attempts with a 5s sleep interval and 120s timeout for you to respond. In case of final failure, the buyer will receive a refund instead of key replacement. Example:

  • Request 1: Fails immediately
  • Wait time: 5 seconds
  • Request 2: Fails after timeout (120 seconds)
  • Wait time: 5 seconds
  • Request 3: Fails
  • Buyer received a refund
Request

Callback fields:

FieldTypeDescription
actionStringPROVIDE indicates the Provision request
orderIdUUID v1Unique order ID for which replacement is requested
auctionIdUUID v1Your auction (stock) ID the key is being replaced for
keyIdUUID v1Your key ID that is being replaced

Example:

{
  "action": "PROVIDE",
  "orderId": "6ce660cc-4abe-11ed-b878-0242ac120002",
  "auctionId": "6ce664fa-4abe-11ed-b878-0242ac120002",
  "keyId": "6ce660cc-4abe-11ed-b878-0242ac120002"
}
Response

The following structure will be expected in the successful (HTTP status 200) response to the Provision request.

FieldTypeDescription
actionStringPROVIDE indicates the Provision response
orderIdUUID v1Unique order ID
successBooleanIndicates the successful provision
auctions[Auction]A collection of your auctions in the order, see below

Auction fields:

FieldTypeDescription
auctionIdUUID v1Auction ID the keys are provided for
keys[Key]A collection of keys, see below

PROVISION response for key replacement must always have only one auction key

Key fields:

FieldTypeDescription
typeEnumEither TEXT or IMAGE. Indicates the key format
valueStringA plain-text or base64-encoded image
filenameStringIf type: IMAGE - indicates the file name for an image

Example of text key provision:

{
  "action": "PROVIDE",
  "orderId": "6ce660cc-4abe-11ed-b878-0242ac120002",
  "success": true,
  "auctions": [
    {
      "auctionId": "6ce664fa-4abe-11ed-b878-0242ac120002",
      "keys": [
        {
          "type": "TEXT",
          "value": "QS8ND-G0W76-BTSQO-WAAJA-6LCD3"
        }
      ]
    }
  ]
}

Example of image key provision:

{
  "action": "PROVIDE",
  "orderId": "6ce660cc-4abe-11ed-b878-0242ac120002",
  "success": true,
  "auctions": [
    {
      "auctionId": "6ce664fa-4abe-11ed-b878-0242ac120002",
      "keys": [
        {
          "type": "IMAGE",
          "value": "HwcqeNQhr1EfdJoHxko+ymjzBta/ipV6r9sigAAAABJRU5ErkJggg==",
          "filename": "Half-Life 3"
        }
      ]
    }
  ]
}
  • Image type keys provided in Provision response must be of the following types: jpg, jpeg, png.
  • Only raw base64 is supported. Please remove any HTML/CSS attributes, like data:image/png;base64,

Tracking your "Declared Stock" errors

You will find the declared stock dashboard useful for debugging errors and setting up your integration.

You can also get the errors we have found while calling your "Declared Stock" integration with the P_declaredStockResult query.

Copyright 2024 Eneba. All Rights Reserved. JSC “Helis play”, Gyneju St. 4-333, Vilnius, the Republic of Lithuania