Hi, I am using paymentrequest api to implement apple pay on the web. In onshippingaddresschange callback i am checking for country of selected shipping address and if its invalid as per our logic i need to show an error using updateWith(). I am not able to figure out structure of object to pass to the function. I tried this one but it didn't work.
event.updateWith({
shippingAddressErrors: {
country : 'invalid country',
addressLine: "Adress error"
}
})
Can someone help?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Created
Hello, I am implementing apple pay using paymentrequest api. But when I try to fetch some data and await for the data fetch to get complete it throws error " show() was not triggered by user activation" Here's the code I have:
// this function is called on click of apple-pay-button
const onApplePayButtonClicked = async () => {
if (!window.PaymentRequest) {
return;
}
try {
const data = await getData();
// consider paymentMethodData, paymentDetails, paymentOptions to be some mock data for now I will update it as per data fetched
const request = new window.PaymentRequest(paymentMethodData, paymentDetails, paymentOptions);
const response = await request.show();
const status = 'success';
await response.complete(status);
} catch (e) {
// Handle errors
console.log('Received error', e);
}
}
// getData function
function getData(){
return window
.fetch(`${mockUrl}`, {
method: 'GET',
headers,
})
.then(response => response.json())
.catch(err => console.error(err));
}
Any help would be appreciated. Thanks!