Skip to content

Commit 2315d40

Browse files
authored
Merge pull request #17 from CyberSource/release-25.2.0
added support for MLE
2 parents 2b9ddda + 9c60ec2 commit 2315d40

File tree

21 files changed

+499
-74
lines changed

21 files changed

+499
-74
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
### **Cybersource Storefront Reference Architecture Quick Launch Cartridge** ###
1+
### **Cybersource Storefront Reference Architecture Quick Launch Cartridge**
22

3+
- **Description:** Cybersource, a Visa solution, is the only global, modular payment management platform built on secure Visa infrastructure with the payment reach and fraud insights of a massive $500B+ global processing network. You can find out more about what Cybersource does [here](https://www.cybersource.com/en-gb.html)
4+
- **Categories:** Payment Processing, Fraud Detection, Address Validation, Tax Computation
5+
- **Version:** 25.2.0
6+
- **Last Certification Date:** March 2025
7+
- **Supports SFRA v7.0**
8+
- **JavaScript Controllers Friendly:** **YES**
39

4-
* **Description:** Cybersource, a Visa solution, is the only global, modular payment management platform built on secure Visa infrastructure with the payment reach and fraud insights of a massive $500B+ global processing network. You can find out more about what Cybersource does [here](https://www.cybersource.com/en-gb.html)
5-
* **Categories:** Payment Processing, Fraud Detection, Address Validation, Tax Computation
6-
* **Version:** 25.1.0
7-
* **Last Certification Date:** January 2025
8-
* **Supports SFRA v7.0**
9-
* **JavaScript Controllers Friendly:** **YES**
10+
### Contact
1011

11-
### Contact ###
12-
* <globalpartnersolutionscs@visa.com>
12+
- <globalpartnersolutionscs@visa.com>
1313

14-
----
14+
---
1515

16-
### Installation Guide ###
16+
### Installation Guide
1717

18-
1. [Install the Cartridge and Setup Workspace](documentation/markdown/Install-catridge-WrkSpace-Setup.md)
19-
2. [Configure the Cartridge](documentation/markdown/Configure-cartridge.md)
20-
3. [Configure the Payment Method](documentation/markdown/Configure-payment-method.md)
21-
4. [Configure features (OPTIONAL)](documentation/markdown/Configure-features.md)
22-
5. [Test and go live](documentation/markdown/Test-golive.md)
23-
6. [Release Notes](documentation/markdown/Release-notes.md)
18+
1. [Install the Cartridge and Setup Workspace](documentation/markdown/Install-catridge-WrkSpace-Setup.md)
19+
2. [Configure the Cartridge](documentation/markdown/Configure-cartridge.md)
20+
3. [Configure the Payment Method](documentation/markdown/Configure-payment-method.md)
21+
4. [Configure features (OPTIONAL)](documentation/markdown/Configure-features.md)
22+
5. [Test and go live](documentation/markdown/Test-golive.md)
23+
6. [Release Notes](documentation/markdown/Release-notes.md)

cartridges/int_cybs_sfra/cartridge/client/default/custom/flexMicroform.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'use strict';
44

55
$(document).ready(function () {
6-
var captureContext = $('#flexTokenResponse').val();
6+
var captureContext = JSON.parse($('#flexTokenResponse').val()).keyId;
77
var flex = new Flex(captureContext); // eslint-disable-line no-undef
88
var customStyles = {
99
input: {
@@ -25,7 +25,7 @@ $(document).ready(function () {
2525
color: '#a94442'
2626
}
2727
};
28-
var microform = flex.microform("card",{
28+
var microform = flex.microform({
2929
styles: customStyles
3030
});
3131
var number = microform.createField('number');
@@ -107,7 +107,7 @@ $(document).ready(function () {
107107
var decodedJwt = parseJwt(response);
108108
document.getElementById('cardNumber').valid = true;
109109
$('#flex-response').val(response);
110-
$('#cardNumber').val(decodedJwt.content.paymentInformation.card.number.maskedValue);
110+
$('#cardNumber').val(decodedJwt.data.number);
111111

112112
if ($('.submit-payment').length === 1) {
113113
$('.submit-payment').trigger('click');
@@ -137,7 +137,7 @@ $(document).ready(function () {
137137
case 'discover':
138138
correctCardType = 'Discover';
139139
break;
140-
case 'dinersclub':
140+
case 'diners-club':
141141
correctCardType = 'DinersClub';
142142
break;
143143
case 'maestro':
@@ -146,6 +146,18 @@ $(document).ready(function () {
146146
case 'jcb':
147147
correctCardType = 'JCB';
148148
break;
149+
case "cartesbancaires":
150+
correctCardType = "CartesBancaires";
151+
break;
152+
case "elo":
153+
correctCardType = "Elo";
154+
break;
155+
case "cup":
156+
correctCardType = "China UnionPay";
157+
break;
158+
case "jcrew":
159+
correctCardType = "JCrew";
160+
break;
149161
}
150162
$('#cardType').val(correctCardType);
151163
}

cartridges/int_cybs_sfra_base/cartridge/apiClient/ApiClient.js

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,40 @@ var Bytes = require('dw/util/Bytes');
33
var Encoding = require('dw/crypto/Encoding');
44
var Mac = require('dw/crypto/Mac');
55
var MessageDigest = require('dw/crypto/MessageDigest');
6-
6+
var configObject = require('*/cartridge/configuration/index');
77
var MerchantConfig = require('./merchantConfig');
88
var Logger = require('./logger');
99

10-
var _exports = function () {}
11-
12-
_exports.prototype.createService = function (){
13-
var PaymentsHttpService = dw.svc.LocalServiceRegistry.createService("PaymentHttpService", {
14-
createRequest: function (svc, url, headers, method, requestBody) {
15-
var keys = Object.keys(headers);
16-
var StringHeaders = "";
17-
for (var i = 0; i < keys.length; i++) {
18-
var key = keys[i];
19-
svc.addHeader(key, headers[key]);
20-
StringHeaders += key + ":" + headers[key] + "\n";
21-
}
22-
svc.URL = url;
23-
svc.setRequestMethod(method.toUpperCase());
24-
if (method.toUpperCase() === 'POST' || method.toUpperCase() === 'PATCH') {
25-
if (typeof requestBody === 'string') {
26-
return requestBody;
10+
var _exports = function () { }
11+
12+
_exports.prototype.createService = function () {
13+
var PaymentsHttpService = dw.svc.LocalServiceRegistry.createService("PaymentHttpService", {
14+
createRequest: function (svc, url, headers, method, requestBody) {
15+
var keys = Object.keys(headers);
16+
var StringHeaders = "";
17+
for (var i = 0; i < keys.length; i++) {
18+
var key = keys[i];
19+
svc.addHeader(key, headers[key]);
20+
StringHeaders += key + ":" + headers[key] + "\n";
21+
}
22+
svc.URL = url;
23+
svc.setRequestMethod(method.toUpperCase());
24+
if (method.toUpperCase() === 'POST' || method.toUpperCase() === 'PATCH') {
25+
if (typeof requestBody === 'string') {
26+
return requestBody;
27+
}
28+
return JSON.stringify(requestBody);
2729
}
28-
return JSON.stringify(requestBody);
30+
},
31+
parseResponse: function (svc, client) {
32+
return client.text;
33+
},
34+
filterLogMessage: function (msg) {
35+
// No need to filter logs. No sensitive information.
36+
return msg;
2937
}
30-
},
31-
parseResponse: function (svc, client) {
32-
return client.text;
33-
},
34-
filterLogMessage: function (msg) {
35-
// No need to filter logs. No sensitive information.
36-
return msg;
37-
}
38-
});
39-
return PaymentsHttpService;
38+
});
39+
return PaymentsHttpService;
4040
};
4141

4242
_exports.prototype.setConfiguration = function (configObject) {
@@ -183,7 +183,7 @@ _exports.prototype.normalizeParams = function (params) {
183183
return newParams;
184184
}
185185

186-
_exports.prototype.callApi = function (path, httpMethod, pathParams, queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts, returnType, callback) {
186+
_exports.prototype.callApi = function (path, httpMethod, pathParams, queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts, returnType, callback, isMLESupportedByCybsForApi) {
187187
var requestHost = this.basePath.substr(
188188
this.basePath.indexOf("//") + 2
189189
);
@@ -219,6 +219,13 @@ _exports.prototype.callApi = function (path, httpMethod, pathParams, queryParams
219219
}
220220
payload = JSON.stringify(bodyParam);
221221

222+
var isMLEEnabled = configObject.mleEnabled;
223+
224+
if (isMLEEnabled && isMLESupportedByCybsForApi == true) {
225+
var encryptPayload = require('*/cartridge/scripts/mleEncrypt/jweEncrypt.js');
226+
payload = encryptPayload.getJWE(payload);
227+
228+
}
222229
var signature = this.getHttpSignature(resource, method, merchantKeyId, requestHost, merchantId, merchantSecretKey, payload);
223230
var digest = this.generateDigest(payload);
224231
digest = "SHA-256=" + digest;
@@ -247,9 +254,9 @@ _exports.prototype.callApi = function (path, httpMethod, pathParams, queryParams
247254

248255
if (response.ok) {
249256
var responseObj = response.object;
250-
if(path === '/microform/v2/sessions'){
257+
if (path === '/microform/v2/sessions') {
251258
callback(responseObj, false, response);
252-
}else{
259+
} else {
253260
callback(JSON.parse(responseObj), false, response);
254261
}
255262
} else {

cartridges/int_cybs_sfra_base/cartridge/apiClient/api/CaptureApi.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,12 @@
9393
var contentTypes = ['application/json;charset=utf-8'];
9494
var accepts = ['application/hal+json;charset=utf-8'];
9595
var returnType = PtsV2PaymentsCapturesPost201Response;
96+
var isMLESupportedByCybsForApi = true;
9697

9798
return this.apiClient.callApi(
9899
'/pts/v2/payments/{id}/captures', 'POST',
99100
pathParams, queryParams, headerParams, formParams, postBody,
100-
authNames, contentTypes, accepts, returnType, callback
101+
authNames, contentTypes, accepts, returnType, callback, isMLESupportedByCybsForApi
101102
);
102103
}
103104
};

cartridges/int_cybs_sfra_base/cartridge/apiClient/api/PayerAuthenticationApi.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@
8686
var contentTypes = ['application/json;charset=utf-8'];
8787
var accepts = ['application/hal+json;charset=utf-8'];
8888
var returnType = RiskV1AuthenticationsPost201Response;
89+
var isMLESupportedByCybsForApi = true;
8990

9091
return this.apiClient.callApi(
9192
'/risk/v1/authentications', 'POST',
9293
pathParams, queryParams, headerParams, formParams, postBody,
93-
authNames, contentTypes, accepts, returnType, callback
94+
authNames, contentTypes, accepts, returnType, callback, isMLESupportedByCybsForApi
9495
);
9596
}
9697

@@ -131,11 +132,12 @@
131132
var contentTypes = ['application/json;charset=utf-8'];
132133
var accepts = ['application/hal+json;charset=utf-8'];
133134
var returnType = RiskV1AuthenticationSetupsPost201Response;
135+
var isMLESupportedByCybsForApi = true;
134136

135137
return this.apiClient.callApi(
136138
'/risk/v1/authentication-setups', 'POST',
137139
pathParams, queryParams, headerParams, formParams, postBody,
138-
authNames, contentTypes, accepts, returnType, callback
140+
authNames, contentTypes, accepts, returnType, callback, isMLESupportedByCybsForApi
139141
);
140142
}
141143

@@ -176,11 +178,12 @@
176178
var contentTypes = ['application/json;charset=utf-8'];
177179
var accepts = ['application/hal+json;charset=utf-8'];
178180
var returnType = RiskV1AuthenticationResultsPost201Response;
181+
var isMLESupportedByCybsForApi = true;
179182

180183
return this.apiClient.callApi(
181184
'/risk/v1/authentication-results', 'POST',
182185
pathParams, queryParams, headerParams, formParams, postBody,
183-
authNames, contentTypes, accepts, returnType, callback
186+
authNames, contentTypes, accepts, returnType, callback, isMLESupportedByCybsForApi
184187
);
185188
}
186189
};

cartridges/int_cybs_sfra_base/cartridge/apiClient/api/PaymentInstrumentApi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,4 @@
254254
};
255255

256256
return exports;
257-
}));
257+
}));

cartridges/int_cybs_sfra_base/cartridge/apiClient/api/PaymentsApi.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@
8686
var contentTypes = ['application/json;charset=utf-8'];
8787
var accepts = ['application/hal+json;charset=utf-8'];
8888
var returnType = PtsV2PaymentsPost201Response;
89+
var isMLESupportedByCybsForApi = true;
8990

9091
return this.apiClient.callApi(
9192
'/pts/v2/payments', 'POST',
9293
pathParams, queryParams, headerParams, formParams, postBody,
93-
authNames, contentTypes, accepts, returnType, callback
94+
authNames, contentTypes, accepts, returnType, callback, isMLESupportedByCybsForApi
9495
);
9596
}
9697

@@ -138,11 +139,12 @@
138139
var contentTypes = ['application/json;charset=utf-8'];
139140
var accepts = ['application/hal+json;charset=utf-8'];
140141
var returnType = PtsV2IncrementalAuthorizationPatch201Response;
142+
var isMLESupportedByCybsForApi = true;
141143

142144
return this.apiClient.callApi(
143145
'/pts/v2/payments/{id}', 'PATCH',
144146
pathParams, queryParams, headerParams, formParams, postBody,
145-
authNames, contentTypes, accepts, returnType, callback
147+
authNames, contentTypes, accepts, returnType, callback, isMLESupportedByCybsForApi
146148
);
147149
}
148150
};

cartridges/int_cybs_sfra_base/cartridge/apiClient/api/ReversalApi.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,12 @@
9393
var contentTypes = ['application/json;charset=utf-8'];
9494
var accepts = ['application/hal+json;charset=utf-8'];
9595
var returnType = PtsV2PaymentsReversalsPost201Response;
96+
var isMLESupportedByCybsForApi = true;
9697

9798
return this.apiClient.callApi(
9899
'/pts/v2/payments/{id}/reversals', 'POST',
99100
pathParams, queryParams, headerParams, formParams, postBody,
100-
authNames, contentTypes, accepts, returnType, callback
101+
authNames, contentTypes, accepts, returnType, callback, isMLESupportedByCybsForApi
101102
);
102103
}
103104

cartridges/int_cybs_sfra_base/cartridge/apiClient/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = {
3131
SANDBOX_RUN_ENV: "cybersource.environment.sandbox",
3232
PRODUCTION_RUN_ENV: "cybersource.environment.production",
3333
APPLICATION_NAME: "Salesforce B2C(REST)",
34-
APPLICATION_VERSION: "25.1.0",
34+
APPLICATION_VERSION: "25.2.0",
3535

3636
/* Digest Constants*/
3737
SIGNATURE_ALGORITHAM: "SHA-256=",

cartridges/int_cybs_sfra_base/cartridge/configuration/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var LogfileMaxSize = '5242880'; // 10 MB In Bytes
2323
* Send this value in all requests that are sent through the partner solution. CyberSource assigns the ID to the partner.
2424
* Note When you see a partner ID of 999 in reports, the partner ID that was submitted is incorrect.
2525
*/
26-
var SolutionId = 'FTN2UOLO';
26+
var SolutionId = 'GTIWK1VH';
2727

2828
var CruiseDDCEndPoint = {
2929
Stage: 'https://centinelapistag.cardinalcommerce.com/V1/Cruise/Collect',
@@ -127,10 +127,15 @@ function getConfig(config) {
127127
googlePayEnvironment: config.googlePayEnvironment || customPreferences.GooglePay.Preferences.GooglePayEnvironment.getValue(),
128128
enableGooglePayOnCart: config.enableGooglePayOnCart || customPreferences.GooglePay.Preferences.EnableGooglePayOnCart.getValue(),
129129

130-
// DecisionManager
130+
// Click to pay
131131
visaSRCEnabled: config.vscCheckoutEnabled || customPreferences.ClicktoPay.Preferences.ClicktoPayEnabled.getValue(),
132132
visaSRCKey: config.visaSRCKey || customPreferences.ClicktoPay.Preferences.ClicktoPayKey.getValue(),
133-
VisaSRCProduction: config.VisaSRCProduction || customPreferences.ClicktoPay.Preferences.ClicktoPayProduction.getValue()
133+
VisaSRCProduction: config.VisaSRCProduction || customPreferences.ClicktoPay.Preferences.ClicktoPayProduction.getValue(),
134+
135+
//MLE
136+
mleEnabled: config.mleEnabled || customPreferences.MLE.Preferences.EnableMLE.getValue(),
137+
mleCertificateSerialNumber: config.mleCertificateSerialNumber || customPreferences.MLE.Preferences.MLECertificateSerialNumber.getValue(),
138+
mleCertificateAlias: config.mleCertificateAlias || customPreferences.MLE.Preferences.MLECertificateAlias.getValue()
134139
};
135140
}
136141
module.exports = getConfig();

0 commit comments

Comments
 (0)