Git Product home page Git Product logo

adyen-java-api-library's Introduction

Java

Adyen Java API Library

This is the officially supported Java library for using Adyen's APIs.

Supported API versions

The Library supports all APIs under the following services:

API Description Service Name Supported version
BIN lookup API The BIN Lookup API provides endpoints for retrieving information based on a given BIN. BinLookup v54
Capital API Adyen Capital allows you to build an embedded financing offering for your users to serve their operational needs. Capital v3
Checkout API Our latest integration for accepting online payments. Checkout v70
Configuration API The Configuration API enables you to create a platform where you can onboard your users as account holders and create balance accounts, cards, and business accounts. balanceplatform package subclasses v2
DataProtection API Adyen Data Protection API provides a way for you to process Subject Erasure Requests as mandated in GDPR. Use our API to submit a request to delete shopper's data, including payment details and other related information (for example, delivery address or shopper email) DataProtection v1
Legal Entity Management API Manage legal entities that contain information required for verification. legalentitymanagement package subclasses v3
Local/Cloud-based Terminal API Our point-of-sale integration. TerminalLocalAPI or TerminalCloudAPI -
Management API Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. management package subclasses v1
Payments API Our classic integration for online payments. Payment v68
Payouts API Endpoints for sending funds to your customers. Payout v68
Account API This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead. Account v6
Fund API This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead. Fund v6
Hosted onboarding API This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead. Hop v6
Notification Configuration API This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead. Notification v6
Platforms Notifications Webhooks Models only v6
POS Terminal Management API Endpoints for managing your point-of-sale payment terminals. TerminalManagement v1
Recurring API Endpoints for managing saved payment details. Recurring v68
Stored Value API Manage both online and point-of-sale gift cards and other stored-value cards. StoredValue v46
Transfers API The Transfers API provides endpoints that can be used to get information about all your transactions, move funds within your balance platform or send funds from your balance platform to a transfer instrument. Transfers v3
Webhooks Adyen uses webhooks to send notifications about payment status updates, newly available reports, and other events that can be subscribed to. For more information, refer to our documentation. Models only v1

For more information, refer to our documentation or the API Explorer.

Prerequisites

Installation

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>20.0.1</version>
</dependency>

Alternatively, you can download the release on GitHub.

Using the library

General use with API key

Every API the library supports is represented by a service object. The name of the service matching the corresponding API is listed in the Supported API versions section of this document.

// Import the required classes
import com.adyen.Client;
import com.adyen.enums.Environment;
import com.adyen.service.checkout.PaymentsApi;
import com.adyen.model.checkout.*;

// Setup Client and Service
Client client = new Client("Your X-API-KEY", Environment.TEST);
PaymentsApi paymentsApi = new PaymentsApi(client);

// Create PaymentRequest 
PaymentRequest paymentRequest = new PaymentRequest();
paymentRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
CardDetails cardDetails = new CardDetails();
    cardDetails.encryptedCardNumber("test_4111111111111111")
        .encryptedSecurityCode("test_737")
        .encryptedExpiryMonth("test_03")
        .encryptedExpiryYear("test_2030");
paymentRequest.setPaymentMethod(new CheckoutPaymentMethod(cardDetails));
Amount amount = new Amount().currency("EUR").value(1000L);
paymentRequest.setAmount(amount);
paymentRequest.setReference("Your order number");
paymentRequest.setReturnUrl("https://your-company.com/checkout?shopperOrder=12xy..");

// Make a call to the /payments endpoint
PaymentResponse paymentResponse = paymentsApi.payments(paymentRequest);

General use with API key for live environment

For requests on live environment, you need to pass the Live URL Prefix to the Client object:

// Import the required classes
import com.adyen.Client;
import com.adyen.enums.Environment;
import com.adyen.service.checkout.ModificationsApi

// Setup Client and Service
Client client = new Client("Your X-API-KEY", Environment.LIVE, "Your live URL prefix");
ModificationsApi modificationsApi = new ModificationsApi(client);

...

General use with basic auth

// Import the required classes
import com.adyen.Client;
import com.adyen.enums.Environment;
import com.adyen.service.checkout.PaymentLinksApi

// Setup Client and Service
Client client = new Client("Your username", "Your password", Environment.LIVE, "Your live URL prefix", "Your application name");
PaymentLinksApi paymentLinksApi = new PaymentLinksApi(client);
 
...

Using notification webhooks parser

// Import the required classes
import java.util.List;
import com.adyen.util.HMACValidator;
import com.adyen.notification.WebhookHandler;
import com.adyen.model.notification.NotificationRequest;
import com.adyen.model.notification.NotificationRequestItem;

// YOUR_HMAC_KEY from the Customer Area
String hmacKey = "YOUR_HMAC_KEY";
String notificationRequestJson = "NOTIFICATION_REQUEST_JSON";
HMACValidator hmacValidator = new HMACValidator();

WebhookHandler webhookHandler = new WebhookHandler();
NotificationRequest notificationRequest = webhookHandler.handleNotificationJson(notificationRequestJson);

// fetch first (and only) NotificationRequestItem
var notificationRequestItem = notificationRequest.getNotificationItems().stream().findFirst();

if (notificationRequestItem.isPresent()) {
    if ( hmacValidator.validateHMAC(notificationRequestItem, hmacKey) ) {
      // Process the notification based on the eventCode
      log.info("Received webhook with event {} : \n" +
        "Merchant Reference: {}\n" +
        "Alias : {}\n" +
        "PSP reference : {}", 
        notificationRequestItem.getEventCode(), 
        notificationRequestItem.getMerchantReference(),
        notificationRequestItem.getAdditionalData().get("alias"),
        notificationRequestItem.getPspReference());
    } else {
      // Non valid NotificationRequest
	  throw new RuntimeException("Invalid HMAC signature");
    }
}

Proxy configuration

You can configure a proxy connection by injecting your own AdyenHttpClient on your client instance.

Example:

...
// Import the required classes
import com.adyen.httpclient.AdyenHttpClient;
import java.net.InetSocketAddress;
import java.net.Proxy;

// Set http proxy
AdyenHttpClient adyenHttpClientWithProxy = new AdyenHttpClient();

Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("PROXY_HOST", PROXY_PORT));
adyenHttpClientWithProxy.setProxy(proxy);

client.setHttpClient(adyenHttpClientWithProxy);

If your proxy requires authentication, set all the settings as system properties instead (don't mix with previous approach), for example:

System.setProperty("https.proxyHost", "127.0.0.1");
System.setProperty("https.proxyPort", "3128");
System.setProperty("https.proxyUser", "squid");
System.setProperty("https.proxyPassword", "ward");

Example integrations

For a closer look at how our Java library works, you can clone one of our example integrations:

These include commented code, highlighting key features and concepts, and examples of API calls that can be made using the library.

Feedback

We value your input! Help us enhance our API Libraries and improve the integration experience by providing your feedback. Please take a moment to fill out our feedback form to share your thoughts, suggestions or ideas.

Contributing

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.

Support

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.

Licence

This repository is available under the MIT license.

See also

adyen-java-api-library's People

Contributors

abhilash-adyen avatar adyenautomationbot avatar aleffio avatar alexandrosmor avatar amortj avatar andrei-dediu avatar dbaneman avatar dependabot-preview[bot] avatar dependabot[bot] avatar gcatanese avatar jillingk avatar jnorkus avatar lancergr avatar maassenbas avatar martinsrenato avatar michaelngangom avatar michaelpaul avatar morerice avatar renovate-bot avatar renovate[bot] avatar rickwieman avatar rikterbeek avatar rkewlani avatar sanmibuh avatar saquibsayyad avatar scriptease avatar smic1909 avatar vladimirbutch avatar wboereboom avatar zurmalik avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.