Search Unity

[iOS] transaction receipt problem

Discussion in 'Unity IAP' started by Seung-Hur, Jul 5, 2019.

  1. Seung-Hur

    Seung-Hur

    Joined:
    Apr 5, 2016
    Posts:
    4
    Hi.
    Under normal purchasing conditions,
    AppleExtensions.GetTransactionReceiptForProduct works well in ProcessPurchase.

    After purchasing from ProcessPurchase,
    PurchaseProcessingResult.Pending returned for server validation.
    We then try to test various situations, such as crashes, by quitting the application.

    After the application is restarted, initializing UnityIAP
    If an incomplete transaction exists
    ProcessPurchase is called again.

    However, in this call situation, we can check the app receipt.
    but Calling AppleExtensions.GetTransactionReceiptForProduct
    does not get the current transaction receipt.

    How do I get a transaction receipt for an abnormally terminated transaction?

    Thank you.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,944
    Please provide exact steps to reproduce and the results that you see, including the transaction history.
     
  3. Seung-Hur

    Seung-Hur

    Joined:
    Apr 5, 2016
    Posts:
    4
    The following code

    Code (CSharp):
    1.  
    2. public PurchaseProcessingResult ProcessPurchase( PurchaseEventArgs purchaseEventArgs )
    3. {
    4.     Debug.Log( "ReceiptForProduct = " + m_AppleExtensions.GetTransactionReceiptForProduct( purchaseEventArgs.purchasedProduct ) );
    5.  
    6.     ......
    7.  
    8.     return PurchaseProcessingResult.Pending;
    9. }
    10.  
    I can get a transaction receipt when I buy
    If it is pending, it is re-invoked at initialization after execution again.
    Nothing.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,944
    Sorry what do you mean by "re-invoked". We are returning the receipt returned by Apple, we have no control over this.
     
  5. Seung-Hur

    Seung-Hur

    Joined:
    Apr 5, 2016
    Posts:
    4
    Sorry for the confusion.

    At the time of purchase, after returning PurchaseProcessingResult.Pending from ProcessPurchase,
    If my code was terminated without calling controller.ConfirmPendingPurchase,
    When I rerun my app again and initialize the IAP, ProcessPurchase is called.

    At this time, my code can check the application receipt, but not the transaction receipt through m_AppleExtensions.GetTransactionReceiptForProduct.

    Thank you.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,944
    Why not? Please be specific, with examples.
     
  7. Seung-Hur

    Seung-Hur

    Joined:
    Apr 5, 2016
    Posts:
    4
    Code (CSharp):
    1. public PurchaseProcessingResult ProcessPurchase (PurchaseEventArgs purchaseEventArgs) {
    2.  
    3.     m_LastTransactionID = purchaseEventArgs.purchasedProduct.transactionID;
    4.  
    5.     try {
    6.         var result = validator.Validate (purchaseEventArgs.purchasedProduct.receipt);
    7.  
    8.         foreach (IPurchaseReceipt productReceipt in result) {
    9.  
    10.             DateTime utcToLocal = productReceipt.purchaseDate.ToLocalTime ();
    11.  
    12.             AppleInAppPurchaseReceipt apple = productReceipt as AppleInAppPurchaseReceipt;
    13.  
    14.             if (productReceipt.transactionID == m_LastTransactionID) {
    15.  
    16.                 logBuyTransaction += "productID    - " + productReceipt.productID + "\n";
    17.                 logBuyTransaction += "purchaseDate - " + productReceipt.purchaseDate + "\n";
    18.                 logBuyTransaction += "transactionID - " + productReceipt.transactionID + "\n";
    19.                 logBuyTransaction += "utcToLocal - " + utcToLocal + "\n";
    20.  
    21.                 if (null != apple) {
    22.                     logBuyTransaction += "originalTransactionIdentifier = " + apple.originalTransactionIdentifier + "\n";
    23.                     logBuyTransaction += "subscriptionExpirationDate = " + apple.subscriptionExpirationDate + "\n";
    24.                     logBuyTransaction += "cancellationDate = " + apple.cancellationDate + "\n";
    25.                     logBuyTransaction += "quantity = " + apple.quantity + "\n";
    26.                 }
    27.                 logBuyTransaction += "ReceiptForProduct = " + m_AppleExtensions.GetTransactionReceiptForProduct (purchaseEventArgs.purchasedProduct);
    28.  
    29.                  Debug.Log (logBuyTransaction);
    30.                  //server validation
    31.                  ///....
    32.  
    33.                  return PurchaseProcessingResult.Pending;
    34.  
    35.             }
    36.  
    37.  
    38.         }
    39.  
    40.     } catch (IAPSecurityException ex) {
    41.         Debug.Log ("Invalid receipt --- " + ex);
    42.         return PurchaseProcessingResult.Complete;
    43.     }
    44.  
    45. }
    46.  

    The log at the time of purchase.

    productID - 1038
    purchaseDate - 07/09/2019 00:31:06
    transactionID - 1000000544813537
    utcToLocal - 07/09/2019 09:31:06
    originalTransactionIdentifier = 1000000544813537
    subscriptionExpirationDate = 01/01/0001 00:00:00
    cancellationDate = 01/01/0001 00:00:00
    quantity = 1
    ReceiptForProduct = ewoJInNpZ25hdHVyZSIgPSAiQTBoTEZ2cGNjT21YZnhSVCtzQ1c........
    IAPManager:processPurchase(PurchaseEventArgs)
    UnityEngine.Purchasing.PurchasingManager:processPurchaseIfNew(Product)
    UnityEngine.Purchasing.JSONStore:OnPurchaseSucceeded(String, String, String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()
    (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)


    Log after app restart.


    productID - 1038
    purchaseDate - 07/09/2019 00:31:06
    transactionID - 1000000544813537
    utcToLocal - 07/09/2019 09:31:06
    originalTransactionIdentifier = 1000000544813537
    subscriptionExpirationDate = 01/01/0001 00:00:00
    cancellationDate = 01/01/0001 00:00:00
    quantity = 1
    ReceiptForProduct =
    IAPManager:processPurchase(PurchaseEventArgs)
    UnityEngine.Purchasing.PurchasingManager:processPurchaseIfNew(Product)
    UnityEngine.Purchasing.PurchasingManager:OnProductsRetrieved(List`1)
    UnityEngine.Purchasing.AppleStoreImpl:OnProductsRetrieved(String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()

    (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)

    Version - UnityIAP 1.22 , Unity 5.6.6f2
     
    Last edited: Jul 11, 2019