Search in sources :

Example 1 with AmazonIAPHelper

use of net.osmand.live.subscriptions.AmazonIAPHelper in project OsmAnd-tools by osmandapp.

the class UserdataController method revalidateAmazonSubscription.

private SupporterDeviceSubscription revalidateAmazonSubscription(SupporterDeviceSubscription s) {
    if (amazonIAPHelper == null) {
        amazonIAPHelper = new AmazonIAPHelper();
    }
    try {
        if (s.orderId == null) {
            return s;
        }
        AmazonSubscription subscription = amazonIAPHelper.getAmazonSubscription(s.orderId, s.purchaseToken);
        if (subscription != null) {
            if (s.expiretime == null || s.expiretime.getTime() < subscription.renewalDate) {
                s.expiretime = new Date(subscription.renewalDate);
                // s.checktime = new Date(); // don't set checktime let jenkins do its job
                s.valid = System.currentTimeMillis() < subscription.renewalDate;
                subscriptionsRepo.save(s);
            }
        }
    } catch (IOException e) {
        LOG.error(String.format("Error retrieving amazon subscription %s - %s: %s", s.sku, s.orderId, e.getMessage()), e);
    }
    return s;
}
Also used : IOException(java.io.IOException) AmazonSubscription(net.osmand.live.subscriptions.AmazonIAPHelper.AmazonSubscription) AmazonIAPHelper(net.osmand.live.subscriptions.AmazonIAPHelper) Date(java.util.Date)

Aggregations

IOException (java.io.IOException)1 Date (java.util.Date)1 AmazonIAPHelper (net.osmand.live.subscriptions.AmazonIAPHelper)1 AmazonSubscription (net.osmand.live.subscriptions.AmazonIAPHelper.AmazonSubscription)1