Reputation: 1
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(); } })
Upvotes: 0
Views: 586
Reputation: 558
You need to implement PaymentResultListener
class PaymentActivity: Activity(), PaymentResultListener {
override fun onPaymentError(errorCode: Int, response: String?)
{
}
override fun onPaymentSuccess(razorpayPaymentId: String?) {
}
Upvotes: 0