Assigning Purchased Plans To Custom User Database

I’m looking to gain a bit of knowledge and help for trying to achieve what I mentioned above.

I want this mapping of purchased plan to a user row in a database to happen at the time of them buying a plan but I’m not sure how straightforward it is for my use case. I have users that are linked to a member but are not actually members themselves (member’s pets) so it would be nice if I could somehow ask them to fill a form at any point of buying a plan to what pet they want it assigned to.

I know you can create custom bookings form fields but I don’t think this will work for me trying to assign a specific plan to a petbecause that comes after they have purchased a plan. I looked through the onPurchasedPlan() event handler but none of the information seems useful. It would be nice if there was a form field they fill then that information is passed in an event to the backend.

I was also thinking of maybe adding a custom step right before the checkout process but I’m not sure theres anyway to force that they choose a pet for it to be mapped to before they checkout.

Any insight would be much appreciated!