简体   繁体   中英

How to permanently disable payment button after successful payment in Android studio

I have a android studio project that is an E-Book. There is a Razorpay payment gateway in this project. I want to disable payment button permanently after successful payment. That means if a user use back press or reopen the app this payment button do not show after one successful payment. Please help me and thank you for reading...

This is my code

public class DetailsActivity extends BaseActivity implements PaymentResultListener  {

ImageView RazerPayButn; NestedScrollView ScroolBtn;

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

    ScroolBtn = findViewById(R.id.scrollviewid);
    RazerPayButn = (ImageView) findViewById(R.id.razorpay);

}

public void startPayment() {
@Override
public void onPaymentSuccess(String s) {
    Log.d("ONSUCCESS", "onPaymentSuccess: " + s);

}



@Override
public void onPaymentError(int i, String s) {
    Log.d("ONERROR", "onPaymentError: "+s);

}



public void onClick(View v){
    startPayment();
    Toast.makeText(mActivity, "Please wait...", Toast.LENGTH_SHORT).show();

    RazerPayButn.setVisibility(View.GONE);
    ScroolBtn.setVisibility(View.VISIBLE);


}

You could use data store or Room to save data permanently in a local database. Consider if the user clears the application storage your data will be lost. Another approach could be sending data to the server side and getting it from the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM