use of com.android.billingclient.api.SkuDetails in project zype-android by zype.
the class BillingManager method querySkuDetailsAsync.
/**
* Query SKUs available for purchase
*/
public void querySkuDetailsAsync(@SkuType final String itemType, final List<String> skuList, final SkuDetailsResponseListener listener) {
// Creating a runnable from the request to use it inside our connection retry policy below
Runnable queryRequest = new Runnable() {
@Override
public void run() {
// Query the purchase async
SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
params.setSkusList(skuList).setType(itemType);
mBillingClient.querySkuDetailsAsync(params.build(), new SkuDetailsResponseListener() {
@Override
public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) {
listener.onSkuDetailsResponse(responseCode, skuDetailsList);
}
});
}
};
executeServiceRequest(queryRequest);
}
use of com.android.billingclient.api.SkuDetails in project Android-InAppBilling by LiteKite.
the class BillingManager method querySkuDetailsAsync.
/**
* Queries SKU Details from Google Play Remote Server of SKU Types (InApp and Subscription).
*
* @param skuResultList contains SKU ID and Price Details returned by the sku details
* query.
* @param params contains list of SKU IDs and SKU Type (InApp or Subscription).
* @param billingType InApp or Subscription.
* @param executeWhenFinished contains query for InApp SKU Details that will be run after
* getting results of Subscription based SKU Details.
*/
private void querySkuDetailsAsync(final List<SkuDetails> skuResultList, final SkuDetailsParams.Builder params, @SkuType final String billingType, final Runnable executeWhenFinished) {
// Creating a runnable from the request to use it inside our connection retry policy below
final Runnable queryRequest = new Runnable() {
@Override
public void run() {
myBillingClient.querySkuDetailsAsync(params.build(), new SkuDetailsResponseListener() {
@Override
public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) {
// Process the result.
if (responseCode != BillingResponse.OK) {
BaseActivity.printLog(TAG, "Unsuccessful query for type: " + billingType + ". Error code: " + responseCode);
} else if (skuDetailsList != null && skuDetailsList.size() > 0) {
skuResultList.addAll(skuDetailsList);
}
if (executeWhenFinished != null) {
executeWhenFinished.run();
return;
}
if (skuResultList.size() == 0) {
BaseActivity.printLog(TAG, "sku error: " + context.getString(R.string.err_no_sku));
} else {
BaseActivity.printLog(TAG, "storing sku list locally");
storeSkuDetailsLocally(skuResultList);
}
}
});
}
};
executeServiceRequest(queryRequest);
}
use of com.android.billingclient.api.SkuDetails in project PhoneProfiles by henrichg.
the class DonationFragment method purchaseSuccessful.
public void purchaseSuccessful(List<Purchase> purchases) {
if (purchases != null) {
for (Purchase purchase : purchases) {
String sku = purchase.getSku();
for (SkuDetails skuDetail : SKU_DETAILS) {
if (skuDetail.getSku().equals(sku)) {
PPApplication.logE(TAG, "purchaseSuccessful - sku=" + sku);
PPApplication.logE(TAG, "purchaseSuccessful - currency=" + skuDetail.getPriceCurrencyCode());
PPApplication.logE(TAG, "purchaseSuccessful - priceS=" + skuDetail.getPrice());
PPApplication.logE(TAG, "purchaseSuccessful - priceMicros=" + skuDetail.getPriceAmountMicros());
PPApplication.logE(TAG, "purchaseSuccessful - price=" + skuDetail.getPriceAmountMicros() / 1000000.0);
Answers.getInstance().logPurchase(new PurchaseEvent().putItemPrice(BigDecimal.valueOf(skuDetail.getPriceAmountMicros() / 1000000.0)).putCurrency(Currency.getInstance(skuDetail.getPriceCurrencyCode())).putItemName("Donation").putItemId(sku).putSuccess(true));
}
}
}
}
if (getActivity() != null) {
PPApplication.setDonationDonated(getActivity().getApplicationContext());
Toast.makeText(getActivity().getApplicationContext(), getString(R.string.donation_thanks_dialog), Toast.LENGTH_LONG).show();
}
}
use of com.android.billingclient.api.SkuDetails in project sms-backup-plus by jberkel.
the class DonationActivity method onSkuDetailsResponse.
@Override
public void onSkuDetailsResponse(@BillingResponse int responseCode, List<SkuDetails> details) {
log("onSkuDetailsResponse(" + responseCode + ", " + details + ")");
if (isFinishing() || responseCode != OK) {
Log.w(TAG, "failed to query inventory: " + responseCode);
return;
}
List<SkuDetails> skuDetailsList = new ArrayList<SkuDetails>();
for (SkuDetails d : details) {
if (d.getSku().startsWith(DONATION_PREFIX)) {
skuDetailsList.add(d);
}
}
showSelectDialog(skuDetailsList);
}
use of com.android.billingclient.api.SkuDetails in project sms-backup-plus by jberkel.
the class DonationActivity method showSelectDialog.
private void showSelectDialog(List<SkuDetails> skuDetails) {
if (billingClient == null)
return;
ArrayList<Sku> skus = new ArrayList<Sku>(skuDetails.size());
for (SkuDetails detail : skuDetails) {
skus.add(new Sku(detail));
}
if (DEBUG_IAB) {
Collections.addAll(skus, Sku.Test.SKUS);
}
Collections.sort(skus);
final DonationListFragment donationList = new DonationListFragment();
donationList.setArguments(new BundleBuilder().putParcelableArrayList(SKUS, skus).build());
donationList.show(getSupportFragmentManager(), null);
}
Aggregations