Last active
September 1, 2021 03:00
-
-
Save mrbusche/e04f68bacd68eab546668c46ad741670 to your computer and use it in GitHub Desktop.
Cybersource ColdFusion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.javaSettings = {LoadPaths = [".\libraries\cybersource-rest-client-java-0.0.35.jar", ".\libraries\AuthenticationSdk-0.0.17.jar"], loadColdFusionClassPath = true, reloadOnChange = false} | |
//https://mvnrepository.com/artifact/com.cybersource/cybersource-rest-client-java/0.0.35 | |
//https://mvnrepository.com/artifact/com.cybersource/AuthenticationSdk/0.0.17 | |
<cfscript> | |
writeDump(retrieveFlexKey()); | |
public String function retrieveFlexKey() throws Exception { | |
flexPublicKey = "NoKeyReturned"; | |
try { | |
props = createObject('java', 'java.util.Properties'); | |
// HTTP_Signature = http_signature and JWT = jwt | |
props.setProperty("authenticationType", "http_signature"); | |
props.setProperty("merchantID", "testrest"); | |
// props.setProperty("runEnvironment", "CyberSource.Environment.SANDBOX"); | |
// props.setProperty("runEnvironment", "api-matest.cybersource.com"); | |
props.setProperty("runEnvironment", "apitest.cybersource.com"); | |
props.setProperty("requestJsonPath", "src/main/resources/request.json"); | |
// JWT Parameters | |
// props.setProperty("keyAlias", "testrest"); | |
// props.setProperty("keyPass", "testrest"); | |
// props.setProperty("keyFileName", "testrest"); | |
// P12 key path. Enter the folder path where the .p12 file is located. | |
props.setProperty("keysDirectory", "src/main/resources"); | |
// HTTP Parameters | |
props.setProperty("merchantKeyId", "08c94330-f618-42a3-b09d-e1e43be5efda"); | |
props.setProperty("merchantsecretKey", "yBJxy6LjM2TmcPGu+GaJrHtkke25fPpUX+UY6/L/1tE="); | |
// 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"); | |
merchantConfig = createObject('java', 'com.cybersource.authsdk.core.MerchantConfig').init(props); | |
apiClient = createObject('java', 'Invokers.ApiClient'); | |
apiClient.merchantConfig = merchantConfig; | |
keyGenerationApi = createObject('java', 'Api.KeyGenerationApi').init(apiClient); | |
requestInfo = createObject('java', 'Model.GeneratePublicKeyRequest'); | |
requestInfo.encryptionType("RsaOaep256"); | |
requestInfo.targetOrigin("http://localhost:8500"); | |
response = keyGenerationApi.generatePublicKey("JWT", requestInfo); | |
responseCode = apiClient.responseCode; | |
status = apiClient.status; | |
flexPublicKey = response.getKeyId(); | |
} catch (Exception e) { | |
writeDump(e); | |
} | |
return flexPublicKey; | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment