Reputation: 23587
Working on Apple Pay web implementation with Java as backed system. I am getting following josn from my backend 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": "[email protected]",
"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": "[email protected]",
"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
var var2= getCartPaymentRequest();
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 above code to
var request1 = {
"supportedNetworks": [
"amex",
"discover",
"maestro",
"masterCard",
"visa"
],
"requiredShippingContactFields": [
"email",
"name",
"phone",
"postalAddress"
],
"requiredBillingContactFields": [
"postalAddress"
],
"merchantCapabilities": [
"supportsCredit",
"supportsDebit",
"supports3DS"
],
"shippingContact": {
"phoneNumber": "111-111-1111",
"emailAddress": "[email protected]",
"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": "[email protected]",
"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);
The only difference is between the Ajax call and hard-coded payload. Here is my Ajax call code
function getCartPaymentRequest() {
var result = "";
$.ajax({
type: 'GET',
url: ACC.config.encodedContextPath + '/checkout/payment-request',
dataType: 'json',
success: function (response) {
result = response;
},
});
return result;
}
The country code in my Java bean is a String and I am not sure what is the issue as same payload is accepted by Apple Pay if I hard code it
Upvotes: 0
Views: 511