Skip to content

Commit b31646b

Browse files
authored
Merge pull request #101 from mlesar/unified_receipt
Adding unified receipt to the Apple S2S notification
2 parents 3d3bd2b + 1bd9924 commit b31646b

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

appstore/model.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,18 @@ type (
8585

8686
// The InApp type has the receipt attributes
8787
InApp struct {
88-
Quantity string `json:"quantity"`
89-
ProductID string `json:"product_id"`
90-
TransactionID string `json:"transaction_id"`
91-
OriginalTransactionID string `json:"original_transaction_id"`
92-
WebOrderLineItemID string `json:"web_order_line_item_id,omitempty"`
88+
Quantity string `json:"quantity"`
89+
ProductID string `json:"product_id"`
90+
TransactionID string `json:"transaction_id"`
91+
OriginalTransactionID string `json:"original_transaction_id"`
92+
WebOrderLineItemID string `json:"web_order_line_item_id,omitempty"`
93+
PromotionalOfferID string `json:"promotional_offer_id"`
94+
SubscriptionGroupIdentifier string `json:"subscription_group_identifier"`
9395

9496
IsTrialPeriod string `json:"is_trial_period"`
9597
IsInIntroOfferPeriod string `json:"is_in_intro_offer_period,omitempty"`
98+
IsUpgraded string `json:"is_upgraded"`
99+
96100
ExpiresDate
97101

98102
PurchaseDate

appstore/notification.go

+14
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ const (
99
// Subscription was canceled by Apple customer support.
1010
NotificationTypeCancel NotificationType = "CANCEL"
1111
// Automatic renewal was successful for an expired subscription.
12+
// Deprecated: DID_RECOVER should be used instead of RENEWAL
1213
NotificationTypeRenewal NotificationType = "RENEWAL"
14+
// Expired subscription recovered through a billing retry.
15+
NotificationTypeDidRecover NotificationType = "DID_RECOVER"
1316
// Customer renewed a subscription interactively after it lapsed.
1417
NotificationTypeInteractiveRenewal NotificationType = "INTERACTIVE_RENEWAL"
1518
// Customer changed the plan that takes affect at the next subscription renewal. Current active plan is not affected.
@@ -53,6 +56,14 @@ type NotificationReceipt struct {
5356
CancellationDate
5457
}
5558

59+
type NotificationUnifiedReceipt struct {
60+
Status string `json:"status"`
61+
Environment Environment `json:"environment"`
62+
LatestReceipt string `json:"latest_receipt"`
63+
LatestReceiptInfo []InApp `json:"latest_receipt_info"`
64+
PendingRenewalInfo []PendingRenewalInfo `json:"pending_renewal_info,omitempty"`
65+
}
66+
5667
type SubscriptionNotification struct {
5768
Environment NotificationEnvironment `json:"environment"`
5869
NotificationType NotificationType `json:"notification_type"`
@@ -80,6 +91,9 @@ type SubscriptionNotification struct {
8091
LatestReceipt string `json:"latest_receipt"`
8192
LatestReceiptInfo NotificationReceipt `json:"latest_receipt_info"`
8293

94+
// In the new notifications above properties latest_receipt, latest_receipt_info are moved under this one
95+
UnifiedReceipt NotificationUnifiedReceipt `json:"unified_receipt"`
96+
8397
// Posted only if the notification_type is RENEWAL or CANCEL or if renewal failed and subscription expired.
8498
LatestExpiredReceipt string `json:"latest_expired_receipt"`
8599
LatestExpiredReceiptInfo NotificationReceipt `json:"latest_expired_receipt_info"`

0 commit comments

Comments
 (0)