Put the flour, icing sugar, cocoa powder, and salt in a bowl and mix together.
Preheat oven to 350°F / 180°C and line a baking sheet with parchment paper.
Melt the butter in the microwave and pour into the dry ingredients along with the vanilla extract.
Mix everything together until a smooth, thick paste is formed.
Knead the paste into a dough with your hands - just 3 or 4 times, don't overwork it.
Flatten the pastry onto the lined baking sheet, use a small rolling pin or just your hands to work it into a large flat circle, slightly larger than your pastry ring. Try to make it as flat as possible, but don't worry about the sides being neat as they will be cut off.
Bake for 10 minutes or until the top of the pastry no longer looks shiny.
Remove from the oven and immediately press the pastry ring into the pastry like a giant cookie cutter. Do not remove the pastry ring. If you are using a loose-bottomed cake pan instead of a pastry ring, see notes for instructions.
Make the Chocolate Custard
Put the eggs and egg yolks into a bowl and whisk together with the sugar. Whisk vigorously for about 30 seconds - the eggs should lighten slightly in color.
Add the cornstarch and salt and whisk until smooth.
Put the milk and the cream in a large saucepan and heat over medium heat.
Once the milk/cream mixture starts to get hot (steam is starting to rise from it), add a small amount to the egg/sugar mixture and whisk in. Then gradually add more, bit by bit, whisking as you go. Be sure not to add the hot milk too quickly as we are trying to slowly bring the eggs up to temperature to stop them from scrambling.
Once all the milk is incorporated, pour the whole mixture back into the saucepan and turn the heat down to medium-low. Whisk constantly until the the custard starts to boil, then keep whisking for 1-2 minutes until it thickens.
You'll know the custard is ready when you can coat the back of a spoon, run your finger through it and it leaves a line on the spoon.
Remove the custard from the heat, if you have gotten any lumps in the custard while cooking, you can pass it through a sieve to remove any lumps. If it looks smooth then go ahead to the next step.
Add the chopped chocolate to the hot custard and continue whisking until all the chocolate has melted and it is smooth and silky.
Make the Chocolate Flan
Your pastry ring should still be sitting in the chocolate pastry. Leave it there and break off all the outside excess pastry.
Lightly grease the inside of your pastry ring with butter.
Pour the chocolate custard into the pastry ring, on top of what should now be a perfect circle of pastry. Smooth out the top of the custard as much as possible using a palette knife.
Bake for 50 - 60 minutes. When it's done the outside will be set but the middle will still be very jiggly as it will continue to bake after it comes out of the oven.
Allow to cool on the countertop completely and then transfer to the fridge, covering in plastic wrap. Let it chill overnight. Do not attempt to cut into the flan before you have let it chill!
Once the flan has completely chilled, remove from the pastry ring. If it doesn't lift easily, try running a sharp knife around the outside of the flan, or even apply heat to the outside to soften it up a little
If you'd like the shiny finish, melt 1 tablespoon of jam in the microwave for 20 seconds and then brush a thin layer all over the flan with a pastry brush. It is traditional to use apricot jam, but I didn't have any so I used strawberry - you really don't taste the flavor of the jam so it's not important what kind you use.
Notes
If you don't have a pastry ring:The easiest way to make this chocolate flan recipe is with a pastry ring, but you can make it without. If you don't have one, you can use a loose-bottomed cake pan instead.If you are using a cake pan, you will need to use the pan as a guide to cut the pastry base out with a knife, then place the base inside the cake pan. When unmolding your flan, just push up from the bottom, rather than lifting it off.Testing when the flan is done - it can be tricky to tell when baked custards are done. Inserting a toothpick in the middle won't work, as it should still be gooey in the middle when you finish baking, so it can continue to bake once out of the oven. To test if your flan is ready, insert a toothpick about 1 inch from the edge, if that comes out clean, then the flan is ready. Excess pastry base - when you break off the excess pastry outside of the pastry ring, don't throw it out! We don't need it for the recipe, but it makes a great crunchy snack or a nice crumbly topping for ice cream or yoghurt!