Recurring payment integration help needed.
I have a payment provider and i've made a module (epay_recurring) which allows a user to subscribe to recurring payments using his credit card, and then the module can authorize a specific amount at a later time, and capture the money afterwards.
I need this to provide a service for users, where they can start a session, which authorizes an amount from their card, and afterwards when theyre done using the service, the exact amount (based on their usage) will be captured from their card, using the previous authorization.
To give an example, the service could be a sun tanning bed, where the user initially makes an authorization for a max time (let's say one hour) an then when the user is done (after 25 minutes), the price for 25 minutes should be captured.
I'm in doubt about how to design the payment flow. I guess that the tanning bed is a product that should be added to a line item and put into an order (when the user clicks a button on a site or in an app) - but before adding it to the order, I want to make the authorization - and then do the capture when the order is checked out (i.e. the user is done).
It's hard for me to see how this can be done with the existing rules events and actions, and the hooks provided by the commerce_payment module.
Any ideas would be highly appreciated :-)