7 Commits

Author SHA1 Message Date
Junpei Tsuji
b31646baf4 Merge pull request #101 from mlesar/unified_receipt
Adding unified receipt to the Apple S2S notification
2019-11-26 00:20:18 +09:00
Matija Lesar
1bd99243d7 Changed environment property type 2019-11-25 12:42:41 +01:00
Matija Lesar
7d624ad068 Updated order of properties 2019-11-25 11:26:42 +01:00
Matija Lesar
31a625b71e CR changes 2019-11-25 11:25:31 +01:00
Matija Lesar
4209b06a64 Added unified receipt 2019-11-25 10:00:13 +01:00
Junpei Tsuji
3d3bd2b6cf Merge pull request #99 from jun06t/error-message
Fixed test error messages
2019-10-10 11:56:32 +09:00
Junpei Tsuji
934d4ffbbd Fixed test error messages 2019-10-10 10:58:16 +09:00
3 changed files with 27 additions and 9 deletions

View File

@@ -85,14 +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"`
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

View File

@@ -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.
@@ -53,6 +56,14 @@ type NotificationReceipt struct {
CancellationDate
}
type NotificationUnifiedReceipt struct {
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"`
}
type SubscriptionNotification struct {
Environment NotificationEnvironment `json:"environment"`
NotificationType NotificationType `json:"notification_type"`
@@ -80,6 +91,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"`

View File

@@ -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 {