๐
Welcome to nextpay-kt
Connect to NextPay.ir payment gateway in easy way.
๐
Homepage
Setup
Kotlin KTS
1- Add mavenCentral()
to your repositories
section of build.gradle.kts
repositories {
mavenCentral()
}
2- Add dependency to your project.
dependencies {
implementation("dev.falhad:nextpay:1.0.2")
}
Groovy
1- Add maven()
to your repositories
section of build.gradle.kts
repositories {
maven()
}
2- Add dependency to your project.
dependencies {
implementation 'dev.falhad:nextpay:1.0.2'
}
๐
Basic Usage
If you are not familiar with the transaction processing flow its good to see Nextpay.ir documents first.
Initialize Nextpay-KT
val nextPay = NextPay(apiKey = NEXTPAY_API_KEY, logging = false)
Step 1 - Generate Token
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
,allowedCard
andcustomJsonFields
if you needed. - If you set
autoVerify = true
the transaction will be auto verify, and you don't need to verify the transaction manually.
Step 2 - Verify/Reject Payment
If you set autoVerify to false
in step 1 you should verify the transaction within 10 minutes or transaction will be reverted automatically.
Verify Payment
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}")
}
})
Reject Payment
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}")
}
})
Checkout / Other Apis
See Nextpay-KT Wiki for docs and more examples.
Author
- Website: https://falhad.dev
- Twitter: @iarcxxi
- Github: @falhad
- LinkedIn: @farhadarcxx
Show your support
Give a
My Public Address to Receive USDT (TRC20)
is TQ43UdYtFAHQCNVciNCd9ndE4TQaMMzboX
๐
License
Copyright ยฉ 2021 Farhad Navayazdan.
This project is MIT licensed.
This README was generated with