Skip to content

Commit

Permalink
Merge pull request #51 from Adyen/release/3.1.1
Browse files Browse the repository at this point in the history
Release/3.1.1
  • Loading branch information
dcardos authored Jun 10, 2024
2 parents c7f9546 + 94f6f47 commit e88caa7
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 103 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Salesforce CI/CD

on:
pull_request:
branches:
- '**'
workflow_dispatch:

jobs:
build-and-deploy:
runs-on: ubuntu-latest

env:
PBO_AUTH_URL: ${{ secrets.PBO_AUTH_URL }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install Salesforce CLI
run: npm install @salesforce/cli --global

- name: Create authentication file from secret
run: echo ${PBO_AUTH_URL} > secret.json

- name: Authenticate to Dev Hub
run: sf org login sfdx-url -f secret.json --set-default-dev-hub

- name: Create Scratch Org
run: sf org create scratch -f config/project-scratch-def.json --set-default --alias ScratchOrg --no-namespace -y 1

- name: Push source to Scratch Org
run: sf project deploy start --target-org ScratchOrg

- name: Run Apex tests
run: sf apex run test --target-org ScratchOrg --code-coverage -w 5

- name: Delete Scratch Org
if: always()
run: sf org delete scratch --target-org ScratchOrg --no-prompt
140 changes: 86 additions & 54 deletions force-app/main/default/classes/ACHDetails.cls
Original file line number Diff line number Diff line change
@@ -1,88 +1,120 @@
/*
* Adyen Checkout API
* Adyen Checkout API provides a simple and flexible way to initiate and authorise online payments.
* You can use the same integration for payments made with cards (including 3D Secure), mobile wallets, and local payment methods (for example, iDEAL and Sofort).
* This API reference provides information on available endpoints and how to interact with them. To learn more about the API, visit [Checkout documentation](https://docs.adyen.com/checkout).\n\n## Authentication\nEach request to the Checkout API must be signed with an API key. For this, obtain an API Key from your Customer Area, as described in [How to get the API key](https://docs.adyen.com/user-management/how-to-get-the-api-key). Then set this key to the `X-API-Key` header value, for example:\n\n```\ncurl\n-H "Content-Type: application/json" \\n-H "X-API-Key: Your_Checkout_API_key" \\n...\n```\nNote that when going live, you need to generate a new API Key to access the [live endpoints](https://docs.adyen.com/development-resources/live-endpoints).\n\n## Versioning\nCheckout API supports versioning of its endpoints through a version suffix in the endpoint URL. This suffix has the following format: "vXX", where XX is the version number.\n\nFor example:\n```\nhttps://checkout-test.adyen.com/v64/payments\n```
*
* Contact: support@adyen.com
@NamespaceAccessible
public with sharing class ACHDetails implements PaymentMethodDetails {
/**
* The bank account number (without separators).
*/
@NamespaceAccessible
public String bankAccountNumber;

* Do not edit the class manually.
*/
/**
* The bank account type (checking, savings...)
*/
@NamespaceAccessible
public String bankAccountType;

@namespaceAccessible
public with sharing class ACHDetails implements PaymentMethodDetails {
/**
* Get encryptedBankAccountNumber
* @return encryptedBankAccountNumber
* The bank routing number of the account. The field value is nil in most cases
*/
@namespaceAccessible
public String encryptedBankAccountNumber { get; set; }
@NamespaceAccessible
public String bankLocationId;

/**
* Get encryptedBankLocationId
* @return encryptedBankLocationId
* The checkout attempt identifier
*/
@namespaceAccessible
public String encryptedBankLocationId { get; set; }
@NamespaceAccessible
public String checkoutAttemptId;

/**
* Get ownerName
* @return ownerName
* Encrypted bank account number. The bank account number (without separators)
*/
@namespaceAccessible
public String ownerName { get; set; }
@NamespaceAccessible
public String encryptedBankAccountNumber;

/**
* **scheme**
* @return type
* Encrypted location id. The bank routing number of the account. The field value is nil in most cases
*/
@namespaceAccessible
public String type { get; set; }
@NamespaceAccessible
public String encryptedBankLocationId;

@namespaceAccessible
public ACHDetails() {
type = 'ach';
}
/**
* The name of the bank account holder
* If you submit a name with non-Latin characters, we automatically replace some of them with corresponding Latin characters to meet the FATF recommendations
*/
@NamespaceAccessible
public String ownerName;

@namespaceAccessible
public String getType() {
return type;
}
/**
* This is the recurringDetailReference returned in the response when you created the token
*/
@NamespaceAccessible
public String storedPaymentMethodId;

@namespaceAccessible
public void setType(String type) {
this.type = type;
/**
* ach
*/
@NamespaceAccessible
public String type;

@NamespaceAccessible
public ACHDetails() {
type = 'ach';
}

@namespaceAccessible
@NamespaceAccessible
public static ACHDetails getExample() {
ACHDetails achDetails = new ACHDetails();
achDetails.encryptedBankAccountNumber = '';
achDetails.encryptedBankLocationId = '';
achDetails.ownerName = '';
achDetails.type = '';
achDetails.bankAccountNumber = '123456789';
achDetails.bankAccountType = 'checking';
achDetails.bankLocationId = null;
achDetails.checkoutAttemptId = 'abc123';
achDetails.encryptedBankAccountNumber = 'adyenjs_0_1_25$GTE/ytzAupIEbFEybScAA/T3W8+Xj3...';
achDetails.encryptedBankLocationId = 'adyenjs_0_1_25$UbyYyi7693Ya9e3cZNYOJj//l7...';
achDetails.ownerName = 'John Smith';
achDetails.storedPaymentMethodId = null;
achDetails.type = 'ach';
return achDetails;
}

@namespaceAccessible
@NamespaceAccessible
public Boolean equals(Object obj) {
if (obj instanceof ACHDetails) {
ACHDetails achDetails = (ACHDetails) obj;
return this.encryptedBankAccountNumber == achDetails.encryptedBankAccountNumber
&& this.encryptedBankLocationId == achDetails.encryptedBankLocationId
&& this.ownerName == achDetails.ownerName
&& this.type == achDetails.type;
ACHDetails otherACHDetails = (ACHDetails) obj;
return this.bankAccountNumber == otherACHDetails.bankAccountNumber
&& this.bankAccountType == otherACHDetails.bankAccountType
&& this.bankLocationId == otherACHDetails.bankLocationId
&& this.checkoutAttemptId == otherACHDetails.checkoutAttemptId
&& this.encryptedBankAccountNumber == otherACHDetails.encryptedBankAccountNumber
&& this.encryptedBankLocationId == otherACHDetails.encryptedBankLocationId
&& this.ownerName == otherACHDetails.ownerName
&& this.storedPaymentMethodId == otherACHDetails.storedPaymentMethodId
&& this.type == otherACHDetails.type
;
}
return false;
}

@namespaceAccessible
@NamespaceAccessible
public Integer hashCode() {
Integer hashCode = 43;
hashCode = (17 * hashCode) + (encryptedBankAccountNumber == null ? 0 : System.hashCode(encryptedBankAccountNumber));
hashCode = (17 * hashCode) + (encryptedBankLocationId == null ? 0 : System.hashCode(encryptedBankLocationId));
hashCode = (17 * hashCode) + (ownerName == null ? 0 : System.hashCode(ownerName));
hashCode = (17 * hashCode) + (type == null ? 0 : System.hashCode(type));
hashCode = (17 * hashCode) + (bankAccountNumber == null ? 0 : bankAccountNumber.hashCode());
hashCode = (17 * hashCode) + (bankAccountType == null ? 0 : bankAccountType.hashCode());
hashCode = (17 * hashCode) + (bankLocationId == null ? 0 : bankLocationId.hashCode());
hashCode = (17 * hashCode) + (checkoutAttemptId == null ? 0 : checkoutAttemptId.hashCode());
hashCode = (17 * hashCode) + (encryptedBankAccountNumber == null ? 0 : encryptedBankAccountNumber.hashCode());
hashCode = (17 * hashCode) + (encryptedBankLocationId == null ? 0 : encryptedBankLocationId.hashCode());
hashCode = (17 * hashCode) + (ownerName == null ? 0 : ownerName.hashCode());
hashCode = (17 * hashCode) + (storedPaymentMethodId == null ? 0 : storedPaymentMethodId.hashCode());
hashCode = (17 * hashCode) + (type == null ? 0 : type.hashCode());
return hashCode;
}

@NamespaceAccessible
public String getType() {
return type;
}

@NamespaceAccessible
public void setType(String type) {
this.type = type;
}
}
2 changes: 1 addition & 1 deletion force-app/main/default/classes/ACHDetails.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>52.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
36 changes: 13 additions & 23 deletions force-app/main/default/classes/ACHDetailsTest.cls
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
@isTest
@IsTest
public class ACHDetailsTest {
/**
* Test method to enhance code coverage for Apex Models; This ain't validating any specific business use cases.
* Enhances code coverage for ACHDetails apex class
*/
@isTest
private static void testAllMethodsFromACHDetails(){
ACHDetails achTestInstance0 = ACHDetails.getExample();
System.assertEquals(achTestInstance0.encryptedBankAccountNumber,'');

ACHDetails achTestInstance1 = new ACHDetails();
achTestInstance1.setType('TestString');
String retStringVal = achTestInstance1.getType();
System.debug('retStringVal : ' + retStringVal);
Boolean retBooleanVal1 = achTestInstance1.equals(achTestInstance1);
Integer retIntValue = achTestInstance1.hashCode();
System.assertEquals(retBooleanVal1,true);

ACHDetails achTestInstance2 = new ACHDetails();
Boolean retBooleanVal2 = achTestInstance2.equals('Test');
System.assertEquals(retBooleanVal2,false);

@IsTest
private static void achDetailsEqualityTest() {
// given
ACHDetails achTest1 = ACHDetails.getExample();
ACHDetails achTest2 = ACHDetails.getExample();
ACHDetails achTest3 = ACHDetails.getExample();
achTest3.setType('another type');
// then
Assert.areEqual(achTest1, achTest2);
Assert.areEqual(achTest1.hashCode(), achTest2.hashCode());
Assert.areNotEqual(achTest1, achTest3);
Assert.areNotEqual(achTest1.hashCode(), achTest3.hashCode());
}

}
2 changes: 1 addition & 1 deletion force-app/main/default/classes/ACHDetailsTest.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>52.0</apiVersion>
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
26 changes: 10 additions & 16 deletions force-app/main/default/classes/Address.cls
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,45 @@
* Do not edit the class manually.
*/

@namespaceAccessible
@NamespaceAccessible
public with sharing class Address {
/**
* The name of the city.
* @return city
*/
@namespaceAccessible
@NamespaceAccessible
public String city { get; set; }

/**
* The two-character country code as defined in ISO-3166-1 alpha-2. For example, **US**.\n> If you don\'t know the country or are not collecting the country from the shopper, provide `country` as `ZZ`.
* @return country
*/
@namespaceAccessible
@NamespaceAccessible
public String country { get; set; }

/**
* The number or name of the house.
* @return houseNumberOrName
*/
@namespaceAccessible
@NamespaceAccessible
public String houseNumberOrName { get; set; }

/**
* A maximum of five digits for an address in the US, or a maximum of ten characters for an address in all other countries.
* @return postalCode
*/
@namespaceAccessible
@NamespaceAccessible
public String postalCode { get; set; }

/**
* State or province codes as defined in ISO 3166-2. For example, **CA** in the US or **ON** in Canada.\n> Required for the US and Canada.
* @return stateOrProvince
*/
@namespaceAccessible
@NamespaceAccessible
public String stateOrProvince { get; set; }

/**
* The name of the street.\n> The house number should not be included in this field; it should be separately provided via `houseNumberOrName`.
* @return street
*/
@namespaceAccessible
@NamespaceAccessible
public String street { get; set; }

@namespaceAccessible
@NamespaceAccessible
public static Address getExample() {
Address address = new Address();
address.city = '';
Expand All @@ -63,7 +57,7 @@ public with sharing class Address {
return address;
}

@namespaceAccessible
@NamespaceAccessible
public Boolean equals(Object obj) {
if (obj instanceof Address) {
Address address = (Address) obj;
Expand All @@ -77,7 +71,7 @@ public with sharing class Address {
return false;
}

@namespaceAccessible
@NamespaceAccessible
public Integer hashCode() {
Integer hashCode = 43;
hashCode = (17 * hashCode) + (city == null ? 0 : System.hashCode(city));
Expand Down
6 changes: 6 additions & 0 deletions force-app/main/default/classes/PaymentsResponse.cls
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ public with sharing class PaymentsResponse {
@namespaceAccessible
public ResultCodeEnum resultCode { get; set; }

@namespaceAccessible
public Map<String, String> paymentMethod { get; set; }

@namespaceAccessible
public PaymentsResponse() {
authentication = new Map<String, String>();
Expand All @@ -151,6 +154,7 @@ public with sharing class PaymentsResponse {
paymentsResponse.refusalReason = '';
paymentsResponse.refusalReasonCode = '';
paymentsResponse.resultCode = ResultCodeEnum.AUTHENTICATIONFINISHED;
paymentsResponse.paymentMethod = new Map<String, String>{'key'=>''};
return paymentsResponse;
}

Expand All @@ -171,6 +175,7 @@ public with sharing class PaymentsResponse {
&& this.redirect == paymentsResponse.redirect
&& this.refusalReason == paymentsResponse.refusalReason
&& this.refusalReasonCode == paymentsResponse.refusalReasonCode
&& this.paymentMethod == paymentsResponse.paymentMethod
&& this.resultCode == paymentsResponse.resultCode;
}
return false;
Expand All @@ -192,6 +197,7 @@ public with sharing class PaymentsResponse {
hashCode = (17 * hashCode) + (redirect == null ? 0 : System.hashCode(redirect));
hashCode = (17 * hashCode) + (refusalReason == null ? 0 : System.hashCode(refusalReason));
hashCode = (17 * hashCode) + (refusalReasonCode == null ? 0 : System.hashCode(refusalReasonCode));
hashCode = (17 * hashCode) + (paymentMethod == null ? 0 : System.hashCode(paymentMethod));
hashCode = (17 * hashCode) + (resultCode == null ? 0 : System.hashCode(resultCode));
return hashCode;
}
Expand Down
Loading

0 comments on commit e88caa7

Please sign in to comment.