
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
io.github.eealba.payper:payper-core
Advanced tools
Core functionalities and utilities for the Payper library, providing methods to interact with the PayPal REST API.
Payper is an unofficial Java client for the PayPal REST API. It is designed to be used with Java 17 and is prepared for multithreading and high concurrency. Payper uses immutable objects and provides a fluent API for ease of use.
API Name | Version | Links |
---|---|---|
Catalog Products | v1 | API Reference |
Subscriptions | v1 | API Reference |
Orders | v2 | API Reference |
Payments | v2 | API Reference |
Invoices | v2 | API Reference |
Webhooks Management | v1 | API Reference |
To use Payper in your project, add the appropriate dependency for the paypal service you want to consume
in your pom.xml
, in the table below the corresponding payper module appears for each service:
<dependency>
<groupId>io.github.eealba.payper</groupId>
<artifactId>payper-subscriptions-v1</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>io.github.eealba.payper</groupId>
<artifactId>payper-catalog-products-v1</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>io.github.eealba.payper</groupId>
<artifactId>payper-orders-v2</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>io.github.eealba.payper</groupId>
<artifactId>payper-payments-v2</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>io.github.eealba.payper</groupId>
<artifactId>payper-invoices-v2</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>io.github.eealba.payper</groupId>
<artifactId>payper-webhooks-v1</artifactId>
<version>1.0.0</version>
</dependency>
API Name | Version | Links |
---|---|---|
Add Tracking | v1 | API Reference |
Disputes | v1 | API Reference |
Partner Referrals | v2 | API Reference |
Payment Experience | v1 | API Reference |
Payment Method Tokens | v3 | API Reference |
Payouts | v1 | API Reference |
Transaction Search | v1 | API Reference |
import io.github.eealba.payper.catalog.products.v1.api.CatalogProductsApiClient;
import io.github.eealba.payper.catalog.products.v1.model.ProductCategory;
import io.github.eealba.payper.catalog.products.v1.model.ProductRequestPOST;
public class PayperExample {
public static void main(String[] args) {
var catalogProductsApiClient = CatalogProductsApiClient.create();
var productRequest = ProductRequestPOST.builder()
.name("Product Name")
.description("Product Description")
.type(ProductRequestPOST.Type.PHYSICAL)
.category(ProductCategory.ACCESSORIES)
.imageUrl("https://example.com/image.jpg")
.build();
var product = catalogProductsApiClient.products()
.create()
.withBody(productRequest)
.retrieve()
.toEntity();
System.out.println("Created product ID: " + product.id());
}
}
import io.github.eealba.payper.catalog.products.v1.api.CatalogProductsApiClient;
public class PayperExample {
public static void main(String[] args) {
var catalogProductsApiClient = CatalogProductsApiClient.create();
var product = catalogProductsApiClient.products()
.get()
.withId("1")
.retrieve()
.toEntity();
System.out.println("Retrieved product ID: " + product.id());
}
}
import io.github.eealba.payper.subscriptions.v1.api.SubscriptionsApiClient;
public class PayperExample {
public static void main(String[] args) {
var subscriptionsApiClient = SubscriptionsApiClient.create();
var plan = subscriptionsApiClient.billingPlans()
.get()
.withId("1")
.retrieve()
.toEntity();
System.out.println("Retrieved plan ID: " + plan.id());
}
}
import io.github.eealba.payper.subscriptions.v1.api.SubscriptionsApiClient;
public class PayperExample {
public static void main(String[] args) {
var subscriptionsApiClient = SubscriptionsApiClient.create();
var futurePlan = subscriptionsApiClient.billingPlans()
.get()
.withId("1")
.retrieve()
.toFuture();
futurePlan.thenAccept( response -> {
if (response.statusCode() == 200) {
System.out.println("Plan retrieved successfully");
} else {
System.out.println("Failed to retrieve plan");
}
});
}
}
import io.github.eealba.payper.invoices.v2.api.InvoicesApi;
import io.github.eealba.payper.invoices.v2.api.InvoicingApiClient;
import io.github.eealba.payper.invoices.v2.model.Invoice;
public class PayperExample {
public static void main(String[] args) {
InvoicesApi invoicesApi = InvoicingApiClient.create().invoices();
// Create an invoice
var invoice = invoicesApi.create()
.withBody(Invoice.builder().build())
.retrieve()
.toEntity();
// List invoices
var listInvoices = invoicesApi.list()
.withPage(1)
.withPageSize(10)
.withTotalRequired(true)
.retrieve()
.toEntity();
// Get an invoice
invoice = invoicesApi.get().withId("invoice-id").retrieve().toEntity();
// Update an invoice
var updateInvoice = invoicesApi.update().withId("invoice-id")
.withBody(Invoice.builder().build())
.retrieve()
.toEntity();
// Delete an invoice
invoicesApi.delete().withId("invoice-id").retrieve().toVoid();
}
}
import io.github.eealba.payper.webhooks.v1.model.EventType;
import io.github.eealba.payper.webhooks.v1.model.Patch;
import io.github.eealba.payper.webhooks.v1.model.PatchRequest;
import io.github.eealba.payper.webhooks.v1.model.Webhook;
import java.util.List;
import static io.github.eealba.payper.webhooks.v1.model.Patch.Op.REPLACE;
public class PayperExample {
public static void main(String[] args) {
var webhooksApi = WebhooksApiClient.create().webhooks();
// Create a webhook
EventType eventType = EventType.builder().name("PAYMENT.AUTHORIZATION.CREATED").build();
Webhook webhookRequest = Webhook.builder().url("https://example.com/webhook")
.eventTypes(List.of(eventType)).build();
var webhook = webhooksApi.create().withBody(webhookRequest).retrieve().toEntity();
System.out.println("Created webhook ID: " + webhook.id());
// List webhooks
var webhooksList = webhooksApi.list().retrieve().toEntity();
System.out.println("First webhook ID: " + webhooksList.webhooks().get(0).id());
// Get a webhook
var webhookDetails = webhooksApi.get().withId("WH-1234567890").retrieve().toEntity();
System.out.println("Webhook URL: " + webhookDetails.url());
// Update a webhook
Patch patch = Patch.builder().op(REPLACE).path("/url").value("https://example" + ".com/new-webhook").build();
PatchRequest patchRequest = new PatchRequest(List.of(patch));
var updatedWebhook = webhooksApi.update().withId("WH-1234567890").withBody(patchRequest).retrieve().toEntity();
System.out.println("Updated webhook URL: " + updatedWebhook.url());
// Delete a webhook
webhooksApi.delete().withId("WH-1234567890").retrieve().toVoid();
// List event types for a webhook
var eventTypes = webhooksApi.listEventTypes().withId("WH-1234567890").retrieve().toEntity();
System.out.println("First event type: " + eventTypes.eventTypes().get(0).name());
}
}
PayPal REST APIs use OAuth 2.0 access tokens to authenticate requests. Your access token authorizes you to use the PayPal REST API server.
Payper is able to obtain the OAuth 2.0 access tokens before calling the Paypal Rest API, it is only necessary to pass the corresponding CLIENT_ID and CLIENT_SECRET.
Refer to the PayPal Developer Documentation for more information.
The easy way to pass the CLIENT_ID and CLIENT_SECRET is to set the following environment variables or system properties:
export PAYPAL-CLIENT-ID=YOUR_CLIENT_ID
export PAYPAL-CLIENT-SECRET=YOUR_CLIENT_SECRET
export PAYPAL-BASE-URL=https://api-m.sandbox.paypal.com
export PAYPAL-CLIENT-ID=YOUR_CLIENT_ID
export PAYPAL-CLIENT-SECRET=YOUR_CLIENT_SECRET
export PAYPAL-BASE-URL=https://api-m.paypal.com
Otherwise, you can pass the credentials directly to the Payper client using supplier functions:
public static void main(String[] args) {
PayperConfig config = PayperConfig.builder()
.authenticator(PayperAuthenticator.PayperAuthenticators
.ofSandBox(() -> "CLIENT_ID".toCharArray(),
() -> "CLIENT_SECRET".toCharArray()))
.build();
var subscriptionsApiClient = SubscriptionsApiClient.create(config);
var plan = subscriptionsApiClient.billingPlans()
.get()
.withId("1")
.retrieve()
.toEntity();
System.out.println("Retrieved plan ID: " + plan.id());
}
FAQs
Core functionalities and utilities for the Payper library, providing methods to interact with the PayPal REST API.
We found that io.github.eealba.payper:payper-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.