Skip to content

[IOS] Function to get the on-device receipt #1170

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

Closed
danielp982 opened this issue Mar 2, 2021 · 2 comments
Closed

[IOS] Function to get the on-device receipt #1170

danielp982 opened this issue Mar 2, 2021 · 2 comments
Labels

Comments

@danielp982
Copy link

My team is looking at migrating to this plugin from cordova-plugin-inapppurchase, as this one is still actively maintained and is compatible with Google's Billing Library v3.

One function that seems to be missing from this plugin however is the ability to get the local receipt on an iOS device. We use this functionality in our own app as part of verifying the user's identity, as we need to tie purchases to specific accounts and Apple doesn't easily provide us this information. It would be great if it could be included in this plugin as well!

I could have simply missed a way to do this as part of the existing plugin functionality though, in which case I'm open to suggestions.

@dpa99c
Copy link
Collaborator

dpa99c commented Apr 7, 2021

On-device parsing of the receipt payload is something I figure I now need and this plugin doesn't currently support.

The plugin currently returns the app receipt (including the payload) as base64-encoded binary.

However, as outlined in Apple's Restoring Purchased Products documentation, you may need to parse the receipt payload on the device to determine which products a user owns:

In most cases, you only need to refresh the app receipt and deliver the products listed on the receipt. The refreshed receipt contains a record of the user’s purchases in this app, from any device the user's App Store account is logged into.

Since as stated in that document, you should not automatically invoke a restore operation to determine a user's owned products:

Don't automatically restore purchases, especially when your app is launched. Restoring purchases prompts for the user’s App Store credentials, which interrupts the flow of your app.

Particularly since this creates new transactions for each owned product:

Restoring completed transactions creates a new transaction for every transaction previously completed, essentially replaying history for your transaction queue observer.

Whereas refreshing the receipt does not:

Refreshing a receipt doesn't create new transactions; it requests the latest copy of the receipt from the App Store.

Apple's example of parsing the receipt payload in the Receipt Validation Programming Guide is not great but I might try to figure it out and in which case make a PR to this plugin to return the decoded receipt payload back the to JS layer as JSON.

@stale
Copy link

stale bot commented Apr 19, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Apr 19, 2022
@j3k0 j3k0 closed this as completed Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants