If you want the number of unique email domains with the same payment_id is that not simply a distinct query?
SELECT COUNT(DISTINCT("email_domain")) FROM "my_db"."autogen"."payment_attempts" WHERE time > now() - 14 GROUP BY time(1d), payment_id
If so that would simplify the TICKscript as all you need is that one query without the sub query.
I am not quite sure how to restructure the original query as I am not quite sure what its doing.
Could you share some example data so I can better understand?