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
- Enable "Declared Stock" integration as described in here
- Register DECLARED_STOCK_REPLACEMENT_RESERVATION and DECLARED_STOCK_REPLACEMENT_PROVISION callbacks as described in here
- 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.
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:
Field | Type | Description |
---|---|---|
action | String | RESERVE indicates the Reservation request |
orderId | UUID v1 | Unique order ID for which replacement is requested |
auctionId | UUID v1 | Your auction (stock) ID the key is being replaced for |
keyId | UUID v1 | Your 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:
Field | Type | Description |
---|---|---|
action | String | RESERVE indicates the Reservation response |
orderId | UUID v1 | Unique order ID |
success | Boolean | Confirmation 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:
Field | Type | Description |
---|---|---|
action | String | PROVIDE indicates the Provision request |
orderId | UUID v1 | Unique order ID for which replacement is requested |
auctionId | UUID v1 | Your auction (stock) ID the key is being replaced for |
keyId | UUID v1 | Your 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.
Field | Type | Description |
---|---|---|
action | String | PROVIDE indicates the Provision response |
orderId | UUID v1 | Unique order ID |
success | Boolean | Indicates the successful provision |
auctions | [Auction] | A collection of your auctions in the order, see below |
Auction
fields:
Field | Type | Description |
---|---|---|
auctionId | UUID v1 | Auction 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:
Field | Type | Description |
---|---|---|
type | Enum | Either TEXT or IMAGE . Indicates the key format |
value | String | A plain-text or base64-encoded image |
filename | String | If 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.