Skip to content

Commit 2b12783

Browse files
committed
axa-updates
1 parent b692ed5 commit 2b12783

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

generator/cybersource-javascript-template/ApiClient.mustache

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,16 @@
363363
364364
this.merchantConfig = new MerchantConfig(configObject);
365365
this.constants = Constants;
366-
this.basePath = this.constants.HTTP_URL_PREFIX + this.merchantConfig.getRequestHost();
366+
if(this.merchantConfig.getIntermediateHost()) {
367+
if(this.merchantConfig.getIntermediateHost().startsWith(this.constants.HTTP_URL_PREFIX) ||
368+
this.merchantConfig.getIntermediateHost().startsWith('http://')) {
369+
this.basePath = this.merchantConfig.getIntermediateHost();
370+
} else {
371+
this.basePath = this.constants.HTTP_URL_PREFIX + this.merchantConfig.getIntermediateHost();
372+
}
373+
} else {
374+
this.basePath = this.constants.HTTP_URL_PREFIX + this.merchantConfig.getRequestHost();
375+
}
367376
this.logger = Logger.getLogger(this.merchantConfig, 'ApiClient');
368377
}
369378

@@ -525,6 +534,12 @@
525534
headerParams = this.callAuthenticationHeader(httpMethod, requestTarget, bodyParam, headerParams);
526535
}
527536

537+
if(this.merchantConfig.getDefaultHeaders()) {
538+
for (const [key, value] of Object.entries(this.merchantConfig.getDefaultHeaders())) {
539+
headerParams[`${key}`] = `${value}`;
540+
}
541+
}
542+
528543
// set header parameters
529544
request.set(this.defaultHeaders).set(this.normalizeParams(headerParams));
530545

src/ApiClient.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,16 @@
365365

366366
this.merchantConfig = new MerchantConfig(configObject);
367367
this.constants = Constants;
368-
this.basePath = this.constants.HTTP_URL_PREFIX + this.merchantConfig.getRequestHost();
368+
if(this.merchantConfig.getIntermediateHost()) {
369+
if(this.merchantConfig.getIntermediateHost().startsWith(this.constants.HTTP_URL_PREFIX) ||
370+
this.merchantConfig.getIntermediateHost().startsWith('http://')) {
371+
this.basePath = this.merchantConfig.getIntermediateHost();
372+
} else {
373+
this.basePath = this.constants.HTTP_URL_PREFIX + this.merchantConfig.getIntermediateHost();
374+
}
375+
} else {
376+
this.basePath = this.constants.HTTP_URL_PREFIX + this.merchantConfig.getRequestHost();
377+
}
369378
this.logger = Logger.getLogger(this.merchantConfig, 'ApiClient');
370379
}
371380

@@ -527,6 +536,12 @@
527536
headerParams = this.callAuthenticationHeader(httpMethod, requestTarget, bodyParam, headerParams);
528537
}
529538

539+
if(this.merchantConfig.getDefaultHeaders()) {
540+
for (const [key, value] of Object.entries(this.merchantConfig.getDefaultHeaders())) {
541+
headerParams[`${key}`] = `${value}`;
542+
}
543+
}
544+
530545
// set header parameters
531546
request.set(this.defaultHeaders).set(this.normalizeParams(headerParams));
532547

src/authentication/core/MerchantConfig.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,16 @@ function MerchantConfig(result) {
5959

6060
this.runEnvironment = result.runEnvironment;
6161

62+
/* Intermediate Host */
63+
this.intermediateHost = result.intermediateHost;
64+
6265
this.solutionId = result.solutionId;
6366

6467
this.logConfiguration = new LogConfiguration(result.logConfiguration);
6568

69+
/* Default Custom Headers */
70+
this.defaultHeaders = result.defaultHeaders;
71+
6672
/* Fallback logic*/
6773
this.defaultPropValues();
6874

@@ -268,6 +274,14 @@ MerchantConfig.prototype.setRunEnvironment = function setRunEnvironment(runEnvir
268274
this.runEnvironment = runEnvironment;
269275
}
270276

277+
MerchantConfig.prototype.getIntermediateHost = function getIntermediateHost() {
278+
return this.intermediateHost;
279+
}
280+
281+
MerchantConfig.prototype.setIntermediateHost = function setIntermediateHost(intermediateHost) {
282+
this.intermediateHost = intermediateHost;
283+
}
284+
271285
MerchantConfig.prototype.getProxyAddress = function getProxyAddress() {
272286
return this.proxyAddress;
273287
}
@@ -325,6 +339,14 @@ MerchantConfig.prototype.setLogConfiguration = function setLogConfiguration(logC
325339
this.logConfiguration = new LogConfiguration(logConfig);
326340
}
327341

342+
MerchantConfig.prototype.getDefaultHeaders = function getDefaultHeaders() {
343+
return this.defaultHeaders;
344+
}
345+
346+
MerchantConfig.prototype.setDefaultHeaders = function setDefaultHeaders(defaultHeaders) {
347+
return this.defaultHeaders;
348+
}
349+
328350
MerchantConfig.prototype.runEnvironmentCheck = function runEnvironmentCheck(logger) {
329351

330352
/*url*/

0 commit comments

Comments
 (0)