Fehler validieren Kaufbelastung mit PlayFab und Unity3DAndroid

Forum für diejenigen, die für Android programmieren
Anonymous
 Fehler validieren Kaufbelastung mit PlayFab und Unity3D

Post by Anonymous »

In meinem Unity Mobile/Android -Spiel verwende ich Google Play IAP und muss dann den Kauf mit PlayFab validieren. Ich habe meine Protokolle der Quittungsdaten beigefügt, die ich zusammen mit dem Fehler sende, und den Code.[System.Serializable]
public class ReceiptWrapper
{
public string Store;
public string Payload;
}

[System.Serializable]
public class GooglePayloadWrapper
{
public string json;
public string signature;
}

public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
{
int pearlAmount = GetPearlAmount(args.purchasedProduct.definition.id);

Debug.Log($"JHL: Processing purchase for product: {args.purchasedProduct.definition.id}");
Debug.Log($"JHL: Raw receipt: {args.purchasedProduct.receipt}");

try
{
// Parse the outer receipt wrapper
var wrapper = JsonUtility.FromJson(args.purchasedProduct.receipt);
Debug.Log($"JHL: Store: {wrapper.Store}");
Debug.Log($"JHL: Payload: {wrapper.Payload}");

if (Application.platform == RuntimePlatform.Android)
{
// Parse the Google Play specific payload
var gpDetails = JsonUtility.FromJson(wrapper.Payload);
Debug.Log($"JHL: Google JSON: {gpDetails.json}");
Debug.Log($"JHL: Google Signature: {gpDetails.signature}");

// The json field is already a JSON string, don't parse it again
var request = new ValidateGooglePlayPurchaseRequest
{
ReceiptJson = gpDetails.json,
Signature = gpDetails.signature,
CurrencyCode = args.purchasedProduct.metadata.isoCurrencyCode,
PurchasePrice = (uint)(args.purchasedProduct.metadata.localizedPrice * 100)
};

// Log the complete request for debugging
Debug.Log($"JHL: Complete request being sent to PlayFab:");
Debug.Log($"JHL: ReceiptJson: {request.ReceiptJson}");
Debug.Log($"JHL: Signature: {request.Signature}");
Debug.Log($"JHL: CurrencyCode: {request.CurrencyCode}");
Debug.Log($"JHL: PurchasePrice: {request.PurchasePrice}");

PlayFabClientAPI.ValidateGooglePlayPurchase(request,
result => {
Debug.Log($"JHL: Purchase validation successful!");
Player.Instance.AddPearls(pearlAmount);
UIFunctions.Instance.ShowMessage($"Purchase successful!\nAdded {pearlAmount} pearls");
},
error => {
Debug.LogError($"JHL: Failed to validate purchase: {error.ErrorMessage}");
Debug.LogError($"JHL: Error details: {JsonUtility.ToJson(error)}");
Debug.LogError($"JHL: HTTP code: {error.HttpCode}");
Debug.LogError($"JHL: Error code: {error.Error}");
UIFunctions.Instance.ShowMessage("Purchase validation failed.\nPlease contact support.");
});
}
}
catch (System.Exception e)
{
Debug.LogError($"JHL: Exception while processing receipt: {e}");
Debug.LogError($"JHL: Stack trace: {e.StackTrace}");
}

return PurchaseProcessingResult.Complete;
}
< /code>
Protokolle < /p>
Info Unity JHL: Verarbeitung Kauf für Produkt: com.pixelfish.pearl100
Info Unity IAPMANAGER: processPurchase (CUMESEEventArgs)
info unityEngine. UnityEngine.Purchasing.extension {"orderId":"GPA.3396-9471-9799-74081","packageName":"com.PufferfishStudios.PixelFish","productId":"com.pixelfish.pearl100","purchaseTime":1743075692104,"purchaseState":0,"purchaseToken" : "doeklojbfffbgPhcipbmflaa.ao-j1ozclvrrlk2hohz343vydytid4cxjx2axf-r9-vcngciktek5q3gbqatb9Duq Pubvgeayt9dggxsfjmlywvckw8qx2_lw_3q4pvtrlutjlp0yolcl8a "," Quantität ": 1," Anerkennung ": false}
Info Unity IAPMANAGER: ProcessPurchase (PurchasEEventArgs)
Info Unity UnityEngine.Purchasing.PurchasingManager: ProcessPurchaseifNew (Produkt)
Info Unity UnityEngine.Purchasing.Extension. JEBE5C6YXZFN/RO36+FWTOEXFKHQCTVEHE7/TLJZKOVGFZXT6FKTNXRWQBG0F6OMI5+XZ03RUOSN6RNQIMMIMM6AN CRE3IKWYFGRA9PKFUGJZ0EO2C/5YRTLNLMUYERO9VKT/L7VOWL9VXCVKG7/UQR+6SSAUHSJ7CD5CYKNX8DXVSGZ N02zba9ajom/jzhyumjdlnemq5yBtgpjxgj8hfisy/ybrmskkkhsy+mcbuhu/yavdct0box/nczqud7nt5odkbz qkq8osprrh/2SBXJ21OERDE2PASCEQQHDEUHRE+O+MUAYWHWXDXMQUFPSDDYSXVUDYCLLQI9OXNX5YYG6G ==
Info Unity IapManager: ProcessPurchase (CUPASEEventArgs)
Info Unity UnityEngine.Purchasing. IAPMANAGER: ProcessPurchase (CupaSeEventArgs)
Info Unity UnityEngine.Purchasing.PurchasingManager: ProcessPurchaseIfNew (Produkt)
Info Unity UnityEngine.Purchasing.Extension. Iapmanager: processPurchase (baufasEventArgs)
info unity unityEngine.Purchasing.PurchasingManager: processPurchaseIfNew (Produkt)
Info Unity UnityEngine c: b__18_1 (PlayFaberror)
Fehlereinheit PlayFab.internal.playFabunityHttp: OnResponse (Sinne, CallRequestContainer)
Fehlereinheit Unity PlayFab.internal.d__12: moveNext ()
INITEUMUCEUTINE.SETUPIN.SETUPIN. Intptr)
Fehlereinheit
Fehlereinheit JHL: Fehlerdetails: {"Apiendpoint": " /client /validateGooglePlayPurchase", "httpcode": 400, "httpstatus": "BadRequest", "Fehler": 1021, ErrorMessage ":"}}
c: b__18_1 (PlayFaberror)
Fehlereinheit PlayFab.internal.playFabunityHttp: OnResponse (Sinne, CallRequestContainer)
Fehlereinheit Unity PlayFab.internal.d__12: moveNext ()
INITEUMUCEUTINE.SETUPIN.SETUPIN. IntPtr)
Error Unity
Error Unity JHL: HTTP code: 400
Error Unity c:b__18_1(PlayFabError)
Error Unity PlayFab.Internal.PlayFabUnityHttp:OnResponse(String, CallRequestContainer)
Error Unity PlayFab.Internal.d__12:MoveNext()
Error Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
Error Unity
Error Unity JHL: Error code: InvalidReceipt
Error Unity c:b__18_1(PlayFabError)
Error Unity Playfab.internal.playFabunityHttp: OnResponse (String, CallRequestContainer)
Fehlereinheit Playfab.internal.d__12: moveNext ()
Fehlereinheit UnityEngine.SetupCoroutine: Invokemovext (Ienumerator, Intptr)
ERRECTE < /POKEMEXT (Ienumerator, INTPTR) >

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post