Into Razorpay payment code getActivity is not working

901 views Asked by At

This code is working into activity properly. But if this code is written into a fragment then there was an activity error. Picture one is an error message" Error: onPaymentError probably not implemented in your activity ". The error message is here ↓↓↓↓↓↓↓↓↓↓↓↓↓

https://i.stack.imgur.com/FhFJg.jpg

Razorpay payment code is here:

               checkout.setKeyID("rzp_****_***************");
               checkout.setImage(R.drawable.ic_baseline_home_24);

               try {
                   JSONObject options = new JSONObject();

                   options.put("name", "[![enter image description here][1]][1]Roy");
                   options.put("currency", "INR");
                   options.put("image", R.drawable.ic_baseline_home_24);
                   options.put("amount", 10000);//pass amount in currency subunits
                   options.put("prefill.email", "[email protected]");
                   options.put("prefill.contact", "9999999999");

                   checkout.open(getActivity(), options);

               } catch (Exception e) {
                   Toast.makeText(getActivity(), "Error in starting Razorpay Checkout: " + e, Toast.LENGTH_LONG).show();
                   Log.e(TAG, "Error in starting Razorpay Checkout", e);
               } ```
1

There are 1 answers

1
Rupam Das On

Please make sure, if you are calling the payment start method from inside a fragment, ensure that the fragment's parent activity implements the PaymentResultListener interface.