function validatePayment(req, currentBasket) {
  const creditCardPaymentMethod = PaymentMgr.getPaymentMethod(
    PaymentInstrument.METHOD_CREDIT_CARD,
  );
  const paymentAmount = currentBasket.totalGrossPrice.value;
  const { countryCode } = req.geolocation;
  const currentCustomer = req.currentCustomer.raw;
  const { paymentInstruments } = currentBasket;
  const result = {};

  const applicablePaymentMethods = PaymentMgr.getApplicablePaymentMethods(
    currentCustomer,
    countryCode,
    paymentAmount,
  );
  const applicablePaymentCards = creditCardPaymentMethod.getApplicablePaymentCards(
    currentCustomer,
    countryCode,
    paymentAmount,
  );

  const validatePaymentInstrument = validatePaymentMethod(
    applicablePaymentCards,
    applicablePaymentMethods,
  );

  const isValid = paymentInstruments.toArray().every(validatePaymentInstrument);
  result.error = !isValid;
  return result;
}
/**
 * Validates payment
 * @param {Object} req - The local instance of the request object
 * @param {dw.order.Basket} currentBasket - The current basket
 * @returns {Object} an object that has error information
 */
Validates payment
@param {Object} req - The local instance of the request object
@param {dw.order.Basket} currentBasket - The current basket
@returns {Object} an object that has error information
Validates payment @param { Object } req - The local instance of the request object @param { dw . order . Basket } currentBasket - The current basket @returns { Object } an object that has error information
function validatePayment(req, currentBasket) {
  const creditCardPaymentMethod = PaymentMgr.getPaymentMethod(
    PaymentInstrument.METHOD_CREDIT_CARD,
  );
  const paymentAmount = currentBasket.totalGrossPrice.value;
  const { countryCode } = req.geolocation;
  const currentCustomer = req.currentCustomer.raw;
  const { paymentInstruments } = currentBasket;
  const result = {};
  const applicablePaymentMethods = PaymentMgr.getApplicablePaymentMethods(
    currentCustomer,
    countryCode,
    paymentAmount,
  );
  const applicablePaymentCards = creditCardPaymentMethod.getApplicablePaymentCards(
    currentCustomer,
    countryCode,
    paymentAmount,
  );
  const validatePaymentInstrument = validatePaymentMethod(
    applicablePaymentCards,
    applicablePaymentMethods,
  );
  const isValid = paymentInstruments.toArray().every(validatePaymentInstrument);
  result.error = !isValid;
  return result;
}
function validatePayment ( req , currentBasket ) { const creditCardPaymentMethod = PaymentMgr . getPaymentMethod ( PaymentInstrument . METHOD_CREDIT_CARD , ) ; const paymentAmount = currentBasket . totalGrossPrice . value ; const { countryCode } = req . geolocation ; const currentCustomer = req . currentCustomer . raw ; const { paymentInstruments } = currentBasket ; const result = { } ; const applicablePaymentMethods = PaymentMgr . getApplicablePaymentMethods ( currentCustomer , countryCode , paymentAmount , ) ; const applicablePaymentCards = creditCardPaymentMethod . getApplicablePaymentCards ( currentCustomer , countryCode , paymentAmount , ) ; const validatePaymentInstrument = validatePaymentMethod ( applicablePaymentCards , applicablePaymentMethods , ) ; const isValid = paymentInstruments . toArray ( ) . every ( validatePaymentInstrument ) ; result . error = ! isValid ; return result ; }
Validates payment
 @param {Object} req - The local instance of the request object
 @param {dw.order.Basket} currentBasket - The current basket
 @returns {Object} an object that has error information
Validates payment @param { Object } req - The local instance of the request object @param { dw . order . Basket } currentBasket - The current basket @returns { Object } an object that has error information