Automating Affinity and Keap takes no code: a ready-made scenario does the routine for you.
Starts when: Daily Schedule
Then: Get Customer Data
Check: Is It Their Birthday?
If yes: Generate Discount Code
Then: Send Birthday Email
You can launch this Affinity + Keap integration in Scriptera: describe the task in plain words — the scenario is built, launched and monitored for you.