Files
UnrealEngineUWP/Engine/Build/Android/Java
Rafa Lecina 2868e7204b Added support for subscriptions and full server to server validation to OnlinePurchaseGooglePlay.
Full server validation is enabled by setting ``bDisableLocalAcknowledgeAndConsume`` in ``OnlineSubsystemGooglePlay.Store`` section on the ini files. This way consume and acknowledge should be called after server validation through server to server calls to GooglePlay services and all product types allowed by GooglePlay store can be handled

Subscriptions are identified using a unique product id on GooglePlay like any other regular in app products. The main difference with a regular product is that the same subscription can be purchased by many different ways depending on the GooglePlay app configuration.
A subscription may have different base plans which are identified by a string id. Each base plan defines a base price, whetrer the plan is autorenewable or not, the length before expiration. For instance, a subscription may have a base plan with a price for a 1 month subscription and another plan with a different price for a 1 year subscription
Each base plan may have several offers which are identified by a string id. Those may be triggered on purchase by GooglePlay or by the developer. Those offers may configure several phases on a subscription depending on the number of times it has been renewed. For instance, an offer could set a Free period, then a discount on the first 3 renewals and then following renewals would be at the base plan price
Subscription product ids seen from the engine side have a special format starting with "s-" prefix (``-`` is not allowed in product ids in the GooglePlay store, so there would be no broken id on the licensees side) . In order to request product information (QueryOffersById) the product id can be requested with or without that prefix, but all the product ids reported to the engine will contain the prefix in case the product is a subscription
In order to identify base plans, offers and its price phases ``QueryOffersById`` will store a ``FOnlineStoreOffer``instance for each allowed combination
The product id format for those will be s-<store product id>:<base plan id>:<offer id>:<price phase index>
An instance for each base plan will be created without the offer id and price phase index. Also, an instance for each offer will be created without the price index part and containing the final price point(the last price point. This was explicitly requested) in addition to all the price steps
For example, this could be the list of ``FOnlineStoreOffer`` instances created by ``QueryOffersById`` requesting ``s-test_subscription_1``(which in the store would be identified as just ``test_subscription_1``). That would be a subscription with 2 plans, one of the with 2 offers. First offer would contain 3 phases and second just 2 phases
``s-test_subscription_1:base-plan1``
``s-test_subscription_1:base-plan1:offer-1``
``s-test_subscription_1:base-plan1:offer-1:0``
``s-test_subscription_1:base-plan1:offer-1:1``
``s-test_subscription_1:base-plan1:offer-1:2``
``s-test_subscription_1:base-plan1:offer-2``
``s-test_subscription_1:base-plan1:offer-2:0``
``s-test_subscription_1:base-plan1:offer-2:1``
``s-test_subscription_1:base-plan2``

To ``CheckOut`` a product any of those identifiers could be used. The price index would be discarded since a subscription offer must be started from the initial step (GooglePlay already keeps track if the user already used the Free trial period and removes it). If the identifier contains an offer id the subscription will be purchased using that offer

When receipts are queried using ``QueryReceipts`` we will receive receipts for any non consumed product, any pending product (user still needs to pay using an external method) and for any non expired subscriptions
GoogleBilling Library do not notify on device for expired/canceled/paused subscriptions. Real time notifications can be configured on servers to notify validation/authority servers about those changes and act accordingly, so no additional checks should be done from the client
Only notifications received are when a new product is purchased/becomes pending or a subscriptions is activated or resumed. In order to check for receipts status on device the only way should be to call ``QueryReceipts```again and note that there is no receipt for the given subscription. This should be done only in case validations are done locally on device (which is not secure, but there are many serverless games around in mobile)

#jira UE-176438
#review @Bertrand.Carre, @Michael.Kirzinger, @Chris.Varnsverry, @Dashan.Yue, @Chris.Babcock
#preflight 641c4bdb76461c460b9ceaf3

[CL 25037177 by Rafa Lecina in ue5-main branch]
2023-04-14 03:30:00 -04:00
..