Skip to main content

Installation

Maven

<dependency>
    <groupId>com.plexospay</groupId>
    <artifactId>plexospay-java-sdk</artifactId>
    <version>0.1.0</version>
</dependency>

Gradle

implementation 'com.plexospay:plexospay-java-sdk:0.1.0'
Requires Java 11+.

Usage

import com.plexospay.PlexosPay;
import com.plexospay.model.common.Operator;
import com.plexospay.model.payment.CreatePaymentData;
import com.plexospay.model.payment.Payment;

PlexosPay plexos = new PlexosPay("sk_test_...");

// Create a payment
Payment payment = plexos.payments().create(CreatePaymentData.builder()
    .amount(10000)
    .operator(Operator.CVMOVEL)
    .operatorPhone("+2389001234")
    .build());

System.out.println(payment.getId());
System.out.println(payment.getStatus());

// Create a checkout session
CheckoutSession session = plexos.checkout().create(CreateCheckoutSessionData.builder()
    .amount(30000)
    .returnUrl("https://myshop.com/thanks")
    .build());
System.out.println(session.getUrl());

Configuration

// Default base URL
PlexosPay plexos = new PlexosPay("sk_test_...");

// Custom base URL
PlexosPay plexos = new PlexosPay("sk_test_...", "https://sandbox.plexospay.com");

Webhook Verification

import com.plexospay.WebhookVerifier;

Map<String, Object> event = WebhookVerifier.verify(
    body, signature, timestamp, "whsec_...");
System.out.println(event.get("type"));

Error Handling

import com.plexospay.clients.exceptions.PlexosPayException;

try {
    plexos.payments().get("pi_nonexistent");
} catch (PlexosPayException e) {
    System.out.println(e.status());     // 404
    System.out.println(e.getMessage()); // "PaymentIntent not found"
}

Resources

ResourceMethods
payments()create, get, list, confirm, cancel
customers()create, get, list, update
products()create, get, list, update, delete
checkout()create, get, list, expire
refunds()create, get, list
webhooks()create, get, list, update, delete
balance()get
settlements()get, list, process
transactions()list
analytics()revenue
auditLogs()list

GitHub

View source code and report issues