@ SuppressWarnings ( "unused" ) @ Override public void onPaymentError ( int code , String response ) { try { Toast . makeText ( this , "Payment failed: " + code + " " + response , Toast . LENGTH_SHORT ) . show ( ) ; } catch ( Exception e ) { Log . e ( TAG , "Exception in onPaymentError" , e ) ; } }
The name of the function has to be onPaymentError Wrap your code in try catch as shown to ensure that this method runs correctly