Search in sources :

Example 1 with BillingPurchaseDetails

use of com.litekite.monetize.room.entity.BillingPurchaseDetails in project Android-InAppBilling by LiteKite.

the class BillingManager method storePurchaseResultsLocally.

/**
 * Stores Purchase Details on local storage.
 *
 * @param purchases list of Purchase Details returned from the queries.
 */
private void storePurchaseResultsLocally(List<Purchase> purchases) {
    final List<BillingPurchaseDetails> billingPurchaseDetailsList = new ArrayList<>();
    for (Purchase purchase : purchases) {
        BillingPurchaseDetails billingPurchaseDetails = new BillingPurchaseDetails();
        billingPurchaseDetails.purchaseToken = purchase.getPurchaseToken();
        billingPurchaseDetails.orderID = purchase.getOrderId();
        billingPurchaseDetails.skuID = purchase.getSkus().stream().findFirst().orElse("");
        billingPurchaseDetails.purchaseTime = purchase.getPurchaseTime();
        billingPurchaseDetailsList.add(billingPurchaseDetails);
    }
    workExecutor.execute(() -> appDatabase.insertPurchaseDetails(billingPurchaseDetailsList));
}
Also used : Purchase(com.android.billingclient.api.Purchase) BillingPurchaseDetails(com.litekite.monetize.room.entity.BillingPurchaseDetails) ArrayList(java.util.ArrayList)

Example 2 with BillingPurchaseDetails

use of com.litekite.monetize.room.entity.BillingPurchaseDetails in project Android-InAppBilling by LiteKite.

the class BillingManager method storePurchaseHistoryRecordsLocally.

/**
 * Stores Purchase Details on local storage.
 *
 * @param purchases list of Purchase Details returned from the queries.
 */
private void storePurchaseHistoryRecordsLocally(List<PurchaseHistoryRecord> purchases) {
    final List<BillingPurchaseDetails> billingPurchaseDetailsList = new ArrayList<>();
    for (PurchaseHistoryRecord purchase : purchases) {
        BillingPurchaseDetails billingPurchaseDetails = new BillingPurchaseDetails();
        billingPurchaseDetails.purchaseToken = purchase.getPurchaseToken();
        billingPurchaseDetails.skuID = purchase.getSkus().stream().findFirst().orElse("");
        billingPurchaseDetails.purchaseTime = purchase.getPurchaseTime();
        billingPurchaseDetailsList.add(billingPurchaseDetails);
    }
    workExecutor.execute(() -> appDatabase.insertPurchaseDetails(billingPurchaseDetailsList));
}
Also used : BillingPurchaseDetails(com.litekite.monetize.room.entity.BillingPurchaseDetails) ArrayList(java.util.ArrayList) PurchaseHistoryRecord(com.android.billingclient.api.PurchaseHistoryRecord)

Aggregations

BillingPurchaseDetails (com.litekite.monetize.room.entity.BillingPurchaseDetails)2 ArrayList (java.util.ArrayList)2 Purchase (com.android.billingclient.api.Purchase)1 PurchaseHistoryRecord (com.android.billingclient.api.PurchaseHistoryRecord)1