Skip to content

Commit 2e43fc1

Browse files
authored
Merge pull request #116 from CyberSource/feature/bav-sample-code
Feature/bav sample code
2 parents a3c23c3 + 2f08986 commit 2e43fc1

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package Data;
2+
3+
import java.util.Properties;
4+
5+
public class ConfigurationForBankAccountValidation {
6+
public static Properties getMerchantDetailsForBankAccountValidation() {
7+
8+
Properties props = new Properties();
9+
10+
// 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.
11+
props.setProperty("authenticationType", "JWT");
12+
props.setProperty("merchantID", "testcasmerchpd01001");
13+
props.setProperty("runEnvironment", "apitest.cybersource.com");
14+
15+
// JWT Parameters
16+
props.setProperty("keyAlias", "testcasmerchpd01001");
17+
props.setProperty("keyPass", "Authnet101!");
18+
props.setProperty("keyFileName", "testcasmerchpd01001");
19+
// P12 key path. Enter the folder path where the .p12 file is located.
20+
props.setProperty("keysDirectory", "src/main/resources");
21+
22+
return props;
23+
24+
}
25+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package samples.VisaBankAccountValidation;
2+
3+
import Api.BankAccountValidationApi;
4+
import Data.ConfigurationForBankAccountValidation;
5+
import Invokers.ApiClient;
6+
import Invokers.ApiException;
7+
import Model.*;
8+
import com.cybersource.authsdk.core.MerchantConfig;
9+
10+
import java.lang.invoke.MethodHandles;
11+
import java.util.Properties;
12+
13+
// 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.
14+
//MLE is supported only on the JWT authentication type
15+
// For additional configuration options related to MLE, refer to the documentation at https://github.com/CyberSource/cybersource-rest-client-java/blob/master/MLE.md
16+
// For MLE related sample codes look in the folder samples/MLEFeature
17+
public class BankAccountValidationValidated {
18+
private static String responseCode = null;
19+
private static String status = null;
20+
private static Properties merchantProp;
21+
public static boolean userCapture = false;
22+
23+
public static void WriteLogAudit(int status) {
24+
String filename = MethodHandles.lookup().lookupClass().getSimpleName();
25+
System.out.println("[Sample Code Testing] [" + filename + "] " + status);
26+
}
27+
28+
public static void main(String args[]) throws Exception {
29+
run();
30+
}
31+
32+
public static InlineResponse20013 run() {
33+
34+
AccountValidationsRequest accountValidationRequestObj = new AccountValidationsRequest();
35+
36+
Bavsv1accountvalidationsClientReferenceInformation clientReferenceInformation = new Bavsv1accountvalidationsClientReferenceInformation();
37+
clientReferenceInformation.code("TC50171_100");
38+
accountValidationRequestObj.clientReferenceInformation(clientReferenceInformation);
39+
40+
Bavsv1accountvalidationsProcessingInformation processingInformation = new Bavsv1accountvalidationsProcessingInformation();
41+
processingInformation.validationLevel(1);
42+
accountValidationRequestObj.processingInformation(processingInformation);
43+
44+
Bavsv1accountvalidationsPaymentInformationBankAccount paymentInformationBankAccount = new Bavsv1accountvalidationsPaymentInformationBankAccount();
45+
paymentInformationBankAccount.number("99970");
46+
Bavsv1accountvalidationsPaymentInformationBank paymentInformationBank = new Bavsv1accountvalidationsPaymentInformationBank();
47+
paymentInformationBank.routingNumber("041210163");
48+
paymentInformationBank.account(paymentInformationBankAccount);
49+
Bavsv1accountvalidationsPaymentInformation paymentInformation = new Bavsv1accountvalidationsPaymentInformation();
50+
paymentInformation.bank(paymentInformationBank);
51+
accountValidationRequestObj.paymentInformation(paymentInformation);
52+
53+
InlineResponse20013 result = null;
54+
try {
55+
merchantProp = ConfigurationForBankAccountValidation.getMerchantDetailsForBankAccountValidation();
56+
ApiClient apiClient = new ApiClient();
57+
MerchantConfig merchantConfig = new MerchantConfig(merchantProp);
58+
apiClient.merchantConfig = merchantConfig;
59+
BankAccountValidationApi apiInstance = new BankAccountValidationApi(apiClient);
60+
result = apiInstance.bankAccountValidationRequest(accountValidationRequestObj);
61+
62+
responseCode = apiClient.responseCode;
63+
status = apiClient.status;
64+
System.out.println("ResponseCode :" + responseCode);
65+
System.out.println("ResponseMessage :" + status);
66+
System.out.println(result);
67+
WriteLogAudit(Integer.parseInt(responseCode));
68+
69+
} catch (ApiException e) {
70+
e.printStackTrace();
71+
WriteLogAudit(e.getCode());
72+
} catch (Exception e) {
73+
e.printStackTrace();
74+
}
75+
return result;
76+
}
77+
}
4.88 KB
Binary file not shown.

0 commit comments

Comments
 (0)