Member ApplePayPaymentRequest.countryCode is required and must be an instance of DOMString

I am struggling to understand this error. I am getting following josn from my back-end server using Ajax call

    "supportedNetworks": [
        "amex",
        "discover",
        "maestro",
        "masterCard",
        "visa"
    ],
    "requiredShippingContactFields": [
        "email",
        "name",
        "phone",
        "postalAddress"
    ],
    "requiredBillingContactFields": [
        "postalAddress"
    ],
    "merchantCapabilities": [
        "supportsCredit",
        "supportsDebit",
        "supports3DS"
    ],
    "shippingContact": {
        "phoneNumber": "111-111-1111",
        "emailAddress": "***@gmail.com",
        "givenName": "Test",
        "familyName": "Test",
        "phoneticGivenName": null,
        "phoneticFamilyName": null,
        "addressLines": [
            "Adress"
        ],
        "subLocality": null,
        "locality": null,
        "postalCode": "123456",
        "subAdministrativeArea": null,
        "administrativeArea": "Dummy",
        "country": "United States",
        "countryCode": "US"
    },
    "billingContact": {
        "phoneNumber": "111-111-1111",
        "emailAddress": "***@gmail.com",
        "givenName": "Test",
        "familyName": "Test",
        "phoneticGivenName": null,
        "phoneticFamilyName": null,
        "addressLines": [
            "Adress"
        ],
        "subLocality": null,
        "locality": null,
        "postalCode": "123456",
        "subAdministrativeArea": null,
        "administrativeArea": "Dummy",
        "country": "United States",
        "countryCode": "US"
    },
    "shippingMethods": [],
    "countryCode": "US",
    "currencyCode": "USD",
    "total": {
        "label": "Hello",
        "amount": "23"
    }
}

Here is my code to create Apple Pay session

this.session = new ApplePaySession(3, var2);

While running this code, I am getting following error on the js: TypeError: Member ApplePayPaymentRequest.countryCode is required and must be an instance of DOMString

If I change the code and hard code the same json coming from Ajax call as :

    "supportedNetworks": [
        "amex",
        "discover",
        "maestro",
        "masterCard",
        "visa"
    ],
    "requiredShippingContactFields": [
        "email",
        "name",
        "phone",
        "postalAddress"
    ],
    "requiredBillingContactFields": [
        "postalAddress"
    ],
    "merchantCapabilities": [
        "supportsCredit",
        "supportsDebit",
        "supports3DS"
    ],
    "shippingContact": {
        "phoneNumber": "111-111-1111",
        "emailAddress": "***@gmail.com",
        "givenName": "Test",
        "familyName": "Test",
        "phoneticGivenName": null,
        "phoneticFamilyName": null,
        "addressLines": [
            "Adress"
        ],
        "subLocality": null,
        "locality": null,
        "postalCode": "123456",
        "subAdministrativeArea": null,
        "administrativeArea": "Dummy",
        "country": "United States",
        "countryCode": "US"
    },
    "billingContact": {
        "phoneNumber": "111-111-1111",
        "emailAddress": "***@gmail.com",
        "givenName": "Test",
        "familyName": "Test",
        "phoneticGivenName": null,
        "phoneticFamilyName": null,
        "addressLines": [
            "Adress"
        ],
        "subLocality": null,
        "locality": null,
        "postalCode": "123456",
        "subAdministrativeArea": null,
        "administrativeArea": "Dummy",
        "country": "United States",
        "countryCode": "US"
    },
    "shippingMethods": [],
    "countryCode": "US",
    "currencyCode": "USD",
    "total": {
        "label": "Hello",
        "amount": "23"
    }
}

this.session = new ApplePaySession(3, request1);

There is no issue to ApplePay session and things seems to be working. I am using Java as back end and the country ISO is a String. I am struggling to understand why the Json data coming from Ajax call is causing issue while same data in hard coded in the Javascript seems good to Apple Pay

Member ApplePayPaymentRequest.countryCode is required and must be an instance of DOMString
 
 
Q