@Override public void didFail (SKRequest request, NSError error) { log(LOGTYPEERROR, "Error requesting products: " + (error != null ? error.toString() : "unknown")); // Products request failed (likely due to insuficient network connection). observer.handleInstallError(new RuntimeException("Error requesting products: " + (error != null ? error.toString() : "unknown"))); } }
@Override public void didFail (SKRequest request, NSError error) { String errorMessage = "Error requesting product info to later purchase: " + (error != null ? error.toString() : "unknown"); log(LOGTYPEERROR, errorMessage); observer.handlePurchaseError(new RuntimeException(errorMessage)); } }
@Override public void restoreCompletedTransactionsFailed (SKPaymentQueue queue, NSError error) { // Restoration failed. // Decide if user cancelled or transaction failed. if (error.getCode() == SKErrorCode.PaymentCancelled.value()) { log(LOGTYPEERROR, "Restoring of transactions was cancelled by user!"); observer.handleRestoreError(new RuntimeException("Restoring of purchases was cancelled by user!")); } else { log(LOGTYPEERROR, "Restoring of transactions failed: " + error.toString()); observer.handleRestoreError(new RuntimeException("Restoring of purchases failed: " + error.toString())); } } }
@Override public void restoreFailed(SKPaymentQueue queue, NSError error) { restoredTransactions.clear(); if (error != null && error.getCode() == 2) { for (BillingObserver observer : billingObservers) { observer.onRestoreCancel(); } } else { BillingError billingError = new BillingError(ErrorType.UNKNOWN, "Error restoring transactions: " + (error != null ? error.toString() : "unknown")); for (BillingObserver observer : billingObservers) { observer.onRestoreError(billingError); } } restoringTransactions = false; }
@Override public void didFail(SKRequest request, NSError error) { productsRequest = null; if (error != null && error.getCode() == 2) { for (BillingObserver observer : billingObservers) { observer.onProductsRequestCancel(); } } else { BillingError billingError = new BillingError(ErrorType.UNKNOWN, "Error requesting product data: " + (error != null ? error.toString() : "unknown")); for (BillingObserver observer : billingObservers) { observer.onProductsRequestError(billingError); } } } }
@Override public void didFail (SKRequest request, NSError error) { // Receipt refresh request failed. Let's just continue. log(LOGTYPEERROR, "Receipt fetching failed: " + error.toString()); log(LOGTYPELOG, "Transaction was completed: " + getOriginalTxID(transaction)); observer.handlePurchase(t); // Finish transaction. SKPaymentQueue.getDefaultQueue().finishTransaction(transaction); } });
@Override public void transactionFailed(SKPaymentTransaction skTransaction, NSError error) { if (error != null && error.getCode() == 2) { for (BillingObserver observer : billingObservers) { observer.onPurchaseCancel(); } } else { Transaction transaction = transactionFromSKPaymentTransaction(skTransaction); if (autoFinishTransactions) { transaction.finish(); } BillingError billingError = new BillingError(ErrorType.UNKNOWN, "Error purchasing product: " + (error != null ? error.toString() : "unknown")); for (BillingObserver observer : billingObservers) { observer.onPurchaseError(transaction, billingError); } } }