i have an issue and will be appreciated if u help me .
this is an example of my issue :
I have some variables like (10.000 , 20,000) that user can select them and increase there credit .
when user click and chose one of them it goes to bank gateway and after payment it goes back to my app .
I used a text view to get the amount . it's no problem with this .
the amount that stored and show to user is 10000 or 20000 or 100000 and i want to be like this 10,000 or 20,000 or 100,000
actually every three number put a comma .
code :
private fun makepayment(amount: Long) {
val progress = findViewById<RelativeLayout>(R.id.rl_progress)
val purchase = ZarinPal.getPurchase(this)
val payment: PaymentRequest = ZarinPal.getSandboxPaymentRequest()
payment.merchantID = getString(R.string.MerchantId)
payment.amount = amount
payment.isZarinGateEnable(true)
payment.description = getString(R.string.incresemoney)
payment.setCallbackURL("returnfromzarinpal://mivebaranapp")
purchase.startPayment(payment) {
status, authority, paymentGatewayUri, intent ->
if (status == 100) {
progress.visibility = View.GONE
startActivity(intent)
} else {
Toast.makeText(
this,
"خطایی در برقراری ارتباط با درگاه رخ داده ، لطفا دوباره امتحان کنید",
Toast.LENGTH_LONG
).show()
}
}
}
private fun paymentVerification() {
val textmoney: TextView = findViewById(R.id.money)
val data: Uri? = intent.data
val getpurchase = ZarinPal.getPurchase(this)
getpurchase.verificationPayment(data) {
isPaymentSuccess, refID, paymentRequest ->
if (isPaymentSuccess) {
textmoney.text = "${paymentRequest.amount} تومان "
Toast.makeText(this, "افزایش موجودی شما با موفقیت انجام شد ", Toast.LENGTH_LONG)
.show()
} else {
Toast.makeText(
this,
"در عملیات پرداخت خطایی رخ داده ، لطفا دوباره سعی کنید",
Toast.LENGTH_LONG
).show()
}
}
Try this :
textView.text = "%,d".format(100000)
Output :
100,000