modify scripts
This commit is contained in:
@ -49,6 +49,7 @@ namespace WordsToolkit.Scripts.Popups
|
||||
}
|
||||
|
||||
EventManager.GetEvent<string>(EGameEvent.PurchaseSucceeded).Subscribe(PurchaseSucceded);
|
||||
EventManager.GetEvent<(string, string)>(EGameEvent.PurchaseFailed).Subscribe(PurchaseFailed);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
@ -85,6 +86,44 @@ namespace WordsToolkit.Scripts.Popups
|
||||
}
|
||||
}
|
||||
|
||||
private void PurchaseFailed((string, string) info)
|
||||
{
|
||||
var productId = info.Item1;
|
||||
var errorMessage = info.Item2;
|
||||
|
||||
var errorType = IAPErrorHelper.ParseError(errorMessage);
|
||||
Debug.LogWarning($"Purchase failed for product {productId}: {errorMessage}, Error Type: {errorType}");
|
||||
|
||||
switch (errorType)
|
||||
{
|
||||
case IAPErrorType.InvalidProductID:
|
||||
Debug.LogError($"Invalid product ID: {productId}");
|
||||
ShowErrorMessage("Invalid product ID. Please try again later.");
|
||||
break;
|
||||
case IAPErrorType.UserCancelled:
|
||||
Debug.LogWarning("Purchase cancelled by user.");
|
||||
break;
|
||||
case IAPErrorType.DuplicateTransaction:
|
||||
Debug.LogWarning($"Duplicate transaction for product {productId}. This usually means the purchase was already completed.");
|
||||
break;
|
||||
case IAPErrorType.IAPInitFailed:
|
||||
Debug.LogError("IAP initialization failed. Please check your IAP settings.");
|
||||
ShowErrorMessage("IAP initialization failed. Please try again later.");
|
||||
break;
|
||||
default:
|
||||
ShowErrorMessage($"Payment failed: {errorMessage}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void ShowErrorMessage(string message)
|
||||
{
|
||||
var popup = menuManager.ShowPopup<MessagePopup>();
|
||||
if (popup != null)
|
||||
{
|
||||
popup.SetMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
public void BuyCoins(string id)
|
||||
{
|
||||
// StopInteration();
|
||||
|
||||
Reference in New Issue
Block a user