Connect to IDPay.ir payment gateway from
Kotlin/Javacode base in easy way.
🏠 Homepage
we ⚡ Replace $idpayKTVersion with the latest version
in Maven Repository
or Maven Central.
1- Add mavenCentral() to your repositories section of build.gradle.kts if not already exists.
repositories {
mavenCentral()
}2- Add dependency to your project.
dependencies {
implementation("dev.falhad:idpay:$idpayKTVersion")
}1- Add maven() to your repositories section of build.gradle if not already exists.
repositories {
maven()
}2- Add dependency to your project.
dependencies {
implementation 'dev.falhad:idpay:$idpayKTVersion'
}If you are not familiar with the transaction processing flow its good to see IDPay.ir documents first.
val idPay = IDPay(apiKey = IDPAY_API_KEY, sandbox = true, logging = false)idPay
.requestToken("your-order-id", 1000, "your-website-callback-api")
.fold(onSuccess = { response ->
println("hooray! transaction (${response.id} generated.")
println("redirect user to ${response.link}")
}, onFailure = { error ->
when (error) {
is IDPayException -> println("${error.msg} | ${error.code}")
else -> println("something went wrong. ${error.message}")
}
})You may want to save id, orderId and amount for
prevent Double-spending problem.
If you set autoVerify to false in step 1 you should verify the transaction within 10 minutes or transaction will be
reverted automatically.
idPay.verify("id", "orderId")
.fold({ response ->
println("payment verified.\n$response")
}, { error ->
when (error) {
is IDPayException -> println("${error.msg} | ${error.code}")
else -> println("something went wrong. ${error.message}")
}
})👤 Farhad Navayazdan
- Website: https://falhad.dev
- Twitter: @iarcxxi
- Github: @falhad
- LinkedIn: @farhadarcxx
Give a ⭐️ if this project helped you!
My Public Address to Receive USDT (TRC20) is TQ43UdYtFAHQCNVciNCd9ndE4TQaMMzboX
Copyright © 2021 Farhad Navayazdan.
This project is MIT licensed.
This README was generated with ❤️ by readme-md-generator