Unverified Commit 14a5256c authored by Andrei Mihu's avatar Andrei Mihu Committed by GitHub
Browse files

Accept Google IAP receipts with or without wrapper structures. (#946)

parent 3f3c2d93
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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.
+4 −2
Original line number Diff line number Diff line
@@ -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
}