Exemplo n.º 1
0
    void StartPurchaseResult(PlayfabPurchaser purchaser)
    {
        PurchaseTracker.instance.Add(purchaser);
        SaveLoad.Save();

        purchaser.PayForPurchase(result => PayForPurchaserResult(purchaser), error => Error(purchaser));
    }
Exemplo n.º 2
0
    public PlayfabPurchaser ResumeConfirmingPurchase(string orderId, Action <PlayfabPurchaser> onResult, Action <PlayfabPurchaser> onError)
    {
        var purchaser = new PlayfabPurchaser();

        purchaser.ResumeConfirmingPurchase(orderId, result => { ConfirmPurchaseResult(purchaser); onResult(purchaser); }, error => { Error(purchaser); onError(purchaser); });
        return(purchaser);
    }
Exemplo n.º 3
0
    public PlayfabPurchaser Purchase(params CatalogItemInfo[] catalogItemInfos)
    {
        var purchaser = new PlayfabPurchaser();

        purchaser.StartPurchase(catalogItemInfos, result => StartPurchaseResult(purchaser), error => Error(purchaser));
        return(purchaser);
    }
Exemplo n.º 4
0
    public void ConfirmAllPurchases()
    {
        List <TrackablePurchase> purchases = PurchaseTracker.instance.TryGetAll();

        if (purchases != null)
        {
            Debug.Log("Confirming all purchases.");

            DateTime trackingCutOffUTC = DateTime.UtcNow - maxTrackingTime;

            for (int i = 0, len = purchases.Count; i < len; ++i)
            {
                TrackablePurchase purchaseTracker = purchases[i];
                PlayfabPurchaser  purchaser       = ResumeConfirmingPurchase(purchaseTracker.orderId, purchaser =>
                {
                },
                                                                             onError =>
                {
                    if (purchaseTracker.trackingStartDateUTC < trackingCutOffUTC)
                    {
                        Debug.LogWarning("No longer tracking order Id after " + maxTrackingTime.TotalHours + " hours, " + purchaseTracker.orderId);
                        PurchaseTracker.instance.Remove(purchaseTracker.orderId);
                    }
                });
            }
        }
    }
Exemplo n.º 5
0
 public void ApplyConfirmationResult(PlayfabPurchaser purchaser)
 {
     if (purchaser.confirmPurchaseResult != null)
     {
         PurchaseTracker.instance.Remove(purchaser.orderId);
         ApplyItemsToGame(purchaser.confirmPurchaseResult.Items);
     }
 }
Exemplo n.º 6
0
 void Error(PlayfabPurchaser purchaser)
 {
     if (purchaser.error.ErrorAwaitingPayPalConfirmationPage())
     {
     }
     else
     {
         Debug.LogError("Unkown purchase error\n" + purchaser.error.GenerateErrorReport());
     }
 }
Exemplo n.º 7
0
 void PayForPurchaserResult(PlayfabPurchaser purchaser)
 {
     if (purchaser.IsAwaitingConfirmationPage())
     {
         purchaser.OpenConfirmationPage();
     }
     else
     {
         ConfirmPurchase(purchaser);
     }
 }
Exemplo n.º 8
0
 void OnClick()
 {
     loginWizard.Login(false,
                       result: () =>
     {
         if (playfabPurchaser == null || playfabPurchaser.error != null)
         {
             playfabPurchaser = CatalogManager.instance.Purchase(catalogItemInfo);
         }
     },
                       error: () =>
     {
     });
 }
Exemplo n.º 9
0
 void ConfirmPurchaseResult(PlayfabPurchaser playfabPurchaser)
 {
     ApplyConfirmationResult(playfabPurchaser);
 }
Exemplo n.º 10
0
 void ConfirmPurchase(PlayfabPurchaser purchaser)
 {
     purchaser.ConfirmPurchase(result => ConfirmPurchaseResult(purchaser), error => Error(purchaser));
 }