Closed aminulsec closed 2 years ago
After Building App Error: public void onProductPurchased(String productId, TransactionDetails details) { ^ symbol: class TransactionDetails
IN My Java Class Error: package com.app.package.view.wallet;
import android.app.Dialog; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.databinding.DataBindingUtil; import androidx.lifecycle.ViewModelProviders;
import com.anjlab.android.iab.v3.BillingProcessor; import com.anjlab.android.iab.v3.PurchaseInfo; import com.anjlab.android.iab.v3.TransactionDetails; import com.google.android.material.bottomsheet.BottomSheetDialog; import com.google.android.material.bottomsheet.BottomSheetDialogFragment; import com.app.package.R; import com.app.package.databinding.CustomToastBinding; import com.app.package.databinding.FragmentPurchaseCoinSheetBinding; import com.app.package.viewmodel.CoinPurchaseViewModel; import com.app.package.viewmodelfactory.ViewModelFactory;
import org.jetbrains.annotations.NotNull;
public class CoinPurchaseSheetFragment extends BottomSheetDialogFragment implements BillingProcessor.IBillingHandler {
FragmentPurchaseCoinSheetBinding binding; CoinPurchaseViewModel viewModel; BillingProcessor bp; @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { BottomSheetDialog bottomSheetDialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState); bottomSheetDialog.setOnShowListener(dialog1 -> { BottomSheetDialog dialog = (BottomSheetDialog) dialog1; dialog.setCanceledOnTouchOutside(true); }); return bottomSheetDialog; } @Override public View onCreateView(@NotNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { binding = DataBindingUtil.inflate(inflater, R.layout.fragment_purchase_coin_sheet, container, false); return binding.getRoot(); } @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); viewModel = ViewModelProviders.of(this, new ViewModelFactory(new CoinPurchaseViewModel()).createFor()).get(CoinPurchaseViewModel.class); initView(); initListeners(); initObserve(); binding.setViewmodel(viewModel); } private void initView() { viewModel.fetchCoinPlans(); if (getActivity() != null) { bp = new BillingProcessor(getActivity(), getActivity().getResources().getString(R.string.play_lic_key), this); bp.initialize(); } } private void initListeners() { viewModel.adapter.setOnRecyclerViewItemClick((data, position) -> { viewModel.coins = data.getCoinAmount(); bp.purchase(getActivity(), data.getPlaystoreProductId()); }); } private void initObserve() { viewModel.purchase.observe(getViewLifecycleOwner(), purchase -> showPurchaseResultToast(purchase.getStatus())); } private void showPurchaseResultToast(Boolean status) { dismiss(); CustomToastBinding customToastBinding = DataBindingUtil.inflate(LayoutInflater.from(getActivity()), R.layout.custom_toast, null, false); customToastBinding.setStatus(status); if (status != null && status) { customToastBinding.tvToastMessage.setText("Coins Added To Your Wallet\nSuccessfully.."); } else { String string = "Something Went Wrong !"; customToastBinding.tvToastMessage.setText(string); } Toast toast = new Toast(getContext()); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(customToastBinding.getRoot()); toast.show(); } @**Override** public void onProductPurchased(String productId, **TransactionDetails** details) { bp.**consumePurchase**(productId); viewModel.purchaseCoin(); } @Override public void onProductPurchased(@NonNull String productId, @Nullable PurchaseInfo details) { } @Override public void onPurchaseHistoryRestored() { Log.d("TAG", "onPurchaseHistoryRestored: "); } @Override public void onBillingError(int errorCode, Throwable error) { Toast.makeText(getActivity(), "Something went wrong..", Toast.LENGTH_SHORT).show(); } @Override public void onBillingInitialized() { Log.d("BILLING", "onBillingInitialized: " + "Initialized successfully"); } @Override public void onDestroy() { if (bp != null) { bp.release(); } super.onDestroy(); } @Override public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); bp.**handleActivityResult**(requestCode, resultCode, data); }
}
https://github.com/anjlab/android-inapp-billing-v3/blob/master/UPGRADING.md
After Building App Error: public void onProductPurchased(String productId, TransactionDetails details) { ^ symbol: class TransactionDetails
IN My Java Class Error: package com.app.package.view.wallet;
import android.app.Dialog; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.databinding.DataBindingUtil; import androidx.lifecycle.ViewModelProviders;
import com.anjlab.android.iab.v3.BillingProcessor; import com.anjlab.android.iab.v3.PurchaseInfo; import com.anjlab.android.iab.v3.TransactionDetails; import com.google.android.material.bottomsheet.BottomSheetDialog; import com.google.android.material.bottomsheet.BottomSheetDialogFragment; import com.app.package.R; import com.app.package.databinding.CustomToastBinding; import com.app.package.databinding.FragmentPurchaseCoinSheetBinding; import com.app.package.viewmodel.CoinPurchaseViewModel; import com.app.package.viewmodelfactory.ViewModelFactory;
import org.jetbrains.annotations.NotNull;
public class CoinPurchaseSheetFragment extends BottomSheetDialogFragment implements BillingProcessor.IBillingHandler {
}