rlhindi.setOnClickListener {
val r = Random()
val output =
r.nextInt(2000000 - 200000 + 1).toString() + "20000"
transactionId = "TID" + System.currentTimeMillis() + output
PaymentApp.GOOGLE_PAY
val paymentApp = PaymentApp.GOOGLE_PAY
val builder: EasyUpiPayment.Builder? = upi_payment_id?.let { it1 ->
transactionId?.let { it2 ->
EasyUpiPayment.Builder(this@AddFunds)
.with(paymentApp)
.setPayeeVpa(it1)
.setPayeeName("RR Starline")
.setTransactionId(it2)
.setTransactionRefId(transactionId!!)
.setDescription("RR Straline-$mobile")
.setAmount(edtamount.text.toString() + ".00")
}
}
// END INITIALIZATION
// END INITIALIZATION
try {
// Build instance
if (builder != null) {
easyUpiPayment = builder.build()
}
// Register Listener for Events
easyUpiPayment!!.setPaymentStatusListener(this@AddFunds)
// Start payment / transaction
easyUpiPayment!!.startPayment()
dialog.dismiss()
} catch (exception: java.lang.Exception) {
exception.printStackTrace()
dialog.dismiss()
Toast.makeText(this@AddFunds, "" + exception.message, Toast.LENGTH_SHORT).show()
}
}
dialog.show()
}
else if (upiphonepe == "1") {
val dialog = Dialog(this@AddFunds)
val li =
getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val vi: View = li.inflate(R.layout.dailogpaymentbox, null, false)
val window = dialog.window
window!!.setBackgroundDrawableResource(android.R.color.transparent)
vi.background = resources.getDrawable(R.drawable.roundalert)
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
dialog.setContentView(vi)
val rlenglish = dialog.findViewById<RelativeLayout>(R.id.rlenglish)
val rlhindi = dialog.findViewById<RelativeLayout>(R.id.rlhindi)
rlenglish.visibility = View.GONE
rlhindi.setOnClickListener {
val r = Random()
val output =
r.nextInt(2000000 - 200000 + 1).toString() + "20000"
transactionId = "TID" + System.currentTimeMillis() + output
PaymentApp.PHONE_PE
val paymentApp = PaymentApp.PHONE_PE
val builder: EasyUpiPayment.Builder? = upi_payment_id?.let { it1 ->
transactionId?.let { it2 ->
EasyUpiPayment.Builder(this@AddFunds)
.with(paymentApp)
.setPayeeVpa(it1)
.setPayeeName("RR Starline")
.setTransactionId(it2)
.setTransactionRefId(transactionId!!)
.setDescription("RR Straline-$mobile")
.setAmount(edtamount.text.toString() + ".00")
}
}
// END INITIALIZATION
// END INITIALIZATION
try {
// Build instance
if (builder != null) {
easyUpiPayment = builder.build()
}
// Register Listener for Events
easyUpiPayment!!.setPaymentStatusListener(this@AddFunds)
// Start payment / transaction
easyUpiPayment!!.startPayment()
dialog.dismiss()
} catch (exception: java.lang.Exception) {
exception.printStackTrace()
dialog.dismiss()
Toast.makeText(this@AddFunds, "" + exception.message, Toast.LENGTH_SHORT).show()
}
}
dialog.show()
}
else if (upiothers == "1") {
val dialog = Dialog(this@AddFunds)
val li =
getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val vi: View = li.inflate(R.layout.dailogpaymentbox, null, false)
val window = dialog.window
window!!.setBackgroundDrawableResource(android.R.color.transparent)
vi.background = resources.getDrawable(R.drawable.roundalert)
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
dialog.setContentView(vi)
val rlenglish = dialog.findViewById<RelativeLayout>(R.id.rlenglish)
val rlhindi = dialog.findViewById<RelativeLayout>(R.id.rlhindi)
rlenglish.visibility = View.GONE
rlhindi.setOnClickListener {
val r = Random()
val output =
r.nextInt(2000000 - 200000 + 1).toString() + "20000"
transactionId = "TID" + System.currentTimeMillis() + output
PaymentApp.ALL
val paymentApp = PaymentApp.ALL
val builder: EasyUpiPayment.Builder? = upi_payment_id?.let { it1 ->
transactionId?.let { it2 ->
EasyUpiPayment.Builder(this@AddFunds)
.with(paymentApp)
.setPayeeVpa(it1)
.setPayeeName("RR Starline")
.setTransactionId(it2)
.setTransactionRefId(transactionId!!)
.setDescription("RR Straline-$mobile")
.setAmount(edtamount.text.toString() + ".00")
}
}
// END INITIALIZATION
// END INITIALIZATION
try {
// Build instance
if (builder != null) {
easyUpiPayment = builder.build()
}
// Register Listener for Events
easyUpiPayment!!.setPaymentStatusListener(this@AddFunds)
// Start payment / transaction
easyUpiPayment!!.startPayment()
dialog.dismiss()
} catch (exception: java.lang.Exception) {
exception.printStackTrace()
dialog.dismiss()
Toast.makeText(this@AddFunds, "" + exception.message, Toast.LENGTH_SHORT).show()
}
}
dialog.show()
}`
This is my code where i am selecting a radio button and according to it I am opening the UPI app.