Reputation: 344
so I'm implementing this simple razor payment integration. but it's giving me a "No appropriate payment method found" error. I tried choosing the payment options form before that didn't work either.
val razorpay = RazorpayClient("my key", "my secret key")
val orderRequest = JSONObject()
orderRequest.put("amount", 50000); // amount in the smallest currency unit
orderRequest.put("currency", "INR");
orderRequest.put("receipt", "order_rcptid_11")
try {
val order: Order = razorpay.Orders.create(orderRequest)
Timber.d("order : $order")
startPayment(order)
} catch (e: RazorpayException) {
Timber.e(e)
}
private fun startPayment(order: Order) {
val checkout = Checkout()
checkout.setKeyID("my key my secret key")
/*
* You need to pass current activity in order to let Razorpay create CheckoutActivity
* */
val activity: Activity = this
try {
checkout.open(activity, order.toJson())
} catch (e: Exception) {
Toast.makeText(activity, "Error in payment: " + e.message, Toast.LENGTH_LONG).show()
e.printStackTrace()
}
}
Upvotes: 4
Views: 6480
Reputation: 444
Some times key is not working use another test key of other project
checkout.setKeyID("rzp_test_--------")
Upvotes: 4
Reputation: 9
I have faced the same issue. Go to Razorpay account. Where you found payment methods and tap the request buttons which payment methods do you want to apply. Issue which was fixed payment method activate by Razor pay. "OOPS!Somthing went wrong. No appropriate payment method found"
Upvotes: 0
Reputation: 344
It was my mistake
checkout.setKeyID("my key my secret key")
I needed to provide only "my key" here. the method name literally saying that "setKeyID".
Upvotes: 4