As these are not registration keys AND they still have to be validated, you can simply generate a string of random numbers and characters, perhaps with some dashes between them.
Here is a simple routine that will spit out strings in the format of xxxx-xxxx-xxxx, with 256^6 combinations (281 trillion+) combinations.
function generateRandomCode() {
return substr(chunk_split(bin2hex(random_bytes(6)), 4, '-'), 0, -1);
}
Very low chance you will generate duplicate codes, but you still want your DB to have a unique index on gift_code, and recover should you try and insert a duplicate.
Anything like this would work, as again these are not registration codes, are unique, and would be linked to a particular user.