Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions README_Net461.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ To set your API credentials for an API request, configure the following informat
merchantID = your_merchant_id
merchantKeyId = your_key_serial_number
merchantsecretKey = your_key_shared_secret
useMetaKey = false
enableClientCert = false
```

* Jwt
Expand All @@ -58,8 +60,96 @@ To set your API credentials for an API request, configure the following informat
keyPassword = your_merchant_id
keyFileName = your_merchant_id
keysDirectory = Resource
useMetaKey = false
enableClientCert = false
```

* MetaKey Http

```
authenticationType = http_Signature
merchantID = your_child_merchant_id
merchantKeyId = your_metakey_serial_number
merchantsecretKey = your_metakey_shared_secret
portfolioId = your_portfolio_id
useMetaKey = true
enableClientCert = false
```

* MetaKey JWT

```
authenticationType = Jwt
merchantID = your_child_merchant_id
keyAlias = your_child_merchant_id
keyPassword = your_portfolio_id
keyFileName = your_portfolio_id
keysDirectory = Resource
useMetaKey = true
enableClientCert = false
```

* OAuth

CyberSource OAuth uses mutual authentication. A Client Certificate is required to authenticate against the OAuth API.

Refer to [Supporting Mutual Authentication](https://developer.cybersource.com/api/developer-guides/OAuth/cybs_extend_intro/Supporting-Mutual-Authentication.html) to get information on how to generate Client certificate.

If the certificate (Public Key) and Private Key are in 2 different files, merge them into a single .p12 file using `openssl`.

```bash
openssl pkcs12 -export -out certificate.p12 -inkey privateKey.key -in certificate.crt
```

Set the run environment to OAuth enabled URLs. OAuth only works in these run environments.

```
// For TESTING use
_configurationDictionary.Add("runEnvironment", "cybersource.environment.mutualauth.sandbox")
// For PRODUCTION use
// _configurationDictionary.Add("runEnvironment", "cybersource.environment.mutualauth.production")
```

To generate tokens, an Auth Code is required. The Auth Code can be generated by following the instructions given in [Integrating OAuth](https://developer.cybersource.com/api/developer-guides/OAuth/cybs_extend_intro/integrating_OAuth.html).

This generated Auth Code can then be used to create the Access Token and Refresh Token.

In `Source/Configuration.cs` file, set the following properties.

Note that `authenticationType` is set to `MutualAuth` only to generate the Access Token and the Refresh Token.

```
authenticationType = MutualAuth
enableClientCert = true
clientCertDirectory = resources
clientCertFile = your_client_cert in .p12 format
clientCertPassword = password_for_client_cert
clientId = your_client_id
clientSecret = your_client_secret
```

Once the tokens are obtained, the `authenticationType` can then be set to `OAuth` to use the generated Access Token to send requests to other APIs.

```
authenticationType = OAuth
enableClientCert = true
clientCertDirectory = resources
clientCertFile = your_client_cert - .p12 format
clientCertPassword = password_for_client_cert
clientId = your_client_id
clientSecret = your_client_secret
accessToken = generated_access_token
refreshToken = generated_refresh_token
```

The Access Token is valid for 15 mins, whereas the Refresh Token is valid for 1 year.

Once the Access Token expires, use the Refresh Token to generate another Access Token.

Refer to [StandAloneOAuth.cs](https://github.com/CyberSource/cybersource-rest-samples-csharp/tree/master/Source/Samples/Authentication/StandaloneOAuth.cs) to understand how to consume OAuth.

For further information, refer to the documentation at [Cybersource OAuth 2.0](https://developer.cybersource.com/api/developer-guides/OAuth/cybs_extend_intro.html).

## Switching between the sandbox environment and the production environment

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 appropriate environment constant in `Source\Configuration.cs` file. For example:
Expand All @@ -72,6 +162,15 @@ _configurationDictionary.Add("runEnvironment", "cybersource.environment.sandbox"
// _configurationDictionary.Add("runEnvironment", "cybersource.environment.production");
```

To use OAuth, switch to OAuth enabled URLs

```csharp
// For TESTING use
_configurationDictionary.Add("runEnvironment", "cybersource.environment.mutualauth.sandbox")
// For PRODUCTION use
// _configurationDictionary.Add("runEnvironment", "cybersource.environment.mutualauth.production")
```

The [API Reference Guide](https://developer.cybersource.com/api/reference/api-reference.html) 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.

## License
Expand Down
99 changes: 99 additions & 0 deletions README_NetCore.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ To set your API credentials for an API request, configure the following informat
merchantID = your_merchant_id
merchantKeyId = your_key_serial_number
merchantsecretKey = your_key_shared_secret
useMetaKey = false
enableClientCert = false
```

* Jwt
Expand All @@ -125,8 +127,96 @@ To set your API credentials for an API request, configure the following informat
keyPassword = your_merchant_id
keyFileName = your_merchant_id
keysDirectory = Resource
useMetaKey = false
enableClientCert = false
```

* MetaKey Http

```
authenticationType = http_Signature
merchantID = your_child_merchant_id
merchantKeyId = your_metakey_serial_number
merchantsecretKey = your_metakey_shared_secret
portfolioId = your_portfolio_id
useMetaKey = true
enableClientCert = false
```

* MetaKey JWT

```
authenticationType = Jwt
merchantID = your_child_merchant_id
keyAlias = your_child_merchant_id
keyPassword = your_portfolio_id
keyFileName = your_portfolio_id
keysDirectory = Resource
useMetaKey = true
enableClientCert = false
```

* OAuth

CyberSource OAuth uses mutual authentication. A Client Certificate is required to authenticate against the OAuth API.

Refer to [Supporting Mutual Authentication](https://developer.cybersource.com/api/developer-guides/OAuth/cybs_extend_intro/Supporting-Mutual-Authentication.html) to get information on how to generate Client certificate.

If the certificate (Public Key) and Private Key are in 2 different files, merge them into a single .p12 file using `openssl`.

```bash
openssl pkcs12 -export -out certificate.p12 -inkey privateKey.key -in certificate.crt
```

Set the run environment to OAuth enabled URLs. OAuth only works in these run environments.

```
// For TESTING use
_configurationDictionary.Add("runEnvironment", "cybersource.environment.mutualauth.sandbox")
// For PRODUCTION use
// _configurationDictionary.Add("runEnvironment", "cybersource.environment.mutualauth.production")
```

To generate tokens, an Auth Code is required. The Auth Code can be generated by following the instructions given in [Integrating OAuth](https://developer.cybersource.com/api/developer-guides/OAuth/cybs_extend_intro/integrating_OAuth.html).

This generated Auth Code can then be used to create the Access Token and Refresh Token.

In `Source/Configuration.cs` file, set the following properties.

Note that `authenticationType` is set to `MutualAuth` only to generate the Access Token and the Refresh Token.

```
authenticationType = MutualAuth
enableClientCert = true
clientCertDirectory = resources
clientCertFile = your_client_cert in .p12 format
clientCertPassword = password_for_client_cert
clientId = your_client_id
clientSecret = your_client_secret
```

Once the tokens are obtained, the `authenticationType` can then be set to `OAuth` to use the generated Access Token to send requests to other APIs.

```
authenticationType = OAuth
enableClientCert = true
clientCertDirectory = resources
clientCertFile = your_client_cert - .p12 format
clientCertPassword = password_for_client_cert
clientId = your_client_id
clientSecret = your_client_secret
accessToken = generated_access_token
refreshToken = generated_refresh_token
```

The Access Token is valid for 15 mins, whereas the Refresh Token is valid for 1 year.

Once the Access Token expires, use the Refresh Token to generate another Access Token.

Refer to [StandAloneOAuth.cs](https://github.com/CyberSource/cybersource-rest-samples-csharp/tree/master/Source/Samples/Authentication/StandaloneOAuth.cs) to understand how to consume OAuth.

For further information, refer to the documentation at [Cybersource OAuth 2.0](https://developer.cybersource.com/api/developer-guides/OAuth/cybs_extend_intro.html).

## Switching between the sandbox environment and the production environment

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 appropriate environment constant in `Source\Configuration.cs` file. For example:
Expand All @@ -139,6 +229,15 @@ _configurationDictionary.Add("runEnvironment", "cybersource.environment.sandbox"
// _configurationDictionary.Add("runEnvironment", "cybersource.environment.production");
```

To use OAuth, switch to OAuth enabled URLs

```csharp
// For TESTING use
_configurationDictionary.Add("runEnvironment", "cybersource.environment.mutualauth.sandbox")
// For PRODUCTION use
// _configurationDictionary.Add("runEnvironment", "cybersource.environment.mutualauth.production")
```

The [API Reference Guide](https://developer.cybersource.com/api/reference/api-reference.html) 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.

## License
Expand Down
25 changes: 20 additions & 5 deletions Source/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ public Dictionary<string, string> GetConfiguration()
// Configs related to meta key
_configurationDictionary.Add("portfolioID", string.Empty);
_configurationDictionary.Add("useMetaKey", "false");

// _configurationDictionary.Add("proxyAddress", string.Empty);
// _configurationDictionary.Add("proxyPort", string.Empty);
// _configurationDictionary.Add("proxyUsername", string.Empty);
// _configurationDictionary.Add("proxyPassword", string.Empty);

// Configs related to OAuth
_configurationDictionary.Add("enableClientCert", "false");
_configurationDictionary.Add("clientCertDirectory", "Resource");
_configurationDictionary.Add("clientCertFile", "");
_configurationDictionary.Add("clientCertPassword", "");
_configurationDictionary.Add("clientId", "");
_configurationDictionary.Add("clientSecret", "");

// _configurationDictionary.Add("proxyAddress", string.Empty);
// _configurationDictionary.Add("proxyPort", string.Empty);
// _configurationDictionary.Add("proxyUsername", string.Empty);
// _configurationDictionary.Add("proxyPassword", string.Empty);
return _configurationDictionary;
}

Expand Down Expand Up @@ -61,6 +68,14 @@ public Dictionary<string, string> GetAlternativeConfiguration()
_configurationDictionary.Add("portfolioID", string.Empty);
_configurationDictionary.Add("useMetaKey", "false");

// Configs related to OAuth
_configurationDictionary.Add("enableClientCert", "false");
_configurationDictionary.Add("clientCertDirectory", "Resource");
_configurationDictionary.Add("clientCertFile", "");
_configurationDictionary.Add("clientCertPassword", "");
_configurationDictionary.Add("clientId", "");
_configurationDictionary.Add("clientSecret", "");


return _configurationDictionary;
}
Expand Down
Loading