Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

How i can associate product with server side account?

Discussion in 'Unity IAP' started by DarkVito, Oct 9, 2020.

  1. DarkVito

    DarkVito

    Joined:
    May 21, 2019
    Posts:
    5
    Hello! I have a game with IAP and server side account functional (user data like token saved with PlayerPrefs). So, when i buy product "A" for account "1", close and reinstall application (ProcessPurchase return Pending for this product) and login in account "B", product "1" for account "A" buying for account "B". How i can associate product with server side account?
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry I don't quite follow. Account A is purchasing a product for Account B? That's not possible, purchases are associated with the user account on the phone. How are you switching accounts on the phone? It's the user logged into the Google Play App on the phone.
     
    DarkVito likes this.
  3. DarkVito

    DarkVito

    Joined:
    May 21, 2019
    Posts:
    5
    I switch account inside unity application. I have mysql DB and php server side scripts were I generate token for each user account. I not change google or apple account
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes that won't work. For security, you won't be able to do that with Unity IAP (which uses the Google Billing Library on Android and Apple Storekit on iOS). It's enforced by Google and Apple, not us.
     
    DarkVito likes this.
  5. DarkVito

    DarkVito

    Joined:
    May 21, 2019
    Posts:
    5
    And what should I do?
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    You will need to make a decision based on these facts. You can't switch users in the app and expect IAP to function. It will appear to always be charged to User A. To be clear, we are discussing virtual products offered for sale created on your Google developer dashboard and Apple Connect where game users pay for product (like buying "50 Gold Coins" with an actual credit card). https://docs.unity3d.com/Manual/UnityIAPGoogleConfiguration.html and https://docs.unity3d.com/Manual/UnityIAPAppleConfiguration.html . Some Android devices allow you to configure multiple accounts on the device, but the user needs to manually switch accounts for security under Settings, outside of your app. More common and on iOS, you generally need to reset your phone to switch users.
     
  7. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Do you typically hand your phone to someone else to play a game on to make purchases on with their credit card, or vice versa? It's not common, perhaps in a family situation. But to your initial question, if you have a SINGLE user, and you want to securely store their purchase history in the cloud, you can check out PlayFab or ChilliConnect.
     
    Last edited: Oct 9, 2020