Connect to NextPay.ir payment gateway from
Kotlin/Javacode base in easy way.
🏠 Homepage
⚡ Replace $nextpayKTVersion 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:nextpay:$nextpayKTVersion")
}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:nextpay:$nextpayKTVersion'
}If you are not familiar with the transaction processing flow its good to see Nextpay.ir documents first.
val nextPay = NextPay(apiKey = NEXTPAY_API_KEY, logging = false)nextPay
.requestToken("your-order-id", 1000, "your-website-callback-api")
.fold(onSuccess = { response ->
println("hooray! transaction (${response.transId} generated.")
println("redirect user to ${response.paymentURL()}")
}, onFailure = { error ->
when (error) {
is NextPayException -> println("${error.msg} | ${error.code}")
else -> println("something went wrong. ${error.message}")
}
})You may want to save transId, orderId and amount for
prevent Double-spending problem.
- you also can modify
autoVerify,currency,customerPhone,allowedCardandcustomJsonFieldsif you needed. - If you set
autoVerify = truethe transaction will be auto verify, and you don't need to verify the transaction manually.
If you set autoVerify to false in step 1 you should verify the transaction within 10 minutes or transaction will be
reverted automatically.
nextPay.verifyPayment("tranId", 1000)
.fold({ response ->
println("payment verified.\n$response")
}, { error ->
when (error) {
is NextPayException -> println("${error.msg} | ${error.code}")
else -> println("something went wrong. ${error.message}")
}
}) nextPay.rejectPayment("tranId", 1000)
.fold({ response ->
println("payment rejected.\n$response")
}, { error ->
when (error) {
is NextPayException -> println("${error.msg} | ${error.code}")
else -> println("something went wrong. ${error.message}")
}
})See Nextpay-KT Wiki for docs and more examples.
👤 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