Pastry cream is a simple starch-stabilized variant of a custard. Traditionally it’s vanilla flavored, with some sugar and faffing around with tempering your eggs and such, but it turns out that’s not actually necessary.
350g liquid (~12 fluid oz)
50g egg yolk (~3 yolks)
22g corn starch (I dunno how much, weight it)
Optional: sugar (75g gives a reasonable sweetness most of the time)
Cook over low heat until the mixture is at least 170F/77C. The cornstarch starts gelling at around 140F/60C, and the eggs set somewhere between 149-158F (65C-70C), but you can’t stop there as the egg yolks have enzymes in them that will over the course of a few hours eat the gel networks. Those enzymes are neutralized at the higher temperature. The starch itself gets stronger the hotter you cook it, up to about 209F/98C so going warmer is OK as long as it doesn’t burn. (Which it won’t, there’s a lot of water in here)
You do need to heat things relatively slowly, so the eggs gel rather than curdle, but honestly you can toss everything into a pot and go, which is what I do.
The liquid in pastry cream is traditionally milk, which is fine, but you can use anything! I have made pastry cream with apple cider, hard cider, orange juice, jameson’s whiskey, lemon juice, maple syrup, and a very hoppy Harpoon IPA that beer people surprisingly liked. Neither acid nor alcohol will markedly affect the gelling properties of your pastry cream, though if you use something particularly sugary (like orange juice or apple cider) you may want to cut down on the sugar, and if you use something very sweet like maple syrup you’ll want to do some math to figure out how much water’s actually in the syrup and adjust the amounts accordingly. (For maple syrup I’d recommend about 200g water or milk and 150g of syrup and cut out the extra sugar, but I haven’t tested this particularly well)
The amount of sugar in your pastry cream won’t affect gelling much, though it does bind some of the free water and if you leave out the sugar you may want to cut back on the liquid amounts a bit. Alternately you can add a lot more sugar if you want (if, for example, you’re using straight lemon juice for the liquid without neutralizing it) and things will still be fine.
In all cases you have some leeway here. If you have more liquid relative to your thickeners then the pastry cream will be looser, while more thickeners and it’ll be stiffer. Sometimes thicker is better, for example if you’re going to use it in diplomat cream you might want to thicken the pastry cream a bit.
The gel network generally is fully set once the cream cools, and it won’t naturally reform on its own. This includes breaking the network because you stirred it — stirring your cream once cooled is… ok but it’ll get looser, so if you’re going to have to do this you should start with a stiffer cream.
If for some reason you have not heated the cream enough, and after sitting overnight in your fridge it’s turned to soup, you can save the pastry cream by re-heating it above 170F/77C. Microwaves work well here (short bursts of power and stir; stirring is fine for hot cream), ask me how I know. This isn’t much use if you’ve already filled things with the cream and it’s turned to goop, though.
If you want a clear and strong flavor in your pastry cream — apple, orange, cranberry, whiskey, or whatever — I highly recommend doing it by using a liquid of the appropriate flavor rather than trying to add the flavor extract to regular vanilla pastry cream. Doing it this way gets you a more distinct flavor and nicer cream.
This is also, BTW, an excellent way to get strongly flavored buttercream frosting — make German Buttercream with properly flavored pastry cream. Mmm.