Search in sources :

Example 1 with SKU

use of com.asf.appcoins.sdk.iab.entity.SKU in project AppCoins-ethereumj by AppStoreFoundation.

the class App method buildSkus.

private List<SKU> buildSkus() {
    List<SKU> skus = new LinkedList<>();
    skus.add(new SKU(Skus.SKU_GAS_LABEL, Skus.SKU_GAS_ID, BigDecimal.valueOf(1)));
    skus.add(new SKU(Skus.SKU_PREMIUM_LABEL, Skus.SKU_PREMIUM_ID, BigDecimal.valueOf(2)));
    return skus;
}
Also used : SKU(com.asf.appcoins.sdk.iab.entity.SKU) LinkedList(java.util.LinkedList)

Example 2 with SKU

use of com.asf.appcoins.sdk.iab.entity.SKU in project AppCoins-ethereumj by AppStoreFoundation.

the class AppCoinsSdkImplTest method buildSkus.

private List<SKU> buildSkus() {
    List<SKU> skus = new LinkedList<>();
    skus.add(new SKU("smallpack", "com.marceloporto.bombastic.smallpack", BigDecimal.ONE));
    return skus;
}
Also used : SKU(com.asf.appcoins.sdk.iab.entity.SKU) LinkedList(java.util.LinkedList)

Example 3 with SKU

use of com.asf.appcoins.sdk.iab.entity.SKU in project AppCoins-ethereumj by AppStoreFoundation.

the class PaymentService method buy.

public void buy(String skuId, Activity activity, int defaultRequestCode) {
    SKU sku = skuManager.getSku(skuId);
    BigDecimal amount = skuManager.getSkuAmount(skuId);
    BigDecimal total = amount.multiply(BigDecimal.TEN.pow(DECIMALS));
    Intent intent = buildPaymentIntent(sku, total);
    currentPayment = new PaymentDetails(PaymentStatus.FAIL, skuId, new Transaction(null, null, developerAddress, total.toString(), Status.PENDING));
    if (AndroidUtils.hasHandlerAvailable(intent, activity)) {
        if (payments.containsKey(skuId)) {
            throw new IllegalArgumentException("Pending buy action with the same sku found! Did you forget to consume the former?");
        } else {
            payments.put(skuId, currentPayment);
            activity.startActivityForResult(intent, defaultRequestCode);
        }
    } else {
        Disposable subscribe = showWalletInstallDialog(activity).filter(aBoolean -> aBoolean).doOnSuccess(gotoStore(activity)).subscribe(aBoolean -> {
        }, Throwable::printStackTrace);
    }
}
Also used : Disposable(io.reactivex.disposables.Disposable) Transaction(com.asf.appcoins.sdk.iab.entity.Transaction) Intent(android.content.Intent) SKU(com.asf.appcoins.sdk.iab.entity.SKU) BigDecimal(java.math.BigDecimal)

Aggregations

SKU (com.asf.appcoins.sdk.iab.entity.SKU)3 LinkedList (java.util.LinkedList)2 Intent (android.content.Intent)1 Transaction (com.asf.appcoins.sdk.iab.entity.Transaction)1 Disposable (io.reactivex.disposables.Disposable)1 BigDecimal (java.math.BigDecimal)1