Skip to content

Commit

Permalink
Merge pull request #2 from cybersource-tpi/master
Browse files Browse the repository at this point in the history
Changes for v24.1.0
  • Loading branch information
cybersource-tpi authored Mar 1, 2024
2 parents 9e344f8 + 7a1122a commit b591488
Show file tree
Hide file tree
Showing 36 changed files with 300 additions and 91 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

* **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)
* **Categories:** Payment Processing, Fraud Detection, Address Validation, Tax Computation
* **Version:** 21.1.0
* **Last Certification Date:** July-2021
* **Supports SFRA v5.3.0**
* **Version:** 24.1.0
* **Last Certification Date:** February-2024
* **Supports SFRA v6.3.0**
* **JavaScript Controllers Friendly:** **YES**

### Contact ###
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ var baseUpdatePaymentInformation = base.methods.updatePaymentInformation;
// eslint-disable-next-line consistent-return
base.methods.updatePaymentInformation = function (order, customer) {
// eslint-disable-line no-unused-vars
if ($(".tab-pane.active [name$='paymentMethod']").val() === 'VISA_SRC') {
if ($(".tab-pane.active [name$='paymentMethod']").val() === 'CLICK_TO_PAY') {
var $paymentSummary = $('.payment-details');
var htmlToAppend = '<span>VISA SRC</span>';
var htmlToAppend = '<span>Click to Pay</span>';
$paymentSummary.empty().append(htmlToAppend);
} else {
return baseUpdatePaymentInformation(order, customer);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!--- TEMPLATENAME: Redirect.isml --->
<iscomment>
This template the use to redirect to the conformation page
</iscomment>
<script src="${URLUtils.staticURL('/custom/lib/jquery/jquery-3.5.1.min.js')}" type="text/javascript"></script>
<form action="${URLUtils.https('Order-Confirm')}" method="POST" name="SubmitOrderForm" target="_parent">
<input type="hidden" name="orderID" value="${pdict.orderId}"/>
<input type="hidden" name="orderToken" value="${pdict.orderToken}"/>
</form>
<script type="text/javascript">
document.SubmitOrderForm.submit();
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<div class="row">

<div class="${session.privacy.applepaysession === 'yes'? 'col-6 col-sm-5' : 'col-12' }" id="cart-checkout-button">
<a href="${URLUtils.https('Checkout-Login')}" class="btn btn-primary btn-block checkout-btn ${pdict.valid.error ? 'disabled' : ''} col" role="button">
${Resource.msg('button.checkout','cart',null)}
</a>
<a href="${URLUtils.https('Checkout-Begin')}"
class="btn btn-primary btn-block checkout-btn ${pdict.valid.error ? 'disabled' : ''}" role="button">
${Resource.msg('button.checkout', 'cart', null)}
</a>
</div>

<isif condition="${session.privacy.applepaysession === 'yes'}" >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<isif condition="${paymentOption.ID === 'CREDIT_CARD'}">
<isinclude template="checkout/billing/paymentOptions/creditCardContent" />
</isif>
<isif condition="${paymentOption.ID === 'VISA_SRC' && isCartridgeEnabled}">
<isif condition="${paymentOption.ID === 'CLICK_TO_PAY' && isCartridgeEnabled}">
<isinclude template="checkout/billing/paymentOptions/visaCheckout" />
</isif>
<isif condition="${paymentOption.ID === 'DW_APPLE_PAY' && isCartridgeEnabled}">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="payment-details">
<isloop items="${pdict.order.billing.payment.selectedPaymentInstruments}" var="payment">
<isif condition="${payment.paymentMethod === 'VISA_SRC'}">
<isif condition="${payment.paymentMethod === 'CLICK_TO_PAY'}">
<isinclude template="checkout/billing/paymentOptions/visaSRCSummary" />
</isif>
<isif condition="${payment.paymentMethod === 'CREDIT_CARD'}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<isif condition="${isCartridgeEnabled && paymentOption.ID === 'DW_APPLE_PAY'}">
<isinclude template="checkout/billing/paymentOptions/applePayTab" />
</isif>
<isif condition="${isCartridgeEnabled && isVisaSRCEnabled && paymentOption.ID === 'VISA_SRC'}">
<isif condition="${isCartridgeEnabled && isVisaSRCEnabled && paymentOption.ID === 'CLICK_TO_PAY'}">
<isinclude template="checkout/billing/paymentOptions/visaCheckoutTab" />
</isif>
<isif condition="${isCartridgeEnabled && isGooglePayEnabled && paymentOption.ID === 'DW_GOOGLE_PAY'}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="tab-pane visasrc-content" id="visasrc-content" role="tabpanel">
<fieldset class="payment-form-fields">
<input type="hidden" class="form-control" name="${pdict.forms.billingForm.paymentMethod.htmlName}"
value="VISA_SRC">
value="CLICK_TO_PAY">
</fieldset>
<script type="text/javascript">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<li class="nav-item visasrc-tab-wrapper" data-method-id="${paymentOption.ID}">
<a class="nav-link visasrc-tab" data-toggle="tab" href="#visasrc-content" role="tab">
${paymentOption.name}
${Resource.msg('msg.click.to.pay', 'visaSRC', null)}
</a>
</li>
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,23 @@
</div>
</isif>


<!-- Step 1: Customer -->
<iscomment>We only allow edits for non-registered customers</iscomment>
<isif condition="${!pdict.customer.registeredUser}">
<isinclude template="checkout/customer/customer" />
</isif>
<div class="card customer-summary">
<div class="card-header clearfix">
<h2 class="pull-left card-header-custom">${Resource.msg('heading.checkout.customer', 'checkout', null)}</h2>
<isif condition="${!pdict.customer.registeredUser}">
<button class="edit-button pull-right" aria-label="${Resource.msg('action.edit.step.msg.customer', 'checkout', null)}">${Resource.msg('action.edit.step', 'checkout', null)}</button>
</isif>
</div>
<div class="card-body">
<isinclude template="checkout/customer/customerSummary" />
</div>
</div>

<!-- Step 1: Shipping -->
<isinclude template="checkout/shipping/shipping" />
<div class="card shipping-summary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<isif condition="${pdict.redirect}">
redirectURL = '${URLUtils.http('Checkout-Begin')}?stage=payment&payerAuthError=${pdict.errorMessage}';
<iselse>
redirectURL = '${URLUtils.http('Order-Confirm')}?ID=${pdict.orderID}&token=${pdict.orderToken}';
redirectURL = '${URLUtils.http('COPlaceOrder-SubmitOrderConformation')}?ID=${pdict.orderID}&token=${pdict.orderToken}';
</isif>
window.top.window.location.href = redirectURL;
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
<iscomment>Secure Acceptance Flex Microform Scripts </iscomment>

<isif condition="${dw.system.System.getInstanceType()!= 2}">
<script src="https://testflex.cybersource.com/cybersource/assets/microform/0.11.0/flex-microform.min.js"></script>
<script src="https://testflex.cybersource.com/cybersource/assets/microform/0.11/flex-microform.min.js"></script>
<iselse>
<script src="https://flex.cybersource.com/cybersource/assets/microform/0.11.0/flex-microform.min.js"></script>
<script src="https://flex.cybersource.com/cybersource/assets/microform/0.11/flex-microform.min.js"></script>
</iselse>
</isif>
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
msg.paid.using.visa.src=Paid using VISA SRC
msg.paid.using.visa.src=Paid using Click to Pay
msg.click.to.pay=Click to Pay
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,17 @@ _exports.prototype.getHttpSignature = function (resource, method, merchantKeyId,
// Headers - list is choosen based on HTTP method.
// Digest is not required for GET Method
if (method === "get" || method === "delete") {
var headersForGetMethod = "host date (request-target) v-c-merchant-id";
var headersForGetMethod = "host date request-target v-c-merchant-id";
signatureHeader += ", headers=\"" + headersForGetMethod + "\"";
} else if (method === "post" || method === "patch") {
var headersForPostMethod = "host date (request-target) digest v-c-merchant-id";
var headersForPostMethod = "host date request-target digest v-c-merchant-id";
signatureHeader += ", headers=\"" + headersForPostMethod + "\"";
}

var signatureString = 'host: ' + requestHost;

signatureString += '\ndate: ' + new Date(Date.now()).toUTCString();
signatureString += '\n(request-target): ';
signatureString += '\nrequest-target: ';

if (method === "get" || method === "delete") {
var targetUrlForGet = method + " " + resource;
Expand Down
10 changes: 4 additions & 6 deletions cartridges/int_cybs_sfra_base/cartridge/configuration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var LogfileMaxSize = '5242880'; // 10 MB In Bytes
* Send this value in all requests that are sent through the partner solution. CyberSource assigns the ID to the partner.
* Note When you see a partner ID of 999 in reports, the partner ID that was submitted is incorrect.
*/
var SolutionId = '3VKKRVBF';
var SolutionId = 'J3P4XU2P';

var CruiseDDCEndPoint = {
Stage: 'https://centinelapistag.cardinalcommerce.com/V1/Cruise/Collect',
Expand Down Expand Up @@ -120,7 +120,6 @@ function getConfig(config) {
deviceFingerprintThreadMatrixUrl: config.deviceFingerprintThreadMatrixUrl || customPreferences.DeviceFingerprint.Preferences.ThreadMatrixUrl.getValue(),
deviceFingerprintTimeToLive: config.deviceFingerprintTimeToLive || customPreferences.DeviceFingerprint.Preferences.TimeToLive.getValue(),

// Future enhancement
enableCapture: config.EnableCapture || false,

// PayerAuthentication
Expand All @@ -138,9 +137,8 @@ function getConfig(config) {
enableGooglePayOnCart: config.enableGooglePayOnCart || customPreferences.GooglePay.Preferences.EnableGooglePayOnCart.getValue(),

// DecisionManager
visaSRCEnabled: config.vscCheckoutEnabled || customPreferences.VisaSRC.Preferences.VisaSRCEnabled.getValue(),
visaSRCKey: config.visaSRCKey || customPreferences.VisaSRC.Preferences.VisaSRCKey.getValue(),
VisaSRCProduction: config.VisaSRCProduction || customPreferences.VisaSRC.Preferences.VisaSRCProduction.getValue()
};
visaSRCEnabled: config.vscCheckoutEnabled || customPreferences.ClicktoPay.Preferences.ClicktoPayEnabled.getValue(),
visaSRCKey: config.visaSRCKey || customPreferences.ClicktoPay.Preferences.ClicktoPayKey.getValue(),
VisaSRCProduction: config.VisaSRCProduction || customPreferences.ClicktoPay.Preferences.ClicktoPayProduction.getValue() };
}
module.exports = getConfig();
Original file line number Diff line number Diff line change
Expand Up @@ -590,12 +590,12 @@ module.exports = {
}
},

VisaSRC: {
id: 'Cybersource_VisaSRC',
ClicktoPay: {
id: 'Cybersource_ClicktoPay',
display_name: '',
Preferences: {
VisaSRCProduction: {
id: 'Cybersource_VisaSRCProduction',
ClicktoPayProduction: {
id: 'Cybersource_ClicktoPayProduction',
display_name: 'True for production',
description: '',
type: Types.boolean,
Expand All @@ -604,19 +604,19 @@ module.exports = {
mandatory: false
}
},
VisaSRCEnabled: {
id: 'Cybersource_VisaSRCEnabled',
display_name: 'Enable Visa SRC',
ClicktoPayEnabled: {
id: 'Cybersource_ClicktoPayEnabled',
display_name: 'Enable Click to Pay',
description: '',
type: Types.boolean,
default: false,
flags: {
mandatory: false
}
},
VisaSRCKey: {
id: 'Cybersource_VisaSRCKey',
display_name: 'Visa SRC Key',
ClicktoPayKey: {
id: 'Cybersource_ClicktoPayKey',
display_name: 'Click to Pay Key',
description: '',
type: Types.string,
default: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var checkoutHelper = require('*/cartridge/scripts/checkout/checkoutHelpers');
var OrderModel = require('*/cartridge/models/order');
var hooksHelper = require('*/cartridge/scripts/helpers/hooks');
var configObject = require('../configuration/index');
var csrfProtection = require('*/cartridge/scripts/middleware/csrf');

if (configObject.cartridgeEnabled) {
server.post('Submit', function (req, res, next) {
Expand Down Expand Up @@ -64,4 +65,14 @@ if (configObject.cartridgeEnabled) {
});
}

server.get('SubmitOrderConformation', csrfProtection.generateToken, function (req, res, next) {
var orderId = req.querystring.ID;
var token = req.querystring.token;
res.render('cart/RedirectToConformation', {
orderId: orderId,
orderToken: token
});
return next();
});

module.exports = server.exports();
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var configObject = require('~/cartridge/configuration/index');
server.extend(page);
var currentBasket = BasketMgr.getCurrentBasket();
var paymentMethod = currentBasket && currentBasket.paymentInstrument && currentBasket.paymentInstrument.paymentMethod;
var isVisaSRC = paymentMethod && paymentMethod === 'VISA_SRC';
var isVisaSRC = paymentMethod && paymentMethod === 'CLICK_TO_PAY';
// eslint-disable-next-line no-undef
if (configObject.payerAuthenticationEnabled && configObject.cartridgeEnabled && empty(session.privacy.encryptedDataGP)
&& !isVisaSRC
Expand Down Expand Up @@ -210,7 +210,15 @@ server.append('PlaceOrder', server.middleware.https, function (req, res, next) {
});
// eslint-disable-next-line no-undef
delete session.privacy.AuthorizeErrors;
}else {
res.json({
error: false,
ID: session.privacy.orderID,
token: session.privacy.orderToken,
continueUrl: URLUtils.url('COPlaceOrder-SubmitOrderConformation').toString()
});
}

return next();
});
/**
Expand Down Expand Up @@ -267,7 +275,7 @@ server.post('getResponse', server.middleware.https, function (req, res, next) {

try {
// eslint-disable-next-line block-scoped-var, no-undef
var enrollResponse = payerAuthentication.paEnroll(billingForm, shippingAddress, session.privacy.orderID, totalAmount, currencyCode, referenceId, card, lineItems, order.customer.registered);
var enrollResponse = payerAuthentication.paEnroll(billingForm, shippingAddress, session.privacy.orderID, totalAmount, currencyCode, referenceId, card, lineItems, order);
if (enrollResponse.status === 'PENDING_AUTHENTICATION' && enrollResponse.errorInformation.reason === 'CONSUMER_AUTHENTICATION_REQUIRED') {
if (enrollResponse.consumerAuthenticationInformation.acsUrl
&& enrollResponse.consumerAuthenticationInformation.stepUpUrl
Expand Down Expand Up @@ -321,7 +329,7 @@ server.post('getResponse', server.middleware.https, function (req, res, next) {
errorMessage: Resource.msg('message.payerAuthError', 'error', null),
orderID: order.orderNo,
orderToken: order.orderToken,
continueUrl: URLUtils.url('Order-Confirm').toString()
continueUrl: URLUtils.url('COPlaceOrder-SubmitOrderConformation').toString()
});
} catch (e) {
if (!order) {
Expand Down Expand Up @@ -350,6 +358,7 @@ server.post('handlingConsumerAuthResponse', server.middleware.https, function (r
var OrderMgr = require('dw/order/OrderMgr');
var Resource = require('dw/web/Resource');
var redirect;
var scaEnabled = dw.system.Site.getCurrent().getCustomPreferenceValue('Cybersource_IsSCAEnabled');

var billingForm = server.forms.getForm('billing');
var order = getOrder();
Expand All @@ -368,8 +377,9 @@ server.post('handlingConsumerAuthResponse', server.middleware.https, function (r
}
var mapper = require('~/cartridge/scripts/util/mapper.js');
var lineItems = mapper.MapOrderLineItems(order.allLineItems, true);
session.custom.SCA = true;
// eslint-disable-next-line no-undef, block-scoped-var
var authenticateResponse = payerAuthentication.paConsumerAuthenticate(billingForm, session.privacy.orderID, totalAmount, currencyCode, session.privacy.transactionId, card, lineItems);
var authenticateResponse = payerAuthentication.paConsumerAuthenticate(billingForm, session.privacy.orderID, totalAmount, currencyCode, session.privacy.transactionId, card, lineItems, order);

if (authenticateResponse.status === 'AUTHORIZED' || authenticateResponse.status === 'AUTHORIZED_PENDING_REVIEW') {
var fraudDetectionStatus = hooksHelper('app.fraud.detection', 'fraudDetection', currentBasket, require('*/cartridge/scripts/hooks/fraudDetection').fraudDetection);
Expand All @@ -384,6 +394,15 @@ server.post('handlingConsumerAuthResponse', server.middleware.https, function (r
}
// Sending Email Confirmation
sendConfirmationEmail();
}
// eslint-disable-next-line
else if(authenticateResponse.status === '201' && scaEnabled === true){
session.custom.SCA = false;
var response = payerAuthentication.paConsumerAuthenticate(billingForm, session.privacy.orderID, totalAmount, currencyCode, session.privacy.transactionId, card, lineItems, order);
redirect = true;
Transaction.wrap(function () {
OrderMgr.failOrder(order);
});
} else {
redirect = true;
Transaction.wrap(function () {
Expand All @@ -395,7 +414,7 @@ server.post('handlingConsumerAuthResponse', server.middleware.https, function (r
errorMessage: Resource.msg('message.payerAuthError', 'error', null) + ' ' + authenticateResponse.status,
orderID: order.orderNo,
orderToken: order.orderToken,
continueUrl: URLUtils.url('Order-Confirm').toString()
continueUrl: URLUtils.url('COPlaceOrder-SubmitOrderConformation').toString()
});
// eslint-disable-next-line no-undef
session.privacy.orderID = '';
Expand Down Expand Up @@ -486,7 +505,7 @@ server.post('SubmitPaymentGP', function (req, res, next) {
};

viewData.email = {
value: paymentForm.contactInfoFields.email.value
value: cart.customerEmail
};

viewData.phone = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ exports.authorizeOrderPayment = function (order, response) {
var base64Encoded = Encoding.toBase64(byteData);
var mapper = require('~/cartridge/scripts/util/mapper.js');
var configObject = require('~/cartridge/configuration/index');
var enableCaptureForApplePay = false;

if (dw.system.Site.getCurrent().getCustomPreferenceValue('Cybersource_ApplePayTransactionType').value === 'sale' ){
enableCaptureForApplePay = true;
}
var restRequest = {
clientReferenceInformation: {
code: order.currentOrderNo,
Expand All @@ -33,7 +37,8 @@ exports.authorizeOrderPayment = function (order, response) {
}
},
processingInformation: {
paymentSolution: '001'
paymentSolution: '001',
capture: enableCaptureForApplePay
},
paymentInformation: {
fluidData: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ function Handle(basket, paymentInformation) {
currentBasket.removeAllPaymentInstruments();

var paymentInstruments = currentBasket.getPaymentInstruments(
'VISA_SRC'
'CLICK_TO_PAY'
);

collections.forEach(paymentInstruments, function (item) {
currentBasket.removePaymentInstrument(item);
});

var paymentInstrument = currentBasket.createPaymentInstrument(
'VISA_SRC', currentBasket.totalGrossPrice
'CLICK_TO_PAY', currentBasket.totalGrossPrice
);

paymentInstrument.setCreditCardHolder(currentBasket.billingAddress.fullName);
Expand Down
Loading

0 comments on commit b591488

Please sign in to comment.