I am implementing RazorPay Android Standard SDK for Order and Payment purposes.
Following is the code for payment:
private fun startPayment(razorPayId: String, paymentOrderId: String, totalPrice: String) {
val co = Checkout()
co.setKeyID(razorPayId)
try {
val options = JSONObject()
options.put("name", "Payment")
options.put("description", "")
options.put("order_id", paymentOrderId)
options.put("currency", "INR")
options.put("amount", totalPrice)
options.put("callback_url", "${ApiConstant.BASE_URL}orders/payment")
val preFill = JSONObject()
preFill.put("email", getEmail())
preFill.put("contact", getPhoneNumber())
options.put("prefill", preFill)
val theme = JSONObject()
theme.put("hide_topbar", false)
options.put("theme", theme)
co.open(this, options)
} catch (e: Exception) {
Toast.makeText(this, "Error in payment: " + e.message, Toast.LENGTH_LONG).show()
e.printStackTrace()
}
}
I have used callback_url for securing my payment. The problem is when I used this in test mode, I am getting stuck on the Success page of RazorPay and I am not able to have success callback in my app.
In the given screenshot, the message {"payment": "success"} is the response from my callback_url.
If I press back on this page, I am having two options displayed in the screenshot.
Am I doing something wrong? Can anyone help me with this?
Thank you in advance.
