You need to define events in your code:
https://docs.apify.com/platform/actors/publishing/monetize/pay-per-event
With the events you define in your code, when you set up your pricing in Apify Console you will identify the events and tell Apify how much you want to charge your user for each event.
You don't need to write the pricing logic, just define the events. Apify will handle the pricing from there.