Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payment Link Request allowed payment method attribute #61

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions force-app/main/default/classes/PaymentLinkRequest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
@NamespaceAccessible
public with sharing class PaymentLinkRequest {

@NamespaceAccessible
public List<String> allowedPaymentMethods { get; set; }

@NamespaceAccessible
public Amount amount { get; set; }

Expand All @@ -28,6 +31,7 @@ public with sharing class PaymentLinkRequest {
@NamespaceAccessible
public static PaymentLinkRequest getExample() {
PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest();
paymentLinkRequest.allowedPaymentMethods = new List<String>{'ideal'};
paymentLinkRequest.amount = Amount.getExample();
paymentLinkRequest.applicationInfo = ApplicationInfo.getExample();
paymentLinkRequest.expiresAt = '2024-12-31T23:59:59+01:00';
Expand All @@ -42,7 +46,8 @@ public with sharing class PaymentLinkRequest {
public Boolean equals(Object obj) {
if (obj instanceof PaymentLinkRequest) {
PaymentLinkRequest paymentLinkRequest = (PaymentLinkRequest) obj;
return this.amount == paymentLinkRequest.amount
return this.allowedPaymentMethods == paymentLinkRequest.allowedPaymentMethods
&& this.amount == paymentLinkRequest.amount
&& this.applicationInfo.equals(paymentLinkRequest.applicationInfo)
&& this.expiresAt.equals(paymentLinkRequest.expiresAt)
&& this.merchantAccount.equals(paymentLinkRequest.merchantAccount)
Expand All @@ -56,7 +61,8 @@ public with sharing class PaymentLinkRequest {
@NamespaceAccessible
public Integer hashCode() {
List<Object> requestFields = new List<Object>{
amount,
allowedPaymentMethods,
amount,
applicationInfo,
expiresAt,
merchantAccount,
Expand All @@ -67,7 +73,7 @@ public with sharing class PaymentLinkRequest {
return computeHashCode(requestFields);
}

private Integer computeHashCode(List<Object> requestFields) {
private static Integer computeHashCode(List<Object> requestFields) {
Integer hash = 43;
for (Object field : requestFields) {
hash = (17 * hash) + (field == null ? 0 : System.hashCode(field));
Expand Down
27 changes: 14 additions & 13 deletions force-app/main/default/classes/PaymentLinkRequestTest.cls
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
@IsTest
private class PaymentLinkRequestTest {
@IsTest
static void getExampleTest() {
@IsTest
private class PaymentLinkRequestTest {
@IsTest
static void getExampleTest() {
PaymentLinkRequest paymentLinkRequest = PaymentLinkRequest.getExample();
Assert.isNotNull(paymentLinkRequest);
Assert.isNotNull(paymentLinkRequest.amount);
Assert.isNotNull(paymentLinkRequest.merchantAccount);
Assert.isNotNull(paymentLinkRequest.reference);
}
Assert.isNotNull(paymentLinkRequest);
Assert.isNotNull(paymentLinkRequest.allowedPaymentMethods);
Assert.isNotNull(paymentLinkRequest.amount);
Assert.isNotNull(paymentLinkRequest.merchantAccount);
Assert.isNotNull(paymentLinkRequest.reference);
}

@IsTest
@IsTest
static void testEqualsTrue() {
// Given
PaymentLinkRequest req1 = PaymentLinkRequest.getExample();
Expand All @@ -33,7 +34,7 @@
Boolean result = req1.equals(req2);

// Then
Assert.isTrue(!result, 'Expected PaymentLinkRequest objects to be different');
Assert.isFalse(result, 'Expected PaymentLinkRequest objects to be different');
}

@IsTest
Expand All @@ -51,7 +52,7 @@
}

@IsTest
static void testHashCodeDifferent() {
static void testHashCodeDifferent() {
// Given
PaymentLinkRequest req1 = PaymentLinkRequest.getExample();
PaymentLinkRequest req2 = PaymentLinkRequest.getExample();
Expand All @@ -64,4 +65,4 @@
// Then
Assert.areNotEqual(hashCode1, hashCode2, 'Expected different objects to have different hash codes');
}
}
}
12 changes: 6 additions & 6 deletions force-app/main/default/classes/PaymentLinkResponse.cls
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ public with sharing class PaymentLinkResponse {
@NamespaceAccessible
public Integer hashCode() {
List<Object> responseFields = new List<Object>{
amount,
applicationInfo,
expiresAt,
merchantAccount,
reference,
returnUrl,
amount,
applicationInfo,
expiresAt,
merchantAccount,
reference,
returnUrl,
themeId,
url,
status,
Expand Down