From e895c80eb0f4fbf81c4319349865ab2e5af8d088 Mon Sep 17 00:00:00 2001 From: Junpei Tsuji Date: Tue, 17 Sep 2019 13:23:05 +0900 Subject: [PATCH 1/6] Added grace period fields --- appstore/model.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/appstore/model.go b/appstore/model.go index 58c8eb1..c6a3615 100644 --- a/appstore/model.go +++ b/appstore/model.go @@ -76,6 +76,13 @@ type ( CancellationDatePST string `json:"cancellation_date_pst,omitempty"` } + // The GracePeriodDate type indicates the grace period date for the subscription + GracePeriodDate struct { + GracePeriodDate string `json:"grace_period_expires_date,omitempty"` + GracePeriodDateMS string `json:"grace_period_expires_date_ms,omitempty"` + GracePeriodDatePST string `json:"grace_period_expires_date_pst,omitempty"` + } + // The InApp type has the receipt attributes InApp struct { Quantity string `json:"quantity"` @@ -120,6 +127,8 @@ type ( SubscriptionPriceConsentStatus string `json:"price_consent_status"` ProductID string `json:"product_id"` OriginalTransactionID string `json:"original_transaction_id"` + + GracePeriodDate } // The IAPResponse type has the response properties From 934d4ffbbd0e5930e8dfd1515e70115c3cd5df33 Mon Sep 17 00:00:00 2001 From: Junpei Tsuji Date: Thu, 10 Oct 2019 10:58:16 +0900 Subject: [PATCH 2/6] Fixed test error messages --- playstore/validator_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/playstore/validator_test.go b/playstore/validator_test.go index 6677c49..709a4b1 100644 --- a/playstore/validator_test.go +++ b/playstore/validator_test.go @@ -74,7 +74,7 @@ func TestNewWithClient(t *testing.T) { func TestAcknowledgeSubscription(t *testing.T) { t.Parallel() // Exception scenario - expected := "googleapi: Error 404: No application was found for the given package name., applicationNotFound" + expected := "googleapi: Error 400: Invalid Value, invalid" client, _ := New(jsonKey) ctx := context.Background() @@ -93,7 +93,7 @@ func TestAcknowledgeSubscription(t *testing.T) { func TestVerifySubscription(t *testing.T) { t.Parallel() // Exception scenario - expected := "googleapi: Error 404: No application was found for the given package name., applicationNotFound" + expected := "googleapi: Error 400: Invalid Value, invalid" client, _ := New(jsonKey) ctx := context.Background() @@ -121,7 +121,7 @@ func TestVerifySubscriptionAndroidPublisherError(t *testing.T) { func TestVerifyProduct(t *testing.T) { t.Parallel() // Exception scenario - expected := "googleapi: Error 404: No application was found for the given package name., applicationNotFound" + expected := "googleapi: Error 400: Invalid Value, invalid" client, _ := New(jsonKey) ctx := context.Background() @@ -159,7 +159,7 @@ func TestCancelSubscription(t *testing.T) { } client, _ = New(jsonKey) - expectedStr := "googleapi: Error 404: No application was found for the given package name., applicationNotFound" + expectedStr := "googleapi: Error 400: Invalid Value, invalid" actual = client.CancelSubscription(ctx, "package", "productID", "purchaseToken") if actual.Error() != expectedStr { From 4209b06a646862fdc22db37ee08e318ff250355e Mon Sep 17 00:00:00 2001 From: Matija Lesar Date: Mon, 25 Nov 2019 10:00:13 +0100 Subject: [PATCH 3/6] Added unified receipt --- appstore/notification.go | 48 ++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 14 deletions(-) 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"` From 31a625b71ea62b3383cc89162872e0e6927b3dcc Mon Sep 17 00:00:00 2001 From: Matija Lesar Date: Mon, 25 Nov 2019 11:25:31 +0100 Subject: [PATCH 4/6] CR changes --- appstore/model.go | 8 ++++++-- appstore/notification.go | 37 +++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/appstore/model.go b/appstore/model.go index c6a3615..c42b917 100644 --- a/appstore/model.go +++ b/appstore/model.go @@ -91,8 +91,12 @@ type ( OriginalTransactionID string `json:"original_transaction_id"` WebOrderLineItemID string `json:"web_order_line_item_id,omitempty"` - IsTrialPeriod string `json:"is_trial_period"` - IsInIntroOfferPeriod string `json:"is_in_intro_offer_period,omitempty"` + IsTrialPeriod string `json:"is_trial_period"` + IsInIntroOfferPeriod string `json:"is_in_intro_offer_period,omitempty"` + IsUpgraded string `json:"is_upgraded"` + PromotionalOfferID string `json:"promotional_offer_id"` + SubscriptionGroupIdentifier string `json:"subscription_group_identifier"` + ExpiresDate PurchaseDate diff --git a/appstore/notification.go b/appstore/notification.go index c5eaa8c..6ce70b2 100644 --- a/appstore/notification.go +++ b/appstore/notification.go @@ -35,23 +35,20 @@ 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"` - IsUpgraded string `json:"is_upgraded"` - PromotionalOfferID string `json:"promotional_offer_id"` - SubscriptionGroupIdentifier string `json:"subscription_group_identifier"` + 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"` PurchaseDate OriginalPurchaseDate @@ -65,9 +62,9 @@ type NotificationUnifiedReceipt struct { // 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"` + LatestReceipt string `json:"latest_receipt"` + LatestReceiptInfo []InApp `json:"latest_receipt_info"` + PendingRenewalInfo []PendingRenewalInfo `json:"pending_renewal_info,omitempty"` } type SubscriptionNotification struct { From 7d624ad0683f05b07105325604daf22eebd75043 Mon Sep 17 00:00:00 2001 From: Matija Lesar Date: Mon, 25 Nov 2019 11:26:42 +0100 Subject: [PATCH 5/6] Updated order of properties --- appstore/model.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/appstore/model.go b/appstore/model.go index c42b917..c5ecd96 100644 --- a/appstore/model.go +++ b/appstore/model.go @@ -85,18 +85,18 @@ type ( // The InApp type has the receipt attributes InApp struct { - Quantity string `json:"quantity"` - ProductID string `json:"product_id"` - TransactionID string `json:"transaction_id"` - OriginalTransactionID string `json:"original_transaction_id"` - WebOrderLineItemID string `json:"web_order_line_item_id,omitempty"` - - IsTrialPeriod string `json:"is_trial_period"` - IsInIntroOfferPeriod string `json:"is_in_intro_offer_period,omitempty"` - IsUpgraded string `json:"is_upgraded"` + Quantity string `json:"quantity"` + ProductID string `json:"product_id"` + TransactionID string `json:"transaction_id"` + OriginalTransactionID string `json:"original_transaction_id"` + WebOrderLineItemID string `json:"web_order_line_item_id,omitempty"` PromotionalOfferID string `json:"promotional_offer_id"` SubscriptionGroupIdentifier string `json:"subscription_group_identifier"` + IsTrialPeriod string `json:"is_trial_period"` + IsInIntroOfferPeriod string `json:"is_in_intro_offer_period,omitempty"` + IsUpgraded string `json:"is_upgraded"` + ExpiresDate PurchaseDate From 1bd99243d78297783c42164126f0142b2ee991a9 Mon Sep 17 00:00:00 2001 From: Matija Lesar Date: Mon, 25 Nov 2019 12:42:41 +0100 Subject: [PATCH 6/6] Changed environment property type --- appstore/notification.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/appstore/notification.go b/appstore/notification.go index 6ce70b2..db41010 100644 --- a/appstore/notification.go +++ b/appstore/notification.go @@ -57,11 +57,8 @@ type NotificationReceipt struct { } type NotificationUnifiedReceipt struct { - Status string `json:"status"` - - // For production we will get "Production" instead of "PROD" - Environment NotificationEnvironment `json:"environment"` - + Status string `json:"status"` + Environment Environment `json:"environment"` LatestReceipt string `json:"latest_receipt"` LatestReceiptInfo []InApp `json:"latest_receipt_info"` PendingRenewalInfo []PendingRenewalInfo `json:"pending_renewal_info,omitempty"`