Search Unity

[Solved] [Unity IAP] iOS sandbox testing issue

Discussion in 'Unity IAP' started by OlegGoncharenko, Mar 28, 2016.

Thread Status:
Not open for further replies.
  1. OlegGoncharenko

    OlegGoncharenko

    Joined:
    Nov 25, 2013
    Posts:
    3
    Hi! I am developing IAP system with dedicated server that will check receipts. In Editor everything went good (item purchase, sending of message to server, receiving response, etc.). However, when I run my game on device, it seems like I can make purchase from Apple Store side, but no message is sent over to server. Below I will post pseudo-code of my UIAP store:

    public void BuyProductID(string productId)
    {
    //... checks
    InitiatePurchase(productId)
    //... more checks
    }

    public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
    {
    SendReceiptToServer();
    WaitForServerToRespond(args.purchasedProduct);
    return PurchaseProcessingResult.Pending;
    }

    public void WaitForServerToRespond(Product prod)
    {
    //Wait for set of time for server response;
    //If approved by server then approve purchase
    controller.ConfirmPendingPurchase(prod); //This confirms pending purchase
    //execute code to give player item.

    //If failed to wait for server response
    //show error window.
    }

    I think that there should be issue with my approach (i.e. making purchase pending and then confirm it). If you have any advice how to tackle this issue... please help:)

    P.S.: device connects to server, just doesn't send receipt, thus, it is NOT a network issue.
     
  2. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    You would not want to wait for your server to respond inline on the scripting thread, it would lock up the player while the request took place. Make the request on a coroutine or background thread and then Confirm the pending purchase.

    As for why the data is not sent this depends how you are sending it. Try logging whatever message you are sending.
     
Thread Status:
Not open for further replies.