Official SDKs
Java SDK
The Java SDK is the most mature client library, built with Spring Boot compatibility in mind.
Installation (Maven):
<dependency>
<groupId>com.danipa</groupId>
<artifactId>danipa-java-sdk</artifactId>
<version>1.0.0</version>
</dependency>
Installation (Gradle):
implementation 'com.danipa:danipa-java-sdk:1.0.0'
Quick Start:
import com.danipa.DanipaClient;
import com.danipa.model.*;
DanipaClient danipa = DanipaClient.builder()
.apiKey("dk_live_YOUR_API_KEY")
.environment(Environment.PRODUCTION)
.build();
Create a Payment Link:
PaymentLink link = danipa.paymentLinks().create(
CreatePaymentLinkRequest.builder()
.title("Widget Purchase")
.amount(new BigDecimal("50.00"))
.currency("GHS")
.amountFixed(true)
.build()
);
System.out.println("Share: " + link.getUrl());
Send an Invoice:
Invoice invoice = danipa.invoices().create(
CreateInvoiceRequest.builder()
.customerName("Jane Customer")
.customerEmail("jane@customer.com")
.lineItems(List.of(LineItem.of("Widget A", 2, new BigDecimal("10.00"))))
.currency("GHS")
.dueDate(LocalDate.of(2026, 4, 1))
.build()
);
danipa.invoices().send(invoice.getId());
Send a Remittance:
RemittanceResponse transfer = danipa.remittance().create(
RemittanceRequest.builder()
.sourceCurrency("CAD")
.sourceAmount(100.00)
.destinationProvider("MTN_MOMO")
.destinationMsisdn("+233241234567")
.destinationCurrency("GHS")
.reference("invoice-001")
.build()
);
System.out.println("Transaction: " + transfer.getId());
Spring Boot Integration:
# application.yml
danipa:
api-key: ${DANIPA_API_KEY}
environment: production
@Configuration
public class DanipaConfig {
@Bean
public DanipaClient danipaClient(
@Value("${danipa.api-key}") String apiKey,
@Value("${danipa.environment}") String env) {
return DanipaClient.builder()
.apiKey(apiKey)
.environment(Environment.valueOf(env.toUpperCase()))
.build();
}
}
Node.js SDK
npm install @danipa/node-sdk
Quick Start:
import { Danipa } from '@danipa/node-sdk';
const danipa = new Danipa({
apiKey: process.env.DANIPA_API_KEY,
environment: 'production',
});
Create a Payment Link:
const link = await danipa.paymentLinks.create({
title: 'Widget Purchase',
amount: 50.00,
currency: 'GHS',
amountFixed: true,
});
console.log(`Share: ${link.url}`);
Send an Invoice:
const invoice = await danipa.invoices.create({
customerName: 'Jane Customer',
customerEmail: 'jane@customer.com',
lineItems: [{ description: 'Widget A', quantity: 2, unitPrice: 10.00 }],
currency: 'GHS',
dueDate: '2026-04-01',
});
await danipa.invoices.send(invoice.id);
Send a Remittance:
const transfer = await danipa.remittance.create({
source: { currency: 'CAD', amount: 100.00 },
destination: {
provider: 'MTN_MOMO',
msisdn: '+233241234567',
currency: 'GHS',
},
reference: 'invoice-001',
});
console.log(`Transaction ${transfer.id}: ${transfer.status}`);
Python SDK
pip install danipa
Quick Start:
from danipa import DanipaClient
danipa = DanipaClient(
api_key="dk_live_YOUR_API_KEY",
environment="production",
)
Create a Payment Link:
link = danipa.payment_links.create(
title="Widget Purchase",
amount=50.00,
currency="GHS",
amount_fixed=True,
)
print(f"Share: {link.url}")
Send an Invoice:
invoice = danipa.invoices.create(
customer_name="Jane Customer",
customer_email="jane@customer.com",
line_items=[
{"description": "Widget A", "quantity": 2, "unit_price": 10.00},
],
currency="GHS",
due_date="2026-04-01",
)
danipa.invoices.send(invoice.id)
PHP SDK
composer require danipa/danipa-php
Quick Start:
use Danipa\DanipaClient;
$danipa = new DanipaClient([
'apiKey' => getenv('DANIPA_API_KEY'),
'environment' => 'production',
]);
Create a Payment Link:
$link = $danipa->paymentLinks->create([
'title' => 'Widget Purchase',
'amount' => 50.00,
'currency' => 'GHS',
'amountFixed' => true,
]);
echo "Share: " . $link->url;
Send an Invoice:
$invoice = $danipa->invoices->create([
'customerName' => 'Jane Customer',
'customerEmail' => 'jane@customer.com',
'lineItems' => [
['description' => 'Widget A', 'quantity' => 2, 'unitPrice' => 10.00],
],
'currency' => 'GHS',
'dueDate' => '2026-04-01',
]);
$danipa->invoices->send($invoice->id);
Webhook Verification
All SDKs include a Webhook.verify() helper that checks HMAC-SHA256 signatures and enforces a 300-second replay window.
Java
import com.danipa.webhook.Webhook;
// In your controller
boolean valid = Webhook.verify(
request.getHeader("X-Danipa-Signature"),
request.getHeader("X-Danipa-Timestamp"),
requestBody,
webhookSecret
);
Node.js
import { Webhook } from '@danipa/node-sdk';
// In your Express handler
const event = Webhook.verify(req.rawBody, {
signature: req.headers['x-danipa-signature'],
timestamp: req.headers['x-danipa-timestamp'],
secret: process.env.WEBHOOK_SECRET,
});
Python
from danipa import Webhook
event = Webhook.verify(
payload=request.body,
signature=request.headers["X-Danipa-Signature"],
timestamp=request.headers["X-Danipa-Timestamp"],
secret=os.environ["WEBHOOK_SECRET"],
)
PHP
use Danipa\Webhook;
$event = Webhook::verify(
file_get_contents('php://input'),
$_SERVER['HTTP_X_DANIPA_SIGNATURE'],
$_SERVER['HTTP_X_DANIPA_TIMESTAMP'],
$webhookSecret
);
See the Webhooks guide for the full verification algorithm and manual implementation examples.
Error Handling
All SDKs throw typed exceptions:
try {
danipa.paymentLinks().create(request);
} catch (DanipaValidationException e) {
// 400: Invalid request parameters
log.error("Validation error: {}", e.getErrors());
} catch (DanipaAuthException e) {
// 401/403: Authentication or authorization error
log.error("Auth error: {}", e.getMessage());
} catch (DanipaRateLimitException e) {
// 429: Rate limit exceeded
log.error("Retry after: {}s", e.getRetryAfterSeconds());
} catch (DanipaApiException e) {
// 5xx: Server error
log.error("API error: {} {}", e.getStatusCode(), e.getMessage());
}
Community Libraries
We welcome community-contributed libraries. If you've built a Danipa client library, contact us to get it listed here.
| Language | Library | Maintainer | Status |
|---|---|---|---|
| Go | Coming soon | — | Planned |
| Ruby | Coming soon | — | Planned |