question

Dada E. avatar image
Dada E. asked

Testing IAP - User Identification

Hi, [This thread is related to previous thread #1465] In our attempts to integrate our Mobile Web Apps with the Amazon WebApp In-App Purchasing API for JS, we have found some doubts when it comes to the User Identification. We need to know who is the end user that paid for a subscription content or a consumable content, and we need to be able to identify this user in the future and "map" it to our WebApp User Information. I see in the documentation that during the Purchase flow we will have access to the "UserID" ( https://developer.amazon.com/sdk/webapps/iap/subscription.html). Our question is, how can we use this UserID in the future to detect that this user has already made a purchase? Is there any information in the navigation, maybe provided by the wrapper, that our JavaScript can read to "auto-detect" the "UserID" of the Customer? If not, is there any separate API we can use to cover this need? Separately we have noticed the existence Amazon's "Login" SDK and we were wondering if it could fit our needs and if it can be somehow combined with the In-App Purchase API for JS. In other words: Is the Login SDK providing us the same type of "UserID" that we obtain from the In-App Purchase API for JS? Thanks a lot in advance for your help. Jaime. DadaEntertainment, Inc. - Technology Team
web apps
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Venkat@Amazon avatar image
Venkat@Amazon answered
You can implement RVS ( https://developer.amazon.com/sdk/webapps/iap/rvs.html) to identify the UserId, When app forwards receipt information to verify in your server, you can implement the logic according to your needs. Snippet of API Reference: onPurchaseResponse(event) Called as a response to purchaseItem with the receipts. The structure of the event object is: . requestId . userId . purchaseRequestStatus . receipt
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Venkat@Amazon avatar image
Venkat@Amazon answered
USER_ID provided by the Amazon login SDK and UserID provided by IAP API are different. Example: USER_ID provided by Amazon login SDK looks like : amzn1.account.AHXXXXXUAXXXXXT5P2XXXXXL3Y7Q UserId provided by IAP API looks like : oxxKxXxpxxxkxIx2xrx-xlxexmxxxxxxOxKxxxx6xxx=
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dada E. avatar image
Dada E. answered
Thanks for your response. If I understand correctly, you are indicating how to obtain the UserId when the app forwards the receipt information after a purchase. In that moment, or before we can obtain the UserID. My question is more oriented for a time after the purchase. Let's say that the user finishes the purchase, we collect and validate the receipt (and the UserID), and the user closes the application soon after. Days after, the user launches the application again, and it is time to check if the user is eligible to access the content again. How does the application know about the UserID of the user using the application, so that it can check if there was a previous purchase that can grant access to the content without having to make another purchase? How can we read that UserID and use it to check our receipt DB? Thanks. Jaime. Dada Entertainment, Inc, technology team
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dada E. avatar image
Dada E. answered
Continuing my last reply, perhaps the below question can brief what I was trying to ask before: Can you confirm that we can invoke this method at any time from the application: AmazonServices.IAP.getUserId() If yes, how can we be sure the user is logged in or force them to log in? Thanks again.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Yes. You are correct that the user id could be achived by AmazonServices.IAP.getUserId() when the user comes back to app in the next launch to check for the pending transaction in the server side. But please note the api should be called after making sure that the amzn_wa.IAP is initilized, i.e. you have received callback on ""onSDKAvailable"" after registering the observer in amzn_wa.IAP runtime instance. amzn_wa.IAP.registerObserver({ // Called the the IAP API is available 'onSdkAvailable': function(resp) { if (resp.isSandboxMode) { alert(""Running in test mode""); } // You should call getPurchaseUpdates to get any purchases // that could have been made in a previous run. amzn_wa.IAP.getPurchaseUpdates(state.lastPurchaseCheckTime != null ? state.lastPurchaseCheckTime : amzn_wa.IAP.Offset.BEGINNING); }, // Called as response to getUserId 'onGetUserIdResponse': function(resp) {}, // Called as response to getItemData 'onItemDataResponse': function(data) {}, // Called as response to puchaseItem 'onPurchaseResponse': function(data) { onPurchaseResponse(data); }, // Called as response to getPurchaseUpdates 'onPurchaseUpdatesResponse': function(resp) { onPurchaseUpdatesResponse(resp); } }); https://developer.amazon.com/sdk/webapps/iap/entitlement.html
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.