Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Adyen API Library for Java

License

NotificationsYou must be signed in to change notification settings

Adyen/adyen-java-api-library

Java

Adyen Java API Library

Maven Central

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

Supported API versions

The Library supports all APIs under the following services:

APIDescriptionService NameSupported version
BIN lookup APIThe BIN Lookup API provides endpoints for retrieving information based on a given BIN.BinLookupv54
Checkout APIOur latest integration for accepting online payments.Checkoutv71
Configuration APIThe 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 subclassesv2
DataProtection APIAdyen Data Protection API provides a way for you to processSubject 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)DataProtectionv1
Legal Entity Management APIManage legal entities that contain information required for verification.legalentitymanagement package subclassesv3
Local/Cloud-based Terminal APIOur point-of-sale integration.TerminalLocalAPI or TerminalCloudAPIv1
Management APIConfigure and manage your Adyen company and merchant accounts, stores, and payment terminals.management package subclassesv3
Open Banking APIThe Open Banking API provides secure endpoints to share financial data and services with third parties.openbanking package subclassesv1
Payments APIOur classic integration for online payments.Paymentv68
Payouts APIEndpoints for sending funds to your customers.Payoutv68
POS Terminal Management APIEndpoints for managing your point-of-sale payment terminals.‼️Deprecated: use instead theManagement API for the management of your terminal fleet.TerminalManagementv1
Recurring APIEndpoints for managing saved payment details.Recurringv68
Session Authentication APICreate and manage the JSON Web Tokens (JWT) required for integratingOnboarding andPlatform Experience components.SessionAuthenticationv1
Stored Value APIManage both online and point-of-sale gift cards and other stored-value cards.StoredValuev46
Transfers APIThe 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.Transfersv4
WebhooksAdyen 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 ourdocumentation.Models onlyv1
Classic Platforms Account APIThis API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead.ClassicPlatformAccountApiv6
Classic Platforms Fund APIThis API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead.ClassicPlatformFundApiv6
Classic Platforms Hosted Onboarding Page APIThis API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead.ClassicPlatformHopApiv6
Classic Platforms Notification Configuration APIThis API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead.ClassicPlatformConfigurationApiv6
Disputes APIYou can use theDisputes API to automate the dispute handling process so that you can respond to disputes and chargebacks as soon as they are initiated. The Disputes API lets you retrieve defense reasons, supply and delete defense documents, and accept or defend disputes.DisputesApiv30
POS Mobile APIThe POS Mobile API is used in the mutual authentication flow between an Adyen Android or iOSPOS Mobile SDK and the Adyen payments platform. The POS Mobile SDK for Android or iOS devices enables businesses to accept in-person payments using a commercial off-the-shelf (COTS) device like a phone. For example, Tap to Pay transactions, or transactions on a mobile device in combination with a card readerPOS Mobilev68
Payments App APIThe Payments App API is used to Board and manage the Adyen Payments App on your Android mobile devices.PaymentsAppApiv1

Supported Webhook versions

The library supports all webhooks under the following model directories:

WebhooksDescriptionModel NameSupported Version
Authentication WebhooksAdyen sends this webhook when the process of cardholder authentication is finalized, whether it is completed successfully, fails, or expires.acswebhooksv1
Balance WebhooksAdyen sends webhooks to inform you of balance changes in your balance platform.balancewebhooksv1
Configuration WebhooksYou can use these webhooks to build your implementation. For example, you can use this information to update internal statuses when the status of a capability is changed.configurationwebhooksv2
Transfer WebhooksYou can use these webhooks to build your implementation. For example, you can use this information to update balances in your own dashboards or to keep track of incoming funds.transferwebhooksv4
Report WebhooksYou can download reports programmatically by making an HTTP GET request, or manually from your Balance Platform Customer Areareportwebhooksv1
Negative Balance Warning WebhooksAdyen sends this webhook to inform you about a balance account whose balance has been negative for a given number of days.negativebalancewarningwebhooksv1
Notification WebhooksWe use webhooks to send you updates about payment status updates, newly available reports, and other events that you can subscribe to. For more information, refer to our documentationnotificationv1
Management WebhooksAdyen uses webhooks to inform your system about events that happen with your Adyen company and merchant accounts, stores, payment terminals, and payment methods when using Management APImanagementwebhooksv3
Classic Platform WebhooksThe Notification API sends notifications to the endpoints specified in a given subscription. Subscriptions are managed through the Notification Configuration API. The API specifications listed here detail the format of each notification.marketpaywebhooksv6
Transaction WebhooksAdyen sends webhooks to inform your system about incoming and outgoing transfers in your platform. You can use these webhooks to build your implementation. For example, you can use this information to update balances in your own dashboards or to keep track of incoming funds.transactionwebhooksv4
Tokenization WebhooksAdyen sends webhooks to inform you about the creation and changes to the recurring tokens.tokenizationwebhooksv1

For more information, refer to ourdocumentation ortheAPI 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>40.1.0</version></dependency>

Alternatively, you can download therelease on GitHub.

Using the library

General use with API key

For every API, one or more corresponding service classes can be found in the folder with the same name.Check theSupported API versions.

Note: For requests onlive environment, you must define theLive URL Prefix in the Client object:

// Import the required classesimportcom.adyen.Client;importcom.adyen.enums.Environment;importcom.adyen.service.checkout.PaymentsApi;importcom.adyen.model.checkout.*;// Setup Client using Config objectConfigconfig =newConfig()    .environment(Environment.LIVE)    .liveEndpointUrlPrefix("myCompany")    .apiKey(apiKey);Clientclient =newClient(config);PaymentsApipaymentsApi =newPaymentsApi(client);// Create PaymentRequestCardDetailscardDetails =newCardDetails()      .type(CardDetails.TypeEnum.SCHEME)      .encryptedCardNumber("5136333333333335")      .holderName("John Doe")      .cvc("737")      .encryptedExpiryMonth("08")      .encryptedExpiryYear("2018");PaymentRequestpaymentRequest =newPaymentRequest()      .merchantAccount("YOUR_MERCHANT_ACCOUNT")      .reference("YOUR_REFERENCE")      .amount(newAmount()          .currency("EUR")          .value(1000L))      .returnUrl("https://your-company.example.org/checkout?shopperOrder=12xy..")      .paymentMethod(newCheckoutPaymentMethod(cardDetails));// Make a call to the /payments endpointPaymentResponsepaymentResponse =paymentsApi.payments(paymentRequest);

General use with basic auth

// Import the required classesimportcom.adyen.Client;importcom.adyen.enums.Environment;importcom.adyen.service.checkout.PaymentLinksApi// Setup Client and Service passing prefixClientclient =newClient("Your username","Your password",Environment.LIVE,"mycompany123");// Or setup Client and Service passing prefix and application name//Client client = new Client("Your username", "Your password", Environment.LIVE, "mycompany123", "Your application name");PaymentLinksApipaymentLinksApi =newPaymentLinksApi(client); ...

Making requests with additional headers

You can include additional headers and anidempotency key in your API requests using theRequestOptions object.

importcom.adyen.Client;importcom.adyen.Config;importcom.adyen.enums.Environment;importcom.adyen.model.RequestOptions;importcom.adyen.service.checkout.PaymentsApi;importcom.adyen.model.checkout.PaymentRequest;importcom.adyen.model.checkout.PaymentResponse;importcom.adyen.model.checkout.Amount;importcom.adyen.model.checkout.CardDetails;importcom.adyen.model.checkout.CheckoutPaymentMethod;importjava.util.HashMap;importjava.util.Map;// Setup Client using Config objectConfigconfig =newConfig()    .environment(Environment.TEST)// Or Environment.LIVE    .apiKey("YOUR_API_KEY");Clientclient =newClient(config);// Create RequestOptionsHashMap<String,String>additionalHeaders =newHashMap<>();additionalHeaders.put("X-Custom-Header","custom-value");RequestOptionsrequestOptions =newRequestOptions()    .idempotencyKey("YOUR_IDEMPOTENCY_KEY")// use UUID    .additionalServiceHeaders(additionalHeaders);PaymentsApipaymentsApi =newPaymentsApi(client);// Create PaymentRequest (example from existing README)CardDetailscardDetails =newCardDetails()      .type(CardDetails.TypeEnum.SCHEME)      .encryptedCardNumber("5136333333333335")      .holderName("John Doe")      .cvc("737")      .encryptedExpiryMonth("08")      .encryptedExpiryYear("2018");PaymentRequestpaymentRequest =newPaymentRequest()      .merchantAccount("YOUR_MERCHANT_ACCOUNT")      .reference("YOUR_REFERENCE")      .amount(newAmount()          .currency("EUR")          .value(1000L))      .returnUrl("https://your-company.example.org/checkout?shopperOrder=12xy..")      .paymentMethod(newCheckoutPaymentMethod(cardDetails));// Make a call to the /payments endpoint with RequestOptionsPaymentResponsepaymentResponse =paymentsApi.payments(paymentRequest,requestOptions);// Process paymentResponseSystem.out.println("Payment response: " +paymentResponse.toJson());

Deserializing JSON Strings

In some setups you might need to deserialize JSON strings to request objects. For example, when using the libraries in combination withDropin/Components. Please use the built-in deserialization functions:

// Import the required model classimportcom.adyen.model.checkout.PaymentRequest;// Deserialize using built-in functionPaymentRequestpaymentRequest =PaymentRequest.fromJson("YOUR_JSON_STRING");

Error handling

Use a try-catch block to handle API errors. Catch theApiException to inspect the response and handle specific cases:

try {    service.getPaymentLink("1234");} catch (ApiException e) {    // Obtain response     int statusCode = e.getStatusCode();    String responseBody = e.getResponseBody();    // Check ApiError object    ApiError apiError = e.getError();    String errorCode = apiError.getErrorCode();    List<String> invalidFields = apiError.getInvalidFields();    ....}

Using notification webhooks parser

// Import the required classesimportjava.util.List;importcom.adyen.util.HMACValidator;importcom.adyen.notification.WebhookHandler;importcom.adyen.model.notification.NotificationRequest;importcom.adyen.model.notification.NotificationRequestItem;// YOUR_HMAC_KEY from the Customer AreaStringhmacKey ="YOUR_HMAC_KEY";// The webhook payloadStringnotificationRequestJson ="NOTIFICATION_REQUEST_JSON";HMACValidatorhmacValidator =newHMACValidator();WebhookHandlerwebhookHandler =newWebhookHandler();NotificationRequestnotificationRequest =webhookHandler.handleNotificationJson(notificationRequestJson);// fetch first (and only) NotificationRequestItemvarnotificationRequestItem =notificationRequest.getNotificationItems().stream().findFirst();if (notificationRequestItem.isPresent()) {// validate the HMAC signatureif (hmacValidator.validateHMAC(notificationRequestItem,hmacKey) ) {// Process the notification based on the eventCodelog.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 NotificationRequestthrownewRuntimeException("Invalid HMAC signature");    }}

When deserializing Banking or Management Webhooks, first check if the payload is authentic:

// The webhook payloadStringpayload ="WEBHOOK_JSON_PAYLOAD";// HMAC key from Customer AreaStringhmacKey ="HMAC_KEY_RETRIEVED_FROM_CA";// HMAC signature from hmacsignature headerStringhmacsignature =headers.get("hmacsignature");if (hmacsignature ==null ||hmacsignature.isBlank()) {thrownewRuntimeException("HMAC Signature not found");}// validate the HMAC signatureHMACValidatorhmacValidator =newHMACValidator();if (!hmacValidator.validateHMAC(hmacsignature,hmacKey,payload)) {thrownewRuntimeException("Invalid HMAC signature");}

Use then the relevant webhook handler (i.e. ConfigurationWebhooksHandler) to obtain the object representing the event:

ConfigurationWebhooksHandlerwebhookHandler =newConfigurationWebhooksHandler(payload);// onAccountHolderNotificationRequestwebhookHandler.getAccountHolderNotificationRequest().ifPresent((AccountHolderNotificationRequestevent) -> {System.out.println(event.getData().getBalancePlatform());});// onBalanceAccountNotificationRequestwebhookHandler.getBalanceAccountNotificationRequest().ifPresent((BalanceAccountNotificationRequestevent) -> {System.out.println(event.getData().getBalanceAccount());});

To deserialize Management Webhooks use instead the specific webhook handlerManagementWebhooksHandler:

ManagementWebhooksHandlerwebhookHandler =newManagementWebhooksHandler(payload);// onMerchantCreatedNotificationRequestwebhookHandler.getMerchantCreatedNotificationRequest().isPresent((MerchantCreatedNotificationRequestevent) -> {System.out.println(event.getData().getMerchantId());});

Using Attachments in LEM (Legal Entity Management)

When using Attachments, ensure content is provided as a byte array. It's important to convert it to aBase64-encoded string before initiating the request.

Proxy configuration

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

Example:

...// Import the required classesimportcom.adyen.httpclient.AdyenHttpClient;importjava.net.InetSocketAddress;importjava.net.Proxy;// Set http proxyAdyenHttpClientadyenHttpClientWithProxy =newAdyenHttpClient();Proxyproxy =newProxy(Proxy.Type.HTTP,newInetSocketAddress("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","129.0.0.1");System.setProperty("https.proxyPort","3128");System.setProperty("https.proxyUser","squid");System.setProperty("https.proxyPassword","ward");

Client certificate authentication

// Import the required classesimportcom.adyen.Client;importjavax.net.ssl.KeyManagerFactory;importjavax.net.ssl.SSLContext;importjavax.net.ssl.TrustManagerFactory;importjava.security.KeyStore;// Initialize a KeyManagerFactory with the client KeyStore and passwordKeyManagerFactorykeyManagerFactory =KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());keyManagerFactory.init(clientKeyStore,clientKeyStorePassword);// Create a TrustManagerFactory that trusts the CAs in our Trust KeyStoreTrustManagerFactorytrustManagerFactory =TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());trustManagerFactory.init(trustStore);// Create an SSLContext with the desired protocol that uses our KeyManagers and TrustManagersSSLContextsslContext =SSLContext.getInstance("TLSv1.2");sslContext.init(keyManagerFactory.getKeyManagers(),trustManagerFactory.getTrustManagers(),null);Clientclient =newClient(sslContext,apiKey);// Use the client

Using the Cloud Terminal API

For In-Person Payments integrations with theCloud Terminal API, you must initialise the Clientsetting the closestRegion:

// Step 1: Import the required classesimportcom.adyen.Client;importcom.adyen.enums.Environment;importcom.adyen.service.TerminalCloudAPI;importcom.adyen.model.nexo.*;importcom.adyen.model.terminal.*;// Step 2: Initialize the client objectConfigconfig =newConfig()    .environment(Environment.LIVE)    .terminalApiRegion(Region.EU)    .apiKey(apiKey);Clientclient =newClient(config);// Step 3: Initialize the API objectTerminalCloudAPIterminalCloudApi =newTerminalCloudAPI(client);// Step 4: Create the request objectStringserviceID ="123456789";StringsaleID ="POS-SystemID12345";StringPOIID ="Your Device Name(eg V400m-123456789)";// Use a unique transaction for every other transaction you performStringtransactionID ="TransactionID";TerminalAPIRequestterminalAPIRequest =newTerminalAPIRequest();SaleToPOIRequestsaleToPOIRequest =newSaleToPOIRequest();MessageHeadermessageHeader =newMessageHeader();messageHeader.setMessageClass(MessageClassType.SERVICE);messageHeader.setMessageCategory(MessageCategoryType.PAYMENT);messageHeader.setMessageType(MessageType.REQUEST);messageHeader.setProtocolVersion("3.0");messageHeader.setServiceID(serviceID);messageHeader.setSaleID(saleID);messageHeader.setPOIID(POIID);saleToPOIRequest.setMessageHeader(messageHeader);com.adyen.model.nexo.PaymentRequestpaymentRequest =newcom.adyen.model.nexo.PaymentRequest();SaleDatasaleData =newSaleData();TransactionIdentificationtransactionIdentification =newTransactionIdentification();transactionIdentification.setTransactionID("001");XMLGregorianCalendartimestamp =DatatypeFactory.newInstance().newXMLGregorianCalendar(newGregorianCalendar());transactionIdentification.setTimeStamp(timestamp);saleData.setSaleTransactionID(transactionIdentification);SaleToAcquirerDatasaleToAcquirerData =newSaleToAcquirerData();ApplicationInfoapplicationInfo =newApplicationInfo();CommonFieldmerchantApplication =newCommonField();merchantApplication.setVersion("1");merchantApplication.setName("Test");applicationInfo.setMerchantApplication(merchantApplication);saleToAcquirerData.setApplicationInfo(applicationInfo);saleData.setSaleToAcquirerData(saleToAcquirerData);PaymentTransactionpaymentTransaction =newPaymentTransaction();AmountsReqamountsReq =newAmountsReq();amountsReq.setCurrency("EUR");amountsReq.setRequestedAmount(BigDecimal.valueOf(1000));paymentTransaction.setAmountsReq(amountsReq);paymentRequest.setPaymentTransaction(paymentTransaction);paymentRequest.setSaleData(saleData);saleToPOIRequest.setPaymentRequest(paymentRequest);terminalAPIRequest.setSaleToPOIRequest(saleToPOIRequest);// Step 5: Make the requestTerminalAPIResponseterminalAPIResponse =terminalCloudApi.sync(terminalAPIRequest);

Optional: perform an abort request

To perform anabort request you can use the following example:

TerminalAPIRequestterminalAPIRequest =newTerminalAPIRequest();SaleToPOIRequestsaleToPOIRequest =newSaleToPOIRequest();MessageHeadermessageHeader =newMessageHeader();messageHeader.setMessageClass(MessageClassType.SERVICE);messageHeader.setMessageCategory(MessageCategoryType.ABORT);messageHeader.setMessageType(MessageType.REQUEST);messageHeader.setProtocolVersion("3.0");messageHeader.setServiceID("Different service ID");messageHeader.setSaleID(saleID);messageHeader.setPOIID(POIID);AbortRequestabortRequest =newAbortRequest();abortRequest.setAbortReason("MerchantAbort");MessageReferencemessageReference =newMessageReference();messageReference.setMessageCategory(MessageCategoryType.PAYMENT);messageReference.setSaleID(saleID);messageReference.setPOIID(POIID);// Service ID of the payment you're abortingmessageReference.setServiceID(serviceID);abortRequest.setMessageReference(messageReference);saleToPOIRequest.setAbortRequest(abortRequest);saleToPOIRequest.setMessageHeader(messageHeader);terminalAPIRequest.setSaleToPOIRequest(saleToPOIRequest);TerminalAPIResponseterminalAPIResponse =terminalCloudApi.sync(terminalAPIRequest);

Optional: perform a status request

To perform astatus request you can use the following example:

TerminalAPIRequestterminalAPIRequest =newTerminalAPIRequest();SaleToPOIRequestsaleToPOIRequest =newSaleToPOIRequest();MessageHeadermessageHeader =newMessageHeader();messageHeader.setMessageClass(MessageClassType.SERVICE);messageHeader.setMessageCategory(MessageCategoryType.TRANSACTION_STATUS);messageHeader.setMessageType(MessageType.REQUEST);messageHeader.setProtocolVersion("3.0");messageHeader.setServiceID("Different service ID");messageHeader.setSaleID(saleID);messageHeader.setPOIID(POIID);TransactionStatusRequesttransactionStatusRequest =newTransactionStatusRequest();transactionStatusRequest.setReceiptReprintFlag(true);transactionStatusRequest.getDocumentQualifier().add(DocumentQualifierType.CASHIER_RECEIPT);transactionStatusRequest.getDocumentQualifier().add(DocumentQualifierType.CUSTOMER_RECEIPT);MessageReferencemessageReference =newMessageReference();messageReference.setMessageCategory(MessageCategoryType.PAYMENT);messageReference.setSaleID(saleID);// serviceID of the transaction you want the status update frommessageReference.setServiceID(serviceID);transactionStatusRequest.setMessageReference(messageReference);saleToPOIRequest.setTransactionStatusRequest(transactionStatusRequest);saleToPOIRequest.setMessageHeader(messageHeader);terminalAPIRequest.setSaleToPOIRequest(saleToPOIRequest);TerminalAPIResponseterminalAPIResponse =terminalCloudApi.sync(terminalAPIRequest);

Helper classes

UsePredefinedContentHelper to parse Display notification types which you find inPredefinedContent->ReferenceID

PredefinedContentHelperhelper =newPredefinedContentHelper(predefinedContent.getReferenceID());// Safely extract and use the event type with Optionalhelper.getEvent().ifPresent(event -> {System.out.println("Received event: " +event);if (event ==PredefinedContentHelper.DisplayNotificationEvent.PIN_ENTERED) {// Handle PIN entry eventSystem.out.println("The user has entered their PIN.");    }});

Using the Local Terminal API Integration

The request and response payloads are identical to the Cloud Terminal API, however, additional encryption details are required to perform the requests.

Local terminal API Using Keystore

// Import the required classesimportcom.adyen.Client;importcom.adyen.Config;importcom.adyen.enums.Environment;importcom.adyen.httpclient.TerminalLocalAPIHostnameVerifier;importcom.adyen.service.TerminalLocalAPI;importcom.adyen.model.terminal.security.*;importcom.adyen.model.terminal.*;importjavax.net.ssl.SSLContext;importjavax.net.ssl.TrustManagerFactory;importjava.security.KeyStore;importjava.security.SecureRandom;// Create a KeyStore for the terminal certificateKeyStorekeyStore =KeyStore.getInstance(KeyStore.getDefaultType());keyStore.load(null,null);keyStore.setCertificateEntry("adyenRootCertificate",adyenRootCertificate);// Create a TrustManagerFactory that trusts the CAs in our KeyStoreTrustManagerFactorytrustManagerFactory =TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());trustManagerFactory.init(keyStore);// Create an SSLContext with the desired protocol that uses our TrustManagersSSLContextsslContext =SSLContext.getInstance("SSL");sslContext.init(null,trustManagerFactory.getTrustManagers(),newSecureRandom());// Configure a client for TerminalLocalAPIConfigconfig =newConfig();config.setEnvironment(environment);config.setTerminalApiLocalEndpoint("https://" +terminalIpAddress);config.setSSLContext(sslContext);config.setHostnameVerifier(newTerminalLocalAPIHostnameVerifier(environment));Clientclient =newClient(config);// Create your SecurityKey object used for encrypting the payload (keyIdentifier/passphrase you set up beforehand in CA)SecurityKeysecurityKey =newSecurityKey();securityKey.setKeyVersion(1);securityKey.setAdyenCryptoVersion(1);securityKey.setKeyIdentifier("keyIdentifier");securityKey.setPassphrase("passphrase");// Use TerminalLocalAPITerminalLocalAPIterminalLocalAPI =newTerminalLocalAPI(client,securityKey);TerminalAPIResponseterminalAPIResponse =terminalLocalAPI.request(terminalAPIRequest);

Using Attachments in Document API

When using Attachments, ensure content is provided as a byte array. It's important to convert it to aBase64-encoded string before initiating the request.

Using the Local Terminal API Integration without Encryption (Only on TEST)

If you wish to develop the Local Terminal API integration parallel to your encryption implementation, you can opt for the unencrypted version. Be sure to remove any encryption details from the CA terminal config page. Consider this ONLY for development and testing on localhost.

// Step 1: Import the required classesimportcom.adyen.service.TerminalLocalAPI;importcom.adyen.model.nexo.*;importcom.adyen.model.terminal.*;importjavax.net.ssl.SSLContext;// Step 2: Add your Certificate Path and Local Endpoint to the config path.Clientclient =newClient();client.getConfig().setTerminalApiLocalEndpoint("The IP of your terminal (eg https://192.168.47.169)");client.getConfig().setEnvironment(Environment.TEST);config.setSSLContext(createTrustSSLContext());// Trust all certificates for testing onlyclient.setConfig(config);// Step 3: Create an SSL context that accepts all certificates (Use in TEST only).SSLContextcreateTrustSSLContext()throwsException {TrustManager[]trustAllCerts =newTrustManager[]{newX509TrustManager() {java.security.cert.X509Certificate[]getAcceptedIssuers() {returnnull; }checkClientTrusted(java.security.cert.X509Certificate[]certs,StringauthType) {}checkServerTrusted(java.security.cert.X509Certificate[]certs,StringauthType) {}            }    };SSLContextsc =SSLContext.getInstance("SSL");sc.init(null,trustAllCerts,newjava.security.SecureRandom());returnsc;}// Step 4: Construct a TerminalAPIRequest objectGsongson =newGsonBuilder().create();TerminalAPIRequestterminalAPIPaymentRequest =newTerminalAPIRequest();// Step 5: Make the requestTerminalAPIResponseterminalAPIResponse =terminalLocalAPI.request(terminalAPIRequest);

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 outour 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 ourcontributing 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 theMIT license.

See also

About

Adyen API Library for Java

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors76

Languages


[8]ページ先頭

©2009-2025 Movatter.jp