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

The following examples show how to use com.anjlab.android.iab.v3.TransactionDetails. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InAppBillingBridge.java    From react-native-billing with MIT License 6 votes vote down vote up
private WritableMap mapTransactionDetails(TransactionDetails details) {
    WritableMap map = Arguments.createMap();

    map.putString("receiptData", details.purchaseInfo.responseData.toString());

    if (details.purchaseInfo.signature != null)
        map.putString("receiptSignature", details.purchaseInfo.signature.toString());

    PurchaseData purchaseData = details.purchaseInfo.purchaseData;

    map.putString("productId", purchaseData.productId);
    map.putString("orderId", purchaseData.orderId);
    map.putString("purchaseToken", purchaseData.purchaseToken);
    map.putString("purchaseTime", purchaseData.purchaseTime == null
      ? "" : purchaseData.purchaseTime.toString());
    map.putString("purchaseState", purchaseData.purchaseState == null
      ? "" : purchaseData.purchaseState.toString());
    map.putBoolean("autoRenewing", purchaseData.autoRenewing);

    if (purchaseData.developerPayload != null)
        map.putString("developerPayload", purchaseData.developerPayload);

    return map;
}
 
Example #2
Source File: InAppPurchaseHelper.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onProductPurchased(@NonNull String productId, TransactionDetails details) {
    if (productId.contentEquals(Premium.SKU_PREMIUM)) {
        Premium.setPremiumUser(mActivity, true);
        if (mPurchaseCallback != null) {
            mPurchaseCallback.updateUI(true);
        }
    }
}
 
Example #3
Source File: InAppBillingBridge.java    From react-native-billing with MIT License 5 votes vote down vote up
@ReactMethod
public void getSubscriptionTransactionDetails(final String productId, final Promise promise) {
    if (bp != null) {
        TransactionDetails details = bp.getSubscriptionTransactionDetails(productId);
        if (details != null && productId.equals(details.purchaseInfo.purchaseData.productId))
        {
              WritableMap map = mapTransactionDetails(details);
              promise.resolve(map);
        } else {
            promise.reject("EUNSPECIFIED", "Could not find transaction details for productId.");
        }
    } else {
        promise.reject("EUNSPECIFIED", "Channel is not opened. Call open() on InAppBilling.");
    }
}
 
Example #4
Source File: InAppBillingBridge.java    From react-native-billing with MIT License 5 votes vote down vote up
@ReactMethod
public void getPurchaseTransactionDetails(final String productId, final Promise promise) {
    if (bp != null) {
        TransactionDetails details = bp.getPurchaseTransactionDetails(productId);
        if (details != null && productId.equals(details.purchaseInfo.purchaseData.productId))
        {
              WritableMap map = mapTransactionDetails(details);
              promise.resolve(map);
        } else {
            promise.reject("EUNSPECIFIED", "Could not find transaction details for productId.");
        }
    } else {
        promise.reject("EUNSPECIFIED", "Channel is not opened. Call open() on InAppBilling.");
    }
}
 
Example #5
Source File: InAppBillingBridge.java    From react-native-billing with MIT License 5 votes vote down vote up
@ReactMethod
public void isValidTransactionDetails(final String productId, final Promise promise) {
    if (bp != null) {
        try {
            TransactionDetails details = bp.getPurchaseTransactionDetails(productId);
            promise.resolve(bp.isValidTransactionDetails(details));
        } catch (Exception ex) {
            promise.reject("EUNSPECIFIED", "Failed to validate transaction details: " + ex.getMessage());
        }
    } else {
        promise.reject("EUNSPECIFIED", "Channel is not opened. Call open() on InAppBilling.");
    }
}
 
Example #6
Source File: InAppBillingBridge.java    From react-native-billing with MIT License 5 votes vote down vote up
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    if (details != null && productId.equals(details.purchaseInfo.purchaseData.productId))
    {
        try {
            WritableMap map = mapTransactionDetails(details);
            resolvePromise(PromiseConstants.PURCHASE_OR_SUBSCRIBE, map);
        } catch (Exception ex) {
            rejectPromise(PromiseConstants.PURCHASE_OR_SUBSCRIBE, "Failure on purchase or subscribe callback: " + ex.getMessage());
        }
    } else {
        rejectPromise(PromiseConstants.PURCHASE_OR_SUBSCRIBE, "Failure on purchase or subscribe callback. Details were empty.");
    }
}
 
Example #7
Source File: MainActivity.java    From BusyBox with Apache License 2.0 5 votes vote down vote up
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    // Called when requested PRODUCT ID was successfully purchased
    Analytics.newEvent("in-app purchase").put("product_id", productId).log();
    if (productId.equals(Monetize.decrypt(Monetize.ENCRYPTED_REMOVE_ADS_PRODUCT_ID))) {
        Monetize.removeAds();
        EventBus.getDefault().post(new Monetize.Event.OnAdsRemovedEvent());
    }
}
 
Example #8
Source File: MainActivity.java    From BusyBox with Apache License 2.0 5 votes vote down vote up
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    // Called when requested PRODUCT ID was successfully purchased
    Analytics.newEvent("in-app purchase").put("product_id", productId).log();
    if (productId.equals(Monetize.decrypt(Monetize.ENCRYPTED_REMOVE_ADS_PRODUCT_ID))) {
        Monetize.removeAds();
        EventBus.getDefault().post(new Monetize.Event.OnAdsRemovedEvent());
    }
}
 
Example #9
Source File: BillingActivity.java    From Shipr-Community-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    /*
     * Called when requested PRODUCT ID was successfully purchased
     */

    insertLog("Product Purchased");
}
 
Example #10
Source File: MainActivity.java    From TwistyTimer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    /*
     * Called when requested PRODUCT ID was successfully purchased
     */
    bp.consumePurchase(productId);
}
 
Example #11
Source File: BuyActivity.java    From Telephoto with Apache License 2.0 5 votes vote down vote up
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    L.i("onProductPurchased");
    if (productId.equals(SKU_PRO)) {
        afterPayment();
    }
}
 
Example #12
Source File: MainActivity.java    From GotoSleep with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    if (productId.equals("go_to_sleep_advanced")){
        Log.d("productPurchased", "go to sleep advanced purchased");
        advancedOptionsPurchased = true;
        getPrefs.edit().putBoolean(ADVANCED_PURCHASED_KEY, true).apply();
    }
}
 
Example #13
Source File: SettingsFragment.java    From GotoSleep with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    if (productId.equals("go_to_sleep_advanced")) {
        Log.d("productPurchased", "go to sleep advanced purchased");
        advancedPurchased(sharedPreferences, getPreferenceScreen());
    }

}
 
Example #14
Source File: DonateActivity.java    From GPS2SMS with GNU General Public License v3.0 5 votes vote down vote up
@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 #15
Source File: RequestFragment.java    From candybar-library with Apache License 2.0 4 votes vote down vote up
@Override
protected Boolean doInBackground(Void... voids) {
    while (!isCancelled()) {
        try {
            Thread.sleep(1);
            Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",
                    getResources().getString(R.string.dev_email),
                    null));
            List<ResolveInfo> resolveInfos = getActivity().getPackageManager()
                    .queryIntentActivities(intent, 0);
            if (resolveInfos.size() == 0) {
                noEmailClientError = true;
                return false;
            }

            if (Preferences.get(getActivity()).isPremiumRequest()) {
                TransactionDetails details = InAppBillingProcessor.get(getActivity())
                        .getProcessor().getPurchaseTransactionDetails(
                        Preferences.get(getActivity()).getPremiumRequestProductId());
                if (details == null) return false;

                CandyBarApplication.sRequestProperty = new Request.Property(null,
                        details.purchaseInfo.purchaseData.orderId,
                        details.purchaseInfo.purchaseData.productId);
            }

            RequestFragment.sSelectedRequests = mAdapter.getSelectedItems();
            List<Request> requests = mAdapter.getSelectedApps();
            File appFilter = RequestHelper.buildXml(getActivity(), requests, RequestHelper.XmlType.APPFILTER);
            File appMap = RequestHelper.buildXml(getActivity(), requests, RequestHelper.XmlType.APPMAP);
            File themeResources = RequestHelper.buildXml(getActivity(), requests, RequestHelper.XmlType.THEME_RESOURCES);

            File directory = getActivity().getCacheDir();
            List<String> files = new ArrayList<>();

            for (Request request : requests) {
                Drawable drawable = getHighQualityIcon(getActivity(), request.getPackageName());
                String icon = IconsHelper.saveIcon(files, directory, drawable, request.getName());
                if (icon != null) files.add(icon);
            }

            if (appFilter != null) {
                files.add(appFilter.toString());
            }

            if (appMap != null) {
                files.add(appMap.toString());
            }

            if (themeResources != null) {
                files.add(themeResources.toString());
            }

            CandyBarApplication.sZipPath = FileHelper.createZip(files, new File(directory.toString(),
                    RequestHelper.getGeneratedZipName(RequestHelper.ZIP)));
            return true;
        } catch (Exception e) {
            LogUtil.e(Log.getStackTraceString(e));
            return false;
        }
    }
    return false;
}
 
Example #16
Source File: DonateActivity.java    From SimplicityBrowser with MIT License 4 votes vote down vote up
@Override
public void onProductPurchased(@NonNull String productId, TransactionDetails details) {
    Toast.makeText(this, DXDecryptorxWPYWsyI.decode("LDxEFcSiTykFpTcUcR9JDh4L3wMtz6AD22qEow==")/*"Thank you for your donation!"*/, Toast.LENGTH_SHORT).show();
}
 
Example #17
Source File: DonationsDialog.java    From Phonograph with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onProductPurchased(@NonNull String productId, TransactionDetails details) {
    loadSkuDetails();
    Toast.makeText(getContext(), R.string.thank_you, Toast.LENGTH_SHORT).show();
}
 
Example #18
Source File: PurchaseActivity.java    From Phonograph with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onProductPurchased(@NonNull String productId, @Nullable TransactionDetails details) {
    Toast.makeText(this, R.string.thank_you, Toast.LENGTH_SHORT).show();
    App.notifyProVersionChanged();
}
 
Example #19
Source File: App.java    From Phonograph with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    app = this;

    // default theme
    if (!ThemeStore.isConfigured(this, 1)) {
        ThemeStore.editTheme(this)
                .primaryColorRes(R.color.md_indigo_500)
                .accentColorRes(R.color.md_pink_A400)
                .commit();
    }

    // Set up dynamic shortcuts
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
        new DynamicShortcutManager(this).initDynamicShortcuts();
    }

    // automatically restores purchases
    billingProcessor = new BillingProcessor(this, App.GOOGLE_PLAY_LICENSE_KEY, new BillingProcessor.IBillingHandler() {
        @Override
        public void onProductPurchased(@NonNull String productId, TransactionDetails details) {
        }

        @Override
        public void onPurchaseHistoryRestored() {
            if (App.isProVersion()) {
                App.notifyProVersionChanged();
            }
        }

        @Override
        public void onBillingError(int errorCode, Throwable error) {
        }

        @Override
        public void onBillingInitialized() {
            App.loadPurchases(); // runs in background
        }
    });
}
 
Example #20
Source File: BillingActivity.java    From IslamicLibraryAndroid with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    ((IslamicLibraryApplication) getApplication()).refreshLocale(this, false);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_billing);
    ButterKnife.bind(this);

    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowTitleEnabled(true);
        getSupportActionBar().setTitle(R.string.financial_aid);
    }

    if (!BillingProcessor.isIabServiceAvailable(this)) {
        showToast(R.string.iap_not_available);
    }

    bp = new BillingProcessor(this, LICENSE_KEY, new BillingProcessor.IBillingHandler() {
        @Override
        public void onProductPurchased(@NonNull String productId, @Nullable TransactionDetails details) {
            billingItemsRecyclerViewAdapter.notifyProductPurchased(productId, details);
        }

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

        @Override
        public void onBillingInitialized() {
            readyToPurchase = true;
            billingItemsRecyclerViewAdapter.setReadyToPurchase(true);
            billingItemsRecyclerViewAdapter.notifyDataSetChanged();
        }

        @Override
        public void onPurchaseHistoryRestored() {
            billingItemsRecyclerViewAdapter.notifyDataSetChanged();
        }
    });
    billingItemsRecyclerViewAdapter = new BillingItemsRecyclerViewAdapter(this);
    recyrecyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyrecyclerView.setHasFixedSize(true);
    recyrecyclerView.setAdapter(billingItemsRecyclerViewAdapter);
    mIsArabic = Util.isArabicUi(this);

}
 
Example #21
Source File: DonationsDialog.java    From Orin with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
    loadSkuDetails();
    Toast.makeText(getContext(), R.string.thank_you, Toast.LENGTH_SHORT).show();
}
 
Example #22
Source File: BillingService.java    From fingen with Apache License 2.0 4 votes vote down vote up
@Override
public void onProductPurchased(@NonNull String productId, TransactionDetails details) {
    if (mBillingEventsListener != null) {
        mBillingEventsListener.onProductPurchased(productId, details);
    }
}
 
Example #23
Source File: BillingItemsRecyclerViewAdapter.java    From IslamicLibraryAndroid with GNU General Public License v3.0 2 votes vote down vote up
public void notifyProductPurchased(String productId, TransactionDetails details) {

    }
 
Example #24
Source File: DonateActivity.java    From GotoSleep with GNU General Public License v3.0 2 votes vote down vote up
@Override
public void onProductPurchased(String productId, TransactionDetails details) {

}
 
Example #25
Source File: IBillingEventsListener.java    From fingen with Apache License 2.0 votes vote down vote up
public void onProductPurchased(@NonNull String productId, TransactionDetails details);