Skip to content

Commit

Permalink
fix(SFI-1025): refactor try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
shanikantsingh committed Jan 10, 2025
1 parent e1e2177 commit 83bcc00
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/* API Includes */
const PaymentInstrument = require('dw/order/PaymentInstrument');
const Transaction = require('dw/system/Transaction');
const collections = require('*/cartridge/scripts/util/collections');
const constants = require('*/cartridge/adyen/config/constants');

/* Script Modules */
Expand All @@ -37,7 +38,7 @@ function getOneClickPaymentMethods(customer) {
);
const oneClickPaymentMethods = [];
if (storedPaymentMethods) {
storedPaymentMethods?.forEach((storedPaymentMethod) => {
collections.forEach(storedPaymentMethods, (storedPaymentMethod) => {
if (
storedPaymentMethod?.supportedShopperInteractions &&
storedPaymentMethod?.supportedShopperInteractions.indexOf('Ecommerce') >
Expand Down Expand Up @@ -74,16 +75,16 @@ function updateSavedCards(args) {

Transaction.wrap(() => {
// remove all current METHOD_CREDIT_CARD PaymentInstruments
savedCreditCards?.forEach((savedCreditCard) => {
collections.forEach(savedCreditCards, (savedCreditCard) => {
customer.getProfile().getWallet().removePaymentInstrument(savedCreditCard);
})
// remove all current METHOD_ADYEN_COMPONENT PaymentInstruments
savedCreditCardsComponent?.forEach((savedCreditCard) => {
collections.forEach(savedCreditCardsComponent, (savedCreditCard) => {
customer.getProfile().getWallet().removePaymentInstrument(savedCreditCard);
})

// Create from existing cards a paymentInstrument
oneClickPaymentMethods?.forEach((payment) => {
collections.forEach(oneClickPaymentMethods, (payment) => {
const expiryMonth = payment.expiryMonth ? payment.expiryMonth : '';
const expiryYear = payment.expiryYear ? payment.expiryYear : '';
const holderName = payment.holderName ? payment.holderName : '';
Expand Down

0 comments on commit 83bcc00

Please sign in to comment.