Skip to content

Commit 9e344f8

Browse files
Merge pull request #1 from CyberSource/v21.1.0
Commit changes of v21.1.0
2 parents ead9300 + fbcfb85 commit 9e344f8

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

Lines changed: 1 addition & 0 deletions
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
Lines changed: 23 additions & 1 deletion
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: <SFCC@cybersource.com>
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

Lines changed: 17 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"parserOptions": {
3+
"ecmaVersion": 2018
4+
}
5+
}
Lines changed: 151 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
1.42 KB
Loading
Lines changed: 10 additions & 0 deletions
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+
});
Lines changed: 10 additions & 0 deletions
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+
}

0 commit comments

Comments
 (0)