Problems while checking if user purchases a subscription: empty array for appLicense.AddOnLicenses, weird extra sku object for product

Lingvanex Translator 1 Reputation point
2020-09-14T13:27:06.093+00:00

Hi, I'm trying to add subscriptions to my app. And I have problems while checking if the user purchases a subscription. I have 2 problems:

  1. Method CheckIfUserHasSubscriptionAsync() from documentation always return empty array after I bought a subscription (I tested either with and without trial). I can see that product has property "IsInUserCollection":true when calling method GetSubscriptionProductAsync(), but appLicense.AddOnLicenses inside CheckIfUserHasSubscriptionAsync() is always empty.
  2. Method GetSubscriptionProductAsync() returns strange response with 1 extra sku.

In the documentation in the code comment it is written:

// Check if the first SKU is a trial and notify the customer that a trial is available.
// If a trial is available, the Skus array will always have 2 purchasable SKUs and the
// first one is the trial. Otherwise, this array will only have one SKU.

But actually I have always 3 purchasable SKUs after purchasing a product. And weird thing is that SKU that has the property "IsInUserCollection": true doesn't have any SubscriptionInfo:

   [  
     {  
       "StoreId": "9NJJSGSS23P8",  
       "IsInUserCollection": true,  
       "Title": "1 год подписки",  
       "ProductKind": "Durable",  
       "Price": {  
         "CurrencyCode": "USD",  
         "FormattedPrice": "79,99 $",  
         "FormattedBasePrice": "79,99 $",  
         "FormattedRecurrencePrice": "79,99 $",  
         "IsOnSale": false,  
         "SaleEndDate": "9998-12-30T03:00:00.0000000"  
       },  
       "HasDigitalDownload": false,  
       "InAppOfferToken": "OneYearSubscriptionWithTrialFinal",  
       "Skus": [  
         {  
           "StoreId": "9NJJSGSS23P8/0100",  
           "Title": "1 год подписки",  
           "IsInUserCollection": false,  
           "IsTrial": false,  
           "Price": {  
             "CurrencyCode": "USD",  
             "FormattedPrice": "79,99 $",  
             "FormattedBasePrice": "79,99 $",  
             "FormattedRecurrencePrice": "79,99 $",  
             "IsOnSale": false,  
             "SaleEndDate": "9998-12-30T03:00:00.0000000"  
           },  
           "CollectionData": null,  
           "IsSubscription": true,  
           "SubscriptionInfo": {  
             "BillingPeriod": 1,  
             "BillingPeriodUnit": "Year",  
             "HasTrialPeriod": false,  
             "TrialPeriod": 0,  
             "TrialPeriodUnit": "Week"  
           },  
           "Language": "ru"  
         },  
         {  
           "StoreId": "9NJJSGSS23P8/0101",  
           "Title": "1 год подписки",  
           "IsInUserCollection": false,  
           "IsTrial": false,  
           "Price": {  
             "CurrencyCode": "USD",  
             "FormattedPrice": "0,00 $",  
             "FormattedBasePrice": "0,00 $",  
             "FormattedRecurrencePrice": "79,99 $",  
             "IsOnSale": false,  
             "SaleEndDate": "9998-12-30T03:00:00.0000000"  
           },  
           "CollectionData": null,  
           "IsSubscription": true,  
           "SubscriptionInfo": {  
             "BillingPeriod": 1,  
             "BillingPeriodUnit": "Year",  
             "HasTrialPeriod": true,  
             "TrialPeriod": 1,  
             "TrialPeriodUnit": "Week"  
           },  
           "Language": "ru"  
         },  
         {  
           "StoreId": "9NJJSGSS23P8/0020",  
           "Title": "1 год подписки",  
           "IsInUserCollection": true,  
           "IsTrial": false,  
           "Price": {  
             "CurrencyCode": "USD",  
             "FormattedPrice": "0,00 $",  
             "FormattedBasePrice": "0,00 $",  
             "FormattedRecurrencePrice": "0,00 $",  
             "IsOnSale": false,  
             "SaleEndDate": "9998-12-30T03:00:00.0000000"  
           },  
           "CollectionData": {  
             "CampaignId": "",  
             "StartDate": "2020-09-14T03:00:00.0000000",  
             "EndDate": "2020-09-24T03:00:00.0000000",  
             "AcquiredDate": "2020-09-14T12:26:28.7964538",  
             "IsTrial": true,  
             "TrialTimeRemaining": "10675199:2:48:05,4775807"  
           },  
           "IsSubscription": false,  
           "SubscriptionInfo": null,  
           "Language": "ru"  
         }  
       ]  
     }  
   ]  

For the case when a product doesn't have a trial it has 2 skus, but with the same problem as mentioned above:

   [  
     {  
       "StoreId": "9NVCL1M4W3MT",  
       "IsInUserCollection": true,  
       "Title": "TestSubscription9",  
       "ProductKind": "Durable",  
       "Price": {  
         "CurrencyCode": "USD",  
         "FormattedPrice": "0,00 $",  
         "FormattedBasePrice": "0,00 $",  
         "FormattedRecurrencePrice": "0,00 $",  
         "IsOnSale": false,  
         "SaleEndDate": "9998-12-30T03:00:00.0000000"  
       },  
       "HasDigitalDownload": false,  
       "InAppOfferToken": "TestSubscription9",  
       "Skus": [  
         {  
           "StoreId": "9NVCL1M4W3MT/0100",  
           "Title": "TestSubscription9",  
           "IsInUserCollection": false,  
           "IsTrial": false,  
           "Price": {  
             "CurrencyCode": "USD",  
             "FormattedPrice": "0,00 $",  
             "FormattedBasePrice": "0,00 $",  
             "FormattedRecurrencePrice": "0,00 $",  
             "IsOnSale": false,  
             "SaleEndDate": "9998-12-30T03:00:00.0000000"  
           },  
           "CollectionData": null,  
           "IsSubscription": true,  
           "SubscriptionInfo": {  
             "BillingPeriod": 1,  
             "BillingPeriodUnit": "Month",  
             "HasTrialPeriod": false,  
             "TrialPeriod": 0,  
             "TrialPeriodUnit": "Week"  
           },  
           "Language": "en"  
         },  
         {  
           "StoreId": "9NVCL1M4W3MT/0020",  
           "Title": "TestSubscription9",  
           "IsInUserCollection": true,  
           "IsTrial": false,  
           "Price": {  
             "CurrencyCode": "USD",  
             "FormattedPrice": "0,00 $",  
             "FormattedBasePrice": "0,00 $",  
             "FormattedRecurrencePrice": "0,00 $",  
             "IsOnSale": false,  
             "SaleEndDate": "9998-12-30T03:00:00.0000000"  
           },  
           "CollectionData": {  
             "CampaignId": "",  
             "StartDate": "2020-09-14T03:00:00.0000000",  
             "EndDate": "2020-10-17T03:00:00.0000000",  
             "AcquiredDate": "2020-09-14T12:58:24.8579557",  
             "IsTrial": false,  
             "TrialTimeRemaining": "10675199:2:48:05,4775807"  
           },  
           "IsSubscription": false,  
           "SubscriptionInfo": null,  
           "Language": "en"  
         }  
       ]  
     }  
   ]  
Microsoft Partner Center
Microsoft Partner Center
A Microsoft website for partners that provides access to product support, a partner community, and other partner services.
878 questions
{count} votes