diff --git a/appstore/notification.go b/appstore/notification.go index 4c3df6f..c5eaa8c 100644 --- a/appstore/notification.go +++ b/appstore/notification.go @@ -9,7 +9,10 @@ const ( // Subscription was canceled by Apple customer support. NotificationTypeCancel NotificationType = "CANCEL" // Automatic renewal was successful for an expired subscription. + // Deprecated: DID_RECOVER should be used instead of RENEWAL NotificationTypeRenewal NotificationType = "RENEWAL" + // Expired subscription recovered through a billing retry. + NotificationTypeDidRecover NotificationType = "DID_RECOVER" // Customer renewed a subscription interactively after it lapsed. NotificationTypeInteractiveRenewal NotificationType = "INTERACTIVE_RENEWAL" // Customer changed the plan that takes affect at the next subscription renewal. Current active plan is not affected. @@ -32,20 +35,23 @@ type NotificationExpiresDate struct { } type NotificationReceipt struct { - UniqueIdentifier string `json:"unique_identifier"` - AppItemID string `json:"app_item_id"` - Quantity string `json:"quantity"` - VersionExternalIdentifier string `json:"version_external_identifier"` - UniqueVendorIdentifier string `json:"unique_vendor_identifier"` - WebOrderLineItemID string `json:"web_order_line_item_id"` - ItemID string `json:"item_id"` - ProductID string `json:"product_id"` - BID string `json:"bid"` - BVRS string `json:"bvrs"` - TransactionID string `json:"transaction_id"` - OriginalTransactionID string `json:"original_transaction_id"` - IsTrialPeriod string `json:"is_trial_period"` - IsInIntroOfferPeriod string `json:"is_in_intro_offer_period"` + UniqueIdentifier string `json:"unique_identifier"` + AppItemID string `json:"app_item_id"` + Quantity string `json:"quantity"` + VersionExternalIdentifier string `json:"version_external_identifier"` + UniqueVendorIdentifier string `json:"unique_vendor_identifier"` + WebOrderLineItemID string `json:"web_order_line_item_id"` + ItemID string `json:"item_id"` + ProductID string `json:"product_id"` + BID string `json:"bid"` + BVRS string `json:"bvrs"` + TransactionID string `json:"transaction_id"` + OriginalTransactionID string `json:"original_transaction_id"` + IsTrialPeriod string `json:"is_trial_period"` + IsInIntroOfferPeriod string `json:"is_in_intro_offer_period"` + IsUpgraded string `json:"is_upgraded"` + PromotionalOfferID string `json:"promotional_offer_id"` + SubscriptionGroupIdentifier string `json:"subscription_group_identifier"` PurchaseDate OriginalPurchaseDate @@ -53,6 +59,17 @@ type NotificationReceipt struct { CancellationDate } +type NotificationUnifiedReceipt struct { + Status string `json:"status"` + + // For production we will get "Production" instead of "PROD" + Environment NotificationEnvironment `json:"environment"` + + LatestReceipt string `json:"latest_receipt"` + LatestReceiptInfo []NotificationReceipt `json:"latest_receipt_info"` + PendingRenewalInfo []PendingRenewalInfo `json:"pending_renewal_info,omitempty"` +} + type SubscriptionNotification struct { Environment NotificationEnvironment `json:"environment"` NotificationType NotificationType `json:"notification_type"` @@ -80,6 +97,9 @@ type SubscriptionNotification struct { LatestReceipt string `json:"latest_receipt"` LatestReceiptInfo NotificationReceipt `json:"latest_receipt_info"` + // In the new notifications above properties latest_receipt, latest_receipt_info are moved under this one + UnifiedReceipt NotificationUnifiedReceipt `json:"unified_receipt"` + // Posted only if the notification_type is RENEWAL or CANCEL or if renewal failed and subscription expired. LatestExpiredReceipt string `json:"latest_expired_receipt"` LatestExpiredReceiptInfo NotificationReceipt `json:"latest_expired_receipt_info"`