Easy Digital Downloads – How to use hooks correctly?

I’m using Easy Digital Downloads for my WordPress webshop. After someone buy a item it needs to add data to the SQL database. I got this working by adding PHP code to shortcode-receipt.php. This is working correct but when I reload the receipt via browser or mail the PHP code will fire again.

I figured out that there was a hook in EDD, but i’m not sure how to use them. I figured out that the function needs to be added to functions.php.

file: /wp-content/themes/twentytwenty/functions.php

But in what file do i place

do_action( 'edd_complete_purchase', $payment_id ); ?