-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task: changing names to avoid conflict
- Loading branch information
1 parent
6831105
commit 4b7b34b
Showing
15 changed files
with
178 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
global with sharing class AdyenGatewayAdapter implements CommercePayments.PaymentGatewayAdapter, CommercePayments.PaymentGatewayAsyncAdapter { | ||
|
||
global AdyenGatewayAdapter() {} | ||
|
||
global CommercePayments.GatewayResponse processRequest(CommercePayments.PaymentGatewayContext paymentGatewayContext) { | ||
try { | ||
return AdyenPaymentHelper.handleFulfillmentOrderStatusChange(paymentGatewayContext); | ||
} catch (Exception ex) { | ||
return new CommercePayments.GatewayErrorResponse('500', ex.getMessage()); | ||
} | ||
} | ||
|
||
global CommercePayments.GatewayNotificationResponse processNotification(CommercePayments.PaymentGatewayNotificationContext gatewayNotificationContext) { | ||
return AdyenPaymentHelper.handleAsyncNotificationCallback(gatewayNotificationContext); | ||
} | ||
|
||
public class GatewayException extends Exception {} | ||
} |
5 changes: 5 additions & 0 deletions
5
force-app/main/default/classes/AdyenGatewayAdapter.cls-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>60.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
131 changes: 131 additions & 0 deletions
131
force-app/main/default/classes/AdyenGatewayAdapterTest.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
@IsTest | ||
private class AdyenGatewayAdapterTest { | ||
@TestSetup | ||
static void makeData() { | ||
Account acct = TestDataFactory.createAccount(); | ||
insert acct; | ||
TestDataFactory.insertBasicPaymentRecords(acct.Id, null); | ||
} | ||
|
||
@IsTest | ||
static void testCaptureOutboundSuccess() { | ||
Test.setMock(HttpCalloutMock.class, new TestDataFactory.EchoHttpMock()); | ||
|
||
Test.startTest(); | ||
Id authId = [SELECT Id FROM PaymentAuthorization ORDER BY CreatedDate DESC LIMIT 1].Id; | ||
CommercePayments.CaptureRequest captureRequest = new CommercePayments.CaptureRequest(TestDataFactory.TEST_AMOUNT, authId); | ||
CommercePayments.PaymentGatewayContext context = new CommercePayments.PaymentGatewayContext(captureRequest, CommercePayments.RequestType.Capture); | ||
CommercePayments.GatewayResponse captureResponse = TestDataFactory.adyenAdapter.processRequest(context); | ||
Test.stopTest(); | ||
|
||
Assert.isTrue(captureResponse.toString().contains('[capture-received]')); | ||
Assert.isTrue(captureResponse.toString().contains(TestDataFactory.TEST_PSP_REFERENCE)); | ||
} | ||
|
||
@IsTest | ||
static void testCaptureOutboundFailure() { | ||
Test.setMock(HttpCalloutMock.class, new TestDataFactory.FailureResponse()); | ||
|
||
Test.startTest(); | ||
Id authId = [SELECT Id FROM PaymentAuthorization ORDER BY CreatedDate DESC LIMIT 1].Id; | ||
CommercePayments.CaptureRequest captureRequest = new CommercePayments.CaptureRequest(TestDataFactory.TEST_AMOUNT, authId); | ||
CommercePayments.PaymentGatewayContext context = new CommercePayments.PaymentGatewayContext(captureRequest, CommercePayments.RequestType.Capture); | ||
CommercePayments.GatewayResponse gatewayResponse = TestDataFactory.adyenAdapter.processRequest(context); | ||
Test.stopTest(); | ||
|
||
Assert.isInstanceOfType(gatewayResponse, CommercePayments.GatewayErrorResponse.class); | ||
Assert.isTrue(gatewayResponse.toString().containsIgnoreCase('400')); | ||
} | ||
|
||
@IsTest | ||
static void testCaptureOutboundMissingPaymentAuthorization() { | ||
Test.setMock(HttpCalloutMock.class, new TestDataFactory.EchoHttpMock()); | ||
|
||
Test.startTest(); | ||
CommercePayments.CaptureRequest captureRequest = new CommercePayments.CaptureRequest(TestDataFactory.TEST_AMOUNT, null); | ||
CommercePayments.PaymentGatewayContext context = new CommercePayments.PaymentGatewayContext(captureRequest, CommercePayments.RequestType.Capture); | ||
CommercePayments.GatewayResponse gatewayResponse = TestDataFactory.adyenAdapter.processRequest(context); | ||
Test.stopTest(); | ||
|
||
Assert.isInstanceOfType(gatewayResponse, CommercePayments.GatewayErrorResponse.class); | ||
Assert.isTrue(gatewayResponse.toString().containsIgnoreCase(AdyenPaymentUtility.NO_PAYMENT_AUTH_FOUND_BY_ID)); | ||
} | ||
|
||
@IsTest | ||
static void testCaptureOutboundMissingAmount() { | ||
Test.setMock(HttpCalloutMock.class, new TestDataFactory.EchoHttpMock()); | ||
Id authId = [SELECT Id FROM PaymentAuthorization ORDER BY CreatedDate DESC LIMIT 1].Id; | ||
Test.startTest(); | ||
CommercePayments.CaptureRequest captureRequest = new CommercePayments.CaptureRequest(null, authId); | ||
CommercePayments.PaymentGatewayContext context = new CommercePayments.PaymentGatewayContext(captureRequest, CommercePayments.RequestType.Capture); | ||
CommercePayments.GatewayResponse gatewayResponse = TestDataFactory.adyenAdapter.processRequest(context); | ||
Test.stopTest(); | ||
Assert.isInstanceOfType(gatewayResponse, CommercePayments.GatewayErrorResponse.class); | ||
Assert.isTrue(gatewayResponse.toString().containsIgnoreCase('Payment Amount Missing')); | ||
} | ||
|
||
@IsTest | ||
static void testCaptureInboundSuccess() { | ||
AdyenPaymentHelper.TEST_NOTIFICATION_REQUEST_BODY = TestDataFactory.createNotificationRequestBody('CAPTURE', TestDataFactory.TEST_PSP_REFERENCE); | ||
|
||
Test.startTest(); | ||
CommercePayments.GatewayNotificationResponse captureResponse = TestDataFactory.adyenAdapter.processNotification(null); | ||
Test.stopTest(); | ||
|
||
Assert.isFalse(captureResponse.toString().containsIgnoreCase('error')); | ||
} | ||
|
||
@IsTest | ||
static void testRefundOutboundSuccess() { | ||
Test.setMock(HttpCalloutMock.class, new TestDataFactory.EchoHttpMock()); | ||
|
||
Test.startTest(); | ||
Id paymentId = [SELECT Id FROM Payment ORDER BY CreatedDate DESC LIMIT 1].Id; | ||
CommercePayments.ReferencedRefundRequest refundRequest = new CommercePayments.ReferencedRefundRequest(TestDataFactory.TEST_AMOUNT, paymentId); | ||
CommercePayments.PaymentGatewayContext context = new CommercePayments.PaymentGatewayContext(refundRequest, CommercePayments.RequestType.ReferencedRefund); | ||
CommercePayments.GatewayResponse refundResponse = TestDataFactory.adyenAdapter.processRequest(context); | ||
Test.stopTest(); | ||
|
||
Assert.isTrue(refundResponse.toString().contains('received')); | ||
} | ||
|
||
@IsTest | ||
static void testRefundOutboundFailure() { | ||
Test.setMock(HttpCalloutMock.class, new TestDataFactory.FailureResponse()); | ||
|
||
Test.startTest(); | ||
Id paymentId = [SELECT Id FROM Payment ORDER BY CreatedDate DESC LIMIT 1].Id; | ||
CommercePayments.ReferencedRefundRequest refundRequest = new CommercePayments.ReferencedRefundRequest(TestDataFactory.TEST_AMOUNT, paymentId); | ||
CommercePayments.PaymentGatewayContext context = new CommercePayments.PaymentGatewayContext(refundRequest, CommercePayments.RequestType.ReferencedRefund); | ||
CommercePayments.GatewayResponse refundResponse = TestDataFactory.adyenAdapter.processRequest(context); | ||
Test.stopTest(); | ||
|
||
Assert.isInstanceOfType(refundResponse, CommercePayments.GatewayErrorResponse.class); | ||
Assert.isTrue(refundResponse.toString().containsIgnoreCase('400')); | ||
} | ||
|
||
@IsTest | ||
static void testRefundOutboundMissingPayment() { | ||
Test.setMock(HttpCalloutMock.class, new TestDataFactory.EchoHttpMock()); | ||
Test.startTest(); | ||
CommercePayments.ReferencedRefundRequest refundRequest = new CommercePayments.ReferencedRefundRequest(TestDataFactory.TEST_AMOUNT, null); | ||
CommercePayments.PaymentGatewayContext context = new CommercePayments.PaymentGatewayContext(refundRequest, CommercePayments.RequestType.ReferencedRefund); | ||
CommercePayments.GatewayResponse gatewayResponse = TestDataFactory.adyenAdapter.processRequest(context); | ||
Test.stopTest(); | ||
Assert.isInstanceOfType(gatewayResponse, CommercePayments.GatewayErrorResponse.class); | ||
Assert.isTrue(gatewayResponse.toString().containsIgnoreCase(AdyenPaymentUtility.NO_PAYMENT_FOUND_BY_ID)); | ||
} | ||
|
||
@IsTest | ||
static void testRefundOutboundMissingAmount() { | ||
Test.setMock(HttpCalloutMock.class, new TestDataFactory.EchoHttpMock()); | ||
Id paymentId = [SELECT Id FROM Payment ORDER BY CreatedDate DESC LIMIT 1].Id; | ||
Test.startTest(); | ||
CommercePayments.ReferencedRefundRequest refundRequest = new CommercePayments.ReferencedRefundRequest(null, paymentId); | ||
CommercePayments.PaymentGatewayContext context = new CommercePayments.PaymentGatewayContext(refundRequest, CommercePayments.RequestType.ReferencedRefund); | ||
CommercePayments.GatewayResponse gatewayResponse = TestDataFactory.adyenAdapter.processRequest(context); | ||
Test.stopTest(); | ||
Assert.isInstanceOfType(gatewayResponse, CommercePayments.GatewayErrorResponse.class); | ||
Assert.isTrue(gatewayResponse.toString().containsIgnoreCase('Payment Amount Missing')); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
force-app/main/default/classes/AdyenGatewayAdapterTest.cls-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>60.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ers/Adyen.paymentGatewayProvider-meta.xml → ..._Provider.paymentGatewayProvider-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<PaymentGatewayProvider xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apexAdapter>AdyenAsyncAdapter</apexAdapter> | ||
<apexAdapter>AdyenGatewayAdapter</apexAdapter> | ||
<idempotencySupported>Yes</idempotencySupported> | ||
<masterLabel>SalesforceOrderManagement-Adyen</masterLabel> | ||
<masterLabel>Adyen OMS Provider</masterLabel> | ||
</PaymentGatewayProvider> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters