Skip to content

Commit e948691

Browse files
authored
Merge pull request #120 from OmarElGabry/play-store-one-time-prod-notification
Update the developer notification struct to include one time products
2 parents c16a822 + 53f8c45 commit e948691

File tree

1 file changed

+51
-27
lines changed

1 file changed

+51
-27
lines changed

playstore/notification.go

+51-27
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,63 @@
11
package playstore
22

3+
// https://developer.android.com/google/play/billing/rtdn-reference#sub
4+
type SubscriptionNotificationType int
5+
6+
const (
7+
SubscriptionNotificationTypeRecovered SubscriptionNotificationType = iota + 1
8+
SubscriptionNotificationTypeRenewed
9+
SubscriptionNotificationTypeCanceled
10+
SubscriptionNotificationTypePurchased
11+
SubscriptionNotificationTypeAccountHold
12+
SubscriptionNotificationTypeGracePeriod
13+
SubscriptionNotificationTypeRestarted
14+
SubscriptionNotificationTypePriceChangeConfirmed
15+
SubscriptionNotificationTypeDeferred
16+
SubscriptionNotificationTypePaused
17+
SubscriptionNotificationTypePauseScheduleChanged
18+
SubscriptionNotificationTypeRevoked
19+
SubscriptionNotificationTypeExpired
20+
)
21+
22+
// https://developer.android.com/google/play/billing/rtdn-reference#one-time
23+
type OneTimeProductNotificationType int
24+
25+
const (
26+
OneTimeProductNotificationTypePurchased OneTimeProductNotificationType = iota + 1
27+
OneTimeProductNotificationTypeCanceled
28+
)
29+
330
// DeveloperNotification is sent by a Pub/Sub topic.
431
// Detailed description is following.
5-
// https://developer.android.com/google/play/billing/realtime_developer_notifications.html#json_specification
32+
// https://developer.android.com/google/play/billing/rtdn-reference#json_specification
633
type DeveloperNotification struct {
7-
Version string `json:"version"`
8-
PackageName string `json:"packageName"`
9-
EventTimeMillis string `json:"eventTimeMillis"`
10-
SubscriptionNotification SubscriptionNotification `json:"subscriptionNotification,omitempty"`
11-
TestNotification SubscriptionNotification `json:"testNotification,omitempty"`
34+
Version string `json:"version"`
35+
PackageName string `json:"packageName"`
36+
EventTimeMillis string `json:"eventTimeMillis"`
37+
SubscriptionNotification SubscriptionNotification `json:"subscriptionNotification,omitempty"`
38+
OneTimeProductNotification OneTimeProductNotification `json:"oneTimeProductNotification,omitempty"`
39+
TestNotification TestNotification `json:"testNotification,omitempty"`
1240
}
1341

14-
// SubscriptionNotification has subscription status as notificationType, toke and subscription id
42+
// SubscriptionNotification has subscription status as notificationType, token and subscription id
1543
// to confirm status by calling Google Android Publisher API.
1644
type SubscriptionNotification struct {
17-
Version string `json:"version"`
18-
NotificationType NotificationType `json:"notificationType,omitempty"`
19-
PurchaseToken string `json:"purchaseToken,omitempty"`
20-
SubscriptionID string `json:"subscriptionId,omitempty"`
45+
Version string `json:"version"`
46+
NotificationType SubscriptionNotificationType `json:"notificationType,omitempty"`
47+
PurchaseToken string `json:"purchaseToken,omitempty"`
48+
SubscriptionID string `json:"subscriptionId,omitempty"`
2149
}
2250

23-
type NotificationType int
51+
// OneTimeProductNotification has one-time product status as notificationType, token and sku (product id)
52+
// to confirm status by calling Google Android Publisher API.
53+
type OneTimeProductNotification struct {
54+
Version string `json:"version"`
55+
NotificationType OneTimeProductNotificationType `json:"notificationType,omitempty"`
56+
PurchaseToken string `json:"purchaseToken,omitempty"`
57+
SKU string `json:"sku,omitempty"`
58+
}
2459

25-
const (
26-
NotificationTypeRecovered NotificationType = iota + 1
27-
NotificationTypeRenewed
28-
NotificationTypeCanceled
29-
NotificationTypePurchased
30-
NotificationTypeAccountHold
31-
NotificationTypeGracePeriod
32-
NotificationTypeRestarted
33-
NotificationTypePriceChangeConfirmed
34-
NotificationTypeDeferred
35-
NotificationTypePaused
36-
NotificationTypePauseScheduleChanged
37-
NotificationTypeRevoked
38-
NotificationTypeExpired
39-
)
60+
// TestNotification is the test publish that are sent only through the Google Play Developer Console
61+
type TestNotification struct {
62+
Version string `json:"version"`
63+
}

0 commit comments

Comments
 (0)