Commit da4e85dd authored by Ricardo Ambrogi's avatar Ricardo Ambrogi Committed by GitHub

Update adyen-hpp-method.js

parent 9b5d48cf
...@@ -99,7 +99,15 @@ define( ...@@ -99,7 +99,15 @@ define(
adyenPaymentService.retrieveAvailablePaymentMethods(function () { adyenPaymentService.retrieveAvailablePaymentMethods(function () {
var paymentMethods = adyenPaymentService.getAvailablePaymentMethods(); var paymentMethods = adyenPaymentService.getAvailablePaymentMethods();
if (JSON.stringify(paymentMethods).indexOf("ratepay") > -1) { var paymentMethodsStr;
try {
paymentMethodsStr = JSON.stringify(paymentMethods);
} catch (e) {
// Failed to stringify paymentMethods
}
if (paymentMethodsStr.indexOf("ratepay") > -1) {
var ratePayId = window.checkoutConfig.payment.adyenHpp.ratePayId; var ratePayId = window.checkoutConfig.payment.adyenHpp.ratePayId;
var dfValueRatePay = self.getRatePayDeviceIdentToken(); var dfValueRatePay = self.getRatePayDeviceIdentToken();
...@@ -124,7 +132,7 @@ define( ...@@ -124,7 +132,7 @@ define(
var currentShippingAddressCountryCode = quote.shippingAddress().countryId; var currentShippingAddressCountryCode = quote.shippingAddress().countryId;
// retrieve new payment methods if country code changed // retrieve new payment methods if country code changed
if (shippingAddressCountryCode != currentShippingAddressCountryCode) { if (shippingAddressCountryCode !== currentShippingAddressCountryCode) {
fullScreenLoader.startLoader(); fullScreenLoader.startLoader();
adyenPaymentService.retrieveAvailablePaymentMethods(); adyenPaymentService.retrieveAvailablePaymentMethods();
shippingAddressCountryCode = currentShippingAddressCountryCode; shippingAddressCountryCode = currentShippingAddressCountryCode;
...@@ -252,33 +260,21 @@ define( ...@@ -252,33 +260,21 @@ define(
* @returns {boolean} * @returns {boolean}
*/ */
result.isPaymentMethodKlarna = function () { result.isPaymentMethodKlarna = function () {
if (result.getBrandCode() === "klarna") { return result.getBrandCode() === "klarna";
return true;
}
return false;
}; };
/** /**
* Checks if payment method is after pay * Checks if payment method is after pay
* @returns {boolean} * @returns {boolean}
*/ */
result.isPaymentMethodAfterPay = function () { result.isPaymentMethodAfterPay = function () {
if (result.getBrandCode() === "afterpay_default") { return result.getBrandCode() === "afterpay_default";
return true;
}
return false;
}; };
/** /**
* Checks if payment method is after pay touch * Checks if payment method is after pay touch
* @returns {boolean} * @returns {boolean}
*/ */
result.isPaymentMethodAfterPayTouch = function () { result.isPaymentMethodAfterPayTouch = function () {
if (result.getBrandCode() === "afterpaytouch") { return result.getBrandCode() === "afterpaytouch";
return true;
}
return false;
}; };
/** /**
* Get personal number (SSN) length based on the buyer's country * Get personal number (SSN) length based on the buyer's country
...@@ -320,65 +316,43 @@ define( ...@@ -320,65 +316,43 @@ define(
* @returns {boolean} * @returns {boolean}
*/ */
result.hasIssuersProperty = function () { result.hasIssuersProperty = function () {
if (result.findIssuersProperty() !== false) { return !!result.findIssuersProperty()
return true;
}
return false;
}; };
/** /**
* Checks if the payment method has issuer(s) available * Checks if the payment method has issuer(s) available
* @returns {boolean} * @returns {boolean}
*/ */
result.hasIssuersAvailable = function () { result.hasIssuersAvailable = function () {
if (result.hasIssuersProperty() && value.details[result.findIssuersProperty()].items.length > 0) { return result.hasIssuersProperty() && value.details[result.findIssuersProperty()].items.length > 0
return true;
}
return false;
}; };
/** /**
* Returns the issuers for a payment method * Returns the issuers for a payment method
* @returns {*} * @returns {*}
*/ */
result.getIssuers = function () { result.getIssuers = function () {
if (result.hasIssuersAvailable()) { return result.hasIssuersAvailable())
return value.details[result.findIssuersProperty()].items; ? value.details[result.findIssuersProperty()].items
} : [];
return [];
}; };
/** /**
* Checks if payment method is iDeal * Checks if payment method is iDeal
* @returns {boolean} * @returns {boolean}
*/ */
result.isIdeal = function () { result.isIdeal = function () {
if (result.getBrandCode().indexOf("ideal") >= 0) { return result.getBrandCode().indexOf("ideal") >= 0;
return true;
}
return false;
}; };
/** /**
* Checks if payment method is ACH * Checks if payment method is ACH
* @returns {boolean} * @returns {boolean}
*/ */
result.isAch = function () { result.isAch = function () {
if (result.getBrandCode().indexOf("ach") == 0) { return result.getBrandCode().indexOf("ach") == 0;
return true;
}
return false;
}; };
/** /**
* Checks if payment method is sepa direct debit * Checks if payment method is sepa direct debit
*/ */
result.isSepaDirectDebit = function () { result.isSepaDirectDebit = function () {
if (result.getBrandCode().indexOf("sepadirectdebit") >= 0) { return result.getBrandCode().indexOf("sepadirectdebit") >= 0
return true;
}
return false;
}; };
/** /**
* Renders the secure fields, * Renders the secure fields,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment