InAppPurchasesSystemComponent.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include "InAppPurchases/InAppPurchasesBus.h"
  10. #include <AzCore/Component/Component.h>
  11. namespace InAppPurchases
  12. {
  13. class SystemComponent
  14. : public AZ::Component
  15. , public InAppPurchasesRequestBus::Handler
  16. , public InAppPurchasesResponseAccessorBus::Handler
  17. {
  18. public:
  19. AZ_COMPONENT(SystemComponent, "{D0ABA496-16A7-4090-98AB-6D372BE7BD45}");
  20. static void Reflect(AZ::ReflectContext* context);
  21. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  22. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  23. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  24. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  25. ////////////////////////////////////////////////////////////////////////
  26. // InAppPurchasesRequestBus interface implementation
  27. ////////////////////////////////////////////////////////////////////////
  28. void Initialize() override;
  29. void QueryProductInfoById(const AZStd::string& productId) const override;
  30. void QueryProductInfoByIds(AZStd::vector<AZStd::string>& productIds) const override;
  31. void QueryProductInfo() const override;
  32. void QueryProductInfoFromJson(const AZStd::string& filePath) const override;
  33. const AZStd::vector<AZStd::unique_ptr<ProductDetails const> >* GetCachedProductInfo() const override;
  34. const AZStd::vector<AZStd::unique_ptr<PurchasedProductDetails const> >* GetCachedPurchasedProductInfo() const override;
  35. void PurchaseProductWithDeveloperPayload(const AZStd::string& productId, const AZStd::string& developerPayload) const override;
  36. void PurchaseProduct(const AZStd::string& productId) const override;
  37. void QueryPurchasedProducts() const override;
  38. void RestorePurchasedProducts() const override;
  39. void ConsumePurchase(const AZStd::string& purchaseToken) const override;
  40. void FinishTransaction(const AZStd::string& transactionId, bool downloadHostedContent) const override;
  41. void ClearCachedProductDetails() override;
  42. void ClearCachedPurchasedProductDetails() override;
  43. // Response Accessors
  44. bool GetNextProduct() override;
  45. bool GetPreviousProduct() override;
  46. bool GetNextPurchasedProduct() override;
  47. bool GetPreviousPurchasedProduct() override;
  48. AZStd::string GetProductId() override;
  49. AZStd::string GetProductTitle() override;
  50. AZStd::string GetProductDescription() override;
  51. AZStd::string GetProductPrice() override;
  52. AZStd::string GetProductCurrencyCode() override;
  53. AZ::u64 GetProductPriceMicro() override;
  54. AZStd::string GetPurchasedProductId() override;
  55. AZStd::string GetOrderId() override;
  56. AZStd::string GetDeveloperPayload() override;
  57. AZStd::string GetPurchaseTime() override;
  58. AZStd::string GetPurchaseSignature() override;
  59. AZStd::string GetPackageName() override;
  60. AZStd::string GetPurchaseToken() override;
  61. bool IsAutoRenewing() override;
  62. AZStd::string GetRestoredOrderId() override;
  63. AZ::u64 GetSubscriptionExpirationTime() override;
  64. AZ::u64 GetRestoredPurchaseTime() override;
  65. bool HasDownloads() override;
  66. bool IsProductOwned() override;
  67. void ResetIndices() override;
  68. protected:
  69. ////////////////////////////////////////////////////////////////////////
  70. // AZ::Component interface implementation
  71. void Init() override;
  72. void Activate() override;
  73. void Deactivate() override;
  74. ////////////////////////////////////////////////////////////////////////
  75. private:
  76. int m_productInfoIndex;
  77. int m_purchasedProductInfoIndex;
  78. };
  79. }