Implementing app purchase with subscription add-on

Deepak Patel 60 Reputation points
2024-11-07T06:30:46.9133333+00:00

i implemented app purchase in UWP firstly create add-on in Microsoft partner now status of add-on is (in the Microsoft store). After that write all the code as mention in " https://learn.microsoft.com/en-us/windows/uwp/monetize/enable-subscription-add-ons-for-your-app " then i associate app with store but in code getting license is inactive and not found any add-on product.

can you please suggest me what's the exact problem.

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Junjie Zhu - MSFT 19,641 Reputation points Microsoft Vendor
    2024-11-07T08:51:24.8366667+00:00

    Hello @Deepak Patel ,

    Welcome to Microsoft Q&A!

    Please check if your purchase has been completed. If the license is inactive, it is likely that it has not been purchased yet.

    Please use StoreContext.RequestPurchaseAsync to purchase the application.

    private async Task PromptUserToPurchaseAsync()
    {
        // Request a purchase of the subscription product. If a trial is available it will be offered 
        // to the customer. Otherwise, the non-trial SKU will be offered.
        StorePurchaseResult result = await subscriptionStoreProduct.RequestPurchaseAsync();
        // Capture the error message for the operation, if any.
        string extendedError = string.Empty;
        if (result.ExtendedError != null)
        {
            extendedError = result.ExtendedError.Message;
        }
        switch (result.Status)
        {
            case StorePurchaseStatus.Succeeded:
                // Show a UI to acknowledge that the customer has purchased your subscription 
                // and unlock the features of the subscription. 
                break;
            case StorePurchaseStatus.NotPurchased:
                System.Diagnostics.Debug.WriteLine("The purchase did not complete. " +
                    "The customer may have cancelled the purchase. ExtendedError: " + extendedError);
                break;
            case StorePurchaseStatus.ServerError:
            case StorePurchaseStatus.NetworkError:
                System.Diagnostics.Debug.WriteLine("The purchase was unsuccessful due to a server or network error. " +
                    "ExtendedError: " + extendedError);
                break;
            case StorePurchaseStatus.AlreadyPurchased:
                System.Diagnostics.Debug.WriteLine("The customer already owns this subscription." +
                        "ExtendedError: " + extendedError);
                break;
        }
    }
    

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Deepak Patel 60 Reputation points
    2024-11-12T04:43:21.05+00:00

    Now it's working . if anybody have same issue , please check once by reset your device.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.