XF 2.2 Add duration for an user upgrade



hopefully someone can answer my question. I want create an addon which handles user upgrade with my own payment system besides from the builtin from xenforo.
Which methods or which classes are required to upgrade an user correctly so that xenforo will treated it like a normal user upgrade (handling expires, downgrades, etc).

And is that possible to add duration by an upgrade? Like, if I purchase 1 month user upgrade and purchase 3 months additional, would xenforo adding the duration?

Kind regards