Restore product from receipt (bug 981235)

This function is really long and seems to have several distinct parts. It would probably help readability to break it up and name each part. It's definitely weird how those functions seem to want to return an updated `data` and possibly an `error` though.