question

brendan avatar image
brendan asked

Buy same item multiple times

inesmoital
started a topic on Mon, 06 April 2015 at 12:38 PM

Hello,

I want my players to be able to buy the same item multiple times. I've start using StartPurchase api call but then I need to call PayForPurchase to confirm the purchage. The only think is that I want to use virtualcurrency for this so I don't know what I should put on ProviderName. I also looked at PurchaseItem but that only lets me buy one item at a time. How can I achieve this?

Thanks

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

6 Comments
Brendan Vanous said on Mon, 06 April 2015 at 6:12 PM

We do have a backlog item to make a version of PurchaseItem which takes an array for purchase, but the workaround right now would be:

  • Pass the items the client would like to purchase into StartPurchase.

  • In PayForPurchase, specify the Virtual Currency for Currency and ProviderName as "Title[TitleID]", where [TitleID] is the ID for your game. You should see this in the list of options coming back from the StartPurchase call - in the example, this shows up as "TitleA90A".

  • Call ConfirmPurchase to finalize the transaction.

Brendan


inesmoital said on Tue, 07 April 2015 at 10:44 AM

Thanks Brendan,

I'm now getting this error now: PurchaseInitializationFailure when I call PayForPurchase, any ideas on why this might be happening?


inesmoital said on Tue, 07 April 2015 at 1:16 PM

Ok I tried to change the tittleID all to upper case and now I'm getting a different error (maybe this would help figuring out the problem): System.InvalidCastException: Cannot cast from source type to destination type.

The player I'm using also changed. In it's purchase list it now has items that have it's state as "Init" instead of "CreateCart".


Brendan Vanous said on Tue, 07 April 2015 at 2:05 PM

I believe the main problem is that no price has been specified. While you can set a cost of 0 on an item and purchase it via PurchaseItem, the StartPurchase flow is designed for real-world money purchases, and so it does require a non-zero purchase price. Can you try setting your items to have a cost, and see if that helps?

And that said, the error message you're getting (InvalidCastException) is unexpected. Is there any chance you could send a repro project to us at devrel@playfab.com?


inesmoital said on Tue, 07 April 2015 at 2:10 PM

Hi Brendan,

What do you mean by repro project? I can copy past the code I'm using for this. Would that be ok?


Brendan Vanous said on Tue, 07 April 2015 at 2:13 PM

Yes, please do. Having a full project which can be run to reproduce the error would be best, but if we can at least see all the code you're using, we should be able to work with that.

Thanks,

Brendan

10 |1200

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

Andrea avatar image
Andrea answered

I have a problem with Ue4, I'm developing payment from store with real Money, what should I put in Array in start purchase? It always gives me error, is it possible to see an example? thank you and sorry for my english

10 |1200

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

Andrea avatar image
Andrea answered

That's the problem, I can't figure out what to link in an array


immagine.jpg (419.0 KiB)
10 |1200

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

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.