Checking for past purchases

If your app needs a list of digital goods that a user already purchased (for example, to avoid promoting to the user a digital good that the user already owns), you can use the paymentservice_get_existing_purchases_request() function. This function retrieves all the purchases that a user made, including purchases that a user made before an upgrade, or purchases that a user made after they uninstalled your app and downloaded it again.

If an error is thrown, you can use the following functions to get more information:

The paymentservice_get_existing_purchases_request() function accepts a parameter called allow_refresh, which is a Boolean value that indicates whether the list of past purchases should be refreshed when a request is made. A value of true indicates that data is refreshed from the server, and a value of false means that a cached list of purchases is returned.

The following code sample requests the list of existing purchases by using the paymentservice_get_existing_purchases_request() function, passing in a Boolean value to refresh the data from the server.

do_get_existing(int selected_index, char** result_str)
    unsigned request_id = 0;
    if (selected_index == GET_EXISTING_REFRESH_FALSE) {
        paymentservice_get_existing_purchases_request(false, get_window_group_id(), &request_id);
    } else if (selected_index == GET_EXISTING_REFRESH_TRUE) {
        paymentservice_get_existing_purchases_request(true, get_window_group_id(), &request_id);

    sprintf(*result_str, "Sent getExistingPurchases request. ID: %d\n", request_id);

Last modified: 2013-12-24

Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus