Skip to content

Commit 96e2697

Browse files
authored
Merge pull request #1 from CyberSource/run-env-change
Run env change
2 parents af8329d + 6776d14 commit 96e2697

File tree

3 files changed

+95
-113
lines changed

3 files changed

+95
-113
lines changed

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,33 @@
22

33
The CyberSource Node client provides convenient access to the [CyberSource REST API](https://developer.cybersource.com/api/reference/api-reference.html) from your Node application.
44

5-
## Requirements
5+
## Requirements
6+
67
* Node.js version 6.17.1 or higher
78
* A CyberSource account (see _Registration & Configuration_ section below)
89

9-
1010
## Installation
1111

1212
```shell
13-
npm install cybersource-rest-client
13+
npm install cybersource-rest-client
1414
```
1515

1616
## Registration & Configuration
17+
1718
Use of this SDK and the CyberSource APIs requires having an account on our system. You can find details of getting a test account and creating your keys [here](https://developer.cybersource.com/api/developer-guides/dita-gettingstarted/registration.html)
1819

1920
Remember this SDK is for use in server-side Node applications that access the CyberSource REST API and credentials should always be securely stored and accessed appropriately.
2021

2122
## SDK Usage Examples and Sample Code
23+
2224
To get started using this SDK, it's highly recommended to download our sample code repository:
25+
2326
* [Cybersource Node.js Sample Code Repository (on GitHub)](https://github.com/CyberSource/cybersource-rest-samples-node)
2427

2528
In that respository, we have comprehensive sample code for all common uses of our API:
2629

2730
Additionally, you can find details and examples of how our API is structured in our API Reference Guide:
31+
2832
* [Developer Center API Reference](https://developer.cybersource.com/api/reference/api-reference.html)
2933

3034
The API Reference Guide provides examples of what information is needed for a particular request and how that information would be formatted. Using those examples, you can easily determine what methods would be necessary to include that information in a request using this SDK.
@@ -40,18 +44,18 @@ MIDs continue to be able to create keys for themselves, even if a Meta Key is ge
4044
Further information on MetaKey can be found in [New Business Center User Guide](https://developer.cybersource.com/library/documentation/dev_guides/Business_Center/New_Business_Center_User_Guide.pdf).
4145

4246
### Switching between the sandbox environment and the production environment
43-
Cybersource maintains a complete sandbox environment for testing and development purposes. This sandbox environment is an exact duplicate of our production environment with the transaction authorization and settlement process simulated. By default, this SDK is configured to communicate with the sandbox environment. To switch to the production environment, set the `runEnvironment` in the SDK Configuration. See our sample at https://github.com/CyberSource/cybersource-rest-samples-node/blob/master/Data/Configuration.js.
47+
48+
Cybersource maintains a complete sandbox environment for testing and development purposes. This sandbox environment is an exact duplicate of our production environment with the transaction authorization and settlement process simulated. By default, this SDK is configured to communicate with the sandbox environment. To switch to the production environment, set the `runEnvironment` in the SDK Configuration. See our sample at <https://github.com/CyberSource/cybersource-rest-samples-node/blob/master/Data/Configuration.js>.
4449

4550
```javascript
46-
// For TESTING use
47-
const RunEnvironment = "cybersource.environment.sandbox";
48-
// For PRODUCTION use
49-
const RunEnvironment = "cybersource.environment.production";
51+
// For TESTING use
52+
const RunEnvironment = "apitest.cybersource.com";
53+
// For PRODUCTION use
54+
const RunEnvironment = "api.cybersource.com";
5055
```
5156

5257
API credentials are different for each environment, so be sure to switch to the appropriate credentials when switching environments.
5358

54-
55-
5659
## License
60+
5761
This repository is distributed under a proprietary license. See the provided [`LICENSE.txt`](/LICENSE.txt) file.

src/authentication/core/MerchantConfig.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -306,21 +306,12 @@ MerchantConfig.prototype.runEnvironmentCheck = function runEnvironmentCheck(logg
306306
if (typeof (this.runEnvironment) !== "string") {
307307
this.runEnvironment = this.runEnvironment.toString();
308308
}
309-
if (this.runEnvironment.toLowerCase() === Constants.SANDBOX_RUN_ENV) {
310-
this.setRequestHost(Constants.SANDBOX_URL);
311-
} else if (this.runEnvironment.toLowerCase() === Constants.PRODUCTION_RUN_ENV) {
312-
this.setRequestHost(Constants.PRODUCTION_URL);
313-
} else if (this.runEnvironment.toLowerCase() === Constants.BOA_SANDBOX_RUN_ENV) {
314-
this.setRequestHost(Constants.BOA_SANDBOX_URL);
315-
} else if (this.runEnvironment.toLowerCase() === Constants.BOA_PRODUCTION_RUN_ENV) {
316-
this.setRequestHost(Constants.BOA_PRODUCTION_URL);
317-
} else if (this.runEnvironment.toLowerCase() === Constants.IDC_SANDBOX_RUN_ENV) {
318-
this.setRequestHost(Constants.IDC_SANDBOX_URL);
319-
} else if (this.runEnvironment.toLowerCase() === Constants.IDC_PRODUCTION_RUN_ENV) {
320-
this.setRequestHost(Constants.IDC_PRODUCTION_URL);
321-
} else {
322-
this.setRequestHost(this.runEnvironment);
309+
310+
if (Constants.OLD_RUN_ENVIRONMENT_CONSTANTS.includes(this.runEnvironment.toUpperCase())) {
311+
ApiException.ApiException(Constants.DEPRECATED_RUN_ENVIRONMENT, logger);
323312
}
313+
314+
this.setRequestHost(this.runEnvironment);
324315
}
325316

326317
}

src/authentication/util/Constants.js

Lines changed: 76 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -4,103 +4,90 @@
44
* These are constant variables
55
*/
66
module.exports = {
7-
POST : "post",
8-
GET : "get",
9-
PUT : "put",
10-
DELETE : "delete",
11-
PATCH : "patch",
12-
HTTP_URL_PREFIX : "https://",
13-
/**/
14-
HTTP : "http_signature",
15-
JWT : "jwt",
16-
V_C_MERCHANTID : "v-c-merchant-id",
17-
DATE : "date",
18-
HOST : "host",
19-
SIGNATURE : "Signature",
20-
USERAGENT : "User-Agent",
21-
USER_AGENT_VALUE : "Mozilla/5.0",
22-
CONTENT_TYPE : "Content-Type",
23-
APPLICATION_JSON : "application/json",
24-
V_C_CORRELATION_ID : "v-c-correlation-id",
25-
STATUS_INFORMATION : "Status Information",
26-
DIGEST : "digest",
27-
REQUEST_TYPE : "Request Type",
28-
29-
SANDBOX_URL : "apitest.cybersource.com",
30-
PRODUCTION_URL : "api.cybersource.com",
31-
SANDBOX_RUN_ENV : "cybersource.environment.sandbox",
32-
PRODUCTION_RUN_ENV : "cybersource.environment.production",
33-
34-
BOA_SANDBOX_URL : "apitest.merchant-services.bankofamerica.com",
35-
BOA_PRODUCTION_URL : "api.merchant-services.bankofamerica.com",
36-
BOA_SANDBOX_RUN_ENV : "bankofamerica.environment.sandbox",
37-
BOA_PRODUCTION_RUN_ENV : "bankofamerica.environment.production",
7+
POST : "post",
8+
GET : "get",
9+
PUT : "put",
10+
DELETE : "delete",
11+
PATCH : "patch",
12+
HTTP_URL_PREFIX : "https://",
13+
HTTP : "http_signature",
14+
JWT : "jwt",
15+
V_C_MERCHANTID : "v-c-merchant-id",
16+
DATE : "date",
17+
HOST : "host",
18+
SIGNATURE : "Signature",
19+
USERAGENT : "User-Agent",
20+
USER_AGENT_VALUE : "Mozilla/5.0",
21+
CONTENT_TYPE : "Content-Type",
22+
APPLICATION_JSON : "application/json",
23+
V_C_CORRELATION_ID : "v-c-correlation-id",
24+
STATUS_INFORMATION : "Status Information",
25+
DIGEST : "digest",
26+
REQUEST_TYPE : "Request Type",
3827

39-
IDC_SANDBOX_URL : "apitest.cybersource.com",
40-
IDC_PRODUCTION_URL : "api.in.cybersource.com",
41-
IDC_SANDBOX_RUN_ENV : "cybersource.in.environment.sandbox",
42-
IDC_PRODUCTION_RUN_ENV : "cybersource.in.environment.production",
28+
OLD_RUN_ENVIRONMENT_CONSTANTS : ["CYBERSOURCE.ENVIRONMENT.SANDBOX", "CYBERSOURCE.ENVIRONMENT.PRODUCTION",
29+
"CYBERSOURCE.IN.ENVIRONMENT.SANDBOX", "CYBERSOURCE.IN.ENVIRONMENT.PRODUCTION"],
4330

4431
/* Digest Constants*/
45-
SIGNATURE_ALGORITHAM : "SHA-256=",
46-
HmacSHA256 : "HmacSHA256",
47-
32+
SIGNATURE_ALGORITHAM : "SHA-256=",
33+
HmacSHA256 : "HmacSHA256",
34+
4835
/* Logging Labels*/
49-
BEGIN_TRANSACTION : "************************ LOGGING START ************************",
50-
END_TRANSACTION : "************************ LOGGING END ************************",
51-
MERCHANTID : "MERCHANTID",
52-
MERCHANT_KEY_ID : "MERCHANT_KEY_ID",
53-
MERCHANT_SECERT_KEY : "MERCHANT_SECERT_KEY",
54-
REQUEST_BODY : "Request Body",
55-
RESPONSE_CODE : "Response Code",
56-
RESPONSE_MESSAGE : "Response Message",
57-
AUTHORIZATION : "Authorization",
58-
HideMerchantConfigProps : "merchantID,merchantsecretKey,merchantKeyId,keyAlias,keyPass,requestJsonData",
36+
BEGIN_TRANSACTION : "************************ LOGGING START ************************",
37+
END_TRANSACTION : "************************ LOGGING END ************************",
38+
MERCHANTID : "MERCHANTID",
39+
MERCHANT_KEY_ID : "MERCHANT_KEY_ID",
40+
MERCHANT_SECERT_KEY : "MERCHANT_SECERT_KEY",
41+
REQUEST_BODY : "Request Body",
42+
RESPONSE_CODE : "Response Code",
43+
RESPONSE_MESSAGE : "Response Message",
44+
AUTHORIZATION : "Authorization",
45+
HideMerchantConfigProps : "merchantID,merchantsecretKey,merchantKeyId,keyAlias,keyPass,requestJsonData",
5946

6047
/* Masking list*/
61-
MASKING_DATA : "expirationMonth, expirationYear, email,firstName, lastName, phoneNumber, number, securityCode, type",
62-
63-
/* Exception labels */
64-
PROXY_PREFIX : "https",
65-
FILE_NOT_FOUND : "File not found, Re-Enter path/file name, Entered path/file name :: ",
66-
AUTH_ERROR : "Check Authentication Type (HTTP_Signature/JWT) in cybs.json.",
67-
KEY_ALIAS_NULL_EMPTY : "KeyAlias Empty/Null. Assigining merchantID value",
68-
REQUEST_JSON_ERROR : "Request Json File missing. File Path :: ",
69-
KEY_FILE_EMPTY : "KeyFileName is empty, Assigining merchantID value",
70-
REFER_LOG : "Please refer Log for details",
71-
MERCHANTID_REQ : "MerchantID is mandatory",
72-
INCORRECT_KEY_ALIAS : "The Entered key_alias is Incorrect, Assigining merchantID value",
73-
INCORRECT_KEY_PASS : "The Entered keyPass is Incorrect",
74-
AUTHENTICATION_REQ : "AuthenticationType is Mandatory",
75-
MERCHANT_KEY_ID_REQ : "MerchantKeyId is Mandatory",
76-
PORTFOLIO_ID_REQ : "PortfolioID is Mandatory",
77-
RUN_ENVIRONMENT_REQ : "RunEnvironment is Mandatory",
78-
MERCHANT_SECRET_KEY_REQ : "MerchantSecretKey is Mandatory",
79-
KEY_PASS_EMPTY : "KeyPass Empty/Null. Assigining merchantID value",
80-
KEY_DIRECTORY_EMPTY : "KeysDirectory not provided. Using Default Path:",
81-
REQUEST_JSON_EMPTY : "RequestJsonPath not provided",
82-
INVALID_LOGDIRECTORY : "Entered log directory does not exists. Taking default log directory ./log",
83-
INVALID_REQUEST_TYPE_METHOD :"Entered Request Type should be (GET/POST/PUT/DELETE)",
48+
MASKING_DATA : "expirationMonth, expirationYear, email,firstName, lastName, phoneNumber, number, securityCode, type",
8449

50+
/* Exception labels */
51+
PROXY_PREFIX : "https",
52+
FILE_NOT_FOUND : "File not found, Re-Enter path/file name, Entered path/file name : ",
53+
AUTH_ERROR : "Check Authentication Type (HTTP_Signature/JWT) in cybs.json.",
54+
KEY_ALIAS_NULL_EMPTY : "KeyAlias Empty/Null. Assigining merchantID value",
55+
REQUEST_JSON_ERROR : "Request Json File missing. File Path : ",
56+
KEY_FILE_EMPTY : "KeyFileName is empty, Assigining merchantID value",
57+
REFER_LOG : "Please refer Log for details",
58+
MERCHANTID_REQ : "MerchantID is mandatory",
59+
INCORRECT_KEY_ALIAS : "The Entered key_alias is Incorrect, Assigining merchantID value",
60+
INCORRECT_KEY_PASS : "The Entered keyPass is Incorrect",
61+
AUTHENTICATION_REQ : "AuthenticationType is Mandatory",
62+
MERCHANT_KEY_ID_REQ : "MerchantKeyId is Mandatory",
63+
PORTFOLIO_ID_REQ : "PortfolioID is Mandatory",
64+
RUN_ENVIRONMENT_REQ : "RunEnvironment is Mandatory",
65+
MERCHANT_SECRET_KEY_REQ : "MerchantSecretKey is Mandatory",
66+
KEY_PASS_EMPTY : "KeyPass Empty/Null. Assigining merchantID value",
67+
KEY_DIRECTORY_EMPTY : "KeysDirectory not provided. Using Default Path : ",
68+
REQUEST_JSON_EMPTY : "RequestJsonPath not provided",
69+
INVALID_LOGDIRECTORY : "Entered log directory does not exists. Taking default log directory ./log",
70+
INVALID_REQUEST_TYPE_METHOD : "Entered Request Type should be (GET/POST/PUT/DELETE)",
71+
DEPRECATED_RUN_ENVIRONMENT : "The value provided for this field `RunEnvironment` has been deprecated and will not be used anymore.\n\nPlease refer to the README file [ https://github.com/CyberSource/cybersource-rest-samples-node/blob/master/README.md ] for information about the new values that are accepted.",
8572
/*Fall back default values*/
8673

87-
DEFAULT_LOG_SIZE : "10485760", //10 MB
88-
DEFAULT_PROXY_ADDRESS : "userproxy.visa.com",
89-
DEFAULT_PROXY_PORT : "443",
90-
DEFAULT_TIMEOUT : 1000, //1000 milliseconds
91-
DEFAULT_LOG_DIRECTORY : "./log",
92-
DEFAULT_KEYS_DIRECTORY : "resource",
93-
DEFAULT_LOG_FILENAME : "cybs",
94-
DEFAULT_MAX_LOG_FILES : "10d",
95-
DEFAULT_LOGGING_LEVEL : "error",
74+
DEFAULT_LOG_SIZE : "10485760", //10 MB
75+
DEFAULT_PROXY_ADDRESS : "userproxy.visa.com",
76+
DEFAULT_PROXY_PORT : "443",
77+
DEFAULT_TIMEOUT : 1000, //1000 milliseconds
78+
DEFAULT_LOG_DIRECTORY : "./log",
79+
DEFAULT_KEYS_DIRECTORY : "resource",
80+
DEFAULT_LOG_FILENAME : "cybs",
81+
DEFAULT_MAX_LOG_FILES : "10d",
82+
DEFAULT_LOGGING_LEVEL : "error",
9683

97-
STATUS200 : "Transaction Successful",
98-
STATUS400 : "Bad Request",
99-
STATUS401 : "Authentication Failed",
100-
STATUS403 : "Forbidden",
101-
STATUS404 : "URL not found",
102-
STATUS500 : "Internal Server Error",
103-
STATUS502 : "Bad Gateway",
104-
STATUS503 : "Service Unavailable",
105-
STATUS504 : "Gateway Timeout"
84+
STATUS200 : "Transaction Successful",
85+
STATUS400 : "Bad Request",
86+
STATUS401 : "Authentication Failed",
87+
STATUS403 : "Forbidden",
88+
STATUS404 : "URL not found",
89+
STATUS500 : "Internal Server Error",
90+
STATUS502 : "Bad Gateway",
91+
STATUS503 : "Service Unavailable",
92+
STATUS504 : "Gateway Timeout"
10693
};

0 commit comments

Comments
 (0)