From 5c41451e64fef3cd2e728ac095f24dc5e09ff48e Mon Sep 17 00:00:00 2001 From: Ayodeji Ogundare <63319309+ayodejidev@users.noreply.github.com> Date: Sun, 22 Dec 2024 20:25:47 +0100 Subject: [PATCH] Deprecate TerminalLocalAPIUnencrypted.java --- README.md | 99 ++++++++++--------- .../service/TerminalLocalAPIUnencrypted.java | 3 + .../java/com/adyen/TerminalLocalAPITest.java | 17 ---- 3 files changed, 58 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 3790feb13..87f0d2b3d 100644 --- a/README.md +++ b/README.md @@ -10,44 +10,44 @@ This is the officially supported Java library for using Adyen's APIs. The Library supports all APIs under the following services: -| API | Description | Service Name | Supported version | -|------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------|-------------------| -| [BIN lookup API](https://docs.adyen.com/api-explorer/BinLookup/54/overview) | The BIN Lookup API provides endpoints for retrieving information based on a given BIN. | BinLookup | **v54** | -| [Capital API](https://docs.adyen.com/api-explorer/capital/3/overview) | Adyen Capital allows you to build an embedded financing offering for your users to serve their operational needs. | Capital | **v3** | -| [Checkout API](https://docs.adyen.com/api-explorer/Checkout/71/overview) | Our latest integration for accepting online payments. | Checkout | **v71** | -| [Configuration API](https://docs.adyen.com/api-explorer/balanceplatform/2/overview) | 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](https://docs.adyen.com/development-resources/data-protection-api) | Adyen Data Protection API provides a way for you to process [Subject Erasure Requests](https://gdpr-info.eu/art-17-gdpr/) 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](https://docs.adyen.com/api-explorer/legalentity/3/overview) | Manage legal entities that contain information required for verification. | legalentitymanagement package subclasses | **v3** | -| [Local/Cloud-based Terminal API](https://docs.adyen.com/point-of-sale/terminal-api-reference) | Our point-of-sale integration. | TerminalLocalAPI or TerminalCloudAPI | - | -| [Management API](https://docs.adyen.com/api-explorer/Management/3/overview) | Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. | management package subclasses | **v3** | -| [Payments API](https://docs.adyen.com/api-explorer/Payment/68/overview) | Our classic integration for online payments. | Payment | **v68** | -| [Payouts API](https://docs.adyen.com/api-explorer/Payout/68/overview) | Endpoints for sending funds to your customers. | Payout | **v68** | -| [POS Terminal Management API](https://docs.adyen.com/api-explorer/postfmapi/1/overview) | Endpoints for managing your point-of-sale payment terminals. | TerminalManagement | **v1** | -| [Recurring API](https://docs.adyen.com/api-explorer/Recurring/68/overview) | Endpoints for managing saved payment details. | Recurring | **v68** | -| [Stored Value API](https://docs.adyen.com/payment-methods/gift-cards/stored-value-api) | Manage both online and point-of-sale gift cards and other stored-value cards. | StoredValue | **v46** | -| [Transfers API](https://docs.adyen.com/api-explorer/transfers/4/overview) | 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 | **v4** | -| [Webhooks](https://docs.adyen.com/api-explorer/Webhooks/1/overview) | 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](https://docs.adyen.com/development-resources/webhooks). | *Models only* | **v1** | -| [Classic Platforms Account API](https://docs.adyen.com/api-explorer/Account/6/overview) | This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead. | ClassicPlatformAccountApi | **v6** | -| [Classic Platforms Fund API](https://docs.adyen.com/api-explorer/Fund/6/overview) | This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead. | ClassicPlatformFundApi | **v6** | -| [Classic Platforms Hosted Onboarding Page API](https://docs.adyen.com/api-explorer/Hop/6/overview) | This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead. | ClassicPlatformHopApi | **v6** | -| [Classic Platforms Notification Configuration API](https://docs.adyen.com/api-explorer/NotificationConfiguration/6/overview) | This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead. | ClassicPlatformConfigurationApi | **v6** | -| [Disputes API](https://docs.adyen.com/api-explorer/Disputes/30/overview) | You can use the [Disputes API](https://docs.adyen.com/risk-management/disputes-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. | DisputesApi | **v30** | -| [POS Mobile API](https://docs.adyen.com/api-explorer/possdk/68/overview) | The POS Mobile API is used in the mutual authentication flow between an Adyen Android or iOS [POS Mobile SDK](https://docs.adyen.com/point-of-sale/ipp-mobile/) 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 reader | POS Mobile | **v68** | -| [Payments App API](https://docs.adyen.com/api-explorer/payments-app/1/overview) | The Payments App API is used to Board and manage the Adyen Payments App on your Android mobile devices. | PaymentsAppApi | **v1** | +| API | Description | Service Name | Supported version | +|------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------|-------------------| +| [BIN lookup API](https://docs.adyen.com/api-explorer/BinLookup/54/overview) | The BIN Lookup API provides endpoints for retrieving information based on a given BIN. | BinLookup | **v54** | +| [Capital API](https://docs.adyen.com/api-explorer/capital/3/overview) | Adyen Capital allows you to build an embedded financing offering for your users to serve their operational needs. | Capital | **v3** | +| [Checkout API](https://docs.adyen.com/api-explorer/Checkout/71/overview) | Our latest integration for accepting online payments. | Checkout | **v71** | +| [Configuration API](https://docs.adyen.com/api-explorer/balanceplatform/2/overview) | 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](https://docs.adyen.com/development-resources/data-protection-api) | Adyen Data Protection API provides a way for you to process [Subject Erasure Requests](https://gdpr-info.eu/art-17-gdpr/) 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](https://docs.adyen.com/api-explorer/legalentity/3/overview) | Manage legal entities that contain information required for verification. | legalentitymanagement package subclasses | **v3** | +| [Local/Cloud-based Terminal API](https://docs.adyen.com/point-of-sale/terminal-api-reference) | Our point-of-sale integration. | TerminalLocalAPI or TerminalCloudAPI | - | +| [Management API](https://docs.adyen.com/api-explorer/Management/3/overview) | Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. | management package subclasses | **v3** | +| [Payments API](https://docs.adyen.com/api-explorer/Payment/68/overview) | Our classic integration for online payments. | Payment | **v68** | +| [Payouts API](https://docs.adyen.com/api-explorer/Payout/68/overview) | Endpoints for sending funds to your customers. | Payout | **v68** | +| [POS Terminal Management API](https://docs.adyen.com/api-explorer/postfmapi/1/overview) | Endpoints for managing your point-of-sale payment terminals. | TerminalManagement | **v1** | +| [Recurring API](https://docs.adyen.com/api-explorer/Recurring/68/overview) | Endpoints for managing saved payment details. | Recurring | **v68** | +| [Stored Value API](https://docs.adyen.com/payment-methods/gift-cards/stored-value-api) | Manage both online and point-of-sale gift cards and other stored-value cards. | StoredValue | **v46** | +| [Transfers API](https://docs.adyen.com/api-explorer/transfers/4/overview) | 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 | **v4** | +| [Webhooks](https://docs.adyen.com/api-explorer/Webhooks/1/overview) | 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](https://docs.adyen.com/development-resources/webhooks). | *Models only* | **v1** | +| [Classic Platforms Account API](https://docs.adyen.com/api-explorer/Account/6/overview) | This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead. | ClassicPlatformAccountApi | **v6** | +| [Classic Platforms Fund API](https://docs.adyen.com/api-explorer/Fund/6/overview) | This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead. | ClassicPlatformFundApi | **v6** | +| [Classic Platforms Hosted Onboarding Page API](https://docs.adyen.com/api-explorer/Hop/6/overview) | This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead. | ClassicPlatformHopApi | **v6** | +| [Classic Platforms Notification Configuration API](https://docs.adyen.com/api-explorer/NotificationConfiguration/6/overview) | This API is used for the classic integration. If you are just starting your implementation, refer to our new integration guide instead. | ClassicPlatformConfigurationApi | **v6** | +| [Disputes API](https://docs.adyen.com/api-explorer/Disputes/30/overview) | You can use the [Disputes API](https://docs.adyen.com/risk-management/disputes-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. | DisputesApi | **v30** | +| [POS Mobile API](https://docs.adyen.com/api-explorer/possdk/68/overview) | The POS Mobile API is used in the mutual authentication flow between an Adyen Android or iOS [POS Mobile SDK](https://docs.adyen.com/point-of-sale/ipp-mobile/) 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 reader | POS Mobile | **v68** | +| [Payments App API](https://docs.adyen.com/api-explorer/payments-app/1/overview) | The Payments App API is used to Board and manage the Adyen Payments App on your Android mobile devices. | PaymentsAppApi | **v1** | ## Supported Webhook versions The library supports all webhooks under the following model directories: -| Webhooks | Description | Model Name | Supported Version | -|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|-------------------| -| [Authentication Webhooks](https://docs.adyen.com/api-explorer/acs-webhook/1/overview) | Adyen sends this webhook when the process of cardholder authentication is finalized, whether it is completed successfully, fails, or expires. | [acswebhooks](src/main/java/com/adyen/model/acswebhooks) | **v1** | -| [Configuration Webhooks](https://docs.adyen.com/api-explorer/balanceplatform-webhooks/2/overview) | You 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. | [configurationwebhooks](src/main/java/com/adyen/model/configurationwebhooks) | **v2** | -| [Transfer Webhooks](https://docs.adyen.com/api-explorer/transfer-webhooks/4/overview) | 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. | [transferwebhooks](src/main/java/com/adyen/model/transferwebhooks) | **v4** | -| [Report Webhooks](https://docs.adyen.com/api-explorer/report-webhooks/1/overview) | You can download reports programmatically by making an HTTP GET request, or manually from your Balance Platform Customer Area | [reportwebhooks](src/main/java/com/adyen/model/reportwebhooks) | **v1** | -| [Notification Webhooks](https://docs.adyen.com/api-explorer/Webhooks/1/overview) | We 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 documentation | [notification](src/main/java/com/adyen/model/notification) | **v1** | -| [Management Webhooks](https://docs.adyen.com/api-explorer/ManagementNotification/3/overview) | Adyen 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 API | [managementwebhooks](src/main/java/com/adyen/model/managementwebhooks) | **v3** | -| [Classic Platform Webhooks](https://docs.adyen.com/api-explorer/Notification/6/overview#retry) | The 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. | [marketpaywebhooks](src/main/java/com/adyen/model/marketpaywebhooks) | **v6** | -| [Transaction Webhooks](https://docs.adyen.com/api-explorer/transaction-webhooks/4/overview) | Adyen 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. | [transactionwebhooks](src/main/java/com/adyen/model/transactionwebhooks) | **v4** | +| Webhooks | Description | Model Name | Supported Version | +|---------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|-------------------| +| [Authentication Webhooks](https://docs.adyen.com/api-explorer/acs-webhook/1/overview) | Adyen sends this webhook when the process of cardholder authentication is finalized, whether it is completed successfully, fails, or expires. | [acswebhooks](src/main/java/com/adyen/model/acswebhooks) | **v1** | +| [Configuration Webhooks](https://docs.adyen.com/api-explorer/balanceplatform-webhooks/2/overview) | You 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. | [configurationwebhooks](src/main/java/com/adyen/model/configurationwebhooks) | **v2** | +| [Transfer Webhooks](https://docs.adyen.com/api-explorer/transfer-webhooks/4/overview) | 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. | [transferwebhooks](src/main/java/com/adyen/model/transferwebhooks) | **v4** | +| [Report Webhooks](https://docs.adyen.com/api-explorer/report-webhooks/1/overview) | You can download reports programmatically by making an HTTP GET request, or manually from your Balance Platform Customer Area | [reportwebhooks](src/main/java/com/adyen/model/reportwebhooks) | **v1** | +| [Notification Webhooks](https://docs.adyen.com/api-explorer/Webhooks/1/overview) | We 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 documentation | [notification](src/main/java/com/adyen/model/notification) | **v1** | +| [Management Webhooks](https://docs.adyen.com/api-explorer/ManagementNotification/3/overview) | Adyen 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 API | [managementwebhooks](src/main/java/com/adyen/model/managementwebhooks) | **v3** | +| [Classic Platform Webhooks](https://docs.adyen.com/api-explorer/Notification/6/overview#retry) | The 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. | [marketpaywebhooks](src/main/java/com/adyen/model/marketpaywebhooks) | **v6** | +| [Transaction Webhooks](https://docs.adyen.com/api-explorer/transaction-webhooks/4/overview) | Adyen 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. | [transactionwebhooks](src/main/java/com/adyen/model/transactionwebhooks) | **v4** | For more information, refer to our [documentation](https://docs.adyen.com/) or the [API Explorer](https://docs.adyen.com/api-explorer/). @@ -488,7 +488,7 @@ When using Attachments, ensure content is provided as a byte array. It's importa 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. ```java // Step 1: Import the required classes -import com.adyen.service.TerminalLocalAPIUnencrypted; +import com.adyen.service.TerminalLocalAPI; import com.adyen.model.nexo.*; import com.adyen.model.terminal.*; import javax.net.ssl.SSLContext; @@ -497,18 +497,29 @@ import javax.net.ssl.SSLContext; Client client = new Client(); 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 only +client.setConfig(config); + +// Step 3: Create an SSL context that accepts all certificates (Use in TEST only). +SSLContext createTrustSSLContext() throws Exception { + TrustManager[] trustAllCerts = new TrustManager[]{ + new X509TrustManager() { + java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } + checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {} + checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {} + } + }; + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, trustAllCerts, new java.security.SecureRandom()); + return sc; +} -// Optionally: verify the certificate, the library will ignore this validation when set to null (!!) -client.getConfig().setSSLContext(sslContext); - -// Step 3 Initialize the client and the API objects; -TerminalLocalAPIUnencrypted terminalLocalAPIUnencrypted = new TerminalLocalAPIUnencrypted(client); - -// Step 4: Create the request object -TerminalAPIRequest terminalAPIPaymentRequest = ///....same as the one used in the other examples; +// Step 4: Construct a TerminalAPIRequest object +Gson gson = new GsonBuilder().create(); +TerminalAPIRequest terminalAPIPaymentRequest = new TerminalAPIRequest(); // Step 5: Make the request -TerminalAPIResponse terminalAPIResponse = terminalLocalAPIUnencrypted.request(terminalAPIPaymentRequest); +TerminalAPIResponse terminalAPIResponse = terminalLocalAPI.request(terminalAPIRequest); ``` diff --git a/src/main/java/com/adyen/service/TerminalLocalAPIUnencrypted.java b/src/main/java/com/adyen/service/TerminalLocalAPIUnencrypted.java index b7e3b911c..769b46462 100644 --- a/src/main/java/com/adyen/service/TerminalLocalAPIUnencrypted.java +++ b/src/main/java/com/adyen/service/TerminalLocalAPIUnencrypted.java @@ -21,6 +21,9 @@ import java.security.cert.X509Certificate; /** + * @deprecated This class is planned for deprecation in future releases. + * Find guide on how to use the local terminal API without encryption in the README. + *
* [UNENCRYPTED] Local Terminal Api. * Use this class (in TEST only) to experiment with the Local Terminal API separately * from the encryption implementation required for live payments. diff --git a/src/test/java/com/adyen/TerminalLocalAPITest.java b/src/test/java/com/adyen/TerminalLocalAPITest.java index 030a43fe2..f706adfc1 100644 --- a/src/test/java/com/adyen/TerminalLocalAPITest.java +++ b/src/test/java/com/adyen/TerminalLocalAPITest.java @@ -38,7 +38,6 @@ import com.adyen.model.terminal.TerminalAPIResponse; import com.adyen.model.terminal.security.SecurityKey; import com.adyen.service.TerminalLocalAPI; -import com.adyen.service.TerminalLocalAPIUnencrypted; import org.junit.Test; import java.math.BigDecimal; @@ -136,20 +135,4 @@ public void syncPaymentRequestSuccess() throws Exception { assertEquals("EUR", paymentResult.getAmountsResp().getCurrency()); assertEquals(BigDecimal.ONE, paymentResult.getAmountsResp().getAuthorizedAmount()); } - - /** - * Test success flow for local request unencrypted - */ - @Test - public void unencryptedPaymentRequestSuccess() throws Exception { - Client client = createMockClientFromFile("mocks/terminal-api/payment-sync-success.json"); - TerminalLocalAPIUnencrypted terminalLocalAPIUnencrypted = new TerminalLocalAPIUnencrypted(client); - TerminalAPIResponse response = terminalLocalAPIUnencrypted.request(createTerminalAPIPaymentRequest()); - assertNotNull(response); - assertNotNull(response.getSaleToPOIResponse()); - - SaleToPOIResponse saleToPoiResponse = response.getSaleToPOIResponse(); - assertNotNull(saleToPoiResponse.getMessageHeader()); - assertNotNull(saleToPoiResponse.getPaymentResponse()); - } }