Search code examples
vb.netwindows-phone-7

Buy now functionality


I found such a code to program my button to get new license from windows phone marketplace. I am not sure if it works, because when I click it in emulator, nothing happens. Can someone tell me if that code is good?

Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
    Dim task As New MarketplaceDetailTask()
    task.ContentType = MarketplaceContentType.Applications
    task.ContentIdentifier = "dbd49f16-69e7-408b-bda9-03afda9fa30b"
    task.Show()
End Sub

Solution

  • You won't get a new license with that code, it only opens the marketplace and displays the app with id dbd49f16-69e7-408b-bda9-03afda9fa30b. Of course, from that page the user is able to purchase the app, so you need to update the "IsTrial/IsPurchased" state when the app is activated again. The id for your app is available when you've published your application, and go to the details page after you've clicked on your app in the dashboard at http://dev.windowsphone.com.

    Also note that the appid you get from the dev center is not equal to the one in your WPManifest file, so don't use that one.

    To get a new license, using the Trial mode that is available, use the LicenseInformation.IsTrial method, and check it each time your application is activated. There are several tutorials available on how to create trial mode applications for windows phone, one at http://windowsphonegeek.com/articles/Creating-a-Windows-Phone-7-Trial-Application-Implementation-and-Best-Practices for instance.