Search in sources :

Example 1 with Transaction

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

the class TransactionFactory method fromEthGetTransactionReceipt.

public static Transaction fromEthGetTransactionReceipt(EthGetTransactionReceipt ethGetTransactionReceipt) {
    TransactionReceipt transactionReceipt = ethGetTransactionReceipt.getTransactionReceipt();
    String hash = transactionReceipt.getTransactionHash();
    String from = transactionReceipt.getFrom();
    Log log = transactionReceipt.getLogs().get(0);
    String to = log.getAddress();
    String value = extractValueFromEthGetTransactionReceipt(log.getData());
    Status status = parseStatus(transactionReceipt.getStatus());
    String contractAddress = ethGetTransactionReceipt.getTransactionReceipt().getTo();
    return new Transaction(hash, from, to, value, status);
}
Also used : Status(com.asf.appcoins.sdk.iab.entity.Transaction.Status) EthTransaction(org.web3j.protocol.core.methods.response.EthTransaction) Transaction(com.asf.appcoins.sdk.iab.entity.Transaction) Log(org.web3j.protocol.core.methods.response.Log) TransactionReceipt(org.web3j.protocol.core.methods.response.TransactionReceipt) EthGetTransactionReceipt(org.web3j.protocol.core.methods.response.EthGetTransactionReceipt)

Example 2 with Transaction

use of com.asf.appcoins.sdk.iab.entity.Transaction 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

Transaction (com.asf.appcoins.sdk.iab.entity.Transaction)2 Intent (android.content.Intent)1 SKU (com.asf.appcoins.sdk.iab.entity.SKU)1 Status (com.asf.appcoins.sdk.iab.entity.Transaction.Status)1 Disposable (io.reactivex.disposables.Disposable)1 BigDecimal (java.math.BigDecimal)1 EthGetTransactionReceipt (org.web3j.protocol.core.methods.response.EthGetTransactionReceipt)1 EthTransaction (org.web3j.protocol.core.methods.response.EthTransaction)1 Log (org.web3j.protocol.core.methods.response.Log)1 TransactionReceipt (org.web3j.protocol.core.methods.response.TransactionReceipt)1