Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLE implementation #120

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f916928
add MLE implementation
monu-kumar-visa Feb 5, 2025
516933d
created a method for request body
monu-kumar-visa Feb 5, 2025
64bef5b
mustache file changes
monu-kumar-visa Feb 6, 2025
245322e
corrected mustache changes
monu-kumar-visa Feb 6, 2025
750c3a8
Merge remote-tracking branch 'origin/master' into feature/mle-impleme…
monu-kumar-visa Feb 6, 2025
f5306bd
minor fix
monu-kumar-visa Feb 7, 2025
6c00f39
resolved PR comments
monu-kumar-visa Feb 10, 2025
df69aa5
checking keys type in mapToControlMLE hash
monu-kumar-visa Feb 10, 2025
c606460
added cache
monu-kumar-visa Feb 10, 2025
a5685d6
corrected log level and message
monu-kumar-visa Feb 11, 2025
727836f
minor fix
monu-kumar-visa Feb 11, 2025
4914d21
fix for appending bactrace in exception message
monu-kumar-visa Feb 11, 2025
6925d42
corrected map check and mustache file
monu-kumar-visa Feb 11, 2025
3330e4e
added empty json check
monu-kumar-visa Feb 11, 2025
608f19d
resolving pr comment and removed unused function
monu-kumar-visa Feb 13, 2025
16f9322
corrected error throw in case of incorrect auth type for MLE
monu-kumar-visa Feb 13, 2025
1e3a469
add MLE.md
monu-kumar-visa Feb 18, 2025
1db105f
added MLE section in readme and add sample codes link
monu-kumar-visa Feb 27, 2025
200b8fb
Deprecated method for JWE decryption
gnongsie Feb 28, 2025
18c16d0
Changes from API updates - Feb 2025
gnongsie Feb 28, 2025
c52ab56
Enforced sensitive masking of logs
gnongsie Mar 21, 2025
159eadc
Enforced sensitive masking of logs
gnongsie Mar 21, 2025
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
109 changes: 109 additions & 0 deletions MLE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
[![Generic badge](https://img.shields.io/badge/MLE-NEW-GREEN.svg)](https://shields.io/)

# Message Level Encryption (MLE) Feature

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.

## Configuration

### Global MLE Configuration

In the `merchantConfig` object, set the `useMLEGlobally` variable to enable or disable MLE for all supported APIs for the Rest SDK.

- **Variable**: `useMLEGlobally`
- **Type**: `Boolean`
- **Default**: `false`
- **Description**: Enables MLE globally for all APIs when set to `true`. If set to `true`, it will enable MLE for all API calls that support MLE by CyberSource, unless overridden by `mapToControlMLEonAPI`.

### API-level MLE Control

Optionally, you can control the MLE feature at the API level using the `mapToControlMLEonAPI` variable in the `merchantConfig` object.

- **Variable**: `mapToControlMLEonAPI`
- **Type**: `Hash of string to boolean`
- **Description**: Overrides the global MLE setting for specific APIs. The key is the function name of the API in the SDK, and the value is a boolean indicating whether MLE should be enabled (`true`) or disabled (`false`) for that specific API call.

### MLE Key Alias

Another optional parameter for MLE is `mleKeyAlias`, which specifies the key alias used to retrieve the MLE certificate from the JWT P12 file.

- **Variable**: `mleKeyAlias`
- **Type**: `String`
- **Default**: `CyberSource_SJC_US`
- **Description**: By default, CyberSource uses the `CyberSource_SJC_US` public certificate to encrypt the payload. However, users can override this default value by setting their own key alias.

## Notes

- If `useMLEGlobally` is set to true, it will enable MLE for all API calls that support MLE by CyberSource, unless overridden by `mapToControlMLEonAPI`.
- If `mapToControlMLEonAPI` is not provided or does not contain a specific API function name, the global `useMLEGlobally` setting will be applied.
- The `mleKeyAlias` parameter is optional and defaults to `CyberSource_SJC_US` if not specified by the user. Users can override this default value by setting their own key alias.
- Example configurations contain only properties related to MLE.

## Example Configuration

### Option 1: Enable MLE globally for all MLE supported APIs

```ruby
configuration_dictionary = {
"useMLEGlobally": true # Globally MLE will be enabled for all MLE supported APIs
}
```

### Option 2: Enable/Disable MLE for specific APIs

```ruby
configuration_dictionary = {}
configuration_dictionary['useMLEGlobally'] = true # globally MLE will be enabled for all the MLE supported APIs by Cybs in SDK
mapToControlMLE = {
'create_payment' => false, # only create_payment function will have MLE=false i.e. (/pts/v2/payments POST API) out of all MLE supported APIs
'capture_payment' => true # capture_payment function will have MLE=true i.e. (/pts/v2/payments/{id}/captures POST API), if it not in list of MLE supportedAPIs else it will already have MLE=true by global MLE parameter.
}
configuration_dictionary['mapToControlMLEonAPI'] = mapToControlMLE
# Set other properties
api_client = CyberSource::ApiClient.new
# Create API instance using the configuration dictionary
api_instance = CyberSource::PaymentsApi.new(api_client, configuration_dictionary)

```

### Option 3: Disable MLE globally and enable for specific APIs

```ruby
configuration_dictionary = {
"useMLEGlobally": false, # Globally MLE will be disabled for all APIs
"mleKeyAlias": "Custom_Key_Alias" # optional if any custom value provided by Cybs
}
mapToControlMLE = {
'apiFunctionName1' => false, # MLE will be disabled for this API
'apiFunctionName2' => true # MLE will be enabled for this API
}
configuration_dictionary['mapToControlMLEonAPI'] = mapToControlMLE
```

In the above examples:
- MLE is enabled/disabled globally (`useMLEGlobally` is true/false).
- `apiFunctionName1` will have MLE disabled/enabled based on value provided.
- `apiFunctionName2` will have MLE enabled.
- `mleKeyAlias` is set to `Custom_Key_Alias`, overriding the default value.

Please refer to the given link for sample codes with MLE: [MLE Samples](https://github.com/CyberSource/cybersource-rest-samples-ruby/tree/master/Samples/MLEFeature)


## Additional Information

### API Support

- MLE is initially designed to support a few APIs.
- It can be extended to support more APIs in the future based on requirements and updates.

### Authentication Type

- MLE is only supported with `JWT (JSON Web Token)` authentication type within the SDK.

### Using the SDK

To use the MLE feature in the SDK, configure the `merchantConfig` object as shown above and pass it to the SDK initialization.

## Contact

For any issues or further assistance, please open an issue on the GitHub repository or contact our support team.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ API credentials are different for each environment, so be sure to switch to the

## Features

### Message Level Encryption (MLE) Feature
[![Generic badge](https://img.shields.io/badge/MLE-NEW-GREEN.svg)](https://shields.io/)

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](MLE.md)

### MetaKey Support

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**parent_profile_id** | **String** | Specify the Vault ID to which transacting MID needs to be assigned.Provide Vault ID as seen on EBC Vault management page. If not provided , transacting MID will be assigned to the existing default Vault at merchant's level. If there are no Vaults at merchant level , a new Vault will be created and transacting MID will be assigned to it. | [optional]
**vault** | [**CommerceSolutionsProductsTokenManagementConfigurationInformationConfigurationsVault**](CommerceSolutionsProductsTokenManagementConfigurationInformationConfigurationsVault.md) | | [optional]
**network_token_enrollment** | [**NetworkTokenEnrollment**](NetworkTokenEnrollment.md) | | [optional]


3 changes: 2 additions & 1 deletion docs/GenerateCaptureContextRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**client_version** | **String** | Specify the version of Microform that you want to use. | [optional]
**target_origins** | **Array<String>** | The [target origin](https://developer.mozilla.org/en-US/docs/Glossary/Origin) of the website on which you will be launching Microform is defined by the scheme (protocol), hostname (domain) and port number (if used). You must use https://hostname (unless you use http://localhost) Wildcards are NOT supported. Ensure that subdomains are included. Any valid top-level domain is supported (e.g. .com, .co.uk, .gov.br etc) Examples: - https://example.com - https://subdomain.example.com - https://example.com:8080<br><br> If you are embedding within multiple nested iframes you need to specify the origins of all the browser contexts used, for example: targetOrigins: [ \"https://example.com\", \"https://basket.example.com\", \"https://ecom.example.com\" ] | [optional]
**allowed_card_networks** | **Array<String>** | The list of card networks you want to use for this Microform transaction. Microform currently supports the following card networks: - VISA - MASTERCARD - AMEX - CARNET - CARTESBANCAIRES - CUP - DINERSCLUB - DISCOVER - EFTPOS - ELO - JCB - JCREW - MADA - MAESTRO - MEEZA **Important:** - When integrating Microform (Accept Card) at least one card network should be specified in the allowedCardNetworks field in the capture context request. - When integrating Microform (Accept Check) the allowedCardNetworks field is not required in the capture context request. - When integrating both Microform (Accept Card) and Microform (Accept Check) at least one card network should be specified in the allowedCardNetworks field in the capture context request. | [optional]
**allowed_card_networks** | **Array<String>** | The list of card networks you want to use for this Microform transaction. Microform currently supports the following card networks: - VISA - MASTERCARD - AMEX - CARNET - CARTESBANCAIRES - CUP - DINERSCLUB - DISCOVER - EFTPOS - ELO - JCB - JCREW - MADA - MAESTRO - MEEZA **Important:** - When integrating Microform (Card) at least one card network should be specified in the allowedCardNetworks field in the capture context request. - When integrating Microform (ACH/Echeck) the allowedCardNetworks field is not required in the capture context request. - When integrating both Microform (Card) and Microform (ACH/Echeck) at least one card network should be specified in the allowedCardNetworks field in the capture context request. | [optional]
**allowed_payment_types** | **Array<String>** | The payment types that are allowed for the merchant. Possible values when launching Microform: - CARD - CHECK <br><br> | [optional]
**transient_token_response_options** | [**Microformv2sessionsTransientTokenResponseOptions**](Microformv2sessionsTransientTokenResponseOptions.md) | | [optional]


1 change: 1 addition & 0 deletions docs/GenerateUnifiedCheckoutCaptureContextRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ Name | Type | Description | Notes
**locale** | **String** | Localization of the User experience conforming to the ISO 639-1 language standards and two-character ISO Standard Country Code. Please refer to list of [supported locales through Unified Checkout](https://developer.cybersource.com/docs/cybs/en-us/unified-checkout/developer/all/rest/unified-checkout/uc-appendix-languages.html) | [optional]
**capture_mandate** | [**Upv1capturecontextsCaptureMandate**](Upv1capturecontextsCaptureMandate.md) | | [optional]
**order_information** | [**Upv1capturecontextsOrderInformation**](Upv1capturecontextsOrderInformation.md) | | [optional]
**transient_token_response_options** | [**Microformv2sessionsTransientTokenResponseOptions**](Microformv2sessionsTransientTokenResponseOptions.md) | | [optional]


8 changes: 8 additions & 0 deletions docs/Microformv2sessionsTransientTokenResponseOptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# CyberSource::Microformv2sessionsTransientTokenResponseOptions

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**include_card_prefix** | **BOOLEAN** | Use the transientTokenResponseOptions.includeCardPrefix field to choose your preferred card number prefix length: 6-digit, 8-digit, or no card number prefix. Possible values: - True - False<br><br> To select the type of card number prefix: - No field included: A 6-digit prefix is returned (default) - True: An 8-digit prefix is returned - False: No prefix is returned<br><br> The following conditions apply: - 8-digit card number prefixes only apply to Discover, JCB, Mastercard, UnionPay, and Visa brands with 16-digit card numbers or more. - Any card with less than 16-digit numbers will return a 6-digit prefix even when the transientTokenResponseOptions.includeCardPrefix field is set to true. - Any card brand other than Discover, JCB, Mastercard, UnionPay, or Visa will return a 6-digit prefix even when the transientTokenResponseOptions.includeCardPrefix field is set to true. - If any card brand is co-branded with Discover, JCB, Mastercard, UnionPay, or Visa, an 8-digit prefix will be returned if the transientTokenResponseOptions.includeCardPrefix field is set to true.<br><br> **Important:** If your application does NOT require a card number prefix for routing or identification purposes, set the transientTokenResponseOptions.includeCardPrefix field to False. This will minimize your personal data exposure. | [optional]


9 changes: 9 additions & 0 deletions docs/NetworkTokenEnrollment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CyberSource::NetworkTokenEnrollment

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**business_information** | [**TmsBusinessInformation**](TmsBusinessInformation.md) | | [optional]
**network_token_services** | [**NetworkTokenServicesEnablement**](NetworkTokenServicesEnablement.md) | | [optional]


9 changes: 9 additions & 0 deletions docs/NetworkTokenServicesEnablement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CyberSource::NetworkTokenServicesEnablement

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**visa_token_service** | [**NetworkTokenServicesEnablementVisaTokenService**](NetworkTokenServicesEnablementVisaTokenService.md) | | [optional]
**mastercard_digital_enablement_service** | [**NetworkTokenServicesEnablementMastercardDigitalEnablementService**](NetworkTokenServicesEnablementMastercardDigitalEnablementService.md) | | [optional]


Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# CyberSource::NetworkTokenServicesEnablementMastercardDigitalEnablementService

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**enrollment** | **BOOLEAN** | Indicates if an enrollment to create a TRID for the MasterCard card association should be attempted | [optional]


8 changes: 8 additions & 0 deletions docs/NetworkTokenServicesEnablementVisaTokenService.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# CyberSource::NetworkTokenServicesEnablementVisaTokenService

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**enrollment** | **BOOLEAN** | Indicates if an enrollment to create a TRID for the Visa card association should be attempted | [optional]


14 changes: 14 additions & 0 deletions docs/TmsBusinessInformation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# CyberSource::TmsBusinessInformation

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **String** | Name of the network token merchant. | [optional]
**doing_business_as** | **String** | Name the network token merchant does business as | [optional]
**address** | [**TmsBusinessInformationAddress**](TmsBusinessInformationAddress.md) | | [optional]
**website_url** | **String** | Website of network token merchant. | [optional]
**business_identification_type** | **String** | The Identifier associated with the business type; required unless both acquirerId and acquirerMerchantId are provided. | [optional]
**business_identification_value** | **String** | The value associated with the business identifier type; required unless both acquirerId and acquirerMerchantId are provided. | [optional]
**acquirer** | [**TmsBusinessInformationAcquirer**](TmsBusinessInformationAcquirer.md) | | [optional]


9 changes: 9 additions & 0 deletions docs/TmsBusinessInformationAcquirer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CyberSource::TmsBusinessInformationAcquirer

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**acquirer_id** | **String** | Acquirer ID; required unless both businessIdentificationType and businessIdentificationValue are provided. | [optional]
**acquirer_merchant_id** | **String** | Acquirer merchant ID; required unless both businessIdentificationType and businessIdentificationValue are provided. | [optional]


9 changes: 9 additions & 0 deletions docs/TmsBusinessInformationAddress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CyberSource::TmsBusinessInformationAddress

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**country** | **String** | Country of network token merchant. | [optional]
**locality** | **String** | City of network token merchant. | [optional]


2 changes: 2 additions & 0 deletions docs/Upv1capturecontextsCaptureMandate.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ Name | Type | Description | Notes
**request_shipping** | **BOOLEAN** | Configure Unified Checkout to capture customer shipping details. Possible values: - True - False | [optional]
**ship_to_countries** | **Array<String>** | List of countries available to ship to. Use the two-character ISO Standard Country Codes. | [optional]
**show_accepted_network_icons** | **BOOLEAN** | Configure Unified Checkout to display the list of accepted card networks beneath the payment button Possible values: - True - False | [optional]
**request_save_card** | **BOOLEAN** | Configure Unified Checkout to display the \"Save card for future use\" checkbox.<br> Configurable check box that will show in a Manual card entry flow to allow a Cardholder to give consent to store their manually entered credential with the Merchant that they are paying.<br> Applicable when manually entering the details and not enrolling in Click to Pay. Possible values: - True - False<br><br> **Use Cases:** **Offer consumers option to save their card in Unified Checkout:** - Include the captureMandate.requestSaveCard field in the capture context request and set it to true. - When set to true, this will show a checkbox with the message 'Save card for future use' in Unified Checkout. - When selected this provides a response in both the Transient Token and Get Credentials API response.<br><br> **Do not offer consumers the option to save their card in Unified Checkout:** - Include the captureMandate.requestSaveCard field in the capture context request and set it to false OR omit the field from the capture context request. - When set to false, the save card option is not shown to consumers when manually entering card details. | [optional]
**combo_card** | **BOOLEAN** | Configure Unified Checkout to display combo card at checkout.<br> A combo debit/credit card is a single card that functions both as a Debit/Credit card. Unified Checkout / Click to Pay Drop-in UI allows the Cardholder to choose whether they would like the transaction to be paid for using either debit or credit card. **Important:** This is applicable to Visa cards only. Possible values: - True - False<br><br> **Use Cases:** **Offer Combo Card at Checkout:** - Include the captureMandate.comboCard field in the capture context request and set it to true. - When set to true, Combo Card selection is shown at checkout <br><br> **Do not offer Combo Card at Checkout:** - Include the captureMandate.comboCard field in the capture context request and set it to false OR omit the field from the capture context request. - The Combo Card selection is not shown at checkout. | [optional]


Loading