コード例 #1
0
        /// <summary>
        /// Implementation of com.android.billingclient.api.PurchasesUpdatedListener#onPurchasesUpdated
        /// </summary>
        /// <param name="billingResult"></param>
        /// <param name="purchasesList"></param>
        void onPurchasesUpdated(AndroidJavaObject billingResult, AndroidJavaObject purchasesList)
        {
            GoogleBillingResult result = new GoogleBillingResult(billingResult);

            if (result.responseCode == BillingClientResponseEnum.OK() && purchasesList != null)
            {
                ApplyOnPurchases(purchasesList, OnPurchaseOk);
            }
            else if (result.responseCode == BillingClientResponseEnum.USER_CANCELED() && purchasesList != null)
            {
                ApplyOnPurchases(purchasesList, OnPurchaseCanceled);
            }
            else if (result.responseCode == BillingClientResponseEnum.ITEM_ALREADY_OWNED() && purchasesList != null)
            {
                ApplyOnPurchases(purchasesList, OnPurchaseAlreadyOwned);
            }
            else
            {
                HandleErrorCases(result, purchasesList);
            }
        }
コード例 #2
0
 void HandleErrorCases(GoogleBillingResult billingResult, AndroidJavaObject purchasesList)
 {
     if (purchasesList == null)
     {
         if (billingResult.responseCode == BillingClientResponseEnum.ITEM_ALREADY_OWNED())
         {
             m_GooglePurchaseCallback.OnPurchaseFailed(
                 new PurchaseFailureDescription(
                     m_LastKnownProductService.GetLastKnownProductId(),
                     PurchaseFailureReason.DuplicateTransaction,
                     billingResult.debugMessage
                     )
                 );
         }
         else if (billingResult.responseCode == BillingClientResponseEnum.USER_CANCELED())
         {
             m_GooglePurchaseCallback.OnPurchaseFailed(
                 new PurchaseFailureDescription(
                     m_LastKnownProductService.GetLastKnownProductId(),
                     PurchaseFailureReason.UserCancelled,
                     billingResult.debugMessage
                     )
                 );
         }
         else
         {
             m_GooglePurchaseCallback.OnPurchaseFailed(
                 new PurchaseFailureDescription(
                     m_LastKnownProductService.GetLastKnownProductId(),
                     PurchaseFailureReason.Unknown,
                     billingResult.debugMessage + " {M: GPUL.HEC}"
                     )
                 );
         }
     }
     else
     {
         ApplyOnPurchases(purchasesList, billingResult, OnPurchaseFailed);
     }
 }