The partner API allows us to access transactions, such as AppSubscriptionSale. Each transaction is associated with a chargeId (the subscription itself) and an amount. However, there's no information on the service period the transaction is associated with - for instance, when a customer upgrades a subscription, there might be two transactions on his next billing interval- one prorated for the overlapping period with the old subscription, and one for the new subscription. Attached is an example response from the API on one of our customers (details redacted):
In this case, the customer has switched plans, thus there were 2 transactions - one for $20 (for partial usage of the new subscription), and one for $150 (for the following month).
However, there's no way to associate each charge with the actual period it refers to - for example, how do we know which dates of service are under the $20 charge? We could guess by using the "full price" and prorating, then looking back at the entire subscription history to figure out the cycle, but this gets very complicated quickly, as transactions can happen on all sorts of occasions - before / after an upgrade / a downgrade, before / after a frozen subscription, with / without a discount, with or without a trial, during or long after a subscription, etc.
Right now, there's no way to connect a transaction to a subscription period due to this issue, which makes financial analytics very hard to calculate. Would it be possible to add the service period from the BrokeredSale into the AppSubscriptionTransaction?