Skip to content

Malipopay/malipopay-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Malipopay Java SDK

Official Java SDK for the Malipopay payment platform (Tanzania).

Requires Java 11+.

Installation

Maven

<dependency>
    <groupId>co.tz.malipopay</groupId>
    <artifactId>malipopay-java</artifactId>
    <version>1.1.0</version>
</dependency>

Gradle

implementation 'co.tz.malipopay:malipopay-java:1.1.0'

Quick Start

import co.tz.malipopay.Malipopay;
import co.tz.malipopay.ApiResponse;

import java.util.Map;

Malipopay client = new Malipopay("your-api-key");

// Collect mobile money
ApiResponse<Object> response = client.payments().collect(Map.of(
    "amount", 5000,
    "phone", "255712345678",
    "provider", "Vodacom",
    "reference", "ORDER-001"
));

System.out.println(response.getData());

Configuration

import co.tz.malipopay.MalipopayConfig;

MalipopayConfig config = new MalipopayConfig.Builder()
    .environment(MalipopayConfig.Environment.UAT)  // or PRODUCTION (default)
    .timeout(60000)          // request timeout in ms (default: 30000)
    .retries(5)              // retry count for 5xx/network errors (default: 3)
    .webhookSecret("whsec_xxx")
    .build();

Malipopay client = new Malipopay("your-api-key", config);

You can also override the base URL directly:

MalipopayConfig config = new MalipopayConfig.Builder()
    .baseUrl("https://custom-api.example.com")
    .build();

Resources

Payments

// Initiate a payment
client.payments().initiate(params);

// Collect mobile money
client.payments().collect(params);

// Disburse funds
client.payments().disburse(params);

// Pay now
client.payments().payNow(params);

// Verify a payment
client.payments().verify("reference");

// Get payment by reference
client.payments().get("reference");

// List payments
client.payments().list();
client.payments().list(queryParams);

// Search payments
client.payments().search(queryParams);

// Approve a payment
client.payments().approve(params);

// Retry a failed payment
client.payments().retry("reference");

// Create a payment link
client.payments().createLink(params);

Customers

client.customers().create(params);
client.customers().list();
client.customers().get("customer-id");
client.customers().search(queryParams);
client.customers().verify(params);

Invoices

client.invoices().create(params);
client.invoices().list();
client.invoices().get("invoice-id");
client.invoices().recordPayment(params);
client.invoices().approveDraft(params);

Products

client.products().create(params);
client.products().list();
client.products().get("product-id");

Transactions

client.transactions().list();
client.transactions().get("transaction-id");
client.transactions().search(queryParams);

Account

client.account().transactions();
client.account().reconciliation();

SMS

client.sms().send(params);
client.sms().sendBulk(params);
client.sms().schedule(params);

References

client.references().banks();
client.references().currencies();
client.references().countries();
client.references().institutions();

Webhooks

Verify and parse incoming webhook events:

import co.tz.malipopay.webhooks.Webhooks;

// Via the client (uses config webhookSecret)
boolean valid = client.webhooks().verify(rawBody, signatureHeader);
Map<String, Object> event = client.webhooks().constructEvent(rawBody, signatureHeader);

// Or standalone
Webhooks webhooks = new Webhooks("whsec_your_secret");
Map<String, Object> event = webhooks.constructEvent(rawBody, signatureHeader);

Error Handling

The SDK throws typed exceptions for different error scenarios:

import co.tz.malipopay.exceptions.*;

try {
    client.payments().collect(params);
} catch (AuthenticationException e) {
    // 401 - Invalid API key
} catch (ValidationException e) {
    // 422 - Invalid parameters
} catch (NotFoundException e) {
    // 404 - Resource not found
} catch (RateLimitException e) {
    // 429 - Too many requests
} catch (ApiException e) {
    // 5xx - Server error
} catch (ConnectionException e) {
    // Network error
} catch (MalipopayException e) {
    // Any other Malipopay error
    System.err.println("Status: " + e.getStatusCode());
    System.err.println("Code: " + e.getCode());
    System.err.println("Details: " + e.getDetails());
}

Environments

Environment Base URL
Production https://core-prod.malipopay.co.tz
UAT https://core-uat.malipopay.co.tz

License

MIT - Lockwood Technology Ltd


See Also

SDK Install
Node.js npm install malipopay
Python pip install malipopay
PHP composer require malipopay/malipopay-php
Java Maven / Gradle
.NET dotnet add package Malipopay
Ruby gem install malipopay

API Reference | OpenAPI Spec | Test Scenarios

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages