-
Notifications
You must be signed in to change notification settings - Fork 79
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
Merchant boarding Sample codes #97
base: master
Are you sure you want to change the base?
Changes from 1 commit
a362740
72d4271
d9a2790
99eecc8
cc1c95d
64a6bb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package Data; | ||
|
||
import java.util.Properties; | ||
|
||
public class MerchantBoardingConfiguration { | ||
|
||
public static Properties getMerchantBoardingDetails() { | ||
Properties props = new Properties(); | ||
|
||
// HTTP_Signature = http_signature and JWT = jwt | ||
props.setProperty("authenticationType", "jwt"); | ||
props.setProperty("merchantID", "apitester00"); | ||
props.setProperty("runEnvironment", "apitest.cybersource.com"); | ||
props.setProperty("requestJsonPath", "src/main/resources/request.json"); | ||
|
||
// MetaKey Parameters | ||
props.setProperty("portfolioID", ""); | ||
props.setProperty("useMetaKey", "false"); | ||
|
||
// JWT Parameters | ||
props.setProperty("keyAlias", "apitester00");//merchid | ||
props.setProperty("keyPass", "Ap!C38tp12@");//pwd | ||
props.setProperty("keyFileName", "apitester00");//filename | ||
|
||
// P12 key path. Enter the folder path where the .p12 file is located. | ||
|
||
props.setProperty("keysDirectory", "src/main/resources"); | ||
// HTTP Parameters | ||
props.setProperty("merchantKeyId", "");//blank | ||
props.setProperty("merchantsecretKey", "");//blank | ||
// Logging to be enabled or not. | ||
props.setProperty("enableLog", "true"); | ||
// Log directory Path | ||
props.setProperty("logDirectory", "log"); | ||
props.setProperty("logFilename", "cybs"); | ||
|
||
// Log file size in KB | ||
props.setProperty("logMaximumSize", "5M"); | ||
|
||
// OAuth related properties. | ||
props.setProperty("enableClientCert", "true"); | ||
props.setProperty("clientCertDirectory", "src/main/resources"); | ||
props.setProperty("clientCertFile", "apitester00"); | ||
props.setProperty("clientCertPassword", "Ap!C38tp12@"); | ||
props.setProperty("clientId", "apitester00"); | ||
props.setProperty("clientSecret", "Ap!C38tp12@"); | ||
|
||
/* | ||
PEM Key file path for decoding JWE Response Enter the folder path where the .pem file is located. | ||
It is optional property, require adding only during JWE decryption. | ||
*/ | ||
// props.setProperty("jwePEMFileDirectory", "src/main/resources/NetworkTokenCert.pem"); | ||
|
||
return props; | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,230 @@ | ||
package samples.MerchantBoarding; | ||
|
||
import Api.CustomerApi; | ||
import Api.MerchantBoardingApi; | ||
import Data.MerchantBoardingConfiguration; | ||
import Invokers.ApiClient; | ||
import Invokers.ApiException; | ||
import Model.*; | ||
import com.cybersource.authsdk.core.MerchantConfig; | ||
|
||
import java.lang.invoke.MethodHandles; | ||
import java.util.*; | ||
|
||
public class CreateRegistration { | ||
|
||
private static String responseCode = null; | ||
private static String status = null; | ||
private static Properties merchantProp; | ||
|
||
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 { | ||
// Accept required parameters from args[] and pass to run. | ||
run(); | ||
|
||
} | ||
|
||
|
||
public static InlineResponse2012 run() { | ||
System.out.println("Inside Merchant boarding..........."); | ||
PostRegistrationBody reqObj=new PostRegistrationBody(); | ||
|
||
Boardingv1registrationsOrganizationInformation organizationInformation=new Boardingv1registrationsOrganizationInformation(); | ||
organizationInformation.parentOrganizationId("apitester00"); | ||
organizationInformation.type(Boardingv1registrationsOrganizationInformation.TypeEnum.MERCHANT); | ||
organizationInformation.configurable(true); | ||
|
||
Boardingv1registrationsOrganizationInformationBusinessInformation businessInformation=new Boardingv1registrationsOrganizationInformationBusinessInformation(); | ||
businessInformation.name("StuartWickedFastEatz"); | ||
Boardingv1registrationsOrganizationInformationBusinessInformationAddress address=new Boardingv1registrationsOrganizationInformationBusinessInformationAddress(); | ||
address.country("US"); | ||
address.address1("123456 SandMarket"); | ||
address.locality("ORMOND BEACH"); | ||
address.administrativeArea("FL"); | ||
address.postalCode("32176"); | ||
businessInformation.address(address); | ||
businessInformation.websiteUrl("https://www.StuartWickedEats.com"); | ||
businessInformation.phoneNumber("6574567813"); | ||
|
||
Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact businessContact=new Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact(); | ||
businessContact.firstName("Stuart"); | ||
businessContact.lastName("Stuart"); | ||
businessContact.phoneNumber("6574567813"); | ||
businessContact.email("[email protected]"); | ||
businessInformation.businessContact(businessContact); | ||
businessInformation.merchantCategoryCode("5999"); | ||
organizationInformation.businessInformation(businessInformation); | ||
|
||
reqObj.organizationInformation(organizationInformation); | ||
|
||
|
||
Boardingv1registrationsProductInformation productInformation=new Boardingv1registrationsProductInformation(); | ||
|
||
Boardingv1registrationsProductInformationSelectedProducts selectedProducts=new Boardingv1registrationsProductInformationSelectedProducts(); | ||
|
||
PaymentsProducts payments=new PaymentsProducts(); | ||
PaymentsProductsPayerAuthentication payerAuthentication=new PaymentsProductsPayerAuthentication(); | ||
PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation=new PaymentsProductsPayerAuthenticationSubscriptionInformation(); | ||
subscriptionInformation.enabled(true); | ||
payerAuthentication.subscriptionInformation(subscriptionInformation); | ||
|
||
PaymentsProductsPayerAuthenticationConfigurationInformation configurationInformation=new PaymentsProductsPayerAuthenticationConfigurationInformation(); | ||
PayerAuthConfig configurations=new PayerAuthConfig(); | ||
PayerAuthConfigCardTypes cardTypes=new PayerAuthConfigCardTypes(); | ||
PayerAuthConfigCardTypesVerifiedByVisa verifiedByVisa=new PayerAuthConfigCardTypesVerifiedByVisa(); | ||
List<PayerAuthConfigCardTypesVerifiedByVisaCurrencies> currencies=new ArrayList<>(); | ||
PayerAuthConfigCardTypesVerifiedByVisaCurrencies currency1=new PayerAuthConfigCardTypesVerifiedByVisaCurrencies(); | ||
List<String> currencyCodes=new ArrayList<>(); | ||
currencyCodes.add("ALL"); | ||
currency1.currencyCodes(currencyCodes); | ||
currency1.acquirerId("469216"); | ||
currency1.processorMerchantId("678855"); | ||
|
||
currencies.add(currency1); | ||
verifiedByVisa.currencies(currencies); | ||
cardTypes.verifiedByVisa(verifiedByVisa); | ||
configurations.cardTypes(cardTypes); | ||
configurationInformation.configurations(configurations); | ||
payerAuthentication.configurationInformation(configurationInformation); | ||
payments.payerAuthentication(payerAuthentication); | ||
|
||
PaymentsProductsCardProcessing cardProcessing=new PaymentsProductsCardProcessing(); | ||
PaymentsProductsCardProcessingSubscriptionInformation subscriptionInformation2=new PaymentsProductsCardProcessingSubscriptionInformation(); | ||
subscriptionInformation2.enabled(true); | ||
Map<String, PaymentsProductsCardProcessingSubscriptionInformationFeatures> features=new HashMap<>(); | ||
PaymentsProductsCardProcessingSubscriptionInformationFeatures obj=new PaymentsProductsCardProcessingSubscriptionInformationFeatures(); | ||
obj.enabled(true); | ||
features.put("cardNotPresent",obj); | ||
subscriptionInformation2.features(features); | ||
cardProcessing.subscriptionInformation(subscriptionInformation2); | ||
|
||
PaymentsProductsCardProcessingConfigurationInformation configurationInformation2=new PaymentsProductsCardProcessingConfigurationInformation(); | ||
|
||
CardProcessingConfig configurations2=new CardProcessingConfig(); | ||
CardProcessingConfigCommon common=new CardProcessingConfigCommon(); | ||
common.merchantCategoryCode("1234"); | ||
CardProcessingConfigCommonMerchantDescriptorInformation merchantDescriptorInformation=new CardProcessingConfigCommonMerchantDescriptorInformation(); | ||
|
||
merchantDescriptorInformation.name("r4ef"); | ||
merchantDescriptorInformation.city("Bellevue"); | ||
merchantDescriptorInformation.country("US"); | ||
merchantDescriptorInformation.phone("4255547845"); | ||
merchantDescriptorInformation.state("WA"); | ||
merchantDescriptorInformation.street("StreetName"); | ||
merchantDescriptorInformation.zip("98007"); | ||
common.merchantDescriptorInformation(merchantDescriptorInformation); | ||
|
||
|
||
Map<String, CardProcessingConfigCommonProcessors> processors=new HashMap<>(); | ||
CardProcessingConfigCommonProcessors obj2=new CardProcessingConfigCommonProcessors(); | ||
obj2.merchantId("123456789101"); | ||
obj2.terminalId("1231"); | ||
obj2.industryCode(CardProcessingConfigCommonProcessors.IndustryCodeEnum.D); | ||
obj2.vitalNumber("71234567"); | ||
obj2.merchantBinNumber("123456"); | ||
obj2.merchantLocationNumber("00001"); | ||
obj2.storeID("1234"); | ||
obj2.settlementCurrency("USD"); | ||
processors.put("tsys",obj2); | ||
common.processors(processors); | ||
configurations2.common(common); | ||
|
||
CardProcessingConfigFeatures features2=new CardProcessingConfigFeatures(); | ||
CardProcessingConfigFeaturesCardNotPresent cardNotPresent=new CardProcessingConfigFeaturesCardNotPresent(); | ||
|
||
cardNotPresent.visaStraightThroughProcessingOnly(true); | ||
features2.cardNotPresent(cardNotPresent); | ||
configurations2.features(features2); | ||
configurationInformation2.configurations(configurations2); | ||
cardProcessing.configurationInformation(configurationInformation2); | ||
payments.cardProcessing(cardProcessing); | ||
|
||
PaymentsProductsVirtualTerminal virtualTerminal=new PaymentsProductsVirtualTerminal(); | ||
PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation3=new PaymentsProductsPayerAuthenticationSubscriptionInformation(); | ||
|
||
subscriptionInformation3.enabled(true); | ||
virtualTerminal.subscriptionInformation(subscriptionInformation3); | ||
payments.virtualTerminal(virtualTerminal); | ||
|
||
PaymentsProductsTax customerInvoicing=new PaymentsProductsTax(); | ||
PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation4=new PaymentsProductsPayerAuthenticationSubscriptionInformation(); | ||
|
||
subscriptionInformation4.enabled(true); | ||
customerInvoicing.subscriptionInformation(subscriptionInformation4); | ||
payments.customerInvoicing(customerInvoicing); | ||
|
||
PaymentsProductsPayouts payouts=new PaymentsProductsPayouts(); | ||
PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation5=new PaymentsProductsPayerAuthenticationSubscriptionInformation(); | ||
subscriptionInformation5.enabled(true); | ||
payouts.subscriptionInformation(subscriptionInformation5); | ||
payments.payouts(payouts); | ||
|
||
selectedProducts.payments(payments); | ||
|
||
CommerceSolutionsProducts commerceSolutions=new CommerceSolutionsProducts(); | ||
CommerceSolutionsProductsTokenManagement tokenManagement=new CommerceSolutionsProductsTokenManagement(); | ||
|
||
PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation6=new PaymentsProductsPayerAuthenticationSubscriptionInformation(); | ||
|
||
subscriptionInformation6.enabled(true); | ||
tokenManagement.subscriptionInformation(subscriptionInformation6); | ||
commerceSolutions.tokenManagement(tokenManagement); | ||
selectedProducts.commerceSolutions(commerceSolutions); | ||
|
||
RiskProducts risk=new RiskProducts(); | ||
RiskProductsFraudManagementEssentials fraudManagementEssentials=new RiskProductsFraudManagementEssentials(); | ||
|
||
PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation7=new PaymentsProductsPayerAuthenticationSubscriptionInformation(); | ||
subscriptionInformation7.enabled(true); | ||
fraudManagementEssentials.subscriptionInformation(subscriptionInformation7); | ||
|
||
RiskProductsFraudManagementEssentialsConfigurationInformation configurationInformation5=new RiskProductsFraudManagementEssentialsConfigurationInformation(); | ||
|
||
UUID templateId = UUID.fromString("E4EDB280-9DAC-4698-9EB9-9434D40FF60C"); | ||
configurationInformation5.templateId(templateId); | ||
fraudManagementEssentials.configurationInformation(configurationInformation5); | ||
risk.fraudManagementEssentials(fraudManagementEssentials); | ||
|
||
selectedProducts.risk(risk); | ||
|
||
productInformation.selectedProducts(selectedProducts); | ||
|
||
reqObj.productInformation(productInformation); | ||
|
||
System.out.println("Req obj created..........."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why this comment? |
||
|
||
|
||
InlineResponse2012 result=null; | ||
|
||
try { | ||
merchantProp = MerchantBoardingConfiguration.getMerchantBoardingDetails(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename this getMerchantBoardingDetails() to getMerchantConfigForBoardingAPI() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add comment line here, that "Boarding API support only JWT Auth Type" |
||
ApiClient apiClient = new ApiClient(); | ||
MerchantConfig merchantConfig = new MerchantConfig(merchantProp); | ||
apiClient.merchantConfig = merchantConfig; | ||
|
||
MerchantBoardingApi apiInstance = new MerchantBoardingApi(apiClient); | ||
result = apiInstance.postRegistration(reqObj, null); | ||
|
||
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()); | ||
System.out.println("Msg.."+e.getMessage()+" Respbody.."+e.getResponseBody()+" cause.."+e.getCause()); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
|
||
|
||
return result; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this comment?