예제 #1
0
 public void HandleFinishTransaction(ProductDefinition product, GooglePurchase googlePurchase, GoogleBillingResult billingResult, string purchaseToken)
 {
     if (!m_ProcessedPurchaseToken.Contains(purchaseToken))
     {
         if (billingResult.responseCode == GoogleBillingResponseCode.k_Ok)
         {
             m_ProcessedPurchaseToken.Add(purchaseToken);
             CallPurchaseSucceededUpdateReceipt(product, googlePurchase, purchaseToken);
         }
         else if (IsResponseCodeInRecoverableState(billingResult))
         {
             FinishTransaction(product, purchaseToken);
         }
         else
         {
             m_StoreCallback?.OnPurchaseFailed(
                 new PurchaseFailureDescription(
                     product.storeSpecificId,
                     PurchaseFailureReason.Unknown,
                     billingResult.debugMessage + " {code: " + billingResult.responseCode + ", M: GPSFTS.HFT}"
                     )
                 );
         }
     }
 }
        public void UpgradeDowngradeSubscription(string oldSku, string newSku, int desiredProrationMode)
        {
            Product product    = m_StoreCallback.FindProductById(newSku);
            Product oldProduct = m_StoreCallback.FindProductById(oldSku);

            if (product != null && product.definition.type == ProductType.Subscription &&
                oldProduct != null && oldProduct.definition.type == ProductType.Subscription)
            {
                m_GooglePlayStoreService.Purchase(product.definition, oldProduct, desiredProrationMode);
            }
            else
            {
                m_StoreCallback?.OnPurchaseFailed(
                    new PurchaseFailureDescription(
                        newSku ?? "",
                        PurchaseFailureReason.ProductUnavailable,
                        "Please verify that the products are subscriptions and are not null."));
            }
        }
예제 #3
0
        public void OnPurchaseFailed(PurchaseFailureDescription failure, string json = null)
        {
            if (!eventsDisabled)
            {
                SendPurchaseFailedEvent(failure, json);
            }

            lastPurchaseFailureDescription = failure;
            _lastPurchaseErrorCode         = ParseStoreSpecificPurchaseErrorCode(json);

            unity.OnPurchaseFailed(failure);
        }
        void FinishTransaction(GooglePurchase purchase)
        {
            Product product = m_StoreCallback.FindProductById(purchase.sku);

            if (product != null)
            {
                m_TransactionService.FinishTransaction(product.definition, purchase.purchaseToken);
            }
            else
            {
                m_StoreCallback.OnPurchaseFailed(new PurchaseFailureDescription(purchase.sku, PurchaseFailureReason.ProductUnavailable, "Product was not found but was purchased"));
            }
        }
예제 #5
0
        /// <summary>
        ///
        /// </summary>
        public void OnPurchaseFailed(string error, int code)
        {
            if (error.Contains("response:"))
            {
                int startAt = error.IndexOf("response:") + 10;
                int lastAt  = error.IndexOf(":", startAt);
                int.TryParse(error.Substring(startAt, lastAt - startAt), out code);
            }

            PurchaseFailureReason reason = PurchaseFailureReason.Unknown;

            switch (code)
            {
            case 1:
            case -1005:
                reason = PurchaseFailureReason.UserCancelled;
                break;

            case 2:
            case 3:
            case -1001:
            case -1009:
                reason = PurchaseFailureReason.PurchasingUnavailable;
                break;

            case 4:
                reason = PurchaseFailureReason.ProductUnavailable;
                break;

            case 5:
            case -1003:
            case -1004:
            case -1007:
                reason = PurchaseFailureReason.SignatureInvalid;
                break;

            case 7:
                reason = PurchaseFailureReason.ExistingPurchasePending;
                break;
            }

            callback.OnPurchaseFailed(new PurchaseFailureDescription(currentProduct, reason, error));
        }
예제 #6
0
        public void OnPurchaseFailed(string error, int code)
        {
            PurchaseFailureReason reason = PurchaseFailureReason.Unknown;

            switch (code)
            {
            case 1:
            case -1005:
                reason = PurchaseFailureReason.UserCancelled;
                break;

            case 3:
            case -1009:
                reason = PurchaseFailureReason.PurchasingUnavailable;
                break;

            case 4:
            case -1006:
                reason = PurchaseFailureReason.ProductUnavailable;
                break;

            case 5:
            case -1002:
            case -1003:
            case -1004:
                reason = PurchaseFailureReason.SignatureInvalid;
                break;

            case 7:
            case -1010:
                reason = PurchaseFailureReason.ExistingPurchasePending;
                break;
            }

            callback.OnPurchaseFailed(new PurchaseFailureDescription(currentProduct, reason, error));
        }
 public void OnPurchaseFailed(PurchaseFailureDescription purchaseFailureDescription)
 {
     m_StoreCallback?.OnPurchaseFailed(purchaseFailureDescription);
 }
 public void OnPurchaseFailed(PurchaseFailureDescription desc)
 {
     m_Util.RunOnMainThread(() => m_ForwardTo.OnPurchaseFailed(desc));
 }
예제 #9
0
 /// <summary>
 /// Method we are calling for any failed (real money) results in the billing interaction.
 /// </summary>
 public void OnPurchaseFailed(PlayFabError error)
 {
     callback.OnPurchaseFailed(new PurchaseFailureDescription(currentProduct, PurchaseFailureReason.PaymentDeclined, ""));
 }