Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return error on empty Google receipt PackageName #1085

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions iap/iap.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ func decodeReceiptGoogle(receipt string) (*ReceiptGoogle, error) {
if err := json.Unmarshal([]byte(unwrapped), &gr); err != nil {
return nil, errors.New("receipt is malformed")
}
if gr.PackageName == "" {
return nil, errors.New("receipt is malformed")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make the error more useful if we actually returned the reason (like in package name is empty) here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

being purposefully generic as this field should always be present if the receipt is in the expected format, otherwise valid json is unmarshalled without error but the struct will have none of the expected fields set.

}

return &gr, nil
}

Expand Down
Loading