Add myket in app purchase
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

46 rader
1.7 KiB

  1. /* Copyright (c) 2012 Google Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. package ir.appeto.myketpayment.util;
  16. /**
  17. * Represents the result of an in-app billing operation.
  18. * A result is composed of a response code (an integer) and possibly a
  19. * message (String). You can get those by calling
  20. * {@link #getResponse} and {@link #getMessage()}, respectively. You
  21. * can also inquire whether a result is a success or a failure by
  22. * calling {@link #isSuccess()} and {@link #isFailure()}.
  23. */
  24. public class IabResult {
  25. int mResponse;
  26. String mMessage;
  27. public IabResult(int response, String message) {
  28. mResponse = response;
  29. if (message == null || message.trim().length() == 0) {
  30. mMessage = IabHelper.getResponseDesc(response);
  31. }
  32. else {
  33. mMessage = message + " (response: " + IabHelper.getResponseDesc(response) + ")";
  34. }
  35. }
  36. public int getResponse() { return mResponse; }
  37. public String getMessage() { return mMessage; }
  38. public boolean isSuccess() { return mResponse == IabHelper.BILLING_RESPONSE_RESULT_OK; }
  39. public boolean isFailure() { return !isSuccess(); }
  40. public String toString() { return "IabResult: " + getMessage(); }
  41. }