Skip to content

Commit fbcfb85

Browse files
author
Krishna Prasad
committed
Commit changes of v21.1.0
1 parent ead9300 commit fbcfb85

File tree

933 files changed

+108383
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

933 files changed

+108383
-1
lines changed

LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

README.md

100644100755
+23-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
1-
# cybersource-plugins-rest-salesforceb2ccommerce
1+
### **Cybersource Storefront Reference Architecture Quick Launch Cartridge** ###
2+
3+
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:** 21.1.0
7+
* **Last Certification Date:** July-2021
8+
* **Supports SFRA v5.3.0**
9+
* **JavaScript Controllers Friendly:** **YES**
10+
11+
### Contact ###
12+
* Lindsey Rodgers: <[email protected]>
13+
14+
----
15+
16+
### Installation Guide ###
17+
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/.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>int_cybs_sfra</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>com.demandware.studio.core.beehiveElementBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>com.demandware.studio.core.beehiveNature</nature>
16+
</natures>
17+
</projectDescription>

cartridges/int_cybs_sfra/README

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Edit hooks.json to match app.payment.processor.basic_credit.base hook with it's correct path.
2+
This should point to app_storefront_base cartridge.
3+
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"parserOptions": {
3+
"ecmaVersion": 2018
4+
}
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/* eslint-disable no-undef */
2+
3+
'use strict';
4+
5+
$(document).ready(function () {
6+
var captureContext = JSON.parse($('#flexTokenResponse').val()).keyId;
7+
var flex = new Flex(captureContext); // eslint-disable-line no-undef
8+
var customStyles = {
9+
input: {
10+
'font-family': '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"',
11+
'font-size': '1em',
12+
'line-height': '1.5',
13+
color: '#495057'
14+
},
15+
':focus': {
16+
color: 'blue'
17+
},
18+
':disabled': {
19+
cursor: 'not-allowed'
20+
},
21+
valid: {
22+
color: '#3c763d'
23+
},
24+
invalid: {
25+
color: '#a94442'
26+
}
27+
};
28+
var microform = flex.microform({
29+
styles: customStyles
30+
});
31+
var number = microform.createField('number');
32+
var securityCode = microform.createField('securityCode');
33+
securityCode.load('#securityCode-container');
34+
number.load('#cardNumber-container');
35+
number.on('change', function (data) {
36+
var cardType = data.card[0].name;
37+
$('.card-number-wrapper').attr('data-type', cardType);
38+
$('#cardType').val(cardType);
39+
});
40+
/**
41+
* *
42+
* @param {*} token *
43+
* @returns {*} *
44+
*/
45+
function parseJwt(token) {
46+
var base64Url = token.split('.')[1];
47+
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
48+
var jsonPayload = decodeURIComponent(atob(base64).split('').map(function (c) { // eslint-disable-line no-undef
49+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
50+
}).join(''));
51+
52+
return JSON.parse(jsonPayload);
53+
}
54+
55+
/**
56+
* *
57+
* @returns {*} *
58+
*/
59+
function flexTokenCreation() {
60+
var expMonth = $('#expirationMonth').val();
61+
var expYear = $('#expirationYear').val();
62+
63+
if (expMonth === '' || expYear === '') {
64+
return false;
65+
}
66+
// Send in optional parameters from other parts of your payment form
67+
var options = {
68+
expirationMonth: expMonth.length === 1 ? '0' + expMonth : expMonth,
69+
expirationYear: expYear
70+
// cardType: /* ... */
71+
};
72+
// validation
73+
// look for field validation errors
74+
75+
// eslint-disable-next-line consistent-return
76+
microform.createToken(options, function (err, response) {
77+
// At this point the token may be added to the form
78+
// as hidden fields and the submission continued
79+
80+
if (err) {
81+
$('.card-number-wrapper .invalid-feedback').text(err.message).css('display', 'block');
82+
return true;
83+
}
84+
var decodedJwt = parseJwt(response);
85+
document.getElementById('cardNumber').valid = true;
86+
$('#flex-response').val(response);
87+
$('#cardNumber').val(decodedJwt.data.number);
88+
89+
if ($('.submit-payment').length === 1) {
90+
$('.submit-payment').trigger('click');
91+
} else {
92+
$('.save-payment').trigger('click');
93+
}
94+
});
95+
return true;
96+
}
97+
// check for card type function
98+
/**
99+
*/
100+
function assignCorrectCardType() {
101+
var cardType = $('#cardType').val();
102+
if (cardType.charCodeAt(0) !== cardType.toUpperCase().charCodeAt(0)) {
103+
var correctCardType = '';
104+
switch (cardType) { // eslint-disable-line default-case
105+
case 'visa':
106+
correctCardType = 'Visa';
107+
break;
108+
case 'mastercard':
109+
correctCardType = 'Master Card';
110+
break;
111+
case 'amex':
112+
correctCardType = 'Amex';
113+
break;
114+
case 'discover':
115+
correctCardType = 'Discover';
116+
break;
117+
case 'diners-club':
118+
correctCardType = 'DinersClub';
119+
break;
120+
case 'maestro':
121+
correctCardType = 'Maestro';
122+
break;
123+
case 'jcb':
124+
correctCardType = 'JCB';
125+
break;
126+
}
127+
$('#cardType').val(correctCardType);
128+
}
129+
}
130+
131+
$('.payment-summary .edit-button').on('click', function () {
132+
$('#flex-response').val('');
133+
});
134+
135+
// intercept the form submission and make a tokenize request instead
136+
$('.submit-payment').on('click', function (event) {
137+
if ($('.tab-pane.active').find("input[name$='paymentMethod']").val() === 'CREDIT_CARD') {
138+
if (($('#flex-response').val() === '' || $('#flex-response').val() === undefined) && $('.payment-information').data('is-new-payment')) {
139+
flexTokenCreation();
140+
event.stopImmediatePropagation();
141+
}
142+
}
143+
});
144+
$('.save-payment').on('click', function (event) {
145+
if (($('#flex-response').val() === '' || $('#flex-response').val() === undefined)) {
146+
flexTokenCreation();
147+
assignCorrectCardType();
148+
event.preventDefault();
149+
}
150+
});
151+
});

cartridges/int_cybs_sfra/cartridge/client/default/custom/lib/jquery/jquery-3.5.1.min.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* eslint-disable no-undef */
2+
3+
'use strict';
4+
5+
var processInclude = require('base/util');
6+
7+
$(document).ready(function () {
8+
processInclude(require('./checkout/checkout'));
9+
processInclude(require('./checkout/applePay'));
10+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* eslint-disable no-undef */
2+
3+
'use strict';
4+
5+
if (window.dw
6+
&& window.dw.applepay
7+
&& window.ApplePaySession
8+
&& window.ApplePaySession.canMakePayments()) {
9+
$('body').addClass('apple-pay-enabled');
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/* eslint-disable no-undef */
2+
3+
'use strict';
4+
5+
var base = require('base/checkout/billing');
6+
var addressHelpers = require('base/checkout/address');
7+
8+
/**
9+
* updates the billing address form values within payment forms
10+
* @param {Object} order - the order model
11+
*/
12+
function updateBillingAddressFormValues(order) {
13+
var billing = order.billing;
14+
if (!billing.billingAddress || !billing.billingAddress.address) return;
15+
16+
var form = $('form[name=dwfrm_billing]');
17+
if (!form) return;
18+
19+
$('input[name$=_firstName]', form).val(billing.billingAddress.address.firstName);
20+
$('input[name$=_lastName]', form).val(billing.billingAddress.address.lastName);
21+
$('input[name$=_address1]', form).val(billing.billingAddress.address.address1);
22+
$('input[name$=_address2]', form).val(billing.billingAddress.address.address2);
23+
$('input[name$=_city]', form).val(billing.billingAddress.address.city);
24+
$('input[name$=_postalCode]', form).val(billing.billingAddress.address.postalCode);
25+
$('select[name$=_stateCode],input[name$=_stateCode]', form)
26+
.val(billing.billingAddress.address.stateCode);
27+
$('select[name$=_country]', form).val(billing.billingAddress.address.countryCode.value);
28+
$('input[name$=_phone]', form).val(billing.billingAddress.address.phone);
29+
$('input[name$=_email]', form).val(order.orderEmail);
30+
31+
if (billing.payment && billing.payment.selectedPaymentInstruments
32+
&& billing.payment.selectedPaymentInstruments.length > 0) {
33+
var instrument = billing.payment.selectedPaymentInstruments[0];
34+
$('select[name$=expirationMonth]', form).val(instrument.expirationMonth);
35+
$('select[name$=expirationYear]', form).val(instrument.expirationYear);
36+
// Force security code and card number clear
37+
$('input[name$=securityCode]', form).val('');
38+
if (document.getElementById('flexTokenResponse') != null && !document.getElementById('flexTokenResponse').value) {
39+
$('input.cardNumber').data('cleave').setRawValue('');
40+
}
41+
}
42+
}
43+
44+
base.methods.updateBillingInformation = function (order, customer) {
45+
base.methods.updateBillingAddressSelector(order, customer);
46+
47+
// update billing address form
48+
updateBillingAddressFormValues(order);
49+
50+
// update billing address summary
51+
addressHelpers.methods.populateAddressSummary('.billing .address-summary',
52+
order.billing.billingAddress.address);
53+
54+
// update billing parts of order summary
55+
$('.order-summary-email').text(order.orderEmail);
56+
57+
if (order.billing.billingAddress.address) {
58+
$('.order-summary-phone').text(order.billing.billingAddress.address.phone);
59+
}
60+
};
61+
var baseUpdatePaymentInformation = base.methods.updatePaymentInformation;
62+
// eslint-disable-next-line consistent-return
63+
base.methods.updatePaymentInformation = function (order, customer) {
64+
// eslint-disable-line no-unused-vars
65+
if ($(".tab-pane.active [name$='paymentMethod']").val() === 'VISA_SRC') {
66+
var $paymentSummary = $('.payment-details');
67+
var htmlToAppend = '<span>VISA SRC</span>';
68+
$paymentSummary.empty().append(htmlToAppend);
69+
} else {
70+
return baseUpdatePaymentInformation(order, customer);
71+
}
72+
};
73+
74+
module.exports = base;

0 commit comments

Comments
 (0)