PDA

View Full Version : مشکل در پرداخت درون برنامه ای کافه بازار



کاظم فلاحی خواه
چهارشنبه 12 مهر 1396, 16:23 عصر
با سلام خدمت دوستان
من در حال نوشتن نرم افزاری برای اندروید با اندروید استودیو هستم و مشکلی با مستندات پرداخت درون برنامه ای کافه بازار ندارم در واقع همشون رو می دونم و در نرم افزارم به طور صحیح قرار دادم مشکل اصلی من اینه که وقتی روی دکمه پرداخت می زنم و بعد از وارد کردن رمز کافه بازار دیالوگ پرداخت نشون داده نمیشه؟

من سورس کد های زیادی رو دانلود کردم و مستندات گوناگون پرداخت کافه بازار رو سایت های مختلف خوندم و همه چیز رو توی پروژه ام بررسی کردم ولی نمی دونم چرا وقتی روی پرداخت می زنم می نویسه لطفا صبر کنید بعدش صبر کنید پنهان میشه و هیچ اتفاقی نمی افته؟


package inappbilling.kazem.com.cafebazaarinappbilling;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;


import inappbilling.kazem.com.cafebazaarinappbilling.util .IabHelper;
import inappbilling.kazem.com.cafebazaarinappbilling.util .IabResult;
import inappbilling.kazem.com.cafebazaarinappbilling.util .Inventory;
import inappbilling.kazem.com.cafebazaarinappbilling.util .Purchase;


public class MainActivity extends Activity {
// Debug tag, for logging
static final String TAG = "Test:";


// SKUs for our products: the premium upgrade (non-consumable)
static final String SKU_PREMIUM = "itest.buyproduct";


// Does the user have the premium upgrade?
boolean mIsPremium = false;


// (arbitrary) request code for the purchase flow
static final int RC_REQUEST = 10001;


// The helper object
IabHelper mHelper;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


String base64EncodedPublicKey = "MIHNMA0GCSqGSIb3DQEBAQUAA4G7ADCBtwKBrwC5lYtzNWtAo5 nLiFBeFtvRWm2sTFboyYhpFwdgZX4ne5pL0plVmgW50hnlEomZ 5H+VC0hT3vbjUQEsuBbLxlJU3GqupIjmZRerwkA7cN2fMwNNPi AS+VhCykAK/he16ar6OOF6RsIIcb3+myadSYr8lHOgf/Kev8UcE2sNYzJw2IqFgURjbzgYA86Zc0qc6WYavBMcmvhjvgBH Bp4GPxhVUilDc7ScFfPXzjuTiR0CAwEAAQ==";
// You can find it in your Bazaar console, in the Dealers section.
// It is recommended to add more security than just pasting it in your source code;
mHelper = new IabHelper(this, base64EncodedPublicKey);


Log.d(TAG, "Starting setup.");
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
Log.d(TAG, "Setup finished.");


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!
mHelper.queryInventoryAsync(mGotInventoryListener) ;
}
});


Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mHelper.launchPurchaseFlow(MainActivity.this, SKU_PREMIUM, RC_REQUEST, mPurchaseFinishedListener, "payload-string");
}
});
}


IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
Log.d(TAG, "Query inventory finished.");
if (result.isFailure()) {
Log.d(TAG, "Failed to query inventory: " + result);
return;
} else {
Log.d(TAG, "Query inventory was successful.");
// does the user have the premium upgrade?
mIsPremium = inventory.hasPurchase(SKU_PREMIUM);


// update UI accordingly


Log.d(TAG, "User is " + (mIsPremium ? "PREMIUM" : "NOT PREMIUM"));
}


Log.d(TAG, "Initial inventory query finished; enabling main UI.");
}
};


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(SKU_PREMIUM)) {
// give user access to premium content and update the UI
}
}
};


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);


Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);


// Pass on the activity result to the helper for handling
if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
} else {
Log.d(TAG, "onActivityResult handled by IABUtil.");
}
}


@Override
public void onDestroy() {
super.onDestroy();
if (mHelper != null)
mHelper.dispose();
mHelper = null;
}
}