|
1 | 1 | package playstore
|
2 | 2 |
|
| 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 | + |
3 | 30 | // DeveloperNotification is sent by a Pub/Sub topic.
|
4 | 31 | // 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 |
6 | 33 | 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"` |
12 | 40 | }
|
13 | 41 |
|
14 |
| -// SubscriptionNotification has subscription status as notificationType, toke and subscription id |
| 42 | +// SubscriptionNotification has subscription status as notificationType, token and subscription id |
15 | 43 | // to confirm status by calling Google Android Publisher API.
|
16 | 44 | 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"` |
21 | 49 | }
|
22 | 50 |
|
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 | +} |
24 | 59 |
|
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