From 684a6b70d6d6d36bfbefa20cc297e80b5dfca72f Mon Sep 17 00:00:00 2001 From: ShubhamVijaivargiya <37690773+ShubhamVijaivargiya@users.noreply.github.com> Date: Mon, 16 Oct 2023 15:18:11 +0200 Subject: [PATCH] Release Package Version 3Dot0Dot0 (#27) * PW-6485-OMSRefactoring * Leveraging AdyenClient model instead of AdyenService model to make callout * Addressing review comments * ModelUpdatePW7289 * Convert recurringProcessingModel from string to enum * Introducing Webhook Models * Adding relevant comments * Delete idea folder * Changing model from AdditionalData to LineItem array for checkout api * Adding LineItem class * Increasing unit test coverage * Release 3Dot0Dot0 (#25) * feat: updating code owners for this repository --------- Co-authored-by: vandana Co-authored-by: daniloc Co-authored-by: Danilo Cardoso Co-authored-by: Arinc Elhan --- .../main/default/classes/AdyenClient.cls | 2 +- .../main/default/classes/AdyenConstants.cls | 3 + .../default/classes/AdyenNotification.cls | 14 +++ .../classes/AdyenNotification.cls-meta.xml | 5 + .../default/classes/AuthorisationRequest.cls | 17 +++ .../classes/CheckoutCaptureRequest.cls | 41 +++--- .../classes/CheckoutCaptureRequestTest.cls | 3 + .../classes/CheckoutModificationRequest.cls | 5 +- .../default/classes/CheckoutRefundRequest.cls | 118 ++++++++++-------- .../classes/CheckoutRefundRequestTest.cls | 3 + force-app/main/default/classes/LineItem.cls | 104 +++++++++++++++ .../default/classes/LineItem.cls-meta.xml | 5 + .../main/default/classes/LineItemTest.cls | 25 ++++ .../default/classes/LineItemTest.cls-meta.xml | 5 + .../default/classes/NotificationItems.cls | 7 ++ .../classes/NotificationItems.cls-meta.xml | 5 + .../classes/NotificationRequestItem.cls | 37 ++++++ .../NotificationRequestItem.cls-meta.xml | 5 + sfdx-project.json | 3 +- 19 files changed, 336 insertions(+), 71 deletions(-) create mode 100644 force-app/main/default/classes/AdyenNotification.cls create mode 100644 force-app/main/default/classes/AdyenNotification.cls-meta.xml create mode 100644 force-app/main/default/classes/LineItem.cls create mode 100644 force-app/main/default/classes/LineItem.cls-meta.xml create mode 100644 force-app/main/default/classes/LineItemTest.cls create mode 100644 force-app/main/default/classes/LineItemTest.cls-meta.xml create mode 100644 force-app/main/default/classes/NotificationItems.cls create mode 100644 force-app/main/default/classes/NotificationItems.cls-meta.xml create mode 100644 force-app/main/default/classes/NotificationRequestItem.cls create mode 100644 force-app/main/default/classes/NotificationRequestItem.cls-meta.xml diff --git a/force-app/main/default/classes/AdyenClient.cls b/force-app/main/default/classes/AdyenClient.cls index a1d53c3..caec355 100644 --- a/force-app/main/default/classes/AdyenClient.cls +++ b/force-app/main/default/classes/AdyenClient.cls @@ -28,7 +28,7 @@ public with sharing class AdyenClient { } private HttpResponse sendRequest(HttpRequest request){ - Http httpClient = new Http(); + commercepayments.PaymentsHttp httpClient = new commercepayments.PaymentsHttp(); return httpClient.send(request); } diff --git a/force-app/main/default/classes/AdyenConstants.cls b/force-app/main/default/classes/AdyenConstants.cls index 310c47f..56dbad1 100644 --- a/force-app/main/default/classes/AdyenConstants.cls +++ b/force-app/main/default/classes/AdyenConstants.cls @@ -61,4 +61,7 @@ public with sharing class AdyenConstants { @namespaceAccessible public static final Integer HTTP_ERROR_CODE = 400; + + @namespaceAccessible + public final static String HTTP_SERVER_ERROR_CODE = '500'; } \ No newline at end of file diff --git a/force-app/main/default/classes/AdyenNotification.cls b/force-app/main/default/classes/AdyenNotification.cls new file mode 100644 index 0000000..7c27dac --- /dev/null +++ b/force-app/main/default/classes/AdyenNotification.cls @@ -0,0 +1,14 @@ +/* +* Represents an incoming Adyen Webhook Notification +* https://docs.adyen.com/development-resources/webhooks/understand-notifications +*/ +@namespaceAccessible +public with sharing class AdyenNotification { + + @namespaceAccessible + public String live {get;set;} + + @namespaceAccessible + public List notificationItems {get;set;} + +} \ No newline at end of file diff --git a/force-app/main/default/classes/AdyenNotification.cls-meta.xml b/force-app/main/default/classes/AdyenNotification.cls-meta.xml new file mode 100644 index 0000000..dd61d1f --- /dev/null +++ b/force-app/main/default/classes/AdyenNotification.cls-meta.xml @@ -0,0 +1,5 @@ + + + 52.0 + Active + diff --git a/force-app/main/default/classes/AuthorisationRequest.cls b/force-app/main/default/classes/AuthorisationRequest.cls index 8fa9913..84744dd 100644 --- a/force-app/main/default/classes/AuthorisationRequest.cls +++ b/force-app/main/default/classes/AuthorisationRequest.cls @@ -79,6 +79,23 @@ public without sharing class AuthorisationRequest { @namespaceAccessible public String shopperReference { get; set; } + /** + * Specifies the recurringProcessingModel + */ + @namespaceAccessible + public enum RecurringProcessingModelEnum { + Subscription, + CardOnFile, + UnscheduledCardOnFile + } + + /** + * Defines a recurring payment type. + * @return recurringProcessingModel + */ + @namespaceAccessible + public RecurringProcessingModelEnum recurringProcessingModel { get; set; } + @namespaceAccessible public AuthorisationRequest() { } diff --git a/force-app/main/default/classes/CheckoutCaptureRequest.cls b/force-app/main/default/classes/CheckoutCaptureRequest.cls index 4af431e..7d8d431 100644 --- a/force-app/main/default/classes/CheckoutCaptureRequest.cls +++ b/force-app/main/default/classes/CheckoutCaptureRequest.cls @@ -1,60 +1,73 @@ /* * Represents an Adyen Capture Request */ -@namespaceAccessible +@NamespaceAccessible public with sharing class CheckoutCaptureRequest implements CheckoutModificationRequest { /** * Payment capture amount - * @return amount */ - @namespaceAccessible + @NamespaceAccessible public Amount amount { get; set; } - @namespaceAccessible + @NamespaceAccessible public Amount getAmount() { return amount; } - @namespaceAccessible + @NamespaceAccessible public void setAmount(Amount amount) { this.amount = amount; } /** * The reference to uniquely identify a payment. This reference is used in all communication with you about the payment status. We recommend using a unique value per payment; however, it is not a requirement.\nIf you need to provide multiple references for a transaction, separate them with hyphens ("-").\nMaximum length: 80 characters. - * @return reference */ - @namespaceAccessible + @NamespaceAccessible public String reference { get; set; } - @namespaceAccessible + @NamespaceAccessible public String getReference() { return reference; } - @namespaceAccessible + @NamespaceAccessible public void setReference(String reference) { this.reference = reference; } /** * Merchant account name - * @return merchantAccount */ - @namespaceAccessible + @NamespaceAccessible public String merchantAccount { get; set; } - @namespaceAccessible + @NamespaceAccessible public String getMerchantAccount() { return merchantAccount; } - @namespaceAccessible + @NamespaceAccessible public void setMerchantAccount(String merchantAccount) { this.merchantAccount = merchantAccount; } - @namespaceAccessible + /** + * Line Items + */ + @NamespaceAccessible + public List lineItems { get; set; } + + @NamespaceAccessible + public List getLineItems() { + return lineItems; + } + + @NamespaceAccessible + public void setLineItems(List lineItems) { + this.lineItems = lineItems; + } + + @NamespaceAccessible public CheckoutCaptureRequest(){} } diff --git a/force-app/main/default/classes/CheckoutCaptureRequestTest.cls b/force-app/main/default/classes/CheckoutCaptureRequestTest.cls index bdd9e74..0e13b05 100644 --- a/force-app/main/default/classes/CheckoutCaptureRequestTest.cls +++ b/force-app/main/default/classes/CheckoutCaptureRequestTest.cls @@ -20,5 +20,8 @@ public class CheckoutCaptureRequestTest { testCaptureRequest.setMerchantAccount(AdyenConstants.TEST_MERCHANT_ACCOUNT); System.assertEquals(testCaptureRequest.getMerchantAccount(), AdyenConstants.TEST_MERCHANT_ACCOUNT ); + + testCaptureRequest.setLineItems(new List{new LineItem()}); + System.assertEquals(1, testCaptureRequest.getLineItems().size()); } } \ No newline at end of file diff --git a/force-app/main/default/classes/CheckoutModificationRequest.cls b/force-app/main/default/classes/CheckoutModificationRequest.cls index f4c5753..72ae6c0 100644 --- a/force-app/main/default/classes/CheckoutModificationRequest.cls +++ b/force-app/main/default/classes/CheckoutModificationRequest.cls @@ -1,4 +1,4 @@ -@namespaceAccessible +@NamespaceAccessible public interface CheckoutModificationRequest { //interface to declare common methods from CheckoutCaptureRequest and CheckoutRefundRequest Amount getAmount(); @@ -9,4 +9,7 @@ public interface CheckoutModificationRequest { String getMerchantAccount(); void setMerchantAccount(String merchantAccount); + + List getLineItems(); + void setLineItems(List lineItems); } diff --git a/force-app/main/default/classes/CheckoutRefundRequest.cls b/force-app/main/default/classes/CheckoutRefundRequest.cls index 0728b08..3014176 100644 --- a/force-app/main/default/classes/CheckoutRefundRequest.cls +++ b/force-app/main/default/classes/CheckoutRefundRequest.cls @@ -1,61 +1,71 @@ /* * Represents an Adyen Checkout Refund Request */ -@namespaceAccessible +@NamespaceAccessible public with sharing class CheckoutRefundRequest implements CheckoutModificationRequest { - /** - * Payment refund amount - * @return amount - */ - @namespaceAccessible - public Amount amount { get; set; } - - @namespaceAccessible - public Amount getAmount() { - return amount; - } - - @namespaceAccessible - public void setAmount(Amount amount) { - this.amount = amount; - } - - /** - * The reference to uniquely identify a payment. This reference is used in all communication with you about the payment status. We recommend using a unique value per payment; however, it is not a requirement.\nIf you need to provide multiple references for a transaction, separate them with hyphens ("-").\nMaximum length: 80 characters. - * @return reference - */ - @namespaceAccessible - public String reference { get; set; } - - @namespaceAccessible - public String getReference() { - return reference; - } - - @namespaceAccessible - public void setReference(String reference) { - this.reference = reference; - } - - /** - * Merchant account name - * @return merchantAccount - */ - @namespaceAccessible - public String merchantAccount { get; set; } - - @namespaceAccessible - public String getMerchantAccount() { - return merchantAccount; - } - - @namespaceAccessible - public void setMerchantAccount(String merchantAccount) { - this.merchantAccount = merchantAccount; - } - - @namespaceAccessible - public CheckoutRefundRequest(){} + /** + * Payment refund amount + */ + @NamespaceAccessible + public Amount amount { get; set; } + + @NamespaceAccessible + public Amount getAmount() { + return amount; + } + + @NamespaceAccessible + public void setAmount(Amount amount) { + this.amount = amount; + } + + /** + * The reference to uniquely identify a payment. This reference is used in all communication with you about the payment status. We recommend using a unique value per payment; however, it is not a requirement.\nIf you need to provide multiple references for a transaction, separate them with hyphens ("-").\nMaximum length: 80 characters. + */ + @NamespaceAccessible + public String reference { get; set; } + + @NamespaceAccessible + public String getReference() { + return reference; + } + + @NamespaceAccessible + public void setReference(String reference) { + this.reference = reference; + } + + /** + * Merchant account name + */ + @NamespaceAccessible + public String merchantAccount { get; set; } + + @NamespaceAccessible + public String getMerchantAccount() { + return merchantAccount; + } + + @NamespaceAccessible + public void setMerchantAccount(String merchantAccount) { + this.merchantAccount = merchantAccount; + } + + @NamespaceAccessible + public List lineItems { get; set; } + + @NamespaceAccessible + public List getLineItems() { + return lineItems; + } + + @NamespaceAccessible + public void setLineItems(List lineItems) { + this.lineItems = lineItems; + } + + @NamespaceAccessible + public CheckoutRefundRequest(){} } \ No newline at end of file diff --git a/force-app/main/default/classes/CheckoutRefundRequestTest.cls b/force-app/main/default/classes/CheckoutRefundRequestTest.cls index d6b5304..aa6c51a 100644 --- a/force-app/main/default/classes/CheckoutRefundRequestTest.cls +++ b/force-app/main/default/classes/CheckoutRefundRequestTest.cls @@ -20,5 +20,8 @@ public class CheckoutRefundRequestTest { testRefundRequest.setMerchantAccount(AdyenConstants.TEST_MERCHANT_ACCOUNT); System.assertEquals(testRefundRequest.getMerchantAccount(), AdyenConstants.TEST_MERCHANT_ACCOUNT); + + testRefundRequest.setLineItems(new List{new LineItem()}); + System.assertEquals(1, testRefundRequest.getLineItems().size()); } } \ No newline at end of file diff --git a/force-app/main/default/classes/LineItem.cls b/force-app/main/default/classes/LineItem.cls new file mode 100644 index 0000000..5088a3f --- /dev/null +++ b/force-app/main/default/classes/LineItem.cls @@ -0,0 +1,104 @@ +@NamespaceAccessible +public with sharing class LineItem { + /** + * Item amount excluding the tax, in minor units. + */ + @NamespaceAccessible + public Integer amountExcludingTax { get; set; } + + /** + * Item amount including the tax, in minor units. + */ + @NamespaceAccessible + public Integer amountIncludingTax { get; set; } + + /** + * Brand of the item. + */ + @NamespaceAccessible + public String brand { get; set; } + + /** + * Color of the item. + */ + @NamespaceAccessible + public String color { get; set; } + + /** + * Description of the line item. + */ + @NamespaceAccessible + public String description { get; set; } + + /** + * ID of the line item. + */ + @NamespaceAccessible + public String id { get; set; } + + /** + * Link to the picture of the purchased item. + */ + @NamespaceAccessible + public String imageUrl { get; set; } + + /** + * Item category, used by the payment methods PayPal and Ratepay. + */ + @NamespaceAccessible + public String itemCategory { get; set; } + + /** + * Manufacturer of the item. + */ + @NamespaceAccessible + public String manufacturer { get; set; } + + /** + * Link to the purchased item. + */ + @NamespaceAccessible + public String productUrl { get; set; } + + /** + * Number of items. + */ + @NamespaceAccessible + public Integer quantity { get; set; } + + /** + * Email associated with the given product in the basket (usually in electronic gift cards). + */ + @NamespaceAccessible + public String receiverEmail { get; set; } + + /** + * Size of the item. + */ + @NamespaceAccessible + public String size { get; set; } + + /** + * Stock keeping unit. + */ + @NamespaceAccessible + public String sku { get; set; } + + /** + * Tax amount, in minor units. + */ + @NamespaceAccessible + public Integer taxAmount { get; set; } + + /** + * Tax percentage, in minor units. + */ + @NamespaceAccessible + public Integer taxPercentage { get; set; } + + /** + * Universal Product Code. + */ + @NamespaceAccessible + public String upc { get; set; } +} \ No newline at end of file diff --git a/force-app/main/default/classes/LineItem.cls-meta.xml b/force-app/main/default/classes/LineItem.cls-meta.xml new file mode 100644 index 0000000..754ecb1 --- /dev/null +++ b/force-app/main/default/classes/LineItem.cls-meta.xml @@ -0,0 +1,5 @@ + + + 57.0 + Active + diff --git a/force-app/main/default/classes/LineItemTest.cls b/force-app/main/default/classes/LineItemTest.cls new file mode 100644 index 0000000..957b60a --- /dev/null +++ b/force-app/main/default/classes/LineItemTest.cls @@ -0,0 +1,25 @@ +@IsTest +private class LineItemTest { + @IsTest + static void lineItemTest() { + LineItem lineItem = new LineItem(); + lineItem.amountExcludingTax = 100; + lineItem.taxAmount = 5; + lineItem.amountIncludingTax = 105; + lineItem.quantity = 1; + lineItem.size = 'small'; + lineItem.taxPercentage = 5; + lineItem.description = 'grey shirt'; + lineItem.brand = 'Levi'; + lineItem.color = 'grey'; + lineItem.id = '2894019294'; + lineItem.imageUrl = 'https://www.images.com/greyShirt'; + lineItem.itemCategory = 'shirt'; + lineItem.manufacturer = 'Shirts Fabric'; + lineItem.receiverEmail = 'receiver@email.com'; + lineItem.productUrl = 'https://www.myshop.com/greyShirt/small'; + lineItem.sku = 'SFJ23934'; + lineItem.upc = 'SAB2228379'; + Assert.isNotNull(lineItem); + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/LineItemTest.cls-meta.xml b/force-app/main/default/classes/LineItemTest.cls-meta.xml new file mode 100644 index 0000000..754ecb1 --- /dev/null +++ b/force-app/main/default/classes/LineItemTest.cls-meta.xml @@ -0,0 +1,5 @@ + + + 57.0 + Active + diff --git a/force-app/main/default/classes/NotificationItems.cls b/force-app/main/default/classes/NotificationItems.cls new file mode 100644 index 0000000..091ffa5 --- /dev/null +++ b/force-app/main/default/classes/NotificationItems.cls @@ -0,0 +1,7 @@ +@namespaceAccessible +public with sharing class NotificationItems { + + @namespaceAccessible + public NotificationRequestItem NotificationRequestItem {get;set;} + +} \ No newline at end of file diff --git a/force-app/main/default/classes/NotificationItems.cls-meta.xml b/force-app/main/default/classes/NotificationItems.cls-meta.xml new file mode 100644 index 0000000..c30c896 --- /dev/null +++ b/force-app/main/default/classes/NotificationItems.cls-meta.xml @@ -0,0 +1,5 @@ + + + 52.0 + Active + \ No newline at end of file diff --git a/force-app/main/default/classes/NotificationRequestItem.cls b/force-app/main/default/classes/NotificationRequestItem.cls new file mode 100644 index 0000000..0c03832 --- /dev/null +++ b/force-app/main/default/classes/NotificationRequestItem.cls @@ -0,0 +1,37 @@ +/* +* Represents an Adyen Webhook Notification Request Item +*/ +@namespaceAccessible +public with sharing class NotificationRequestItem { + + @namespaceAccessible + public Amount amount {get;set;} + + @namespaceAccessible + public String eventCode {get;set;} + + @namespaceAccessible + public String eventDate {get;set;} + + @namespaceAccessible + public String merchantAccountCode {get;set;} + + @namespaceAccessible + public String paymentMethod {get;set;} + + @namespaceAccessible + public String originalReference {get;set;} + + @namespaceAccessible + public String paymentPspReference {get;set;} + + @namespaceAccessible + public String pspReference {get;set;} + + @namespaceAccessible + public String reason {get;set;} + + @namespaceAccessible + public String success {get;set;} + +} \ No newline at end of file diff --git a/force-app/main/default/classes/NotificationRequestItem.cls-meta.xml b/force-app/main/default/classes/NotificationRequestItem.cls-meta.xml new file mode 100644 index 0000000..c30c896 --- /dev/null +++ b/force-app/main/default/classes/NotificationRequestItem.cls-meta.xml @@ -0,0 +1,5 @@ + + + 52.0 + Active + \ No newline at end of file diff --git a/sfdx-project.json b/sfdx-project.json index dca29ed..c2cfcfd 100644 --- a/sfdx-project.json +++ b/sfdx-project.json @@ -17,6 +17,7 @@ "API Library Apex Adyen": "0Ho4T0000000043SAA", "API Library Apex Adyen@0.1.0-1": "04t4T000001VvbqQAC", "API Library Apex Adyen@1.0.0-0": "04t4T000001VvfJQAS", - "API Library Apex Adyen@2.0.0-0": "04t4T000001HohPQAS" + "API Library Apex Adyen@2.0.0-0": "04t4T000001HohPQAS", + "API Library Apex Adyen@3.0.0-0": "04t4T000001y7BWQAY" } } \ No newline at end of file