question

daniel.berkbox@gmail.com avatar image
daniel.berkbox@gmail.com asked

Restoring purchases (multiple Playfab accounts)

Hi,
In my game I'm using Login with device Id and Playfab account (id/email + pass). Since we have a button "register account" the user could have more than one account in Playfab.

My question is, if the user makes the purchase (validating receipt) with your Account A and then login with your account B (same apple acc) and restores the purchase, in which case we make a RestoreIOSPurchases call, this will ensure you get the item purchased for the account B ? or I have to use GrantItemsToUser? I have to revalidate the receipt? Can you give an example of how it would be the appropriate flow to iOS and Android?

Thank you!

10 |1200

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

brendan avatar image
brendan answered

Our sincere apologies for the confusion on this issue. The issue here was one of confusion between "refresh" and "restore" receipts, and we're fixing all documentation to clarify this. In point of fact, the correct process is to submit the receipt obtained via a call to the restoreCompletedTransactions method of SKPaymentQueue in the Store Kit (https://developer.apple.com/reference/storekit/skpaymentqueue/1506123-restorecompletedtransactions). That receipt will contain updated receipts for all non-consumable purchases made by the player, and so will restore purchases made in another account.

Again though, one thing to bear in mind is that this does provide a hacked client with a way to get multiple instances of non-consumable goods, by hitting the restoreCompletedTransactions call multiple times, and using all those receipts. While this would, ultimately, only cause problems for the player (since it would cause the inventory to fill up with these items if they did this a lot), a safer route would be to only sell virtual currencies (a consumable good) in the iTunes store, and then use that VC to make purchases of digital goods via your game's Catalog (using PurchaseItem). And, of course, the best route is always to make sure you can reliably get the player back to their original account on any device by incorporating alternate authentication systems, like Facebook, Twitch, and Google whenever possible.

10 |1200

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

brendan avatar image
brendan answered

What you do in this case is get the refresh receipt from iTuens (https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Restoring.html#//apple_ref/doc/uid/TP40008267-CH8-SW9) and send it to us in the RestoreIOSPurchases call. We take care of creating instances for all the items and adding them to the account.

5 comments
10 |1200

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

daniel.berkbox@gmail.com avatar image daniel.berkbox@gmail.com commented ·

Thanks again Brendan!

0 Likes 0 ·
daniel.berkbox@gmail.com avatar image daniel.berkbox@gmail.com commented ·

I'm refreshing receipt and calling

RestoreIOSPurchases but getting ReceiptAlreadyUsed error, any idea?

0 Likes 0 ·
brendan avatar image brendan daniel.berkbox@gmail.com commented ·

It's specifically the new receipt you get back from the query to SKReceiptRefreshRequest - not the original receipt. Can you clarify what API calls you're making to Apple, and of the response, what specifically you are passing into our receipt validation?

0 Likes 0 ·
daniel.berkbox@gmail.com avatar image daniel.berkbox@gmail.com commented ·

It Seems to have some pending transactions, this may be causing the problem? anyway I´ll take care about that and if the problem persists I will post more details.

0 Likes 0 ·
brendan avatar image brendan daniel.berkbox@gmail.com commented ·

It shouldn't matter from our side of things. If it's a new Refresh Token, it'll be processed correctly. Do let us know what you find.

0 Likes 0 ·
daniel.berkbox@gmail.com avatar image
daniel.berkbox@gmail.com answered

Hi Brendan,

I still getting the error, here my processes (I'm using prime31 plugin):

call

StoreKitBinding.refreshReceipt();

received event

refreshReceiptSucceededEvent

here my code for this event:

string receiptLocation = StoreKitBinding.getAppStoreReceiptLocation();
receiptLocation = receiptLocation.Replace("file://", string.Empty);
if (!File.Exists(receiptLocation))
{
// error
return;
}
byte[] receiptBytes = File.ReadAllBytes(receiptLocation);
string base64ReceiptData = System.Convert.ToBase64String(receiptBytes);
RestoreIOSPurchasesRequest requestRestore = new RestoreIOSPurchasesRequest()
{
ReceiptData = base64ReceiptData
};
PlayFabClientAPI.RestoreIOSPurchases(requestRestore, (result) =>
{
GetInventory(); // read the inventory

},
(error) =>
{
//here erro I'm getting ReceiptAlreadyUsed
}
);

base64ReceiptData looks like MIIX3AYJKoZIhvcNAQcCoIIXz... need I post full receipt?

7 comments
10 |1200

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

brendan avatar image brendan commented ·

What Title ID are you using? I can have a look at the specifics on our side.

0 Likes 0 ·
daniel.berkbox@gmail.com avatar image daniel.berkbox@gmail.com brendan commented ·

my title id is DDFE

0 Likes 0 ·
brendan avatar image brendan daniel.berkbox@gmail.com commented ·

Thanks, that's helpful. From what I'm seeing, we're not receiving a receipt with anything that can be restored. Can you get a new refresh receipt for your player and send it to us (open a ticket using the option on this page)? Please do not call RestoreIOSPurchases with it - we need it to be completely unused.

0 Likes 0 ·
daniel.berkbox@gmail.com avatar image daniel.berkbox@gmail.com commented ·

Thank you Brendan, I just created a ticked with a unused receipt in the description.

0 Likes 0 ·
brendan avatar image brendan daniel.berkbox@gmail.com commented ·

The Prime31 team confirmed that the flow above is correct, but that doesn't really help to determine why you're getting the same purchase_date and original_purchase_date (which isn't how refresh receipts work). Can you confirm how the item is set up in the iTunes catalog? It should be a durable, non-renewable item. Is that the case?

0 Likes 0 ·
daniel.berkbox@gmail.com avatar image daniel.berkbox@gmail.com brendan commented ·

Hi Brendan,

The item is set up as Non-Consumable in itunes and durable in playfab catalog

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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