T
T
termitik842018-09-02 10:50:31
Android
termitik84, 2018-09-02 10:50:31

Issue with Android In-app billing?

The problem is that after purchasing a subscription, the necessary information is displayed, when you log in again, the information is not displayed, but it asks you to subscribe again, when you choose to pay again, a message pops up that the subscription is already there. Please help me how to fix this???
here is the MainActivity code:

package en.ddr.der;
import android.content.Intent;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.webview;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import com.anjlab.android.iab.v3.BillingProcessor;
import com.anjlab.android.iab.v3.SkuDetails;
import com.anjlab.android.iab.v3.TransactionDetails;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity implements BillingProcessor.IBillingHandler
{
private ImageButton Back,Email, PlayMarket;
private BillingProcessor bp;
private WebView mWebView;
private int getInt;
private String Key = "MIIBIjANBgkqhki......";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Back = findViewById(R.id.imageBack);
Email = findViewById(R.id.imageEmail);
PlayMarket = findViewById(R.id.imageStar);
mWebView = findViewById(R.id.mWebView);
mWebView.getSettings().setJavaScriptEnabled(true);
getInt = getIntent().getIntExtra("Full", 0);
if (getInt == 1)
{
mWebView.loadUrl(" ddr.ru/free.php ");
}else if (getInt == 2)
{
bp = new BillingProcessor(this, Key, this);
bp.initialize();
boolean df = bp.loadOwnedPurchasesFromGoogle();
}else if (getInt == 3)
{
mWebView.loadUrl("ddr.ru/hist.php ");
}
mWebView.setWebViewClient(new MyWebViewClinet());
Back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{
Intent intent = new Intent(MainActivity. this, Navigathion.class);
startActivity(intent);
}
});
Email.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{
Intent i = new Intent(Intent.ACTION_SEND);
i. setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"[email protected]"});
try {
startActivity(Intent.createChooser(i, "The message is sent"));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MainActivity.this, "The message is not sent", Toast.LENGTH_SHORT).show();
}
}
});
PlayMarket.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=ru.d... ")));
}
});
}
@Override
public void onProductPurchased(@NonNull String productId, @Nullable TransactionDetails details)
{
mWebView.loadUrl(" ddr.ru/vip.php ");
Toast.makeText(getApplicationContext(), "The purchase is made", Toast.LENGTH_SHORT).show();
}
@Override
public void onPurchaseHistoryRestored()
{
int a = 0;
}
@Override
public void onBillingError(int errorCode, @Nullable Throwable error)
{
onBackPressed();
}
@Override
public void onBillingInitialized()
{
if (bp.listOwnedProducts().size() != 0)
{
mWebView.loadUrl(" ddr.ru/vip.php ");
}
else
{
AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this);
View view = getLayoutInflater().inflate(R.layout.alert, null);
RadioButton radioButton2 = view.findViewById(R.id.radioButton2);
RadioButton radioButton3 = view.findViewById(R.id.radioButton3);
final RadioGroup ragioGroup = view.findViewById(R.id.radioGroup);
Button sub = view.findViewById(R.id.Sub);
sub.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{
int id = ragioGroup.getCheckedRadioButtonId();
if (id == -1)
{
Toast.makeText(getApplicationContext(), "Select subscription ", Toast.LENGTH_SHORT).show();
}
if (id == R.id.radioButton2)
{
bp.subscribe(MainActivity.this, "wedely");
}else if (id == R.id.radioButton3)
{
bp.subscribe(MainActivity.this, "mesyc");
}
}
});
mBuilder.setView(view);
AlertDialog alertDialog = mBuilder.create();
alertDialog.show();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data)
{
if (!bp.handleActivityResult(requestCode, resultCode, data))
{
super.onActivityResult(requestCode, resultCode, data);
}
}
private class MyWebViewClinet extends WebViewClient
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
}
@Override
public void onBackPressed()
{
if (mWebView.canGoBack())
{
mWebView.goBack();
}
else
{
super.onBackPressed();
}
}
@Override
public void onDestroy() {
if (bp != null) {
bp.release();
}
super.onDestroy();
}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2018-09-02
@dimonchik2013

I recommend replacing the sheet with
Please help me how to fix this ???

?prx=..%2Fbank-notes_coins%2Fbanknote_co

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question