diff --git a/CHANGELOG.md b/CHANGELOG.md index e56fbe972886d2c87df07d00a5191eee6e1de728..c9f37063e18ac6fb83d3417238566a24a629d194 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr - Stricter validation of limit in runtime storage list operations. - Allow subdomain variance in Facebook Limited Login token issuer field. - Renamed `groupsGetRandom` to `groups_get_random` in the Lua runtime for consistency. +- Accept Google IAP receipts with or without wrapper structures. ### Fixed - Fix response selection in purchase lookups by identifier. diff --git a/iap/iap.go b/iap/iap.go index 5f7821b77775797383230d3f6e5d18ca9e02e4e4..43b69e390109d7a4a924ed42d3fbd6d29869635c 100644 --- a/iap/iap.go +++ b/iap/iap.go @@ -266,12 +266,14 @@ func decodeReceiptGoogle(receipt string) (*ReceiptGoogle, error) { unwrapped, ok := wrapper["json"].(string) if !ok { - return nil, errors.New("'json' field not found, receipt is malformed") + // If there is no 'json' field, assume the receipt is not in a + // wrapper. Just attempt and decode from the top level instead. + unwrapped = receipt } var gr ReceiptGoogle if err := json.Unmarshal([]byte(unwrapped), &gr); err != nil { - return nil, err + return nil, errors.New("receipt is malformed") } return &gr, nil }