Java Examples for com.anjlab.android.iab.v3.TransactionDetails

The following java examples will help you to understand the usage of com.anjlab.android.iab.v3.TransactionDetails. These source code samples are taken from different open source projects.

Example 1
Project: submarine-master  File: AndroidStore.java View source code
@Override
public void onPurchaseHistoryRestored() {
    //Gdx.app.log(TAG, "onPurchaseHistoryRestored");
    for (String productId : productIds) {
        TransactionDetails transactionDetails = billingProcessor.getPurchaseTransactionDetails(productId);
        if (transactionDetails != null) {
            for (StoreListener storeListener : storeListeners) {
                storeListener.transactionRestored(productId);
            }
        }
    }
    for (StoreListener storeListener : storeListeners) {
        storeListener.transactionRestoreCompleted();
    }
}
Example 2
Project: WhatsThat-master  File: StoreActivity.java View source code
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    /*
         * Called when requested PRODUCT ID was successfully purchased
         */
    ProductPurchasedCallback callback = mProductPurchaseCallbacks.get(productId);
    if (callback != null) {
        Log.d("Billing", "Product purchased " + productId + " details: " + details);
        int result = callback.onProductPurchased(productId, details);
        mProductPurchaseCallbacks.remove(productId);
        if (result == ProductPurchasedCallback.CONSUME_PRODUCT) {
            if (!mBP.consumePurchase(productId)) {
                Log.e("Billing", "Product consuming failed!");
            }
        }
    }
}
Example 3
Project: Easy_xkcd-master  File: DonateActivity.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_donate);
    prefHelper = new PrefHelper(this);
    mBillingProcessor = new BillingProcessor(this, publicKey, new BillingProcessor.IBillingHandler() {

        @Override
        public void onBillingInitialized() {
            String[] mPrices = new String[5];
            mPrices[0] = mBillingProcessor.getPurchaseListingDetails(iap1).priceText;
            mPrices[1] = mBillingProcessor.getPurchaseListingDetails(iap2).priceText;
            mPrices[2] = mBillingProcessor.getPurchaseListingDetails(iap3).priceText;
            mPrices[3] = mBillingProcessor.getPurchaseListingDetails(iap4).priceText;
            mPrices[4] = mBillingProcessor.getPurchaseListingDetails(iap5).priceText;
            final String[] mIds = new String[5];
            mIds[0] = iap1;
            mIds[1] = iap2;
            mIds[2] = iap3;
            mIds[3] = iap4;
            mIds[4] = iap5;
            AlertDialog.Builder builder = new AlertDialog.Builder(DonateActivity.this);
            builder.setItems(mPrices, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    mBillingProcessor.purchase(DonateActivity.this, mIds[i]);
                }
            }).setTitle(R.string.dialog_donate).setOnCancelListener(new DialogInterface.OnCancelListener() {

                @Override
                public void onCancel(DialogInterface dialog) {
                    DonateActivity.this.finish();
                }
            }).show();
        }

        @Override
        public void onBillingError(int i, Throwable throwable) {
            DonateActivity.this.finish();
        }

        @Override
        public void onProductPurchased(String productId, TransactionDetails transactionDetails) {
            mBillingProcessor.consumePurchase(productId);
            prefHelper.setHideDonate(true);
            DonateActivity.this.finish();
            Toast.makeText(DonateActivity.this, "Thanks :)", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onPurchaseHistoryRestored() {
        }
    });
}
Example 4
Project: android-inapp-billing-v3-master  File: MainActivity.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    TextView title = (TextView) findViewById(R.id.titleTextView);
    title.setText(String.format(getString(R.string.title), getIntent().getIntExtra(ACTIVITY_NUMBER, 1)));
    if (!BillingProcessor.isIabServiceAvailable(this)) {
        showToast("In-app billing service is unavailable, please upgrade Android Market/Play to version >= 3.9.16");
    }
    bp = new BillingProcessor(this, LICENSE_KEY, MERCHANT_ID, new BillingProcessor.IBillingHandler() {

        @Override
        public void onProductPurchased(String productId, TransactionDetails details) {
            showToast("onProductPurchased: " + productId);
            updateTextViews();
        }

        @Override
        public void onBillingError(int errorCode, Throwable error) {
            showToast("onBillingError: " + Integer.toString(errorCode));
        }

        @Override
        public void onBillingInitialized() {
            showToast("onBillingInitialized");
            readyToPurchase = true;
            updateTextViews();
        }

        @Override
        public void onPurchaseHistoryRestored() {
            showToast("onPurchaseHistoryRestored");
            for (String sku : bp.listOwnedProducts()) Log.d(LOG_TAG, "Owned Managed Product: " + sku);
            for (String sku : bp.listOwnedSubscriptions()) Log.d(LOG_TAG, "Owned Subscription: " + sku);
            updateTextViews();
        }
    });
}
Example 5
Project: MDroid-master  File: SettingsActivity.java View source code
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle("Settings");
    // Send a tracker
    ((ApplicationClass) getApplication()).sendScreen(Param.GA_SCREEN_SETTING);
    // Setup billing
    session = new SessionSetting(this);
    settings = PreferenceManager.getDefaultSharedPreferences(this);
    billing = new BillingProcessor(this, Param.BILLING_LICENSE_KEY, new BillingProcessor.IBillingHandler() {

        @Override
        public void onProductPurchased(String productId, TransactionDetails details) {
            Toast.makeText(getApplicationContext(), "You purchased this already!", Toast.LENGTH_LONG).show();
        }

        @Override
        public void onBillingError(int errorCode, Throwable error) {
            Toast.makeText(getApplicationContext(), "Purchase failed! Please try again!", Toast.LENGTH_LONG).show();
        }

        @Override
        public void onBillingInitialized() {
        }

        @Override
        public void onPurchaseHistoryRestored() {
        }
    });
    // Set signature & adsPref in prefs to current account value
    SharedPreferences.Editor editor = settings.edit();
    editor.putString("messagingSignature", session.getMessageSignature());
    editor.putBoolean("hideAds", Param.hideAdsForSession);
    editor.commit();
    /*
		 * Note: Inflate xml after setting signature value or the new value
		 * won't reflect in the inflated setting
		 */
    addPreferencesFromResource(R.xml.preferences);
    // Enable donate only preferences
    if (isProUser()) {
        findPreference("messagingSignature").setEnabled(true);
        findPreference("notifications").setEnabled(true);
    }
    // Add preference click / change listeners
    findPreference("logout").setOnPreferenceClickListener(this);
    findPreference("messagingSignature").setOnPreferenceChangeListener(this);
    findPreference("hideAds").setOnPreferenceChangeListener(this);
    findPreference("notifications").setOnPreferenceChangeListener(this);
    findPreference("notification_frequency").setOnPreferenceChangeListener(this);
    findPreference("help").setOnPreferenceClickListener(this);
    findPreference("privacyPolicy").setOnPreferenceClickListener(this);
    findPreference("tutorial").setOnPreferenceClickListener(this);
    findPreference("aboutMDroid").setOnPreferenceClickListener(this);
    findPreference("aboutDev").setOnPreferenceClickListener(this);
    findPreference("licenses").setOnPreferenceClickListener(this);
    findPreference("translate").setOnPreferenceClickListener(this);
}
Example 6
Project: show-java-master  File: Landing.java View source code
@Override
public void onPurchaseHistoryRestored() {
    try {
        final TransactionDetails transactionDetails = bp.getPurchaseTransactionDetails(BuildConfig.IAP_PRODUCT_ID);
        if (transactionDetails.productId.equals(BuildConfig.IAP_PRODUCT_ID)) {
            AsyncHttpClient client = new AsyncHttpClient();
            RequestParams params = new RequestParams();
            params.put("payload", SV.gen(baseContext, transactionDetails.purchaseToken));
            params.put("order_id", transactionDetails.orderId);
            client.post(com.njlabs.showjava.Constants.VERIFICATION_URL, params, new JsonHttpResponseHandler() {

                @Override
                public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
                    try {
                        if (response.has("status") && response.getString("status").equals("ok")) {
                            if (response.has("payload")) {
                                if (SV.good(baseContext, response.getString("payload"), transactionDetails.purchaseToken)) {
                                    showPurchased();
                                } else {
                                    showError();
                                }
                            } else {
                                showError();
                            }
                        } else {
                            showError();
                        }
                    } catch (JSONException e) {
                        showError();
                    }
                }

                @Override
                public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
                    Ln.e(throwable);
                }
            });
        } else {
            put(false);
        }
    } catch (Exception ignored) {
        put(false);
    }
}
Example 7
Project: GPS2SMS-master  File: DonateActivity.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ShowBackButton();
    setContentView(R.layout.activity_donate);
    bp = new BillingProcessor(DonateActivity.this, LICENSE_KEY, new BillingProcessor.IBillingHandler() {

        @Override
        public void onProductPurchased(String productId, TransactionDetails details) {
            //DBHelper.ShowToastT(DonateActivity.this, "onProductPurchased: " + productId, Toast.LENGTH_LONG);
            refreshPurchasesStatus();
        }

        @Override
        public void onBillingError(int errorCode, Throwable error) {
            // DBHelper.ShowToastT(DonateActivity.this, "onBillingError: " + Integer.toString(errorCode), Toast.LENGTH_LONG);
            refreshPurchasesStatus();
        }

        @Override
        public void onBillingInitialized() {
            readyToPurchase = true;
            DonatePriceTextLoadAsyncTask mt = new DonatePriceTextLoadAsyncTask();
            mt.execute();
        }

        @Override
        public void onPurchaseHistoryRestored() {
            //DBHelper.ShowToastT(DonateActivity.this, "onPurchaseHistoryRestored", Toast.LENGTH_LONG);
            refreshPurchasesStatus();
        }
    });
    // ListView on Fragments
    DonateListFragment fragment = new DonateListFragment();
    getSupportFragmentManager().beginTransaction().replace(R.id.frgmCont, fragment).commit();
}
Example 8
Project: org.numixproject.hermes-master  File: iap.java View source code
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    android.os.Process.killProcess(android.os.Process.myPid());
    System.exit(1);
}
Example 9
Project: wallpaperboard-master  File: InAppBillingHelper.java View source code
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    InAppBillingListener listener = (InAppBillingListener) mContext;
    listener.onInAppBillingConsume(productId);
}
Example 10
Project: WearSquare-master  File: MainFragment.java View source code
@Override
public void onProductPurchased(String s, TransactionDetails transactionDetails) {
    ToastUtil.show(R.string.thanks);
    mBilling.consumePurchase("beer");
}
Example 11
Project: Phonograph-master  File: DonationsDialog.java View source code
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    loadSkuDetails();
    Toast.makeText(getContext(), R.string.thank_you, Toast.LENGTH_SHORT).show();
}
Example 12
Project: DeviceControl-master  File: DonationActivity.java View source code
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    if (details != null && details.productId.contains("donation_sub_")) {
        // we can not consume subscriptions
        return;
    }
    // Consume asap purchased to allow multiple donations
    mBillingProcessor.consumePurchase(productId);
}
Example 13
Project: Timber-master  File: DonateActivity.java View source code
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    checkStatus();
    runOnUiThread(new Runnable() {

        @Override
        public void run() {
            Toast.makeText(DonateActivity.this, "Thanks for your support!", Toast.LENGTH_SHORT).show();
        }
    });
}
Example 14
Project: Blip-master  File: DonateActivity.java View source code
@Override
public void onProductPurchased(String s, TransactionDetails transactionDetails) {
    mBillingProcessor.consumePurchase(s);
}
Example 15
Project: AlgorithmVisualizer-Android-master  File: DonateActivity.java View source code
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    checkStatus();
    runOnUiThread(new Runnable() {

        @Override
        public void run() {
            Toast.makeText(DonateActivity.this, "Thanks for your donation!", Toast.LENGTH_SHORT).show();
        }
    });
}
Example 16
Project: TiM-master  File: DonateActivity.java View source code
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    checkStatus();
    runOnUiThread(new Runnable() {

        @Override
        public void run() {
            Toast.makeText(DonateActivity.this, "Thanks for your support!", Toast.LENGTH_SHORT).show();
        }
    });
}
Example 17
Project: MaxLock-master  File: DonateActivity.java View source code
/**
     * Called when requested PRODUCT ID was successfully purchased
     */
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    new Handler().postDelayed(this::reloadBilling, 200);
}