The CyberSource .NET Standard client provides convenient access to the CyberSource REST API from your .NET application.
- .NET Framework 4.6.1
- .NET Standard 2.0
- .NET Standard 2.1
- .NET 8.0
- Nuget Package Manager
PM> Install-Package CyberSource.Rest.Client
- Account Registration
Follow the first step mentioned in Getting Started with CyberSource REST SDKs to create a sandbox account.
- Configuration
Follow the second step mentioned in Getting Started with CyberSource REST SDKs to configure the SDK by inputting your credentials.
Please note that this is for reference only. Ensure to store the credentials in a more secure manner.
To get started using this SDK, it is highly recommended to download our sample code repository:
- Cybersource .NET Sample Code Repository (on GitHub)
In that repository, we have comprehensive sample codes for all common uses of our APIs.
Additionally, you can find details and examples of how our API is structured in our API Reference Guide:
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.
-
Add CyberSource REST Client into your .NET project.
-
Configure your credentials in
Configuration.csfile -
Use the stored crdentials to create an instance of
CyberSource.Client.Configuration. -
Create an instance of the API Controller using the instance of
CyberSource.Client.Configuration. -
Use the created API instance to call CyberSource APIs. For example SimpleAuthorizationInternet.
For more detailed examples, refer to the cybersource-rest-samples-dotnet repository.
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 property in the SDK Configuration, as shown in Sample Configuration file.
// For TESTING use
_configurationDictionary.Add("runEnvironment", "apitest.cybersource.com");
// For PRODUCTION use
// _configurationDictionary.Add("runEnvironment", "api.cybersource.com");API credentials are different for each environment, so be sure to switch to the appropriate credentials when switching environments.
This feature provides an implementation of Message Level Encryption (MLE) for APIs provided by CyberSource, integrated within our SDK. This feature ensures secure communication by encrypting messages at the application level before they are sent over the network.
More information about this new MLE feature can be found in this file : MLE.md
The SDK's logging is built on top of Microsoft.Extensions.Logging (MEL), the standard logging abstraction for .NET.
More information about this new logging framework can be found in this file : Logging.md
The SDK now allows customizable serialization by injecting user-provided JsonSerializerOptions into the SDK through dependency injection. This lets you control naming policies, converters, null-handling, and other serialization behavior without forking or subclassing the SDK.
More information about this new customizable serialization can be found in this file : Serialization.md
The SDK now allows injection of user-provided HttpClient or IHttpClientFactory through dependency injection, giving you full control over the underlying transport — handler configuration, proxy, client certificates, connection pooling, and lifetime — and letting the SDK participate in a modern Microsoft.Extensions.DependencyInjection HTTP pipeline.
More information about this new HttpClient dependency injection can be found in this file : HttpClientDependencyInjection.md
Request/response models let you send and read JSON fields that are not yet defined as typed properties:
request.SetExtraField("newApiField", "someValue"); // send an unmapped field
string value = response.GetExtraField<string>("newApiField"); // read an unmapped fieldUnknown fields on a response are preserved and re-serialized on the next request.
More information about this new model extensibility feature can be found in this file : Model-Extensions.md
⚠️ HTTP Signature Deprecation Notice: HTTP Signature authentication (HTTP_SIGNATURE) is being deprecated.JWT with Shared Secret (HS256 / HMAC-SHA256) is the recommended migration path — it uses the same
merchantKeyIdandmerchantsecretKeycredentials, requires only two property changes, and enables MLE (Message Level Encryption) support that HTTP Signature does not provide.
JWT authentication now supports two key types, configurable via the jwtKeyType property:
jwtKeyType |
Algorithm | Credentials Required |
|---|---|---|
P12 (default) |
RS256 (asymmetric, RSA-SHA256) | keysDirectory, keyFilename, keyAlias, keyPass |
SHARED_SECRET |
HS256 (symmetric, HMAC-SHA256) | merchantKeyId, merchantsecretKey |
The default value is P12, which preserves full backward compatibility with existing configurations.
_configurationDictionary.Add("authenticationType", "JWT");
_configurationDictionary.Add("merchantID", "your_merchant_id");
_configurationDictionary.Add("runEnvironment", "apitest.cybersource.com");
// jwtKeyType defaults to P12 if omitted
_configurationDictionary.Add("keyAlias", "your_merchant_id");
_configurationDictionary.Add("keyPass", "your_merchant_id");
_configurationDictionary.Add("keyFilename", "your_merchant_id");
_configurationDictionary.Add("keysDirectory", @"path\to\p12\directory");_configurationDictionary.Add("authenticationType", "JWT");
_configurationDictionary.Add("merchantID", "your_merchant_id");
_configurationDictionary.Add("runEnvironment", "apitest.cybersource.com");
_configurationDictionary.Add("jwtKeyType", "SHARED_SECRET");
_configurationDictionary.Add("merchantKeyId", "your_key_id");
_configurationDictionary.Add("merchantsecretKey", "your_base64_encoded_shared_secret");Note: When
jwtKeyTypeis set toSHARED_SECRET, the P12-related properties (keysDirectory,keyFilename,keyAlias,keyPass) are not required and will be ignored. Conversely, when usingP12, themerchantKeyIdandmerchantsecretKeyproperties are not required for JWT authentication.
If you are currently using HTTP Signature authentication, migrating to JWT with Shared Secret requires only two property changes — your credentials remain the same:
// BEFORE (HTTP Signature — deprecated)
_configurationDictionary.Add("authenticationType", "HTTP_SIGNATURE");
_configurationDictionary.Add("merchantKeyId", "your_key_id");
_configurationDictionary.Add("merchantsecretKey", "your_shared_secret");
// AFTER (JWT with Shared Secret / HS256 HMAC-SHA256 — recommended)
_configurationDictionary.Add("authenticationType", "JWT"); // changed
_configurationDictionary.Add("jwtKeyType", "SHARED_SECRET"); // added — uses HS256 (HMAC-SHA256)
_configurationDictionary.Add("merchantKeyId", "your_key_id"); // same
_configurationDictionary.Add("merchantsecretKey", "your_shared_secret"); // sameMLE (Message Level Encryption) is fully supported with the SHARED_SECRET key type. When using jwtKeyType=SHARED_SECRET with MLE, you must provide the MLE public certificate separately via the mleForRequestPublicCertPath property, since there is no P12 file to auto-extract the MLE certificate from.
The request MLE public certificate can be downloaded from the CyberSource Business Center:
- Test: https://businesscentertest.cybersource.com/ebc2
- Production: https://businesscenter.cybersource.com/ebc2
_configurationDictionary.Add("authenticationType", "JWT");
_configurationDictionary.Add("merchantID", "your_merchant_id");
_configurationDictionary.Add("runEnvironment", "apitest.cybersource.com");
_configurationDictionary.Add("jwtKeyType", "SHARED_SECRET");
_configurationDictionary.Add("merchantKeyId", "your_key_id");
_configurationDictionary.Add("merchantsecretKey", "your_base64_encoded_shared_secret");
// Request MLE configuration
_configurationDictionary.Add("enableRequestMLEForOptionalApisGlobally", "true");
_configurationDictionary.Add("mleForRequestPublicCertPath", @"C:\path\to\mle\public\cert.pem");For more details on MLE configuration options (including Response MLE), see MLE.md.
A Meta Key is a single key that can be used by one, some, or all merchants (or accounts, if created by a Portfolio user) in the portfolio.
The Portfolio or Parent Account owns the key and is considered the transaction submitter when a Meta Key is used, while the merchant owns the transaction.
Merchant IDs continue to be able to create keys for themselves, even if a Meta Key is generated.
MetaKey works with all three authentication types: HTTP Signature, JWT (P12), and JWT with Shared Secret.
Further information on MetaKey can be found in New Business Center User Guide.
- Fork the repo and create your branch from
master. - If you've added code that should be tested, add tests.
- Ensure the test suite passes.
- Submit your pull request! (Ensure you have synced your fork with the original repository before initiating the PR).
For any help, you can reach out to us at our Discussion Forum.
CyberSource may allow Customer to access, use, and/or test a CyberSource product or service that may still be in development or has not been market-tested (“Beta Product”) solely for the purpose of evaluating the functionality or marketability of the Beta Product (a “Beta Evaluation”). Notwithstanding any language to the contrary, the following terms shall apply with respect to Customer’s participation in any Beta Evaluation (and the Beta Product(s)) accessed thereunder: The Parties will enter into a separate form agreement detailing the scope of the Beta Evaluation, requirements, pricing, the length of the beta evaluation period (“Beta Product Form”). Beta Products are not, and may not become, Transaction Services and have not yet been publicly released and are offered for the sole purpose of internal testing and non-commercial evaluation. Customer’s use of the Beta Product shall be solely for the purpose of conducting the Beta Evaluation. Customer accepts all risks arising out of the access and use of the Beta Products. CyberSource may, in its sole discretion, at any time, terminate or discontinue the Beta Evaluation. Customer acknowledges and agrees that any Beta Product may still be in development and that Beta Product is provided “AS IS” and may not perform at the level of a commercially available service, may not operate as expected and may be modified prior to release. CYBERSOURCE SHALL NOT BE RESPONSIBLE OR LIABLE UNDER ANY CONTRACT, TORT (INCLUDING NEGLIGENCE), OR OTHERWISE RELATING TO A BETA PRODUCT OR THE BETA EVALUATION (A) FOR LOSS OR INACCURACY OF DATA OR COST OF PROCUREMENT OF SUBSTITUTE GOODS, SERVICES OR TECHNOLOGY, (B) ANY CLAIM, LOSSES, DAMAGES, OR CAUSE OF ACTION ARISING IN CONNECTION WITH THE BETA PRODUCT; OR (C) FOR ANY INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES INCLUDING, BUT NOT LIMITED TO, LOSS OF REVENUES AND LOSS OF PROFITS.
This repository is distributed under a proprietary license.