none
Validation test for a piad app for office RRS feed

  • Question

  • I've been following this guide to add licensing to my app: http://blogs.msdn.com/b/officeapps/archive/2012/11/01/creating-and-verifying-licensing-in-a-paid-app-for-office.aspx
    In test environment the above code works, but the Microsoft Office MarketPlace Validation Test failed my app stating that:

    Fail
    Your app does not function beyond launch as the licensing tokens do not appear to be working correctly. We constantly receive a message that states “You do not have a valid license” regardless of the license type we use for testing.


    Is there something wrong I did in my code??

    protected void Page_Load(object sender, EventArgs e)

            {
                //string token = Request.Params["et"].ToString();
                var token = Request.Params["et"];
              
                bool isPaid = VerifyToken(token);


                if (isPaid){
                    ///redirect to page
                }else {                

    Response.Redirect("./Denied.html");

                }

            }

            public bool VerifyToken(string token)
            {
                bool isPaid = false;
                try
                {
                    ///Se il token è vuoto restituisco false
                    if(String.IsNullOrWhiteSpace(token)) return false;

                    VerificationServiceClient client = new VerificationServiceClient();

                    string decodedURL = HttpUtility.UrlDecode(token);
                    byte[] decodedBytes = Convert.FromBase64String(decodedURL);
                    string decodedToken = Encoding.Unicode.GetString(decodedBytes);

                    VerifyEntitlementTokenRequest request = new VerifyEntitlementTokenRequest();
                    request.EntitlementToken = decodedToken;

                    VerifyEntitlementTokenResponse response = client.VerifyEntitlementToken(request);

                    isPaid = (response.EntitlementType == "Paid");

                }
                catch (Exception ex)
                {

                }

                return isPaid;
            }

    Thursday, January 24, 2013 8:22 AM

Answers

  • Hi giadev,

    This code isn't really trapping all the error conditions - it's possible that something may be wrong in the input that the service is getting, which is resulting in a null response. In this scenario, your code will fall through the blank exception catch and always return the predeclared false value for your experience.

    I would recommend trying a couple of things here:

    1. Check if response.EntitlementType is null and handle that appropriately with a different error page telling you that input to the service is invalid

    2. Add additional code to trap Trial, Paid and Free to Paid conditions and add some code inside your Exception blocks.

    Perhaps this will let you debug exactly what is happening with the service response?

    • Proposed as answer by JesBModerator Friday, January 25, 2013 4:50 PM
    • Marked as answer by JesBModerator Thursday, February 7, 2013 12:11 AM
    Friday, January 25, 2013 1:21 PM