简体   繁体   中英

I want to insert values in database after successful payment using razorpay using android studio

Here is my code I want to add data after payment is success. so I call the save method on payment success but it was give the error.

 //@Override
  public void onPaymentSuccess(String s, PaymentData paymentData) {
   paymentData.getData();
                razorpay_payment_id=  paymentData.getPaymentId();
                save(paymentData);

}

public void save(PaymentData  paymentData)
{
 userid=user_id;
    property_type = ptype1.getText().toString().trim();
    from_date = txtchkin.getText().toString().trim();
    to_date = txtchkout.getText().toString().trim();
    no_of_adults = no_of_adult.getText().toString().trim();
    no_of_childrens = no_of_children.getText().toString().trim();
    price=amount.getText().toString().trim();
    razorpay_payment_id=paymentData.getPaymentId();
    razorpay_order_id=paymentData.getOrderId();



payment_status="success";
    status="Active";
    isAllFieldsChecked = validate();
    if (isAllFieldsChecked) {
        StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
            @Override
    

public void onResponse(String response) {

            Toast.makeText(getApplicationContext(), "Data Inserted Successfully", Toast.LENGTH_LONG).show();
            }
        }
        

    , new Response.ErrorListener() {
        @Override
    

public void onErrorResponse(VolleyError error) { Toast.makeText(getApplicationContext(), error.toString().trim(), Toast.LENGTH_LONG).show(); } })

You need to implement PaymentResultListener

class PaymentActivity: Activity(), PaymentResultListener {
  override fun onPaymentError(errorCode: Int, response: String?)
  {
  
  }    
  override fun onPaymentSuccess(razorpayPaymentId: String?) {
     
  }

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