diff --git a/src/main/java/Data/ConfigurationForBankAccountValidation.java b/src/main/java/Data/ConfigurationForBankAccountValidation.java new file mode 100644 index 0000000..77c1167 --- /dev/null +++ b/src/main/java/Data/ConfigurationForBankAccountValidation.java @@ -0,0 +1,25 @@ +package Data; + +import java.util.Properties; + +public class ConfigurationForBankAccountValidation { + public static Properties getMerchantDetailsForBankAccountValidation() { + + Properties props = new Properties(); + + // MLE (Message Level Encryption) is only supported with JWT authentication. For the Bank Account Validation API, MLE is mandatory, and the SDK defaults to encrypted requests for such APIs. + props.setProperty("authenticationType", "JWT"); + props.setProperty("merchantID", "testcasmerchpd01001"); + props.setProperty("runEnvironment", "apitest.cybersource.com"); + + // JWT Parameters + props.setProperty("keyAlias", "testcasmerchpd01001"); + props.setProperty("keyPass", "Authnet101!"); + props.setProperty("keyFileName", "testcasmerchpd01001"); + // P12 key path. Enter the folder path where the .p12 file is located. + props.setProperty("keysDirectory", "src/main/resources"); + + return props; + + } +} diff --git a/src/main/java/samples/VisaBankAccountValidation/BankAccountValidationValidated.java b/src/main/java/samples/VisaBankAccountValidation/BankAccountValidationValidated.java new file mode 100644 index 0000000..cdd3ba0 --- /dev/null +++ b/src/main/java/samples/VisaBankAccountValidation/BankAccountValidationValidated.java @@ -0,0 +1,77 @@ +package samples.VisaBankAccountValidation; + +import Api.BankAccountValidationApi; +import Data.ConfigurationForBankAccountValidation; +import Invokers.ApiClient; +import Invokers.ApiException; +import Model.*; +import com.cybersource.authsdk.core.MerchantConfig; + +import java.lang.invoke.MethodHandles; +import java.util.Properties; + +// The Bank Account Validation API requires encrypted requests as a mandatory requirement. The SDK by default sends encrypted requests for APIs where Request MLE (Message Level Encryption) is mandatory. +//MLE is supported only on the JWT authentication type +// For additional configuration options related to MLE, refer to the documentation at https://github.com/CyberSource/cybersource-rest-client-java/blob/master/MLE.md +// For MLE related sample codes look in the folder samples/MLEFeature +public class BankAccountValidationValidated { + private static String responseCode = null; + private static String status = null; + private static Properties merchantProp; + public static boolean userCapture = false; + + public static void WriteLogAudit(int status) { + String filename = MethodHandles.lookup().lookupClass().getSimpleName(); + System.out.println("[Sample Code Testing] [" + filename + "] " + status); + } + + public static void main(String args[]) throws Exception { + run(); + } + + public static InlineResponse20013 run() { + + AccountValidationsRequest accountValidationRequestObj = new AccountValidationsRequest(); + + Bavsv1accountvalidationsClientReferenceInformation clientReferenceInformation = new Bavsv1accountvalidationsClientReferenceInformation(); + clientReferenceInformation.code("TC50171_100"); + accountValidationRequestObj.clientReferenceInformation(clientReferenceInformation); + + Bavsv1accountvalidationsProcessingInformation processingInformation = new Bavsv1accountvalidationsProcessingInformation(); + processingInformation.validationLevel(1); + accountValidationRequestObj.processingInformation(processingInformation); + + Bavsv1accountvalidationsPaymentInformationBankAccount paymentInformationBankAccount = new Bavsv1accountvalidationsPaymentInformationBankAccount(); + paymentInformationBankAccount.number("99970"); + Bavsv1accountvalidationsPaymentInformationBank paymentInformationBank = new Bavsv1accountvalidationsPaymentInformationBank(); + paymentInformationBank.routingNumber("041210163"); + paymentInformationBank.account(paymentInformationBankAccount); + Bavsv1accountvalidationsPaymentInformation paymentInformation = new Bavsv1accountvalidationsPaymentInformation(); + paymentInformation.bank(paymentInformationBank); + accountValidationRequestObj.paymentInformation(paymentInformation); + + InlineResponse20013 result = null; + try { + merchantProp = ConfigurationForBankAccountValidation.getMerchantDetailsForBankAccountValidation(); + ApiClient apiClient = new ApiClient(); + MerchantConfig merchantConfig = new MerchantConfig(merchantProp); + apiClient.merchantConfig = merchantConfig; + BankAccountValidationApi apiInstance = new BankAccountValidationApi(apiClient); + result = apiInstance.bankAccountValidationRequest(accountValidationRequestObj); + + responseCode = apiClient.responseCode; + status = apiClient.status; + System.out.println("ResponseCode :" + responseCode); + System.out.println("ResponseMessage :" + status); + System.out.println(result); + WriteLogAudit(Integer.parseInt(responseCode)); + + } catch (ApiException e) { + e.printStackTrace(); + WriteLogAudit(e.getCode()); + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } +} diff --git a/src/main/resources/testcasmerchpd01001.p12 b/src/main/resources/testcasmerchpd01001.p12 new file mode 100644 index 0000000..c48f328 Binary files /dev/null and b/src/main/resources/testcasmerchpd01001.p12 differ