Good day!
I am trying to make a purchase in my application. When you click the button, int monetki is incremented and stored in SharedPreferences.
Payment passes, money is written off, an alert about a successful purchase is issued, but nothing happens in the application. Through debug I can not check because it is a paid purchase. What to do?
IabHelper mHelper; int monetki; SharedPreferences sPref; String str; TextView change; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.buy); sPref = getSharedPreferences("myPref", MODE_PRIVATE); if (sPref.contains("monetki")) { monetki = sPref.getInt("monetki", 0); change = (TextView)findViewById(R.id.monviewbuy); String str = Integer.toString(monetki); change.setText(str); } String base64EncodedPublicKey; base64EncodedPublicKey = "..."; mHelper = new IabHelper(this, base64EncodedPublicKey); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { if (!result.isSuccess()) { // Oh noes, there was a problem. // Log.d(TAG, "Problem setting up In-app Billing: " + result); } // Hooray, IAB is fully set up! } }); } String mon15 = "monetki15"; public void click15(View view) { mHelper.launchPurchaseFlow(this, mon15, 10001, mPurchaseFinishedListener, " "); } String mon40 = "monetki"; public void click40(View view) { mHelper.launchPurchaseFlow(this, mon40, 10002, mPurchaseFinishedListener, " "); } String mon120 = "monetki120"; public void click120(View view) { mHelper.launchPurchaseFlow(this, mon120, 10003, mPurchaseFinishedListener, " "); } IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() { public void onIabPurchaseFinished(IabResult result, Purchase purchase) { if (result.isFailure()) { // Log.d(TAG, "Error purchasing: " + result); return; } else if (purchase.getSku().equals(mon120)) { monetki+=120; str = Integer.toString(monetki); change.setText(str); savemonetki(monetki); } else if (purchase.getSku().equals(mon40)) { monetki+=40; str = Integer.toString(monetki); change.setText(str); savemonetki(monetki); } else if (purchase.getSku().equals(mon15)){ monetki+=15; str = Integer.toString(monetki); change.setText(str); savemonetki(monetki); } } }; public boolean savemonetki(int monetki){ sPref = getSharedPreferences("myPref", MODE_PRIVATE); SharedPreferences.Editor ed = sPref.edit(); ed.putInt("monetki", monetki); ed.commit(); return true; }
result.isFailure()commented out, where is the notification of a successful purchase? This code is generally executed, does the text change inTextView change? - lsillarionov