Custom Wordpress Plugin

Hey, im currently working on a plugin for my site where i use patreon API to sync memberships to RCP. The plugin work by looking at the last payment of the user, but it wont work when someone upgrades to a better tier since then the last payment would be the difference between the tier he was and the new one. Any help? I cant set the price of that difference since it will match an existing tier already. Appreciate any help.

Instead of checking payments, you can use the currently_entitled_tiers and currently_entitled_amount_cents values of each member to determine their current membership level.