Do the App Store Server Notifications "webOrderLineItemId" or "transactionId" stay the same during the renewal attempt process?

I'm trying to ascertain if either the "webOrderLineItemId" or "transactionId" in the notification type v2 webhooks stay the same for the life cycle of each renewal. Ie: The auto-renewing subscription attempt is made and billing fails, additional attempts are made until payment succeeds. Until payment succeeds or subscription is cancelled do either of these attributes stay the same?

Another question, I may be misunderstanding the "webOrderLineItemId", does this represent a successful renewal?

Replies

webOrderLineItemId is an identifier of a completed subscription renewal purchase. For an auto-renewing monthly subscription, a purchase is made once per month to renew the subscription. Each monthly purchase will have its own webOrderLineItemId. Even if the user accesses their subscription from multiple devices or restores purchases, this webOrderLineItemId is the same, since it's tied to their month's purchase of the subscription entitlement. 

Billing issues can delay the next subscription renewal purchase and its associated webOrderLineItemId. The signedTransactionInfo in V2 notifications contains the transaction information for the most recent successful purchase of the subscription. If you receive a V2 notification with type EXPIRED and subtype BILLING_RETRY, that means the subscription failed to renew at the end of the current period and has entered the billing retry state. Since the renewal purchase failed, the most recent completed transaction is for the subscription period that just ended, so it will be that transaction's information in the signedTransactionInfo of the V2 notification. If the billing later succeeds, you'll receive a notification with type DID_RENEW and subtype BILLING_RECOVERY, and the signedTransactionInfo will now contain data for this new renewal purchase transaction, including a new webOrderLineItemId.

The transactionId is less persistent: a new one is generated every time a subscription renews, but also when active subscriptions are restored on another device. For this reason, there could be several transactionIds associated with a single subscription renewal purchase. See here for more information: https://developer.apple.com/documentation/appstoreservernotifications/transactionid

Another relevant field is the originalTransactionId. This field uniquely identifies a subscription, rather than a single subscription renewal purchase. Across any number of subscription renewals, billing retry and grace periods, and periods where the user unsubscribed, this value will remain constant for a given user and subscription product pairing.

In summary: it sounds like webOrderLineItemId is what you're looking for if you want to identify individual subscription renewals.