Official Kotlin & Java SDK for Nylon Pay (Uganda Mobile Money API)
# Nylon Pay Kotlin & Java SDK
Official Kotlin & Java SDK for the Nylon Pay mobile money payment API (Uganda mobile money: MTN MoMo & Airtel Money).
## Features
- **Collect Payments** — Mobile money collections in UGX (MTN / Airtel)
- **Payouts & Withdrawals** — Mobile money disbursement / transfer to customer numbers
- **Transaction Lookup & Real-time Status** — Query payments by reference ID
- **Phone Verification** — Validate mobile money registered phone numbers
- **Webhook Verification** — HMAC-SHA256 signature check + delivery ID idempotency + timestamp replay protection
- **Deterministic Request Signing** — Canonical JSON ordering + HMAC-SHA256 headers (`x-nylon-key`, `x-nylon-nonce`, `x-nylon-timestamp`, `x-nylon-signature`)
- **Response Integrity** — Validates server `_responseSignature` automatically
- **Smart Retries** — Automatic exponential backoff + jitter for transient network/server glitches
- **Zero External Dependencies** — Uses only Java 11+ standard library (`java.net.http`, `javax.crypto`, `java.time`)
---
## Installation
### Option 1: JitPack (Recommended)
#### Gradle (Kotlin DSL)
```kotlin
repositories {
mavenCentral()
maven { url = uri("
jitpack.io") }
}
dependencies {
implementation("com.github.nile-squad:nylon-pay-sdk:1.0.0")
}
```
#### Gradle (Groovy)
```groovy
repositories {
mavenCentral()
maven { url '
jitpack.io' }
}
dependencies {
implementation 'com.github.nile-squad:nylon-pay-sdk:1.0.0'
}
```
#### Maven (`pom.xml`)
```xml
jitpack.io
jitpack.io
com.github.nile-squad
nylon-pay-sdk
1.0.0
```
---
## Quick Start (Kotlin)
```kotlin
import com.carthigan.nylonpay.NylonPayClient
val client = NylonPayClient(
apiKey = "npk_your_api_key",
apiSecret = "nps_your_api_secret",
)
// 1. Collect Mobile Money Payment (Min: 500 UGX)
val payment = client.collectPayment(
amount = 500,
phoneNumber = "0700000000", // Automatically normalized to 256700000000
customerName = "John Doe",
description = "Subscription …