Skip to content

Commit

Permalink
Merge pull request #1 from CyberSource/v21.1.0
Browse files Browse the repository at this point in the history
Commit changes of v21.1.0
  • Loading branch information
krishnaprasadsn25 authored Apr 9, 2023
2 parents ead9300 + fbcfb85 commit 9e344f8
Show file tree
Hide file tree
Showing 933 changed files with 108,383 additions and 1 deletion.
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This software has been made available to you under the Cybersource Software Extension License Agreement, available here: https://developer.cybersource.com/license-agreement.html.
24 changes: 23 additions & 1 deletion README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
# cybersource-plugins-rest-salesforceb2ccommerce
### **Cybersource Storefront Reference Architecture Quick Launch Cartridge** ###


* **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**
* **JavaScript Controllers Friendly:** **YES**

### Contact ###
* Lindsey Rodgers: <SFCC@cybersource.com>

----

### Installation Guide ###

1. [Install the Cartridge and Setup Workspace](documentation/markdown/Install-catridge-WrkSpace-Setup.md)
2. [Configure the Cartridge](documentation/markdown/Configure-cartridge.md)
3. [Configure the Payment Method](documentation/markdown/Configure-payment-method.md)
4. [Configure features (OPTIONAL)](documentation/markdown/Configure-features.md)
5. [Test and go live](documentation/markdown/Test-golive.md)
6. [Release Notes](documentation/markdown/Release-notes.md)
17 changes: 17 additions & 0 deletions cartridges/int_cybs_sfra/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>int_cybs_sfra</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.demandware.studio.core.beehiveElementBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.demandware.studio.core.beehiveNature</nature>
</natures>
</projectDescription>
4 changes: 4 additions & 0 deletions cartridges/int_cybs_sfra/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Edit hooks.json to match app.payment.processor.basic_credit.base hook with it's correct path.
This should point to app_storefront_base cartridge.


5 changes: 5 additions & 0 deletions cartridges/int_cybs_sfra/cartridge/client/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"ecmaVersion": 2018
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/* eslint-disable no-undef */

'use strict';

$(document).ready(function () {
var captureContext = JSON.parse($('#flexTokenResponse').val()).keyId;
var flex = new Flex(captureContext); // eslint-disable-line no-undef
var customStyles = {
input: {
'font-family': '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"',
'font-size': '1em',
'line-height': '1.5',
color: '#495057'
},
':focus': {
color: 'blue'
},
':disabled': {
cursor: 'not-allowed'
},
valid: {
color: '#3c763d'
},
invalid: {
color: '#a94442'
}
};
var microform = flex.microform({
styles: customStyles
});
var number = microform.createField('number');
var securityCode = microform.createField('securityCode');
securityCode.load('#securityCode-container');
number.load('#cardNumber-container');
number.on('change', function (data) {
var cardType = data.card[0].name;
$('.card-number-wrapper').attr('data-type', cardType);
$('#cardType').val(cardType);
});
/**
* *
* @param {*} token *
* @returns {*} *
*/
function parseJwt(token) {
var base64Url = token.split('.')[1];
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
var jsonPayload = decodeURIComponent(atob(base64).split('').map(function (c) { // eslint-disable-line no-undef
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));

return JSON.parse(jsonPayload);
}

/**
* *
* @returns {*} *
*/
function flexTokenCreation() {
var expMonth = $('#expirationMonth').val();
var expYear = $('#expirationYear').val();

if (expMonth === '' || expYear === '') {
return false;
}
// Send in optional parameters from other parts of your payment form
var options = {
expirationMonth: expMonth.length === 1 ? '0' + expMonth : expMonth,
expirationYear: expYear
// cardType: /* ... */
};
// validation
// look for field validation errors

// eslint-disable-next-line consistent-return
microform.createToken(options, function (err, response) {
// At this point the token may be added to the form
// as hidden fields and the submission continued

if (err) {
$('.card-number-wrapper .invalid-feedback').text(err.message).css('display', 'block');
return true;
}
var decodedJwt = parseJwt(response);
document.getElementById('cardNumber').valid = true;
$('#flex-response').val(response);
$('#cardNumber').val(decodedJwt.data.number);

if ($('.submit-payment').length === 1) {
$('.submit-payment').trigger('click');
} else {
$('.save-payment').trigger('click');
}
});
return true;
}
// check for card type function
/**
*/
function assignCorrectCardType() {
var cardType = $('#cardType').val();
if (cardType.charCodeAt(0) !== cardType.toUpperCase().charCodeAt(0)) {
var correctCardType = '';
switch (cardType) { // eslint-disable-line default-case
case 'visa':
correctCardType = 'Visa';
break;
case 'mastercard':
correctCardType = 'Master Card';
break;
case 'amex':
correctCardType = 'Amex';
break;
case 'discover':
correctCardType = 'Discover';
break;
case 'diners-club':
correctCardType = 'DinersClub';
break;
case 'maestro':
correctCardType = 'Maestro';
break;
case 'jcb':
correctCardType = 'JCB';
break;
}
$('#cardType').val(correctCardType);
}
}

$('.payment-summary .edit-button').on('click', function () {
$('#flex-response').val('');
});

// intercept the form submission and make a tokenize request instead
$('.submit-payment').on('click', function (event) {
if ($('.tab-pane.active').find("input[name$='paymentMethod']").val() === 'CREDIT_CARD') {
if (($('#flex-response').val() === '' || $('#flex-response').val() === undefined) && $('.payment-information').data('is-new-payment')) {
flexTokenCreation();
event.stopImmediatePropagation();
}
}
});
$('.save-payment').on('click', function (event) {
if (($('#flex-response').val() === '' || $('#flex-response').val() === undefined)) {
flexTokenCreation();
assignCorrectCardType();
event.preventDefault();
}
});
});

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions cartridges/int_cybs_sfra/cartridge/client/default/js/checkout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable no-undef */

'use strict';

var processInclude = require('base/util');

$(document).ready(function () {
processInclude(require('./checkout/checkout'));
processInclude(require('./checkout/applePay'));
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable no-undef */

'use strict';

if (window.dw
&& window.dw.applepay
&& window.ApplePaySession
&& window.ApplePaySession.canMakePayments()) {
$('body').addClass('apple-pay-enabled');
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* eslint-disable no-undef */

'use strict';

var base = require('base/checkout/billing');
var addressHelpers = require('base/checkout/address');

/**
* updates the billing address form values within payment forms
* @param {Object} order - the order model
*/
function updateBillingAddressFormValues(order) {
var billing = order.billing;
if (!billing.billingAddress || !billing.billingAddress.address) return;

var form = $('form[name=dwfrm_billing]');
if (!form) return;

$('input[name$=_firstName]', form).val(billing.billingAddress.address.firstName);
$('input[name$=_lastName]', form).val(billing.billingAddress.address.lastName);
$('input[name$=_address1]', form).val(billing.billingAddress.address.address1);
$('input[name$=_address2]', form).val(billing.billingAddress.address.address2);
$('input[name$=_city]', form).val(billing.billingAddress.address.city);
$('input[name$=_postalCode]', form).val(billing.billingAddress.address.postalCode);
$('select[name$=_stateCode],input[name$=_stateCode]', form)
.val(billing.billingAddress.address.stateCode);
$('select[name$=_country]', form).val(billing.billingAddress.address.countryCode.value);
$('input[name$=_phone]', form).val(billing.billingAddress.address.phone);
$('input[name$=_email]', form).val(order.orderEmail);

if (billing.payment && billing.payment.selectedPaymentInstruments
&& billing.payment.selectedPaymentInstruments.length > 0) {
var instrument = billing.payment.selectedPaymentInstruments[0];
$('select[name$=expirationMonth]', form).val(instrument.expirationMonth);
$('select[name$=expirationYear]', form).val(instrument.expirationYear);
// Force security code and card number clear
$('input[name$=securityCode]', form).val('');
if (document.getElementById('flexTokenResponse') != null && !document.getElementById('flexTokenResponse').value) {
$('input.cardNumber').data('cleave').setRawValue('');
}
}
}

base.methods.updateBillingInformation = function (order, customer) {
base.methods.updateBillingAddressSelector(order, customer);

// update billing address form
updateBillingAddressFormValues(order);

// update billing address summary
addressHelpers.methods.populateAddressSummary('.billing .address-summary',
order.billing.billingAddress.address);

// update billing parts of order summary
$('.order-summary-email').text(order.orderEmail);

if (order.billing.billingAddress.address) {
$('.order-summary-phone').text(order.billing.billingAddress.address.phone);
}
};
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') {
var $paymentSummary = $('.payment-details');
var htmlToAppend = '<span>VISA SRC</span>';
$paymentSummary.empty().append(htmlToAppend);
} else {
return baseUpdatePaymentInformation(order, customer);
}
};

module.exports = base;
Loading

0 comments on commit 9e344f8

Please sign in to comment.