GADInAppPurchase.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // GADInAppPurchase.h
  3. // Google Mobile Ads SDK
  4. //
  5. // Copyright 2013 Google Inc. All rights reserved.
  6. //
  7. #import <Foundation/Foundation.h>
  8. #import <StoreKit/StoreKit.h>
  9. @protocol GADDefaultInAppPurchaseDelegate;
  10. #pragma mark - Default Purchase Flow
  11. /// The consumable in-app purchase item that has been purchased by the user. The purchase flow is
  12. /// handled by the Google Mobile Ads SDK.
  13. /// Instances of this class are created and passed to your in-app purchase delegate after the user
  14. /// has successfully paid for a product. Your code must correctly deliver the product to the user
  15. /// and then call the didCompletePurchase method to finish the transaction.
  16. @interface GADDefaultInAppPurchase : NSObject
  17. /// Enables the default consumable product in-app purchase flow handled by the Google Mobile Ads
  18. /// SDK. The GADDefaultInAppPurchaseDelegate object is retained while the default purchase flow is
  19. /// enabled. This method adds a SKPaymentTransactionObserver to the default SKPaymentQueue.
  20. ///
  21. /// Call this method early in your application to handle unfinished transactions from previous
  22. /// application sessions. For example, call this method in your application delegate's
  23. /// application:didFinishLaunchingWithOptions: method.
  24. + (void)enableDefaultPurchaseFlowWithDelegate:(id<GADDefaultInAppPurchaseDelegate>)delegate;
  25. /// Disables the default in-app purchase flow handled by the Google Mobile Ads SDK and releases the
  26. /// associated GADDefaultInAppPurchaseDelegate object.
  27. + (void)disableDefaultPurchaseFlow;
  28. /// The in-app purchase product ID.
  29. @property(nonatomic, readonly, copy) NSString *productID;
  30. /// The product quantity.
  31. @property(nonatomic, readonly, assign) NSInteger quantity;
  32. /// The purchased item's completed payment transaction. Your application can use this property's
  33. /// data to save a permanent record of the completed payment. The default purchase flow will finish
  34. /// the transaction on your behalf. Do not finish the transaction yourself.
  35. @property(nonatomic, readonly, strong) SKPaymentTransaction *paymentTransaction;
  36. /// The in-app purchase delegate object must first deliver the user's item and then call this
  37. /// method. Failure to call this method will result in duplicate purchase notifications.
  38. - (void)finishTransaction;
  39. @end
  40. #pragma mark - Custom Purchase Flow
  41. /// Enum of the different statuses resulting from processing a purchase.
  42. typedef NS_ENUM(NSInteger, GADInAppPurchaseStatus) {
  43. kGADInAppPurchaseStatusError = 0, ///< Error occured while processing the purchase.
  44. kGADInAppPurchaseStatusSuccessful = 1, ///< Purchase was completed successfully.
  45. kGADInAppPurchaseStatusCancel = 2, ///< Purchase was cancelled by the user.
  46. kGADInAppPurchaseStatusInvalidProduct = 3 ///< Error occured while looking up the product.
  47. };
  48. /// The in-app purchase item to be purchased with the purchase flow handled by you, the
  49. /// application developer.
  50. /// Instances of this class are created and passed to your GADInAppPurchaseDelegate object when
  51. /// users click a buy button. It is important to report the result of the purchase back to the SDK
  52. /// in order to track metrics about the transaction.
  53. @interface GADInAppPurchase : NSObject
  54. /// The in-app purchase product ID.
  55. @property(nonatomic, readonly, copy) NSString *productID;
  56. /// The product quantity.
  57. @property(nonatomic, readonly, assign) NSInteger quantity;
  58. /// The GADInAppPurchaseDelegate object must call this method after handling the in-app purchase for
  59. /// both successful and unsuccessful purchase attempts. This method reports ad conversion and
  60. /// purchase status information to Google.
  61. - (void)reportPurchaseStatus:(GADInAppPurchaseStatus)purchaseStatus;
  62. @end