آموزش های این وب سایت به صورت رایگان در دسترس است. اطلاعات بیشتر
بروز خطا
   [message]
اشتراک در سوال
رای ها
[dataList]

مشکل در پرداخت درون برنامه ای "کافه بازار"

esmail33  11 سال پیش  11 سال پیش
0 0

سلام دوستان

تغریبا دو سه هفته ای میشه که پرداخت درون برنامه ایی که من ازش استفاده میکردم خود به خود خراب شده!!

الان کل برنامه هایی که فرستادم درون پرداختشون از کار افتاده و باید نسخه ی جدیدشونو با پرداخت سالم دباره بفرستم.

مشکل الان اینجاست: بعد از پرداخت پول از حساب کسر میشه - سطح کاربری ارتقاع داده میشه - ولی وقتی از اکتیویتی مربوط به ارتقا سطح کاربری خارج و دباره وارد میشم دباره سطح کاربری رو کاربر عادی تشخیص میده و قسمت هایی هم که مربوط به کاربران ویژه هست نمایش داده نمیشه!!

یکی از دوستام میگفت که بازار، یه نسخه بروز رسانی بازار داره این مشکل مال اون نسخه هست و کدت یه چیزایی کم داره

 

ببینید این کد:

package com.example.clashup;

import com.example.clashup.util.IabHelper;
import com.example.clashup.util.IabResult;
import com.example.clashup.util.Inventory;
import com.example.clashup.util.Purchase;


import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.app.Activity;
import android.content.Intent;
public class activity_1 extends Activity {

Button btn2;

public ProgressDialog dialog;

SharedPreferences preferences = null ;

private String PACKAGENAME = "" ;

final String KEY1 = "PERIMIUM1" ;

// Debug tag, for logging
static final String TAG = "savedPremium";

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

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

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

// The helper object
IabHelper mHelper;


ListView list;
String[] web = {
"------",
"-------",
"------------",
"------------",
"-----------",
"----------",
"------------",
"-----------",
"--------"

} ;
Integer[] imageId = {
R.drawable.zero_1_3_1,
R.drawable.zero_1_2_1,
R.drawable.zero_1_1_1,
R.drawable.zero_1_4_1,
R.drawable.zero_1_5_1,
R.drawable.zero_1_6_1,
R.drawable.zero_1_9_1,
R.drawable.zero_1_7_1,
R.drawable.zero_1_8_1

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





CustomList adapter = new
CustomList(activity_1.this, web, imageId);
list=(ListView)findViewById(R.id.list);
list.setAdapter(adapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Intent intent = new Intent();
switch(arg2){
case 0: intent.setClass(arg1.getContext(), activity_1_1.class ); startActivity(intent); break;
case 1: intent.setClass(arg1.getContext(), activity_1_2.class ); startActivity(intent); break;
case 2: Toast q =Toast.makeText(activity_1.this, "شما کاربر ویژه ی این قسمت نیستید", 250);q.show();
case 3: Toast w =Toast.makeText(activity_1.this, "شما کاربر ویژه ی این قسمت نیستید", 250);w.show();
case 4: Toast e =Toast.makeText(activity_1.this, "شما کاربر ویژه ی این قسمت نیستید", 250);e.show();
case 5: Toast r =Toast.makeText(activity_1.this, "شما کاربر ویژه ی این قسمت نیستید", 250);r.show();
case 6: Toast y =Toast.makeText(activity_1.this, "شما کاربر ویژه ی این قسمت نیستید", 250);y.show();
case 7: Toast u =Toast.makeText(activity_1.this, "شما کاربر ویژه ی این قسمت نیستید", 250);u.show();
case 8: Toast i =Toast.makeText(activity_1.this, "شما کاربر ویژه ی این قسمت نیستید", 250);i.show();
}}}
);






btn2 = (Button) findViewById(R.id.normalbtn);
// load your setting that are you premium or not?
preferences = getSharedPreferences(PACKAGENAME,Context.MODE_PRIVATE);
PACKAGENAME = getClass().getName();
Log.e("TAG", PACKAGENAME);
mIsPremium1 = preferences.getBoolean(KEY1, false);
if (mIsPremium1 == true) {
updateUi();
return;
}

// show loading dialog with ProgressDialog
dialog = new ProgressDialog(this);
dialog.setMessage("loading...");
dialog.setCancelable(false);
dialog.setInverseBackgroundForced(false);
dialog.show();


String base64EncodedPublicKey = "MIHNMA0GCSqGSIb3DQEBAQUAA4G7ADCBtwKBrwCVLk2SDsudC3S/Z0SXdp3zyyKV8afXFiCt6kQXoqKn4yH5yLkV9C55HAqwdnbDPl+oMr3g2NC2xx89x4/o1jFvplxnHbPUgvguDgbJB1uyVQbhB+TBvFKgAHY5V0xTR5HDmiIMkxi5s7w3A9KYAO1jBSNtHmKXaBq3UvSPiPzI9hzlg7/WdyWqFYORtXCuNcSzDSWQxA16h8BW3zZTgJ3zsU51FsxgHK/VkjNT2KkCAwEAAQ==";
// 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);

}
});
}

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);
dialog.hide();
return;
}
else {
Log.d(TAG, "Query inventory was successful.");
// does the user have the premium upgrade?
mIsPremium1 = inventory.hasPurchase(SKU_PREMIUM);

// update UI accordingly

Log.d(TAG, "User is " + (mIsPremium1 ? "PREMIUM" : "NOT PREMIUM"));
}
dialog.hide();
updateUi();
setWaitScreen(false);
Toast.makeText(getApplicationContext(), mIsPremium1? R.string.premium : R.string.notpremium, Toast.LENGTH_SHORT).show();
Log.d(TAG, "Initial inventory query finished; enabling main UI.");

}

};

public void onSavedUpgradeAppButtonClicked(View arg0) {
Log.d(TAG, "Upgrade button clicked; launching purchase flow for upgrade.");
setWaitScreen(true);

/* TODO: for security, generate your payload here for verification. See the comments on
* verifyDeveloperPayload() for more info. Since this is a SAMPLE, we just use
* an empty string, but on a production app you should carefully generate this. */
String payload = "gdhassdflsldaslfkahsjahsjakaasa";

mHelper.launchPurchaseFlow(this, SKU_PREMIUM, RC_REQUEST,
mPurchaseFinishedListener, payload);
}


@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.");
}

}

boolean verifyDeveloperPayload(Purchase p) {
String payload = p.getDeveloperPayload();

return true;
}

IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
Log.d(TAG, "Purchase finished: " + result + ", purchase: " + purchase);
if (result.isFailure()) {
Log.d(TAG, "Error purchasing: " + result);
setWaitScreen(false);
return;
}
if (!verifyDeveloperPayload(purchase)) {
complain("Error purchasing. Authenticity verification failed.");
setWaitScreen(false);
return;
}

Log.d(TAG, "Purchase successful.");

if (purchase.getSku().equals(SKU_PREMIUM)) {
Log.d(TAG, "Purchase is premium upgrade. Congratulating user.");
alert("Thank you for upgrading to premium!");
mIsPremium1 = true;
updateUi();
setWaitScreen(false);

}
}
};

@Override
public void onDestroy() {
super.onDestroy();

Log.d(TAG, "Destroying helper.");
if (mHelper != null) mHelper.dispose();
mHelper = null;
}

// Update button with updateUi
public void updateUi() {
if (mIsPremium1) {
findViewById(R.id.normalbtn).setBackgroundResource(mIsPremium1? R.drawable.karbar_vizhe : null);





CustomList adapter = new
CustomList(activity_1.this, web, imageId);
list=(ListView)findViewById(R.id.list);
list.setAdapter(adapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Intent intent = new Intent();
switch(arg2){
case 0: intent.setClass(arg1.getContext(), activity_1_1.class ); startActivity(intent); break;
case 1: intent.setClass(arg1.getContext(), activity_1_2.class ); startActivity(intent); break;
case 2: intent.setClass(arg1.getContext(), activity_1_3.class ); startActivity(intent); break;
case 3: intent.setClass(arg1.getContext(), activity_1_4.class ); startActivity(intent); break;
case 4: intent.setClass(arg1.getContext(), activity_1_5.class ); startActivity(intent); break;
case 5: intent.setClass(arg1.getContext(), activity_1_6.class ); startActivity(intent); break;
case 6: intent.setClass(arg1.getContext(), activity_1_9.class ); startActivity(intent); break;

case 7: intent.setClass(arg1.getContext(), activity_1_7.class ); startActivity(intent); break;
case 8: intent.setClass(arg1.getContext(), activity_1_8.class ); startActivity(intent); break;


}}}
);




// change the mIsPremium to true
SharedPreferences.Editor newtask = preferences.edit();
newtask.putBoolean(KEY1, true);
newtask.commit();
}
}

// Enables or disables the "please wait" screen.
void setWaitScreen(boolean set) {
findViewById(R.id.screen_wait).setVisibility(set ? View.VISIBLE : View.GONE);
}

void complain(String message) {
Log.e(TAG, "**** testbilling Error: " + message);
alert("Error: " + message);
}

void alert(String message) {
AlertDialog.Builder bld = new AlertDialog.Builder(this);
bld.setMessage(message);
bld.setNeutralButton("OK", null);
Log.d(TAG, "Showing alert dialog: " + message);
bld.create().show();

}













@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {

case R.id.itemSetting:
startActivity(new Intent(activity_1.this, setting.class));
return true;

case R.id.itemBUY:
startActivity(new Intent(activity_1.this, buy.class));
return true;
default:
return true;
}
}

}

 

 

اینم کد قسمت خرید:

 package com.example.clashup;


import com.example.clashup.util.IabHelper;
import com.example.clashup.util.IabResult;
import com.example.clashup.util.Inventory;
import com.example.clashup.util.Purchase;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class buy_1 extends Activity{

public ProgressDialog dialog ;

Button btn1;

// Debug tag, for logging
static final String TAG = "onlinePremium";

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

// 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.buy_1_layout);
btn1 = (Button) findViewById(R.id.onlinebtn);

// show loading dialog with ProgressDialog
dialog = new ProgressDialog(this);
dialog.setMessage("loading...");
dialog.setCancelable(false);
dialog.setInverseBackgroundForced(false);
dialog.show();


String base64EncodedPublicKey = "MIHNMA0GCSqGSIb3DQEBAQUAA4G7ADCBtwKBrwCVLk2SDsudC3S/Z0SXdp3zyyKV8afXFiCt6kQXoqKn4yH5yLkV9C55HAqwdnbDPl+oMr3g2NC2xx89x4/o1jFvplxnHbPUgvguDgbJB1uyVQbhB+TBvFKgAHY5V0xTR5HDmiIMkxi5s7w3A9KYAO1jBSNtHmKXaBq3UvSPiPzI9hzlg7/WdyWqFYORtXCuNcSzDSWQxA16h8BW3zZTgJ3zsU51FsxgHK/VkjNT2KkCAwEAAQ==";
// 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);

}
});
}

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);
dialog.hide();
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"));
}
dialog.hide();
updateUi();
setWaitScreen(false);
Toast.makeText(getApplicationContext(), mIsPremium? R.string.premium : R.string.notpremium, Toast.LENGTH_SHORT).show();
Log.d(TAG, "Initial inventory query finished; enabling main UI.");

}

};


public void onOnlineUpgradeAppButtonClicked(View arg0) {
Log.d(TAG, "Upgrade button clicked; launching purchase flow for upgrade.");
setWaitScreen(true);

/* TODO: for security, generate your payload here for verification. See the comments on
* verifyDeveloperPayload() for more info. Since this is a SAMPLE, we just use
* an empty string, but on a production app you should carefully generate this. */
String payload = "inbarnametavasotehamedjjsakhteshodeast";

mHelper.launchPurchaseFlow(this, SKU_PREMIUM, RC_REQUEST,
mPurchaseFinishedListener, payload);
}


@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.");
}

}

boolean verifyDeveloperPayload(Purchase p) {
String payload = p.getDeveloperPayload();

return true;
}

IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
Log.d(TAG, "Purchase finished: " + result + ", purchase: " + purchase);
if (result.isFailure()) {
Log.d(TAG, "Error purchasing: " + result);
setWaitScreen(false);
return;
}
if (!verifyDeveloperPayload(purchase)) {
complain("Error purchasing. Authenticity verification failed.");
setWaitScreen(false);
return;
}

Log.d(TAG, "Purchase successful.");

if (purchase.getSku().equals(SKU_PREMIUM)) {
Log.d(TAG, "Purchase is premium upgrade. Congratulating user.");
alert("Thank you for upgrading to premium!");
mIsPremium = true;
updateUi();
setWaitScreen(false);

}
}
};

@Override
public void onDestroy() {
super.onDestroy();

Log.d(TAG, "Destroying helper.");
if (mHelper != null) mHelper.dispose();
mHelper = null;
}
// Update button with updateUi
public void updateUi() {

if (mIsPremium) {
findViewById(R.id.onlinebtn).setBackgroundResource(R.drawable.karbar_vizhe);
btn1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), R.string.clickpremium, Toast.LENGTH_SHORT).show();
}
});

}
}

// Enables or disables the "please wait" screen.
void setWaitScreen(boolean set) {
findViewById(R.id.screen_wait).setVisibility(set ? View.VISIBLE : View.GONE);
}


void complain(String message) {
Log.e(TAG, "**** testbilling Error: " + message);
alert("Error: " + message);
}

void alert(String message) {
AlertDialog.Builder bld = new AlertDialog.Builder(this);
bld.setMessage(message);
bld.setNeutralButton("OK", null);
Log.d(TAG, "Showing alert dialog: " + message);
bld.create().show();

}


}

 

 

الان چیش کمه؟؟

شرمنده کل کد رو گزاشتم چند وقتیه دارم روش کار میکنم نفهمیدم مشکل چیه

 راستی از برنامه ی آقای hamed jj استفاده کردم

 

 

 

 

 

+1 0
لطفا کد هارو پاک کنید و فقط قسمت هایی که فکر میکنید مشکل وجود داره رو بنویسید ، در بلاگ بنده هم میتونید فیلم آموزش کار با پرداخت درون برنامه ای رو دانلود کنید learn.kashizadeh.com (11 سال پیش)
 برای این سوال 2 پاسخ وجود دارد.
پاسخ به سوال 
esmail33  11 سال پیش
0 0

سلام

اگه کسی هست که این کدارو برام درست کنه لطفا پ.خ بده

البته با پرداخت هزینش

پاسخ به سوال 
esmail33  11 سال پیش
0 0

کسی هست مشکل این کد هارو بر طرف کنه؟؟؟

هزینشو پرداخت میکنم

لطفا پ.خ بدید


پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .