Skip to main content

Working with vouchers

Centra Integration API allows management of vouchers, including reusable vouchers (gift certificates) whose remaining value changes over time as they're spent.

Working with reusable vouchers (gift certificates)

Reading original and remaining values for reusable vouchers is best done via the specific values for this found on type VoucherActionResult and parameter reusableValues.

warning

The paramsJSON field also contains values that look related, but these are no longer updated and may diverge from the real values found in reusableValues. Always use reusableValues, not paramsJSON, to read remaining values.

query voucher {
voucher(id: 727) {
actions {
id
result {
id
reusableValues {
pricelist {
id
}
remainingValue {
value
currency {
code
}
}
}
}
}
}
}

Setting/updating values on a reusable voucher is best done via the specific mutations for this, updateVoucherRemainingValue for vouchers and updateSubvouchersRemainingValue for subvouchers.

mutation updateRemainingValue {
updateVoucherRemainingValue(
input: {
action: {
setToValue: {
actionResult: { id: 5 }
pricelist: { id: 19 }
value: { value: 550, currencyIsoCode: "SEK" }
}
}
voucher: { id: 6 }
}
) {
userErrors {
message
}
userWarnings {
message
}
voucher {
actions {
id
result {
reusableValues {
pricelist {
id
}
remainingValue {
value
currency {
code
}
}
}
}
}
}
}
}