This is the officially supported Java library for using Adyen's APIs.
The library supports all APIs under the following services:
- Checkout API: Our latest integration for accepting online payments. Current supported version: v67
- Payments API: Our classic integration for online payments. Current supported version: v52
- Recurring API: Endpoints for managing saved payment details. Current supported version: v49
- Payouts API: Endpoints for sending funds to your customers. Current supported version: v51
- Platforms APIs: Set of APIs when using Adyen for Platforms.
- Account API Current supported version: v6
- Fund API Current supported version: v6
- Notification Configuration API Current supported version: v6
- Hosted Onboarding API Current supported version: v6
- Cloud-based Terminal API: Our point-of-sale integration.
- Local-based Terminal API: Our point-of-sale integration.
- BinLookup API: Our integration for retrieving information, such as cost estimates, and 3D Secure supported version based on a given BIN.
- POS Terminal Management API: Endpoints for managing your point-of-sale payment terminals: v1
- Data Protection API: Endpoints to process Subject Erasure Requests as mandated in General Data Protection Regulation (GDPR): v1
- Stored Value API: Endpoints to manage gift cards and other stored-value cards: v46
For more information, refer to our documentation or the API Explorer.
- Adyen test account
- API key. For testing, your API credential needs to have the API PCI Payments role.
- Java 8 or higher
You can use Maven and add this dependency to your project's POM:
<dependency>
<groupId>com.adyen</groupId>
<artifactId>adyen-java-api-library</artifactId>
<version>16.0.0</version>
</dependency>
Alternatively, you can download the release on GitHub.
Set up the client as a singleton resource; you'll use it for the API calls that you make to Adyen:
// Setup Client and Service
Client client = new Client("Your X-API-KEY", Environment.TEST);
Checkout checkout = new Checkout(client);
// Create PaymentsRequest
PaymentsRequest paymentsRequest = new PaymentsRequest();
paymentsRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
String encryptedCardNumber = "test_4111111111111111";
String encryptedExpiryMonth = "test_03";
String encryptedExpiryYear = "test_2030";
String encryptedSecurityCode = "test_737";
paymentsRequest.addEncryptedCardData(encryptedCardNumber,encryptedExpiryMonth, encryptedExpiryYear, encryptedSecurityCode);
Amount amount = new Amount();
amount.setCurrency("EUR");
amount.setValue(1000L);
paymentsRequest.setAmount(amount);
paymentsRequest.setReference("Your order number");
paymentsRequest.setReturnUrl("https://your-company.com/checkout?shopperOrder=12xy..");
// Make a call to the /payments endpoint
PaymentsResponse paymentsResponse = checkout.payments(paymentsRequest);
For requests on live environment, you need to pass the Live URL Prefix to the Client object:
// Setup Client and Service
Client client = new Client("Your X-API-KEY", Environment.LIVE, "Your live URL prefix");
Checkout checkout = new Checkout(client);
...
// Setup Client and Service
Client client = new Client("Your username", "Your password", Environment.LIVE, "Your live URL prefix", "Your application name");
Checkout checkout = new Checkout(client);
...
String json = "The notification message sent to your webhook";
NotificationHandler notificationHandler = new NotificationHandler();
GenericNotification notificationMessage = notificationHandler.handleMarketpayNotificationJson(json);
...
You can configure a proxy connection by injecting your own AdyenHttpClient on your client instance.
Example:
...
AdyenHttpClient adyenHttpClientWithProxy = new AdyenHttpClient();
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("PROXY_HOST", PROXY_PORT));
adyenHttpClientWithProxy.setProxy(proxy);
client.setHttpClient(adyenHttpClientWithProxy);
For a closer look at how our Java library works, you can clone one of our example integrations:
- Java Spark example integration.
- Java Spring Boot example integration.
- Kotlin Spring Boot example integration.
These include commented code, highlighting key features and concepts, and examples of API calls that can be made using the library.
We encourage you to contribute to this repository, so everyone can benefit from new features, bug fixes, and any other improvements.
Have a look at our contributing guidelines to find out how to raise a pull request.
If you have a feature request, or spotted a bug or a technical problem, create an issue here.
For other questions, contact our Support Team.
This repository is available under the MIT license.
- Example integrations:
- Adyen docs
- API Explorer