We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit a9a85633 authored by attilak's avatar attilak

Check issuers in the whole response detail object

parent f6da96d4
...@@ -289,16 +289,28 @@ define( ...@@ -289,16 +289,28 @@ define(
result.getBankAccountNumberMaxLength = function () { result.getBankAccountNumberMaxLength = function () {
return 17; return 17;
}; };
/**
* Finds the issuer property in the payment method's response and if available returns it's index
* @returns
*/
result.findIssuersProperty = function () {
var issuerKey = false;
if (typeof value.details !== 'undefined') {
$.each(value.details, function(key, detail) {
if (typeof detail.items !== 'undefined' && detail.key == 'issuer') {
issuerKey = key;
}
});
}
return issuerKey;
}
/** /**
* Checks if the payment method has issuers property available * Checks if the payment method has issuers property available
* @returns {boolean} * @returns {boolean}
*/ */
result.hasIssuersProperty = function () { result.hasIssuersProperty = function () {
if ( if (result.findIssuersProperty() !== false) {
typeof value.details !== 'undefined' &&
typeof value.details[0].items !== 'undefined' &&
value.details[0].key == 'issuer'
) {
return true; return true;
} }
...@@ -309,7 +321,7 @@ define( ...@@ -309,7 +321,7 @@ define(
* @returns {boolean} * @returns {boolean}
*/ */
result.hasIssuersAvailable = function () { result.hasIssuersAvailable = function () {
if (result.hasIssuersProperty() && value.details[0].items.length > 0) { if (result.hasIssuersProperty() && value.details[result.findIssuersProperty()].items.length > 0) {
return true; return true;
} }
...@@ -321,7 +333,7 @@ define( ...@@ -321,7 +333,7 @@ define(
*/ */
result.getIssuers = function() { result.getIssuers = function() {
if (result.hasIssuersAvailable()) { if (result.hasIssuersAvailable()) {
return value.details[0].items; return value.details[result.findIssuersProperty()].items;
} }
return []; return [];
......
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