Involved in the biosynthesis of caffeine (PubMed:17401201, PubMed:17434991). Catalyzes the conversion of 7-methylxanthine to caffeine, likely via theobromine as an intermediate (PubMed:17434991). S-adenosyl-L-methionine + theobromine = caffeine + H(+) + S-adenosyl-L-homocysteine 1,7-dimethylxanthine + S-adenosyl-L-methionine = caffeine + H(+) + S-adenosyl-L-homocysteine 7-methylxanthine + S-adenosyl-L-methionine = H(+) + S-adenosyl-L-homocysteine + theobromine Binds 1 Mg(2+) ion per subunit. Alkaloid biosynthesis. Homodimer. Mainly expressed in leaves and fruits (grains) (PubMed:25249475, PubMed:25190796). Also present, at lower levels, in roots, stamens and pistils (PubMed:25190796). In leaves, mostly expressed in young tissues (PubMed:25249475). In fruits, highly expressed in green grains but fades out as they are yellowing to disappear in red mature grains (PubMed:25249475, PubMed:25190796). Belongs to the methyltransferase superfamily. Type-7 methyltransferase family.