From 6753b53cde4efd882ce2f9cc24dab73c440009c1 Mon Sep 17 00:00:00 2001 From: Junpei Tsuji Date: Thu, 28 Dec 2017 11:41:57 +0900 Subject: [PATCH] Added real time notification definition for google play --- appstore/{subscription.go => notification.go} | 0 playstore/notification.go | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+) rename appstore/{subscription.go => notification.go} (100%) create mode 100644 playstore/notification.go diff --git a/appstore/subscription.go b/appstore/notification.go similarity index 100% rename from appstore/subscription.go rename to appstore/notification.go diff --git a/playstore/notification.go b/playstore/notification.go new file mode 100644 index 0000000..583559b --- /dev/null +++ b/playstore/notification.go @@ -0,0 +1,33 @@ +package playstore + +// DeveloperNotification is sent by a Pub/Sub topic. +// Detailed description is following. +// https://developer.android.com/google/play/billing/realtime_developer_notifications.html#json_specification +type DeveloperNotification struct { + Version string `json:"version"` + PackageName string `json:"packageName"` + EventTimeMillis string `json:"eventTimeMillis"` + SubscriptionNotification SubscriptionNotification `json:"subscriptionNotification,omitempty"` + TestNotification SubscriptionNotification `json:"testNotification,omitempty"` +} + +// SubscriptionNotification has subscription status as notificationType, toke and subscription id +// to confirm status by calling Google Android Publisher API. +type SubscriptionNotification struct { + Version string `json:"version"` + NotificationType NotificationType `json:"notificationType,omitempty"` + PurchaseToken string `json:"purchaseToken,omitempty"` + SubscriptionID string `json:"subscriptionId,omitempty"` +} + +type NotificationType int + +const ( + NotificationTypeRecovered NotificationType = iota + 1 + NotificationTypeRenewed + NotificationTypeCanceled + NotificationTypePurchased + NotificationTypeAccountHold + NotificationTypeGracePeriod + NotificationTypeReactivated +)