Post

Replies

Boosts

Views

Activity

Getting "show() was not triggered by user activation" when I am fetching data required for creating payment request
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!
1
1
1.1k
Aug ’22
How to send error to payment sheet when users selects shippingaddress with some country where we don't ship?
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?
0
1
554
Nov ’21