NextPay Kotlin SDK

Related tags

SDK nextpay-kt
Overview

Welcome to nextpay-kt ๐Ÿ‘‹

Version Documentation License: MIT Twitter: iarcxxi

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 and customJsonFields 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

๐Ÿ‘ค Farhad Navayazdan

Show your support

Give a โญ๏ธ if this project helped you!

My Public Address to Receive USDT (TRC20) is TQ43UdYtFAHQCNVciNCd9ndE4TQaMMzboX

๐Ÿ“ License

Copyright ยฉ 2021 Farhad Navayazdan.

This project is MIT licensed.


This README was generated with โค๏ธ by readme-md-generator

You might also like...
Java/Kotlin WE contract SDK.

we-contract-sdk Java/Kotlin contract SDK used for building Docker smart contracts. All transaction handling is done via methods of a single class mark

Android Word/Letter Tracing SDK is a complet solution to build apps for kids learning in pure kotlin
Android Word/Letter Tracing SDK is a complet solution to build apps for kids learning in pure kotlin

Android Word/Letter Tracing SDK is a complet solution to build apps for kids learning in pure kotlin. It supports all kind of shapes and all language letters e.g. english, arabic, Urdu, hindi etc.

AWS SDK for Android. For more information, see our web site:

AWS SDK for Android For new projects, we recommend interacting with AWS using the Amplify Framework. The AWS SDK for Android is a collection of low-le

Countly Product Analytics Android SDK
Countly Product Analytics Android SDK

Countly Android SDK We're hiring: Countly is looking for Android SDK developers, full stack devs, devops and growth hackers (remote work). Click this

Android Real Time Chat & Messaging SDK
Android Real Time Chat & Messaging SDK

Android Chat SDK Overview Applozic brings real-time engagement with chat, video, and voice to your web, mobile, and conversational apps. We power emer

Evernote SDK for Android

Evernote SDK for Android version 2.0.0-RC4 Evernote API version 1.25 Overview This SDK wraps the Evernote Cloud API and provides OAuth authentication

Air Native Extension (iOS and Android) for the Facebook mobile SDK

Air Native Extension for Facebook (iOS + Android) This is an AIR Native Extension for the Facebook SDK on iOS and Android. It has been developed by Fr

Android Chat SDK built on Firebase
Android Chat SDK built on Firebase

Chat21 is the core of the open source live chat platform Tiledesk.com. Chat21 SDK Documentation Features With Chat21 Android SDK you can: Send a direc

Liquid SDK (Android)

Liquid Android SDK Quick Start to Liquid SDK for Android This document is just a quick start introduction to Liquid SDK for Android. We recommend you

Owner
Farhad
Farhad
HubSpot Kotlin SDK ๐Ÿงบ Implementation of HubSpot API for Java/Kotlin in tiny SDK

HubSpot Kotlin SDK ?? Implementation of HubSpot API for Java/Kotlin in tiny SDK

BOOM 3 Oct 27, 2022
Sdk-android - SnapOdds Android SDK

Documentation For the full API documentation go to https://snapodds.github.io/sd

Snapodds 0 Jan 30, 2022
Frogo SDK - SDK Core for Easy Development

SDK for anything your problem to make easier developing android apps

Frogobox 10 Dec 15, 2022
Its measurement app made using kotlin with sceneform sdk by google

ARCORE MEASUREMENT This app is build using sceneform sdk for android using kotlin language It helps you measure the distance between multiple points i

Kashif Mehmood 39 Dec 9, 2022
Storyblok Kotlin Multiplatform SDK sample (Android, JVM, JS)

storyblok-mp-SDK-sample *WIP* ... a showcase of the Storyblok Kotlin Multiplatform Client SDK. (Android, JVM, JS, iOS, ...) What's included ?? โ€ข About

Mike Penz 6 Jan 8, 2022
Kotlin Multi Platform SDK

Xeon SDK (work-in-progress ?? ??๏ธ ??โ€โ™€๏ธ โ› ) Development Version Release This Is Latest Release ~ In Development $version_release = ~ What's New?? * I

Frogobox 3 Oct 15, 2021
WalletConnect Kotlin SDK v2

WalletConnect V2 - Kotlin Kotlin implementation of WalletConnect v2 protocol for Android applications. Requirements Android min SDK 21 Java 11 Install

WalletConnect Labs 11 Dec 22, 2021
Official Appwrite Kotlin SDK ๐Ÿ’™๐Ÿงก

Appwrite Kotlin SDK This SDK is compatible with Appwrite server version 0.11.x. For older versions, please check previous releases. This is the Kotlin

Appwrite 47 Nov 26, 2022
Streem Server SDK for Java & Kotlin

Streem Server SDK for Java & Kotlin Server-side JVM library for interacting with the Streem API, and generation of Streem Tokens for use in client SDK

Streem, Inc. 1 Dec 15, 2022
Implement a Casper Kotlin SDK to interact with the Casper network.

CSPR-Kotlin-SDK Kotlin SDK library for interacting with a CSPR node. What is CSPR-Kotlin-SDK? SDK to streamline the 3rd party Kotlin client integratio

null 2 Mar 28, 2022