Reputation: 145880
Trying to integrate ApplePayJS into my website and getting this annoying message::
InvalidAccessError Code 15
"The object does not support the operation or argument"
Everything seems to have been going well and now nothing works.
Upvotes: 1
Views: 10124
Reputation: 11
I know this is 7 years old but since I got the exact same mistake and it almost drove me mad :
In case you are getting this error message ensure that you are calling session.completeMerchantValidation inside the onvalidatemerchant function. This was the problem for me and getting this error misleaded me to believe something was wrong with my JSON.
Upvotes: 1
Reputation: 1
Who gets an error at this stage.
applePayTokenize.session.completePayment(ApplePaySession.STATUS_SUCCESS);
In my situation, the problem was that the backend took a long time to process the payment because I had my own logic after successful payment and I could not close the session via completePayment
SUCCESS as the session time is rather small and it closes itself or I don't know why that is so.
I solved the problem by getting rid of the long time on the backend by using asynchronous operation after payment processing
Upvotes: 0
Reputation: 239
I have also had this issue but with a different reason
Your domain name in the session needs to equal the domain name of your browser. you set the domain name in the backend during in the initiativeContext
Upvotes: 0
Reputation: 145880
If you get this error, in my experience Safari is now dead to ApplePayJS and you must start by force quitting and reopening it again.
Turns out the reason for me what that the ApplePay API completely craps out if you pass a string instead of an object into the completeMerchantValidation
.
If what you return from your server is not JSON object, but a string instead then you can do this:
session.completeMerchantValidation(JSON.parse(merchantSession));
Or better still - fix your server to return a JSON object instead of a string.
Update 4 years later:
I just saw this again today for a real customer as opposed to during my own testing. In this instance the order had succeeded and the customer thought it had failed so attempted to go through the process again.
Oddly it was on this call with the same error "The object does not support the operation or argument."
applePayTokenize.session.completePayment(ApplePaySession.STATUS_SUCCESS);
Since the payment succeeded I've changed my logic to just ignore the exception (for STATUS_SUCCESS only) and proceed to the final page. I don't even know if the ApplePay sheet was still open but even if it was at least when it cancels it will be on the receipt page.
Upvotes: 3