Skip to content

Commit

Permalink
release-24.2.0 (int_checkoutcom_sfra @24.2.0) (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
shine-tryzens authored Dec 4, 2024
1 parent 2517ec4 commit 41dfd62
Show file tree
Hide file tree
Showing 112 changed files with 14,156 additions and 1,414 deletions.
17 changes: 6 additions & 11 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
{
"extends": "stylelint-config-standard",
"plugins": [
"stylelint-scss"
],
"extends": "stylelint-config-standard-scss",
"rules": {
"indentation": 4,
"scss/at-import-no-partial-leading-underscore": true,
"at-rule-empty-line-before": [ "always", { "ignoreAtRules": ["else"], "ignore": ["blockless-after-same-name-blockless", "inside-block"] } ],
"at-rule-no-unknown": [true, { "ignoreAtRules": ["include", "each", "mixin", "if", "else", "content"] } ],
"color-function-notation": "legacy",
"scss/load-no-partial-leading-underscore": true,
"scss/at-import-partial-extension-blacklist": ["scss"],
"scss/dollar-variable-no-missing-interpolation": true,
"scss/media-feature-value-dollar-variable": "always",
"scss/selector-no-redundant-nesting-selector": true,
"at-rule-empty-line-before": [ "always", { "ignoreAtRules": ["else"], "ignore": ["blockless-after-same-name-blockless", "inside-block"] } ],
"block-closing-brace-newline-after": [ "always", { "ignoreAtRules": ["if", "else"] } ],
"selector-type-no-unknown": [true, { "ignoreTypes": ["isapplepay"]}],
"at-rule-no-unknown": [true, { "ignoreAtRules": ["include", "each", "mixin", "if", "else", "content"] } ]
"scss/selector-no-redundant-nesting-selector": true
}
}
Binary file modified Cartridges.zip
Binary file not shown.
7 changes: 5 additions & 2 deletions Cartridges/bm_checkoutcom/cartridge/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ var constants = {
CKO_BUSINESS_NAME: 'ckoBusinessName',
CKO_MODE: 'ckoMode',
CKO_DEBUG_ENABLED: 'ckoDebugEnabled',
CKO_SANDBOX_ABC_OR_NAS_ENABLED: 'ckoSandboxABCorNASEnabled',
CKO_LIVE_ABC_OR_NAS_ENABLED: 'ckoLiveABCorNASEnabled',
CKO_SANDBOX_NAS_ENABLED: 'ckoSandboxNASEnabled',
CKO_LIVE_NAS_ENABLED: 'ckoLiveNASEnabled',
CKO_REGION: 'ckoRegion',
CKO_REGION_END_POINT: 'ckoRegionEndPoint',
CKO_END_POINTS: /^https?:\/\/[^\/]+/,
};

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,18 @@ function remoteCall() {
// eslint-disable-next-line
var orderNumber = request.httpParameterMap.get('orderNo');

var OrderMgr = require('dw/order/OrderMgr');
var order = OrderMgr.getOrder(orderNumber);
// Prepare the payload
var gRequest = {
// eslint-disable-next-line
amount: formatedAmount, // eslint-disable-next-line
reference: orderNumber.value, // eslint-disable-next-line
chargeId: request.httpParameterMap.get('pid').stringValue,
service: order ? order.custom.orderProcessedByABCorNAS : '',
};

if (CKOHelper.getAbcOrNasEnabled().value === 'NAS' && task.value === 'capture') {
if (CKOHelper.getNasEnabled().value === 'NAS' && task.value === 'capture') {
gRequest.capture_type = 'NonFinal';
}

Expand Down Expand Up @@ -90,6 +93,7 @@ function remoteCall() {
amount: formatedAmount, // eslint-disable-next-line
reference: orderNumber.value, // eslint-disable-next-line
chargeId: request.httpParameterMap.get('pid').stringValue, // eslint-disable-next-line
service: order ? order.custom.orderProcessedByABCorNAS : '',
};

// eslint-disable-next-line
Expand All @@ -99,6 +103,7 @@ function remoteCall() {
chargeId: request.httpParameterMap.get('pid').stringValue, // eslint-disable-next-line
reference: orderNumber.value,
type: 'klarna',
service: order ? order.custom.orderProcessedByABCorNAS : '',
klarna: {
description: CKOHelper.getValue(constants.CKO_BUSINESS_NAME) !== '' && CKOHelper.getValue(constants.CKO_BUSINESS_NAME) !== 'undefined' // eslint-disable-next-line
? CKOHelper.getValue(constants.CKO_BUSINESS_NAME) : Site.getCurrent().httpHostName,
Expand Down
35 changes: 21 additions & 14 deletions Cartridges/bm_checkoutcom/cartridge/scripts/helpers/CKOHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ var CKOHelper = {
refundable_amount: this.getRefundableAmount(paymentInstruments),
captured_amount: this.getCapturedAmount(paymentInstruments),
data_type: paymentTransaction.type.toString(),
abcOrNasEnabled: result[j].custom.orderProcessedByABCorNAS,
nasEnabled: result[j].custom.orderProcessedByABCorNAS,
};

// Add the transaction
Expand Down Expand Up @@ -329,6 +329,11 @@ var CKOHelper = {
// Prepare the request URL and data
if (Object.prototype.hasOwnProperty.call(requestData, 'chargeId')) {
var requestUrl = serv.getURL().replace('chargeId', requestData.chargeId);
var regionEndPoint = this.getValue(constants.CKO_REGION_END_POINT);
var region = this.getValue(constants.CKO_REGION);
if (region && regionEndPoint && region.value !== 'Others') {
requestUrl = requestUrl.replace(constants.CKO_END_POINTS, regionEndPoint);
}
serv.setURL(requestUrl);
delete requestData.chargeId; // eslint-disable-line no-param-reassign
}
Expand Down Expand Up @@ -414,30 +419,32 @@ var CKOHelper = {

/**
* Get live or sandbox account keys.
* @param {string} service order processed by ABC or NAS
* @returns {Object} The configuration account keys
*/
getAccountKeys: function() {
getAccountKeys: function(service) {
var keys = {};
var str = this.getValue(constants.CKO_MODE) === 'live' ? 'Live' : 'Sandbox';
var liveOrSandboxPreference = (str === 'Live') ? constants.CKO_LIVE_ABC_OR_NAS_ENABLED : constants.CKO_SANDBOX_ABC_OR_NAS_ENABLED;
var abcOrNasEnabled = this.getValue(liveOrSandboxPreference);
var ckoMode = this.getValue(constants.CKO_MODE);
var str = ckoMode && ckoMode.value === 'live' ? 'Live' : 'Sandbox';
var liveOrSandboxPreference = (str === 'Live') ? constants.CKO_LIVE_NAS_ENABLED : constants.CKO_SANDBOX_NAS_ENABLED;
var nasEnabled = service || this.getValue(liveOrSandboxPreference);

keys.publicKey = this.getValue('cko' + str + abcOrNasEnabled + 'PublicKey');
keys.secretKey = this.getValue('cko' + str + abcOrNasEnabled + 'SecretKey');
keys.privateKey = this.getValue('cko' + str + abcOrNasEnabled + 'PrivateKey');
keys.publicKey = this.getValue('cko' + str + nasEnabled + 'PublicKey');
keys.secretKey = this.getValue('cko' + str + nasEnabled + 'SecretKey');
keys.privateKey = this.getValue('cko' + str + nasEnabled + 'PrivateKey');

return keys;
},

/**
* Get live or sandbox abc or nas enabled value.
* @returns {Object} The ABC or NAS value
* Get live or sandbox nas enabled value.
* @returns {Object} The NAS value
*/
getAbcOrNasEnabled: function() {
getNasEnabled: function() {
var str = this.getValue(constants.CKO_MODE) === 'live' ? 'Live' : 'Sandbox';
var liveOrSandboxPreference = (str === 'Live') ? constants.CKO_LIVE_ABC_OR_NAS_ENABLED : constants.CKO_SANDBOX_ABC_OR_NAS_ENABLED;
var abcOrNasEnabled = this.getValue(liveOrSandboxPreference);
return abcOrNasEnabled;
var liveOrSandboxPreference = (str === 'Live') ? constants.CKO_LIVE_NAS_ENABLED : constants.CKO_SANDBOX_NAS_ENABLED;
var nasEnabled = this.getValue(liveOrSandboxPreference);
return nasEnabled;
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ var wrapper = {
return LocalServiceRegistry.createService('cko.klarna_transaction.capture.sandbox.service', {
createRequest: function(svc, args) {
// Prepare the http service
svc.addHeader('Authorization', util.getAccountKeys().secretKey);
// The args.service will hold the value of order.custom.orderProcessedByABCorNAS
// to handle Capture, Refund, or Void actions on historical orders based on the order's custom attribute.
svc.addHeader('Authorization', util.getAccountKeys(args ? args.service : '').secretKey);
svc.addHeader('User-Agent', util.getCartridgeMeta());
svc.addHeader('Content-Type', 'application/json;charset=UTF-8');

// eslint-disable-next-line no-param-reassign
delete args.service;
return (args) ? JSON.stringify(args) : null;
},

Expand All @@ -45,10 +49,15 @@ var wrapper = {
// eslint-disable-next-line no-shadow
createRequest: function(svc, args) {
// Prepare the http service
svc.addHeader('Authorization', util.getAccountKeys().secretKey);
// The args.service will hold the value of order.custom.orderProcessedByABCorNAS
// to handle Capture, Refund, or Void actions on historical orders based on the order's custom attribute.
svc.addHeader('Authorization', util.getAccountKeys(args ? args.service : '').secretKey);
svc.addHeader('User-Agent', util.getCartridgeMeta());
svc.addHeader('Content-Type', 'application/json;charset=UTF-8');

// eslint-disable-next-line no-param-reassign
delete args.service;

return (args) ? JSON.stringify(args) : null;
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ var wrapper = {
return LocalServiceRegistry.createService('cko.klarna_transaction.void.sandbox.service', {
createRequest: function(svc, args) {
// Prepare the http service
svc.addHeader('Authorization', util.getAccountKeys().secretKey);
// The args.service will hold the value of order.custom.orderProcessedByABCorNAS
// to handle Capture, Refund, or Void actions on historical orders based on the order's custom attribute.
svc.addHeader('Authorization', util.getAccountKeys(args ? args.service : '').secretKey);
svc.addHeader('User-Agent', util.getCartridgeMeta());
svc.addHeader('Content-Type', 'application/json;charset=UTF-8');

// eslint-disable-next-line no-param-reassign
delete args.service;
return (args) ? JSON.stringify(args) : null;
},

Expand All @@ -44,10 +48,14 @@ var wrapper = {
return LocalServiceRegistry.createService('cko.klarna_transaction.void.live.service', {
createRequest: function(svc, args) {
// Prepare the http service
svc.addHeader('Authorization', util.getAccountKeys().secretKey);
// The args.service will hold the value of order.custom.orderProcessedByABCorNAS
// to handle Capture, Refund, or Void actions on historical orders based on the order's custom attribute.
svc.addHeader('Authorization', util.getAccountKeys(args ? args.service : '').secretKey);
svc.addHeader('User-Agent', util.getCartridgeMeta());
svc.addHeader('Content-Type', 'application/json;charset=UTF-8');

// eslint-disable-next-line no-param-reassign
delete args.service;
return (args) ? JSON.stringify(args) : null;
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ var wrapper = {
return LocalServiceRegistry.createService('cko.transaction.capture.sandbox.service', {
createRequest: function(svc, args) {
// Prepare the http service
svc.addHeader('Authorization', util.getAccountKeys().secretKey);
// The args.service will hold the value of order.custom.orderProcessedByABCorNAS
// to handle Capture, Refund, or Void actions on historical orders based on the order's custom attribute.
svc.addHeader('Authorization', util.getAccountKeys(args ? args.service : '').secretKey);
svc.addHeader('User-Agent', util.getCartridgeMeta());
svc.addHeader('Content-Type', 'application/json;charset=UTF-8');

// eslint-disable-next-line no-param-reassign
delete args.service;
return (args) ? JSON.stringify(args) : null;
},

Expand All @@ -45,10 +49,14 @@ var wrapper = {
// eslint-disable-next-line no-shadow
createRequest: function(svc, args) {
// Prepare the http service
svc.addHeader('Authorization', util.getAccountKeys().secretKey);
// The args.service will hold the value of order.custom.orderProcessedByABCorNAS
// to handle Capture, Refund, or Void actions on historical orders based on the order's custom attribute.
svc.addHeader('Authorization', util.getAccountKeys(args ? args.service : '').secretKey);
svc.addHeader('User-Agent', util.getCartridgeMeta());
svc.addHeader('Content-Type', 'application/json;charset=UTF-8');

// eslint-disable-next-line no-param-reassign
delete args.service;
return (args) ? JSON.stringify(args) : null;
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ var wrapper = {
return LocalServiceRegistry.createService('cko.transaction.refund.sandbox.service', {
createRequest: function(svc, args) {
// Prepare the http service
svc.addHeader('Authorization', util.getAccountKeys().secretKey);
// The args.service will hold the value of order.custom.orderProcessedByABCorNAS
// to handle Capture, Refund, or Void actions on historical orders based on the order's custom attribute.
svc.addHeader('Authorization', util.getAccountKeys(args ? args.service : '').secretKey);
svc.addHeader('User-Agent', util.getCartridgeMeta());
svc.addHeader('Content-Type', 'application/json;charset=UTF-8');

// eslint-disable-next-line no-param-reassign
delete args.service;
return (args) ? JSON.stringify(args) : null;
},

Expand All @@ -44,10 +48,14 @@ var wrapper = {
return LocalServiceRegistry.createService('cko.transaction.refund.live.service', {
createRequest: function(svc, args) {
// Prepare the http service
svc.addHeader('Authorization', util.getAccountKeys().secretKey);
// The args.service will hold the value of order.custom.orderProcessedByABCorNAS
// to handle Capture, Refund, or Void actions on historical orders based on the order's custom attribute.
svc.addHeader('Authorization', util.getAccountKeys(args ? args.service : '').secretKey);
svc.addHeader('User-Agent', util.getCartridgeMeta());
svc.addHeader('Content-Type', 'application/json;charset=UTF-8');

// eslint-disable-next-line no-param-reassign
delete args.service;
return (args) ? JSON.stringify(args) : null;
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ var wrapper = {
return LocalServiceRegistry.createService('cko.transaction.void.sandbox.service', {
createRequest: function(svc, args) {
// Prepare the http service
svc.addHeader('Authorization', util.getAccountKeys().secretKey);
// The args.service will hold the value of order.custom.orderProcessedByABCorNAS
// to handle Capture, Refund, or Void actions on historical orders based on the order's custom attribute.
svc.addHeader('Authorization', util.getAccountKeys(args ? args.service : '').secretKey);
svc.addHeader('User-Agent', util.getCartridgeMeta());
svc.addHeader('Content-Type', 'application/json;charset=UTF-8');

// eslint-disable-next-line no-param-reassign
delete args.service;
return (args) ? JSON.stringify(args) : null;
},

Expand All @@ -44,10 +48,14 @@ var wrapper = {
return LocalServiceRegistry.createService('cko.transaction.void.live.service', {
createRequest: function(svc, args) {
// Prepare the http service
svc.addHeader('Authorization', util.getAccountKeys().secretKey);
// The args.service will hold the value of order.custom.orderProcessedByABCorNAS
// to handle Capture, Refund, or Void actions on historical orders based on the order's custom attribute.
svc.addHeader('Authorization', util.getAccountKeys(args ? args.service : '').secretKey);
svc.addHeader('User-Agent', util.getCartridgeMeta());
svc.addHeader('Content-Type', 'application/json;charset=UTF-8');

// eslint-disable-next-line no-param-reassign
delete args.service;
return (args) ? JSON.stringify(args) : null;
},

Expand Down
34 changes: 0 additions & 34 deletions Cartridges/int_checkoutcom/cartridge/config/ckoApmConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,40 +307,6 @@ var ckoApmConfig = {
return payObject;
},

/**
* Klarna Pay Authorization.
* @param {Object} args The payment arguments
* @returns {Object} The payment parameters
*/
klarnaPayAuthorization: function(args) {
// Gdt the order
var order = OrderMgr.getOrder(args.OrderNo);

// Klarna form fields
var klarnaApproved = paymentForm.get('klarna_approved').value();
if (klarnaApproved) {
// Build the payment object
var payObject = {
amount: ckoHelper.getFormattedPrice(order.totalGrossPrice.value.toFixed(2), ckoHelper.getCurrency(args)),
currency: ckoHelper.getCurrency(args),
capture: false,
source: {
type: 'klarna',
authorization_token: paymentForm.get('klarna_token').value(), // eslint-disable-line
locale: ckoHelper.getLanguage(),
purchase_country: ckoHelper.getBillingObject(args).country,
tax_amount: ckoHelper.getFormattedPrice(order.totalTax.value, ckoHelper.getCurrency(args)),
billing_address: ckoHelper.getOrderBasketAddress(args),
products: ckoHelper.getOrderBasketObject(args),
},
};

return payObject;
}

return { success: false };
},

/**
* Paypal Pay Authorization.
* @param {Object} args The payment arguments
Expand Down
4 changes: 2 additions & 2 deletions Cartridges/int_checkoutcom/cartridge/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ var constants = {
CKO_3DS: 'cko3ds',
CKO_N3DS: 'ckoN3ds',
CKO_GOOGLE_PAY_3DS: 'cko3dsGooglePay',
CKO_SANDBOX_ABC_OR_NAS_ENABLED: 'ckoSandboxABCorNASEnabled',
CKO_LIVE_ABC_OR_NAS_ENABLED: 'ckoLiveABCorNASEnabled',
CKO_SANDBOX_NAS_ENABLED: 'ckoSandboxNASEnabled',
CKO_LIVE_NAS_ENABLED: 'ckoLiveNASEnabled',
CKO_SG_PLATFORM_DATA: 'ckoSgPlatformData',
CKO_MADA_BINS: 'ckoMADABins',
CKO_MADA_PAYMENTS_ENABLED: 'ckoMada',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function handlePayments(order) {
} else {
Transaction.wrap(function() {
/* eslint-disable no-param-reassign */
order.custom.orderProcessedByABCorNAS = ckoHelper.getAbcOrNasEnabled();
order.custom.orderProcessedByABCorNAS = ckoHelper.getNasEnabled();
});

var authorizationResult = PaymentProcessor.authorize(order, paymentInstrument);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@
<!-- Field for Sepa pay -->
<field formid="sepa_iban" label="sepa.iban" type="string" mandatory="true" max-length="40" binding="sepa_iban"/>
<field formid="sepa_bic" label="sepa.bic" type="string" mandatory="true" max-length="40" binding="sepa_bic"/>

<!-- Field for Klarna pay -->
<field formid="klarna_token" type="string" max-length="40" binding="klarna_token"/>
<field formid="klarna_approved" type="string" max-length="40" binding="klarna_approved"/>
<field formid="klarna_finalize_required" type="string" max-length="40" binding="klarna_finalize_required"/>


<!-- Field for Oxxo pay -->
<field formid="oxxo_identification" type="string" label="oxxo.label.id" max-length="40" binding="oxxo_identification"/>

Expand Down
Loading

0 comments on commit 41dfd62

Please sign in to comment.