Skip to content

Commit 3143f3c

Browse files
Merge pull request #13 from cybersource-tpi/v24.3.0_
V24.3.0
2 parents 7eacdcb + b4e5e18 commit 3143f3c

File tree

31 files changed

+433
-236
lines changed

31 files changed

+433
-236
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
* **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)
55
* **Categories:** Payment Processing, Fraud Detection, Address Validation, Tax Computation
6-
* **Version:** 24.2.1
7-
* **Last Certification Date:** May 2024
8-
* **Supports SFRA v6.3.0**
6+
* **Version:** 24.3.0
7+
* **Last Certification Date:** August 2024
8+
* **Supports SFRA v7.0**
99
* **JavaScript Controllers Friendly:** **YES**
1010

1111
### Contact ###

cartridges/int_cybs_sfra/cartridge/client/default/custom/js/flexMicroform.js renamed to cartridges/int_cybs_sfra/cartridge/client/default/custom/flexMicroform.js

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,28 @@ $(document).ready(function () {
3131
var number = microform.createField('number');
3232
var securityCode = microform.createField('securityCode');
3333
securityCode.load('#securityCode-container');
34+
3435
number.load('#cardNumber-container');
3536
number.on('change', function (data) {
37+
if (data.couldBeValid) {
38+
$('.card-number-wrapper .invalid-feedback').css('display', 'none');
39+
}
3640
var cardType = data.card[0].name;
3741
$('.card-number-wrapper').attr('data-type', cardType);
3842
$('#cardType').val(cardType);
3943
});
44+
45+
46+
$('#expirationMonth').on('change', function (event) {
47+
$('#expirationMonthMissingMessage').css('display', 'none');
48+
$('#expiredCardMessage').css('display', 'none');
49+
})
50+
$('#expirationYear').on('change', function (event) {
51+
$('#expirationYearMissingMessage').css('display', 'none');
52+
$('#expiredCardMessage').css('display', 'none');
53+
})
54+
55+
4056
/**
4157
* *
4258
* @param {*} token *
@@ -60,9 +76,6 @@ $(document).ready(function () {
6076
var expMonth = $('#expirationMonth').val();
6177
var expYear = $('#expirationYear').val();
6278

63-
if (expMonth === '' || expYear === '') {
64-
return false;
65-
}
6679
// Send in optional parameters from other parts of your payment form
6780
var options = {
6881
expirationMonth: expMonth.length === 1 ? '0' + expMonth : expMonth,
@@ -76,11 +89,21 @@ $(document).ready(function () {
7689
microform.createToken(options, function (err, response) {
7790
// At this point the token may be added to the form
7891
// as hidden fields and the submission continued
92+
let flag = false;
7993

8094
if (err) {
8195
$('.card-number-wrapper .invalid-feedback').text(err.message).css('display', 'block');
96+
flag = true;
97+
}
98+
99+
if (!cardExpiryValidate()) {
100+
flag = true;
101+
}
102+
103+
if (flag == true) {
82104
return true;
83105
}
106+
84107
var decodedJwt = parseJwt(response);
85108
document.getElementById('cardNumber').valid = true;
86109
$('#flex-response').val(response);
@@ -128,6 +151,34 @@ $(document).ready(function () {
128151
}
129152
}
130153

154+
function cardExpiryValidate() {
155+
var expMonth = $('#expirationMonth').val();
156+
var expYear = $('#expirationYear').val();
157+
158+
if (expMonth == '' || expYear == '') {
159+
if (expMonth == '') {
160+
$('#expirationMonthMissingMessage').css('display', 'block');
161+
}
162+
if (expYear == '') {
163+
$('#expirationYearMissingMessage').css('display', 'block');
164+
}
165+
return false;
166+
}
167+
else {
168+
let currentDate = new Date();
169+
let currentMonth = currentDate.getMonth() + 1;
170+
let currentYear = currentDate.getFullYear();
171+
172+
// Check if the card is expired
173+
if (expYear < currentYear || (expYear == currentYear && expMonth < currentMonth)) {
174+
$('#expiredCardMessage').css('display', 'block');
175+
return false;
176+
}
177+
}
178+
return true;
179+
}
180+
181+
131182
$('.payment-summary .edit-button').on('click', function () {
132183
$('#flex-response').val('');
133184
});

cartridges/int_cybs_sfra/cartridge/client/default/js/checkout/checkout.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,19 @@ $('#checkout-main').on('click', '.next-step-button button', function (event) {
104104
});
105105
}
106106
});
107-
107+
$('#applePayPaymentOptionLink').on('click', function (event) {
108+
$('#placeOrderButton').hide();
109+
});
110+
111+
$('#gPaypaymentOptionLink').on('click', function (event) {
112+
$('#placeOrderButton').hide();
113+
});
114+
115+
$('#visaCheckoutPaymentOptionLink').on('click', function (event) {
116+
$('#placeOrderButton').hide();
117+
});
118+
119+
$('#creditCardPaymentOptionLink').on('click', function (event) {
120+
$('#placeOrderButton').show();
121+
});
108122
module.exports = base;

cartridges/int_cybs_sfra/cartridge/templates/default/account/payment/paymentForm.isml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<isset name="isCartridgeEnabled" value="${require('*/cartridge/configuration/index').cartridgeEnabled}" scope="page" />
44
<isif condition="${isTokenationEnabled && isCartridgeEnabled}">
55
<script src="${URLUtils.staticURL('/custom/lib/jquery/jquery-3.5.1.min.js')}" type="text/javascript"></script>
6-
<script src="${URLUtils.staticURL('/custom/js/flexMicroform.js')}" type="text/javascript"></script>
6+
<script src="${URLUtils.staticURL('/custom/flexMicroform.js')}" type="text/javascript"></script>
77
</isif>
88

99
<form action="${URLUtils.url('PaymentInstruments-SavePayment', 'UUID', pdict.UUID)}" class="payment-form" method="POST" name="payment-form"
@@ -69,9 +69,10 @@
6969
</isif> >${month.label}</option>
7070
</isloop>
7171
</select>
72-
<div class="invalid-feedback">
73-
<isprint value="${pdict.paymentForm.expirationMonth.error}" encoding="htmlcontent" />
74-
</div>
72+
73+
<span class="invalid-feedback" id="expirationMonthMissingMessage">${Resource.msg('payment.card.month.missing', 'forms', null)}</span>
74+
<span class="invalid-feedback" id="expiredCardMessage">${Resource.msg('error.message.creditexpiration.expired', 'forms', null)}</span>
75+
7576
</div>
7677
</div>
7778

@@ -89,7 +90,9 @@
8990
<option id="${year}" value="${year}" <isif condition="${year == pdict.paymentForm.expirationYear.value}">selected</isif> >${year}</option>
9091
</isloop>
9192
</select>
92-
<div class="invalid-feedback"></div>
93+
94+
<span class="invalid-feedback" id="expirationYearMissingMessage">${Resource.msg('payment.card.year.missing', 'forms', null)}</span>
95+
9396
</div>
9497
</div>
9598
</div>
@@ -139,7 +142,7 @@
139142
<!-- Last Name -->
140143
<div class="col-6">
141144
<div class="form-group
142-
${pdict.paymentForm.billToAddressFieldslastName.mandatory === true ? 'required' : ''}">
145+
${pdict.paymentForm.billToAddressFields.lastName.mandatory === true ? 'required' : ''}">
143146
<label class="form-control-label" for="lastName">
144147
<isprint value="${pdict.paymentForm.billToAddressFields.lastName.label}" encoding="htmlcontent" />
145148
</label>

cartridges/int_cybs_sfra/cartridge/templates/default/cart/checkoutButtons.isml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,9 @@
1313
<isapplepay class="apple-pay-cart btn btn-block"></isapplepay>
1414
</div>
1515
</isif>
16+
<div class="col-12">
17+
<isinclude template="checkout/billing/paymentOptions/googleButton" />
18+
</div>
19+
1620
</div>
1721
</div>

cartridges/int_cybs_sfra/cartridge/templates/default/cart/checkoutOptions.isml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
<iselse>
88
<input type="hidden" id="carttotal" value="${pdict.totals.grandTotal}" />
99
</isif>
10-
<isinclude template="checkout/billing/paymentOptions/googleButton" />
10+
1111
</div>
1212
</div>

cartridges/int_cybs_sfra/cartridge/templates/default/checkout/billing/creditCardForm.isml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
<isset name="isFlexEnabled" value="${require('*/cartridge/configuration/index').flexMicroformEnabled}" scope="page" />
44
<isset name="isCartridgeEnabled" value="${require('*/cartridge/configuration/index').cartridgeEnabled}" scope="page" />
5+
<isset name="isTokenizationEnabled" value="${require('*/cartridge/configuration/index').tokenizationEnabled}" scope="page" />
56
<isif condition="${isFlexEnabled && isCartridgeEnabled}">
67
<script src="${URLUtils.staticURL('/custom/lib/jquery/jquery-3.5.1.min.js')}" type="text/javascript"></script>
7-
<script src="${URLUtils.staticURL('/custom/js/flexMicroform.js')}" type="text/javascript"></script>
8+
<script src="${URLUtils.staticURL('/custom/flexMicroform.js')}" type="text/javascript"></script>
89
<isinclude url="${URLUtils.url('SecureAcceptance-CreateFlexToken')}"></isinclude>
910
</isif>
1011

@@ -53,7 +54,12 @@
5354
</option>
5455
</isloop>
5556
</select>
56-
<div class="invalid-feedback" id="expirationMonthInvalidMessage"></div>
57+
58+
<span class="invalid-feedback" id="expirationMonthMissingMessage">${Resource.msg('payment.card.month.missing', 'forms', null)}</span>
59+
<isif condition="${isFlexEnabled}">
60+
<span class="invalid-feedback" id="expiredCardMessage">${Resource.msg('error.message.creditexpiration.expired', 'forms', null)}</span>
61+
</isif>
62+
5763
</div>
5864
</div>
5965
<div class="col-6">
@@ -77,7 +83,10 @@
7783
</option>
7884
</isloop>
7985
</select>
80-
<div class="invalid-feedback" id="expirationYearInvalidMessage"></div>
86+
87+
<span class="invalid-feedback" id="expirationYearMissingMessage">${Resource.msg('payment.card.year.missing', 'forms', null)}</span>
88+
89+
8190
</div>
8291
</div>
8392
</div>
@@ -108,7 +117,7 @@
108117

109118
<div class="row">
110119
<div class="col">
111-
<isif condition="${pdict.customer.registeredUser}">
120+
<isif condition="${pdict.customer.registeredUser && isTokenizationEnabled}">
112121
<div class="save-credit-card custom-control custom-checkbox ">
113122
<input type="checkbox" class="custom-control-input" id="saveCreditCard"
114123
name="${creditFields.saveCard.htmlName}" value="true" checked>

cartridges/int_cybs_sfra/cartridge/templates/default/checkout/billing/paymentOptions/applePayTab.isml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<li class="nav-item applepay-tab-wrapper" data-method-id="${paymentOption.ID}">
2-
<a class="nav-link applepay-tab" data-toggle="tab" href="#applepay-content" role="tab">
2+
<a class="nav-link applepay-tab" data-toggle="tab" href="#applepay-content" role="tab" id="applePayPaymentOptionLink">
33
<img class="applepay-options"
44
src="${URLUtils.staticURL('/images/apple.png')}"
55
height="32"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<li class="nav-item" data-method-id="${paymentOption.ID}">
2+
<a class="nav-link credit-card-tab active" data-toggle="tab" href="#credit-card-content" role="tab" id="creditCardPaymentOptionLink">
3+
<img class="credit-card-option"
4+
src="${URLUtils.staticURL('/images/credit.png')}"
5+
height="32"
6+
alt="${paymentOption.name}"
7+
title="${paymentOption.name}"
8+
>
9+
</a>
10+
</li>

cartridges/int_cybs_sfra/cartridge/templates/default/checkout/billing/paymentOptions/googlePayTab.isml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
--------------------------------------------------------------
44
</iscomment>
55
<li class="nav-item googlepay-tab-wrapper" data-method-id="${paymentOption.ID}">
6-
<a class="nav-link google-tab" data-toggle="tab" href="#googlepay-content" role="tab">
6+
<a class="nav-link google-tab" data-toggle="tab" href="#googlepay-content" role="tab" id="gPaypaymentOptionLink">
77
${paymentOption.name}
88
</a>
99
</li>

0 commit comments

Comments
 (0)